From nicholas at mxc.ca Mon Feb 28 00:20:06 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 28 Feb 2011 06:20:06 -0000 Subject: [llvm-commits] [llvm] r126635 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/icmp.ll Message-ID: <20110228062006.346C62A6C12C@llvm.org> Author: nicholas Date: Mon Feb 28 00:20:05 2011 New Revision: 126635 URL: http://llvm.org/viewvc/llvm-project?rev=126635&view=rev Log: The sign of an srem instruction is the sign of its dividend (the first argument), regardless of the divisor. Teach instcombine about this and fix test7 in PR9343! 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=126635&r1=126634&r2=126635&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Feb 28 00:20:05 2011 @@ -1340,6 +1340,16 @@ } } break; + + case Instruction::SRem: { + bool TrueIfSigned; + if (LHSI->hasOneUse() && + isSignBitCheck(ICI.getPredicate(), RHS, TrueIfSigned)) { + // srem has the same sign as its dividend so the divisor is irrelevant. + return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0), RHS); + } + break; + } } // Simplify icmp_eq and icmp_ne instructions with integer constant RHS. @@ -1855,11 +1865,11 @@ return new ICmpInst(ICmpInst::ICMP_SLT, Op0, ConstantInt::get(CI->getContext(), CI->getValue()+1)); case ICmpInst::ICMP_UGE: - assert(!CI->isMinValue(false)); // A >=u MIN -> TRUE + assert(!CI->isMinValue(false)); // A >=u MIN -> TRUE return new ICmpInst(ICmpInst::ICMP_UGT, Op0, ConstantInt::get(CI->getContext(), CI->getValue()-1)); case ICmpInst::ICMP_SGE: - assert(!CI->isMinValue(true)); // A >=s MIN -> TRUE + assert(!CI->isMinValue(true)); // A >=s MIN -> TRUE return new ICmpInst(ICmpInst::ICMP_SGT, Op0, ConstantInt::get(CI->getContext(), CI->getValue()-1)); } @@ -1913,7 +1923,7 @@ ConstantInt::get(I.getContext(), Op1Min)); // Based on the range information we know about the LHS, see if we can - // simplify this comparison. For example, (x&4) < 8 is always true. + // simplify this comparison. For example, (x&4) < 8 is always true. switch (I.getPredicate()) { default: llvm_unreachable("Unknown icmp opcode!"); case ICmpInst::ICMP_EQ: { Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=126635&r1=126634&r2=126635&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Mon Feb 28 00:20:05 2011 @@ -377,3 +377,13 @@ %c = icmp ugt i32 %lhs, %rhs ret i1 %c } + +; PR9343 #7 +; CHECK: @test39 +; CHECK: ret i1 false +define i1 @test39(i31 %X, i32 %Y) { + %A = zext i31 %X to i32 + %B = srem i32 %A, %Y + %C = icmp slt i32 %B, 0 + ret i1 %C +} From clchiou at gmail.com Mon Feb 28 00:34:09 2011 From: clchiou at gmail.com (Che-Liang Chiou) Date: Mon, 28 Feb 2011 06:34:09 -0000 Subject: [llvm-commits] [llvm] r126636 - in /llvm/trunk: lib/Target/PTX/PTXAsmPrinter.cpp lib/Target/PTX/PTXISelLowering.cpp lib/Target/PTX/PTXInstrInfo.cpp lib/Target/PTX/PTXInstrInfo.td lib/Target/PTX/PTXRegisterInfo.td test/CodeGen/PTX/add.ll test/CodeGen/PTX/ld_float.ll test/CodeGen/PTX/mov.ll test/CodeGen/PTX/mul.ll test/CodeGen/PTX/st_float.ll test/CodeGen/PTX/sub.ll Message-ID: <20110228063409.7FFCD2A6C12C@llvm.org> Author: clchiou Date: Mon Feb 28 00:34:09 2011 New Revision: 126636 URL: http://llvm.org/viewvc/llvm-project?rev=126636&view=rev Log: Add preliminary support for .f32 in the PTX backend. - Add appropriate TableGen patterns for fadd, fsub, fmul. - Add .f32 as the PTX type for the LLVM float type. - Allow parameters, return values, and global variable declarations to accept the float type. - Add appropriate test cases. Patch by Justin Holewinski Added: llvm/trunk/test/CodeGen/PTX/ld_float.ll llvm/trunk/test/CodeGen/PTX/mul.ll llvm/trunk/test/CodeGen/PTX/st_float.ll Modified: llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp llvm/trunk/lib/Target/PTX/PTXInstrInfo.td llvm/trunk/lib/Target/PTX/PTXRegisterInfo.td llvm/trunk/test/CodeGen/PTX/add.ll llvm/trunk/test/CodeGen/PTX/mov.ll llvm/trunk/test/CodeGen/PTX/sub.ll Modified: llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp?rev=126636&r1=126635&r2=126636&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp Mon Feb 28 00:34:09 2011 @@ -84,6 +84,7 @@ static const char *getRegisterTypeName(unsigned RegNo) { #define TEST_REGCLS(cls, clsstr) \ if (PTX::cls ## RegisterClass->contains(RegNo)) return # clsstr; + TEST_REGCLS(RRegf32, f32); TEST_REGCLS(RRegs32, s32); TEST_REGCLS(Preds, pred); #undef TEST_REGCLS @@ -115,6 +116,21 @@ return NULL; } +static const char *getTypeName(const Type* type) { + while (true) { + switch (type->getTypeID()) { + default: llvm_unreachable("Unknown type"); + case Type::FloatTyID: return ".f32"; + case Type::IntegerTyID: return ".s32"; // TODO: Handle 64-bit types. + case Type::ArrayTyID: + case Type::PointerTyID: + type = dyn_cast(type)->getElementType(); + break; + } + } + return NULL; +} + bool PTXAsmPrinter::doFinalization(Module &M) { // XXX Temproarily remove global variables so that doFinalization() will not // emit them again (global variables are emitted at beginning). @@ -218,6 +234,15 @@ case MachineOperand::MO_Register: OS << getRegisterName(MO.getReg()); break; + case MachineOperand::MO_FPImmediate: + APInt constFP = MO.getFPImm()->getValueAPF().bitcastToAPInt(); + if (constFP.getZExtValue() > 0) { + OS << "0F" << constFP.toString(16, false); + } + else { + OS << "0F00000000"; + } + break; } } @@ -265,8 +290,8 @@ decl += " "; } - // TODO: add types - decl += ".s32 "; + decl += getTypeName(gv->getType()); + decl += " "; decl += gvsym->getName(); Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp?rev=126636&r1=126635&r2=126636&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Mon Feb 28 00:34:09 2011 @@ -28,9 +28,12 @@ // Set up the register classes. addRegisterClass(MVT::i1, PTX::PredsRegisterClass); addRegisterClass(MVT::i32, PTX::RRegs32RegisterClass); - + addRegisterClass(MVT::f32, PTX::RRegf32RegisterClass); + setOperationAction(ISD::EXCEPTIONADDR, MVT::i32, Expand); + setOperationAction(ISD::ConstantFP, MVT::f32, Legal); + // Customize translation of memory addresses setOperationAction(ISD::GlobalAddress, MVT::i32, Custom); @@ -87,7 +90,8 @@ bool operator==(MVT::SimpleValueType _VT) const { return VT == _VT; } } argmap[] = { argmap_entry(MVT::i1, PTX::PredsRegisterClass), - argmap_entry(MVT::i32, PTX::RRegs32RegisterClass) + argmap_entry(MVT::i32, PTX::RRegs32RegisterClass), + argmap_entry(MVT::f32, PTX::RRegf32RegisterClass) }; } // end anonymous namespace @@ -185,10 +189,18 @@ if (Outs.size() == 0) return DAG.getNode(PTXISD::RET, dl, MVT::Other, Chain); - assert(Outs[0].VT == MVT::i32 && "Can return only basic types"); - SDValue Flag; - unsigned reg = PTX::R0; + unsigned reg; + + if (Outs[0].VT == MVT::i32) { + reg = PTX::R0; + } + else if (Outs[0].VT == MVT::f32) { + reg = PTX::F0; + } + else { + assert(false && "Can return only basic types"); + } MachineFunction &MF = DAG.getMachineFunction(); PTXMachineFunctionInfo *MFI = MF.getInfo(); Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp?rev=126636&r1=126635&r2=126636&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp Mon Feb 28 00:34:09 2011 @@ -28,6 +28,7 @@ const int opcode; } map[] = { { &PTX::RRegs32RegClass, PTX::MOVrr }, + { &PTX::RRegf32RegClass, PTX::MOVrr }, { &PTX::PredsRegClass, PTX::MOVpp } }; @@ -35,12 +36,13 @@ MachineBasicBlock::iterator I, DebugLoc DL, unsigned DstReg, unsigned SrcReg, bool KillSrc) const { - for (int i = 0, e = sizeof(map)/sizeof(map[0]); i != e; ++ i) - if (PTX::RRegs32RegClass.contains(DstReg, SrcReg)) { + for (int i = 0, e = sizeof(map)/sizeof(map[0]); i != e; ++ i) { + if (map[i].cls->contains(DstReg, SrcReg)) { BuildMI(MBB, I, DL, - get(PTX::MOVrr), DstReg).addReg(SrcReg, getKillRegState(KillSrc)); + get(map[i].opcode), DstReg).addReg(SrcReg, getKillRegState(KillSrc)); return; } + } llvm_unreachable("Impossible reg-to-reg copy"); } Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.td?rev=126636&r1=126635&r2=126636&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.td (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Mon Feb 28 00:34:09 2011 @@ -143,6 +143,18 @@ // Instruction Class Templates //===----------------------------------------------------------------------===// +// Three-operand f32 instruction template +multiclass FLOAT3 { + def rr : InstPTX<(outs RRegf32:$d), + (ins RRegf32:$a, RRegf32:$b), + !strconcat(opcstr, ".%type\t$d, $a, $b"), + [(set RRegf32:$d, (opnode RRegf32:$a, RRegf32:$b))]>; + def ri : InstPTX<(outs RRegf32:$d), + (ins RRegf32:$a, f32imm:$b), + !strconcat(opcstr, ".%type\t$d, $a, $b"), + [(set RRegf32:$d, (opnode RRegf32:$a, fpimm:$b))]>; +} + multiclass INT3 { def rr : InstPTX<(outs RRegs32:$d), (ins RRegs32:$a, RRegs32:$b), @@ -204,6 +216,12 @@ // Instructions //===----------------------------------------------------------------------===// +///===- Floating-Point Arithmetic Instructions ----------------------------===// + +defm FADD : FLOAT3<"add", fadd>; +defm FSUB : FLOAT3<"sub", fsub>; +defm FMUL : FLOAT3<"mul", fmul>; + ///===- Integer Arithmetic Instructions -----------------------------------===// defm ADD : INT3<"add", add>; @@ -223,6 +241,8 @@ : InstPTX<(outs Preds:$d), (ins Preds:$a), "mov.pred\t$d, $a", []>; def MOVrr : InstPTX<(outs RRegs32:$d), (ins RRegs32:$a), "mov.%type\t$d, $a", []>; + def FMOVrr + : InstPTX<(outs RRegf32:$d), (ins RRegf32:$a), "mov.f32\t$d, $a", []>; } let isReMaterializable = 1, isAsCheapAsAMove = 1 in { @@ -232,8 +252,12 @@ def MOVri : InstPTX<(outs RRegs32:$d), (ins i32imm:$a), "mov.s32\t$d, $a", [(set RRegs32:$d, imm:$a)]>; + def FMOVri + : InstPTX<(outs RRegf32:$d), (ins f32imm:$a), "mov.f32\t$d, $a", + [(set RRegf32:$d, fpimm:$a)]>; } +// Integer loads defm LDg : PTX_LD<"ld.global", RRegs32, load_global>; defm LDc : PTX_LD<"ld.const", RRegs32, load_constant>; defm LDl : PTX_LD<"ld.local", RRegs32, load_local>; @@ -243,12 +267,30 @@ def LDpi : InstPTX<(outs RRegs32:$d), (ins MEMpi:$a), "ld.param.%type\t$d, [$a]", []>; +// Floating-point loads +defm FLDg : PTX_LD<"ld.global", RRegf32, load_global>; +defm FLDc : PTX_LD<"ld.const", RRegf32, load_constant>; +defm FLDl : PTX_LD<"ld.local", RRegf32, load_local>; +defm FLDp : PTX_LD<"ld.param", RRegf32, load_parameter>; +defm FLDs : PTX_LD<"ld.shared", RRegf32, load_shared>; + +def FLDpi : InstPTX<(outs RRegf32:$d), (ins MEMpi:$a), + "ld.param.%type\t$d, [$a]", []>; + +// Integer stores defm STg : PTX_ST<"st.global", RRegs32, store_global>; defm STl : PTX_ST<"st.local", RRegs32, store_local>; // Store to parameter state space requires PTX 2.0 or higher? // defm STp : PTX_ST<"st.param", RRegs32, store_parameter>; defm STs : PTX_ST<"st.shared", RRegs32, store_shared>; +// Floating-point stores +defm FSTg : PTX_ST<"st.global", RRegf32, store_global>; +defm FSTl : PTX_ST<"st.local", RRegf32, store_local>; +// Store to parameter state space requires PTX 2.0 or higher? +// defm FSTp : PTX_ST<"st.param", RRegf32, store_parameter>; +defm FSTs : PTX_ST<"st.shared", RRegf32, store_shared>; + ///===- Control Flow Instructions -----------------------------------------===// let isReturn = 1, isTerminator = 1, isBarrier = 1 in { Modified: llvm/trunk/lib/Target/PTX/PTXRegisterInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXRegisterInfo.td?rev=126636&r1=126635&r2=126636&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXRegisterInfo.td (original) +++ llvm/trunk/lib/Target/PTX/PTXRegisterInfo.td Mon Feb 28 00:34:09 2011 @@ -85,6 +85,40 @@ def R30 : PTXReg<"r30">; def R31 : PTXReg<"r31">; +def F0 : PTXReg<"f0">; +def F1 : PTXReg<"f1">; +def F2 : PTXReg<"f2">; +def F3 : PTXReg<"f3">; +def F4 : PTXReg<"f4">; +def F5 : PTXReg<"f5">; +def F6 : PTXReg<"f6">; +def F7 : PTXReg<"f7">; +def F8 : PTXReg<"f8">; +def F9 : PTXReg<"f9">; +def F10 : PTXReg<"f10">; +def F11 : PTXReg<"f11">; +def F12 : PTXReg<"f12">; +def F13 : PTXReg<"f13">; +def F14 : PTXReg<"f14">; +def F15 : PTXReg<"f15">; +def F16 : PTXReg<"f16">; +def F17 : PTXReg<"f17">; +def F18 : PTXReg<"f18">; +def F19 : PTXReg<"f19">; +def F20 : PTXReg<"f20">; +def F21 : PTXReg<"f21">; +def F22 : PTXReg<"f22">; +def F23 : PTXReg<"f23">; +def F24 : PTXReg<"f24">; +def F25 : PTXReg<"f25">; +def F26 : PTXReg<"f26">; +def F27 : PTXReg<"f27">; +def F28 : PTXReg<"f28">; +def F29 : PTXReg<"f29">; +def F30 : PTXReg<"f30">; +def F31 : PTXReg<"f31">; + + //===----------------------------------------------------------------------===// // Register classes //===----------------------------------------------------------------------===// @@ -100,3 +134,9 @@ R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, R26, R27, R28, R29, R30, R31]>; + +def RRegf32 : RegisterClass<"PTX", [f32], 32, + [F0, F1, F2, F3, F4, F5, F6, F7, + F8, F9, F10, F11, F12, F13, F14, F15, + F16, F17, F18, F19, F20, F21, F22, F23, + F24, F25, F26, F27, F28, F29, F30, F31]>; Modified: llvm/trunk/test/CodeGen/PTX/add.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/add.ll?rev=126636&r1=126635&r2=126636&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PTX/add.ll (original) +++ llvm/trunk/test/CodeGen/PTX/add.ll Mon Feb 28 00:34:09 2011 @@ -13,3 +13,17 @@ ; CHECK: ret; ret i32 %z } + +define ptx_device float @t3(float %x, float %y) { +; CHECK: add.f32 f0, f1, f2 +; CHECK-NEXT: ret; + %z = fadd float %x, %y + ret float %z +} + +define ptx_device float @t4(float %x) { +; CHECK: add.f32 f0, f1, 0F3F800000; +; CHECK-NEXT: ret; + %z = fadd float %x, 1.0 + ret float %z +} Added: llvm/trunk/test/CodeGen/PTX/ld_float.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/ld_float.ll?rev=126636&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PTX/ld_float.ll (added) +++ llvm/trunk/test/CodeGen/PTX/ld_float.ll Mon Feb 28 00:34:09 2011 @@ -0,0 +1,86 @@ +; RUN: llc < %s -march=ptx | FileCheck %s + +;CHECK: .extern .global .f32 array[]; + at array = external global [10 x float] + +;CHECK: .extern .const .f32 array_constant[]; + at array_constant = external addrspace(1) constant [10 x float] + +;CHECK: .extern .local .f32 array_local[]; + at array_local = external addrspace(2) global [10 x float] + +;CHECK: .extern .shared .f32 array_shared[]; + at array_shared = external addrspace(4) global [10 x float] + +define ptx_device float @t1(float* %p) { +entry: +;CHECK: ld.global.f32 f0, [r1]; +;CHECK-NEXT: ret; + %x = load float* %p + ret float %x +} + +define ptx_device float @t2(float* %p) { +entry: +;CHECK: ld.global.f32 f0, [r1+4]; +;CHECK-NEXT: ret; + %i = getelementptr float* %p, i32 1 + %x = load float* %i + ret float %x +} + +define ptx_device float @t3(float* %p, i32 %q) { +entry: +;CHECK: shl.b32 r0, r2, 2; +;CHECK-NEXT: add.s32 r0, r1, r0; +;CHECK-NEXT: ld.global.f32 f0, [r0]; +;CHECK-NEXT: ret; + %i = getelementptr float* %p, i32 %q + %x = load float* %i + ret float %x +} + +define ptx_device float @t4_global() { +entry: +;CHECK: ld.global.f32 f0, [array]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float]* @array, i32 0, i32 0 + %x = load float* %i + ret float %x +} + +define ptx_device float @t4_const() { +entry: +;CHECK: ld.const.f32 f0, [array_constant]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float] addrspace(1)* @array_constant, i32 0, i32 0 + %x = load float addrspace(1)* %i + ret float %x +} + +define ptx_device float @t4_local() { +entry: +;CHECK: ld.local.f32 f0, [array_local]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float] addrspace(2)* @array_local, i32 0, i32 0 + %x = load float addrspace(2)* %i + ret float %x +} + +define ptx_device float @t4_shared() { +entry: +;CHECK: ld.shared.f32 f0, [array_shared]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float] addrspace(4)* @array_shared, i32 0, i32 0 + %x = load float addrspace(4)* %i + ret float %x +} + +define ptx_device float @t5() { +entry: +;CHECK: ld.global.f32 f0, [array+4]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float]* @array, i32 0, i32 1 + %x = load float* %i + ret float %x +} Modified: llvm/trunk/test/CodeGen/PTX/mov.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/mov.ll?rev=126636&r1=126635&r2=126636&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PTX/mov.ll (original) +++ llvm/trunk/test/CodeGen/PTX/mov.ll Mon Feb 28 00:34:09 2011 @@ -11,3 +11,15 @@ ; CHECK: ret; ret i32 %x } + +define ptx_device float @t3() { +; CHECK: mov.f32 f0, 0F00000000; +; CHECK-NEXT: ret; + ret float 0.0 +} + +define ptx_device float @t4(float %x) { +; CHECK: mov.f32 f0, f1; +; CHECK-NEXT: ret; + ret float %x +} Added: llvm/trunk/test/CodeGen/PTX/mul.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/mul.ll?rev=126636&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PTX/mul.ll (added) +++ llvm/trunk/test/CodeGen/PTX/mul.ll Mon Feb 28 00:34:09 2011 @@ -0,0 +1,25 @@ +; RUN: llc < %s -march=ptx | FileCheck %s + +;define ptx_device i32 @t1(i32 %x, i32 %y) { +; %z = mul i32 %x, %y +; ret i32 %z +;} + +;define ptx_device i32 @t2(i32 %x) { +; %z = mul i32 %x, 1 +; ret i32 %z +;} + +define ptx_device float @t3(float %x, float %y) { +; CHECK: mul.f32 f0, f1, f2 +; CHECK-NEXT: ret; + %z = fmul float %x, %y + ret float %z +} + +define ptx_device float @t4(float %x) { +; CHECK: mul.f32 f0, f1, 0F40A00000; +; CHECK-NEXT: ret; + %z = fmul float %x, 5.0 + ret float %z +} Added: llvm/trunk/test/CodeGen/PTX/st_float.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/st_float.ll?rev=126636&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PTX/st_float.ll (added) +++ llvm/trunk/test/CodeGen/PTX/st_float.ll Mon Feb 28 00:34:09 2011 @@ -0,0 +1,78 @@ +; RUN: llc < %s -march=ptx | FileCheck %s + +;CHECK: .extern .global .f32 array[]; + at array = external global [10 x float] + +;CHECK: .extern .const .f32 array_constant[]; + at array_constant = external addrspace(1) constant [10 x float] + +;CHECK: .extern .local .f32 array_local[]; + at array_local = external addrspace(2) global [10 x float] + +;CHECK: .extern .shared .f32 array_shared[]; + at array_shared = external addrspace(4) global [10 x float] + +define ptx_device void @t1(float* %p, float %x) { +entry: +;CHECK: st.global.f32 [r1], f1; +;CHECK-NEXT: ret; + store float %x, float* %p + ret void +} + +define ptx_device void @t2(float* %p, float %x) { +entry: +;CHECK: st.global.f32 [r1+4], f1; +;CHECK-NEXT: ret; + %i = getelementptr float* %p, i32 1 + store float %x, float* %i + ret void +} + +define ptx_device void @t3(float* %p, i32 %q, float %x) { +;CHECK: .reg .s32 r0; +entry: +;CHECK: shl.b32 r0, r2, 2; +;CHECK-NEXT: add.s32 r0, r1, r0; +;CHECK-NEXT: st.global.f32 [r0], f1; +;CHECK-NEXT: ret; + %i = getelementptr float* %p, i32 %q + store float %x, float* %i + ret void +} + +define ptx_device void @t4_global(float %x) { +entry: +;CHECK: st.global.f32 [array], f1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float]* @array, i32 0, i32 0 + store float %x, float* %i + ret void +} + +define ptx_device void @t4_local(float %x) { +entry: +;CHECK: st.local.f32 [array_local], f1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float] addrspace(2)* @array_local, i32 0, i32 0 + store float %x, float addrspace(2)* %i + ret void +} + +define ptx_device void @t4_shared(float %x) { +entry: +;CHECK: st.shared.f32 [array_shared], f1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float] addrspace(4)* @array_shared, i32 0, i32 0 + store float %x, float addrspace(4)* %i + ret void +} + +define ptx_device void @t5(float %x) { +entry: +;CHECK: st.global.f32 [array+4], f1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float]* @array, i32 0, i32 1 + store float %x, float* %i + ret void +} Modified: llvm/trunk/test/CodeGen/PTX/sub.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/sub.ll?rev=126636&r1=126635&r2=126636&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PTX/sub.ll (original) +++ llvm/trunk/test/CodeGen/PTX/sub.ll Mon Feb 28 00:34:09 2011 @@ -13,3 +13,17 @@ ;CHECK: ret; ret i32 %z } + +define ptx_device float @t3(float %x, float %y) { +; CHECK: sub.f32 f0, f1, f2 +; CHECK-NEXT: ret; + %z = fsub float %x, %y + ret float %z +} + +define ptx_device float @t4(float %x) { +; CHECK: add.f32 f0, f1, 0FBF800000; +; CHECK-NEXT: ret; + %z = fsub float %x, 1.0 + ret float %z +} From clchiou at gmail.com Mon Feb 28 00:38:45 2011 From: clchiou at gmail.com (Che-Liang Chiou) Date: Mon, 28 Feb 2011 14:38:45 +0800 Subject: [llvm-commits] [PATCH] PTX Backend: Add basic f32 support In-Reply-To: References: Message-ID: Hi Justin, I have committed this patch in r126636. Thanks for the patch. Regards, Che-Liang On Fri, Feb 25, 2011 at 9:38 PM, Justin Holewinski wrote: > > This patch adds preliminary 32-bit floating-point support to the PTX > Backend. ?Floating-point add, sub, and mul instructions can now be emitted, > with the appropriate infrastructure to support the .f32 type in PTX. ?I have > also added updated test cases for all of the added functionality. > As this is my first patch submitted to the list, please let me know if I am > missing anything important needed for this patch to be accepted. :) > > -- > > Thanks, > Justin Holewinski > From nicholas at mxc.ca Mon Feb 28 00:52:12 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 28 Feb 2011 06:52:12 -0000 Subject: [llvm-commits] [llvm] r126637 - /llvm/trunk/lib/Analysis/ValueTracking.cpp Message-ID: <20110228065212.74D6C2A6C12C@llvm.org> Author: nicholas Date: Mon Feb 28 00:52:12 2011 New Revision: 126637 URL: http://llvm.org/viewvc/llvm-project?rev=126637&view=rev Log: Teach ValueTracking to look at the dividend when determining the sign bit of an srem instruction. Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=126637&r1=126636&r2=126637&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original) +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Feb 28 00:52:12 2011 @@ -460,6 +460,18 @@ assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); } } + if (Mask.isNegative()) { // We're looking for the sign bit. + APInt Mask2 = APInt::getSignBit(BitWidth); + KnownZero2 = 0; + KnownOne2 = 0; + ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero2, KnownOne2, TD, + Depth+1); + if (KnownOne2[BitWidth-1]) + KnownOne |= Mask2; + if (KnownZero2[BitWidth-1]) + KnownZero |= Mask2; + assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); + } break; case Instruction::URem: { if (ConstantInt *Rem = dyn_cast(I->getOperand(1))) { From nicholas at mxc.ca Mon Feb 28 02:02:21 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 28 Feb 2011 08:02:21 -0000 Subject: [llvm-commits] [llvm] r126642 - /llvm/trunk/lib/Analysis/ValueTracking.cpp Message-ID: <20110228080221.653662A6C12C@llvm.org> Author: nicholas Date: Mon Feb 28 02:02:21 2011 New Revision: 126642 URL: http://llvm.org/viewvc/llvm-project?rev=126642&view=rev Log: Teach value tracking to make use of flags in more situations. Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=126642&r1=126641&r2=126642&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original) +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Feb 28 02:02:21 2011 @@ -696,6 +696,15 @@ return isPowerOfTwo(SI->getTrueValue(), TD, Depth) && isPowerOfTwo(SI->getFalseValue(), TD, Depth); + // An exact divide or right shift can only shift off zero bits, so the result + // is non-zero only if the first operand is non-zero. + if (match(V, m_Shr(m_Value(), m_Value())) || + match(V, m_IDiv(m_Value(), m_Value()))) { + BinaryOperator *BO = cast(V); + if (BO->isExact()) + return isPowerOfTwo(BO->getOperand(0), TD, Depth); + } + return false; } @@ -732,6 +741,11 @@ // shl X, Y != 0 if X is odd. Note that the value of the shift is undefined // if the lowest bit is shifted off the end. if (BitWidth && match(V, m_Shl(m_Value(X), m_Value(Y)))) { + // shl nuw can't remove any non-zero bits. + BinaryOperator *BO = cast(V); + if (BO->hasNoUnsignedWrap()) + return isKnownNonZero(X, TD, Depth); + APInt KnownZero(BitWidth, 0); APInt KnownOne(BitWidth, 0); ComputeMaskedBits(X, APInt(BitWidth, 1), KnownZero, KnownOne, TD, Depth); @@ -741,11 +755,22 @@ // shr X, Y != 0 if X is negative. Note that the value of the shift is not // defined if the sign bit is shifted off the end. else if (match(V, m_Shr(m_Value(X), m_Value(Y)))) { + // shr exact can only shift out zero bits. + BinaryOperator *BO = cast(V); + if (BO->isExact()) + return isKnownNonZero(X, TD, Depth); + bool XKnownNonNegative, XKnownNegative; ComputeSignBit(X, XKnownNonNegative, XKnownNegative, TD, Depth); if (XKnownNegative) return true; } + // div exact can only produce a zero if the dividend is zero. + else if (match(V, m_IDiv(m_Value(X), m_Value()))) { + BinaryOperator *BO = cast(V); + if (BO->isExact()) + return isKnownNonZero(X, TD, Depth); + } // X + Y. else if (match(V, m_Add(m_Value(X), m_Value(Y)))) { bool XKnownNonNegative, XKnownNegative; From nicholas at mxc.ca Mon Feb 28 02:31:40 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 28 Feb 2011 08:31:40 -0000 Subject: [llvm-commits] [llvm] r126643 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/icmp.ll Message-ID: <20110228083140.D547C2A6C12D@llvm.org> Author: nicholas Date: Mon Feb 28 02:31:40 2011 New Revision: 126643 URL: http://llvm.org/viewvc/llvm-project?rev=126643&view=rev Log: Teach InstCombine to fold "(shr exact X, Y) == 0" --> X == 0, fixing #1 from PR9343. 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=126643&r1=126642&r2=126643&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Feb 28 02:31:40 2011 @@ -1289,13 +1289,21 @@ } case Instruction::LShr: // (icmp pred (shr X, ShAmt), CI) - case Instruction::AShr: - // Only handle equality comparisons of shift-by-constant. - if (ConstantInt *ShAmt = dyn_cast(LHSI->getOperand(1))) - if (Instruction *Res = FoldICmpShrCst(ICI, cast(LHSI), - ShAmt)) + case Instruction::AShr: { + // Handle equality comparisons of shift-by-constant. + BinaryOperator *BO = cast(LHSI); + if (ConstantInt *ShAmt = dyn_cast(LHSI->getOperand(1))) { + if (Instruction *Res = FoldICmpShrCst(ICI, BO, ShAmt)) return Res; + } + + // Handle exact shr's. + if (ICI.isEquality() && BO->isExact() && BO->hasOneUse()) { + if (RHSV.isMinValue()) + return new ICmpInst(ICI.getPredicate(), BO->getOperand(0), RHS); + } break; + } case Instruction::SDiv: case Instruction::UDiv: Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=126643&r1=126642&r2=126643&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Mon Feb 28 02:31:40 2011 @@ -387,3 +387,20 @@ %C = icmp slt i32 %B, 0 ret i1 %C } + +; PR9343 #1 +; CHECK: test40 +; CHECK %B = icmp eq i32 %X, 0 +define i1 @test40(i32 %X, i32 %Y) { + %A = ashr exact i32 %X, %Y + %B = icmp eq i32 %A, 0 + ret i1 %B +} + +; CHECK: test41 +; CHECK %B = icmp ne i32 %X, 0 +define i1 @test41(i32 %X, i32 %Y) { + %A = lshr exact i32 %X, %Y + %B = icmp ne i32 %A, 0 + ret i1 %B +} From baldrick at free.fr Mon Feb 28 03:06:14 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 28 Feb 2011 10:06:14 +0100 Subject: [llvm-commits] [llvm] r126637 - /llvm/trunk/lib/Analysis/ValueTracking.cpp In-Reply-To: <20110228065212.74D6C2A6C12C@llvm.org> References: <20110228065212.74D6C2A6C12C@llvm.org> Message-ID: <4D6B6586.9060708@free.fr> Hi Nick, -10 srem -10 is zero, so has a sign bit of zero regardless of the fact that -10 has a sign bit of one. Ciao, Duncan. From baldrick at free.fr Mon Feb 28 03:09:08 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 28 Feb 2011 10:09:08 +0100 Subject: [llvm-commits] [llvm] r126642 - /llvm/trunk/lib/Analysis/ValueTracking.cpp In-Reply-To: <20110228080221.653662A6C12C@llvm.org> References: <20110228080221.653662A6C12C@llvm.org> Message-ID: <4D6B6634.4080702@free.fr> Hi Nick, > @@ -696,6 +696,15 @@ > return isPowerOfTwo(SI->getTrueValue(), TD, Depth)&& > isPowerOfTwo(SI->getFalseValue(), TD, Depth); > > + // An exact divide or right shift can only shift off zero bits, so the result > + // is non-zero only if the first operand is non-zero. non-zero -> a power of two (both instances) Ciao, Duncan. From nicholas at mxc.ca Mon Feb 28 03:20:10 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 28 Feb 2011 01:20:10 -0800 Subject: [llvm-commits] [llvm] r126637 - /llvm/trunk/lib/Analysis/ValueTracking.cpp In-Reply-To: <4D6B6586.9060708@free.fr> References: <20110228065212.74D6C2A6C12C@llvm.org> <4D6B6586.9060708@free.fr> Message-ID: <4D6B68CA.5040203@mxc.ca> Duncan Sands wrote: > Hi Nick, -10 srem -10 is zero, so has a sign bit of zero regardless of the > fact that -10 has a sign bit of one. Hrm, the LangRef states that the srem instruction returns a result that "has the same sign as the dividend, op1". That's not confusing at all. I'm backing out r126637 and the relevant part of r126635. Nick > > 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 Mon Feb 28 03:17:39 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 28 Feb 2011 09:17:39 -0000 Subject: [llvm-commits] [llvm] r126644 - in /llvm/trunk: lib/Analysis/ValueTracking.cpp lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/icmp.ll Message-ID: <20110228091739.522D42A6C12D@llvm.org> Author: nicholas Date: Mon Feb 28 03:17:39 2011 New Revision: 126644 URL: http://llvm.org/viewvc/llvm-project?rev=126644&view=rev Log: srem doesn't actually have the same resulting sign as its numerator, you could also have a zero when numerator = denominator. Reverts parts of r126635 and r126637. Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp llvm/trunk/test/Transforms/InstCombine/icmp.ll Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=126644&r1=126643&r2=126644&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original) +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Feb 28 03:17:39 2011 @@ -460,18 +460,6 @@ assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); } } - if (Mask.isNegative()) { // We're looking for the sign bit. - APInt Mask2 = APInt::getSignBit(BitWidth); - KnownZero2 = 0; - KnownOne2 = 0; - ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero2, KnownOne2, TD, - Depth+1); - if (KnownOne2[BitWidth-1]) - KnownOne |= Mask2; - if (KnownZero2[BitWidth-1]) - KnownZero |= Mask2; - assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); - } break; case Instruction::URem: { if (ConstantInt *Rem = dyn_cast(I->getOperand(1))) { Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=126644&r1=126643&r2=126644&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Feb 28 03:17:39 2011 @@ -1348,16 +1348,6 @@ } } break; - - case Instruction::SRem: { - bool TrueIfSigned; - if (LHSI->hasOneUse() && - isSignBitCheck(ICI.getPredicate(), RHS, TrueIfSigned)) { - // srem has the same sign as its dividend so the divisor is irrelevant. - return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0), RHS); - } - break; - } } // Simplify icmp_eq and icmp_ne instructions with integer constant RHS. Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=126644&r1=126643&r2=126644&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Mon Feb 28 03:17:39 2011 @@ -378,28 +378,18 @@ ret i1 %c } -; PR9343 #7 -; CHECK: @test39 -; CHECK: ret i1 false -define i1 @test39(i31 %X, i32 %Y) { - %A = zext i31 %X to i32 - %B = srem i32 %A, %Y - %C = icmp slt i32 %B, 0 - ret i1 %C -} - ; PR9343 #1 -; CHECK: test40 +; CHECK: test39 ; CHECK %B = icmp eq i32 %X, 0 -define i1 @test40(i32 %X, i32 %Y) { +define i1 @test39(i32 %X, i32 %Y) { %A = ashr exact i32 %X, %Y %B = icmp eq i32 %A, 0 ret i1 %B } -; CHECK: test41 -; CHECK %B = icmp ne i32 %X, 0 -define i1 @test41(i32 %X, i32 %Y) { +; CHECK: test40 +; CHECK: %B = icmp ne i32 %X, 0 +define i1 @test40(i32 %X, i32 %Y) { %A = lshr exact i32 %X, %Y %B = icmp ne i32 %A, 0 ret i1 %B From nicholas at mxc.ca Mon Feb 28 03:18:11 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 28 Feb 2011 09:18:11 -0000 Subject: [llvm-commits] [llvm] r126645 - /llvm/trunk/lib/Analysis/ValueTracking.cpp Message-ID: <20110228091811.EC5512A6C12D@llvm.org> Author: nicholas Date: Mon Feb 28 03:18:11 2011 New Revision: 126645 URL: http://llvm.org/viewvc/llvm-project?rev=126645&view=rev Log: Fix comment. Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=126645&r1=126644&r2=126645&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original) +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Feb 28 03:18:11 2011 @@ -685,7 +685,7 @@ isPowerOfTwo(SI->getFalseValue(), TD, Depth); // An exact divide or right shift can only shift off zero bits, so the result - // is non-zero only if the first operand is non-zero. + // is a power of two only if the first operand is a power of two. if (match(V, m_Shr(m_Value(), m_Value())) || match(V, m_IDiv(m_Value(), m_Value()))) { BinaryOperator *BO = cast(V); From geek4civic at gmail.com Mon Feb 28 03:24:51 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Mon, 28 Feb 2011 18:24:51 +0900 Subject: [llvm-commits] [cfe-dev] [PATCH] Windows improvements In-Reply-To: <97510B8DF78E714D91EB4A27850A17DA0C3EACB8DC@winserv02.hansoft.local> References: <97510B8DF78E714D91EB4A27850A17DA0C3EACB8DC@winserv02.hansoft.local> Message-ID: Hello Erik, Thank you to work. I have not checked to build them, though, I can tell you some comments, excuse me. * General - Please post patches to cfe-commits and to llvm-commits, too. (IMHO it would not be needed to split articles apart each lists as long as each would be related.) - If you can, please attach files w/o CRLF(dos encodings), or with attached text/plain. - You may split and post an article if your patches were not "series of patches" but "set of functionally individual patches". > llvm-msvc10-fix-warnings.patch: > clang-msvc10-fix-warnings.patch: > Fixes compiler warnings. Looks good to me. They could be applied when gtest guys said ok. > llvm-msvc-format-diagnostics.patch: > clang-msvc-format-diagnostics.patch: > > Complete support for msvc style diagnostics parsable by Visual Studio. Added > column support for msvc locations. I also added indentation so you can > easily see the grouping of errors, include stacks and notes (msvc mode > only). It seems it would be better functionally. But please remember Microsoft's toolchain would not be the only one. Also mingw depends on LLVM_ON_WIN32. (in llvm side). For now, I don't have better answer. > llvm-outputdebugstring-support.patch: > clang-visual-studio-debuggability.patch: > > Visual Studio has no good way of getting stdout and stderr output into its > Output Window. Getting these into the Output Window can be really helpful > for debugging as you can go to diagnostics locations directly from there. > It's also helpful to actually see the compiler output while breaking into > the code. To allow this I have added support for OutputDebugString in llvm > raw_ostream. I then use this from the driver where you can redirect stdout > and stderr to OutputDebugString with -output-diagnostics-as-debug-string > option. Windows/OutputDebugString.inc would be dubious. > #include "Windows.h" It would be better with small letter "windows.h", to be compiled cross on case-sensitive filesystem. > namespace llvm { > void llvm::output_debug_string(const char *String) { > OutputDebugString(String); > } > } Either outer "namespace llvm" or inner specifier "llvm::" might be redundant. It cannot be compiled with g++-4.4.0. > I have also added a shortcut when invoking cc1 so it doesn't actually start > a new process. This is because Visual Studio does not support automatically > attaching to child processes, and doing -### every time you change a command > line option and copying the results is cumbersome. It should also have the > added benefit of speeding up compilation. I don't know enough about clang to > know if this is safe in all instances, and the way it's implemented might > not be optimal. Let me know if this could be done in a better way. Please split clang's patch by functionality. > clang-pragma-message.patch: > > Make pragma message just output the message ignoring location (in msvc mode) > and include stack information (always). This makes #pragma message usable in > the same way when using clang as when using msvc and gcc. Excuse me, I have no idea. > llvm-msvc-multi-processor-compilation.patch: > > Make use of multiple processors when compiling one project in msbuild/Visual > Studio. This greatly decreases turnaround time when changing headers. "/MP" works better for me functionally, though, it would be dubious for style. Oscar, do you have any opinions? FYI, I am using /m with msbuild.exe. > llvm-temp-test-file-fail-on-win32.patch: > > Fix Windows python issue where open temporary files cannot be opened again. > Needed for clang-c++tests. Looks good to me. Daniel, would it be enough? > clang-missing-builtins.patch: > llvm-interrupt-builtin.patch: > > Add builtins needed to implement __debugbreak and _byteswap_ushort from > intrin.h. Before implementing everything else needed for intrin.h I need to > know if this is the correct way? I have no idea, excuse me. :( > clang-msvc10-fix-mm_malloc-error.patch: > > mm_malloc is implemented in Visual Studio 2010, this fixes the compile error > resulting from it being a macro. Also mingw-w64 provides _mm_malloc stuff. I suggest not to tweak _mm_malloc, but rely on provided _mm_malloc. I will work on it, too. I expect it could be possible on known plaforms. #ifdef _mm_malloc static inline void *_mm_malloc() { ... #endif ...Takumi On Mon, Feb 28, 2011 at 1:15 PM, Erik Olofsson wrote: > With GCC being a dead end and hard to use for universal binaries on OSX and > Microsoft refusing to fix bugs in their compiler I thought it would good > idea to get clang compiling our code base. > > > > Before I start fixing bugs and missing features in clang I have created > these patches to make it easier to debug and develop clang on Windows. After > this is done what is needed is reimplementing from Visual Studio > 2010 includes and fixing any bugs that I find in the compiler. Finally I > need lambda expressions which we already use heavily. > > > > llvm-msvc10-fix-warnings.patch: > > clang-msvc10-fix-warnings.patch: > > Fixes compiler warnings. > > > > llvm-msvc-format-diagnostics.patch: > > clang-msvc-format-diagnostics.patch: > > Complete support for msvc style diagnostics parsable by Visual Studio. Added > column support for msvc locations. I also added indentation so you can > easily see the grouping of errors, include stacks and notes (msvc mode > only). > > > > llvm-outputdebugstring-support.patch: > > clang-visual-studio-debuggability.patch: > > Visual Studio has no good way of getting stdout and stderr output into its > Output Window. Getting these into the Output Window can be really helpful > for debugging as you can go to diagnostics locations directly from there. > It's also helpful to actually see the compiler output while breaking into > the code. To allow this I have added support for OutputDebugString in llvm > raw_ostream. I then use this from the driver where you can redirect stdout > and stderr to OutputDebugString with -output-diagnostics-as-debug-string > option. > > > > I have also added a shortcut when invoking cc1 so it doesn't actually start > a new process. This is because Visual Studio does not support automatically > attaching to child processes, and doing -### every time you change a command > line option and copying the results is cumbersome. It should also have the > added benefit of speeding up compilation. I don't know enough about clang to > know if this is safe in all instances, and the way it's implemented might > not be optimal. Let me know if this could be done in a better way. > > > > clang-pragma-message.patch: > > Make pragma message just output the message ignoring location (in msvc mode) > and include stack information (always). This makes #pragma message usable in > the same way when using clang as when using msvc and gcc. > > > > llvm-msvc-multi-processor-compilation.patch: > > Make use of multiple processors when compiling one project in msbuild/Visual > Studio. This greatly decreases turnaround time when changing headers. > > > > llvm-temp-test-file-fail-on-win32.patch: > > Fix Windows python issue where open temporary files cannot be opened again. > Needed for clang-c++tests. > > > > clang-missing-builtins.patch: > > llvm-interrupt-builtin.patch: > > Add builtins needed to implement __debugbreak and _byteswap_ushort from > intrin.h. Before implementing everything else needed for intrin.h I need to > know if this is the correct way? > > > > clang-msvc10-fix-mm_malloc-error.patch: > > mm_malloc is implemented in Visual Studio 2010, this fixes the compile error > resulting from it being a macro. > > > > I have ran check-all on OSX and Visual Studio 2010 and made sure that there > aren't any regressions on these platforms. I would add tests for the > OutputDebugString functionality, but capturing this probably needs extra > support in the testing framework. Let me know what you think of these > patches and I will start fixing more things if they are accepted. > > > > Thanks, > > Erik From fvbommel at gmail.com Mon Feb 28 03:44:07 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Mon, 28 Feb 2011 09:44:07 -0000 Subject: [llvm-commits] [llvm] r126647 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/switch-on-const-select.ll Message-ID: <20110228094407.7D5B42A6C12C@llvm.org> Author: fvbommel Date: Mon Feb 28 03:44:07 2011 New Revision: 126647 URL: http://llvm.org/viewvc/llvm-project?rev=126647&view=rev Log: Teach SimplifyCFG that (switch (select cond, X, Y)) is better expressed as a branch. Based on a patch by Alistair Lynn. Added: llvm/trunk/test/Transforms/SimplifyCFG/switch-on-const-select.ll Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=126647&r1=126646&r2=126647&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Mon Feb 28 03:44:07 2011 @@ -1800,6 +1800,26 @@ return true; } +// SimplifySwitchOnSelect - Replaces +// (switch (select cond, X, Y)) on constant X, Y +// with a branch - conditional if X and Y lead to distinct BBs, +// unconditional otherwise. +static bool SimplifySwitchOnSelect(SwitchInst *SI, SelectInst *Select) { + // Check for constant integer values in the select. + ConstantInt *TrueVal = dyn_cast(Select->getTrueValue()); + ConstantInt *FalseVal = dyn_cast(Select->getFalseValue()); + if (!TrueVal || !FalseVal) + return false; + + // Find the relevant condition and destinations. + Value *Condition = Select->getCondition(); + BasicBlock *TrueBB = SI->getSuccessor(SI->findCaseValue(TrueVal)); + BasicBlock *FalseBB = SI->getSuccessor(SI->findCaseValue(FalseVal)); + + // Perform the actual simplification. + return SimplifyTerminatorOnSelect(SI, Condition, TrueBB, FalseBB); +} + // SimplifyIndirectBrOnSelect - Replaces // (indirectbr (select cond, blockaddress(@fn, BlockA), // blockaddress(@fn, BlockB))) @@ -2309,7 +2329,12 @@ if (BasicBlock *OnlyPred = BB->getSinglePredecessor()) if (SimplifyEqualityComparisonWithOnlyPredecessor(SI, OnlyPred)) return SimplifyCFG(BB) | true; - + + Value *Cond = SI->getCondition(); + if (SelectInst *Select = dyn_cast(Cond)) + if (SimplifySwitchOnSelect(SI, Select)) + return SimplifyCFG(BB) | true; + // If the block only contains the switch, see if we can fold the block // away into any preds. BasicBlock::iterator BBI = BB->begin(); Added: llvm/trunk/test/Transforms/SimplifyCFG/switch-on-const-select.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/switch-on-const-select.ll?rev=126647&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/switch-on-const-select.ll (added) +++ llvm/trunk/test/Transforms/SimplifyCFG/switch-on-const-select.ll Mon Feb 28 03:44:07 2011 @@ -0,0 +1,138 @@ +; RUN: opt < %s -simplifycfg -S | FileCheck %s + +; Test basic folding to a conditional branch. +define i32 @foo(i64 %x, i64 %y) nounwind { +; CHECK: @foo +entry: + %eq = icmp eq i64 %x, %y + br i1 %eq, label %b, label %switch +switch: + %lt = icmp slt i64 %x, %y +; CHECK: br i1 %lt, label %a, label %b + %qux = select i1 %lt, i32 0, i32 2 + switch i32 %qux, label %bees [ + i32 0, label %a + i32 1, label %b + i32 2, label %b + ] +a: + tail call void @bees.a() nounwind + ret i32 1 +; CHECK: b: +; CHECK-NEXT: %retval = phi i32 [ 0, %switch ], [ 2, %entry ] +b: + %retval = phi i32 [0, %switch], [0, %switch], [2, %entry] + tail call void @bees.b() nounwind + ret i32 %retval +; CHECK-NOT: bees: +bees: + tail call void @llvm.trap() nounwind + unreachable +} + +; Test basic folding to an unconditional branch. +define i32 @bar(i64 %x, i64 %y) nounwind { +; CHECK: @bar +entry: +; CHECK-NEXT: entry: +; CHECK-NEXT: tail call void @bees.a() nounwind +; CHECK-NEXT: ret i32 0 + %lt = icmp slt i64 %x, %y + %qux = select i1 %lt, i32 0, i32 2 + switch i32 %qux, label %bees [ + i32 0, label %a + i32 1, label %b + i32 2, label %a + ] +a: + %retval = phi i32 [0, %entry], [0, %entry], [1, %b] + tail call void @bees.a() nounwind + ret i32 0 +b: + tail call void @bees.b() nounwind + br label %a +bees: + tail call void @llvm.trap() nounwind + unreachable +} + +; Test the edge case where both values from the select are the default case. +define void @bazz(i64 %x, i64 %y) nounwind { +; CHECK: @bazz +entry: +; CHECK-NEXT: entry: +; CHECK-NEXT: tail call void @bees.b() nounwind +; CHECK-NEXT: ret void + %lt = icmp slt i64 %x, %y + %qux = select i1 %lt, i32 10, i32 12 + switch i32 %qux, label %b [ + i32 0, label %a + i32 1, label %bees + i32 2, label %bees + ] +a: + tail call void @bees.a() nounwind + ret void +b: + tail call void @bees.b() nounwind + ret void +bees: + tail call void @llvm.trap() + unreachable +} + +; Test the edge case where both values from the select are equal. +define void @quux(i64 %x, i64 %y) nounwind { +; CHECK: @quux +entry: +; CHECK-NEXT: entry: +; CHECK-NEXT: tail call void @bees.a() nounwind +; CHECK-NEXT: ret void + %lt = icmp slt i64 %x, %y + %qux = select i1 %lt, i32 0, i32 0 + switch i32 %qux, label %b [ + i32 0, label %a + i32 1, label %bees + i32 2, label %bees + ] +a: + tail call void @bees.a() nounwind + ret void +b: + tail call void @bees.b() nounwind + ret void +bees: + tail call void @llvm.trap() + unreachable +} + +; A final test, for phi node munging. +define i32 @xyzzy(i64 %x, i64 %y) { +; CHECK: @xyzzy +entry: + %eq = icmp eq i64 %x, %y + br i1 %eq, label %r, label %cont +cont: +; CHECK: %lt = icmp slt i64 %x, %y + %lt = icmp slt i64 %x, %y +; CHECK-NEXT: br i1 %lt, label %a, label %r + %qux = select i1 %lt, i32 0, i32 2 + switch i32 %qux, label %bees [ + i32 0, label %a + i32 1, label %r + i32 2, label %r + ] +r: + %val = phi i32 [0, %entry], [1, %cont], [1, %cont] + ret i32 %val +a: + ret i32 -1 +; CHECK-NOT: bees: +bees: + tail call void @llvm.trap() + unreachable +} + +declare void @llvm.trap() nounwind noreturn +declare void @bees.a() nounwind +declare void @bees.b() nounwind From fvbommel at gmail.com Mon Feb 28 03:50:44 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Mon, 28 Feb 2011 10:50:44 +0100 Subject: [llvm-commits] PATCH: instcombine switch on select of constants to br In-Reply-To: <4D6B101B.8070703@mxc.ca> References: <893CFB3C-832C-4959-AE72-4186FCD61E99@gmail.com> <4D2A730F.2090207@mxc.ca> <130DB463-EF73-40A2-8166-5D3A014D9D12@gmail.com> <4D6B101B.8070703@mxc.ca> Message-ID: On Mon, Feb 28, 2011 at 4:01 AM, Nick Lewycky wrote: > I kinda wish it didn't work this way. Here's what I have in mind: > ?1. fix llvm.org/PR774 (make the default case optional) > ?2. one optimization which finds switches that have two destinations and > turns them into branches > ?3. one optimization which sees select (and other things) feeding into a > switch and removes the impossible cases from the switch, possibly including > the default case. > > That said, if I can't talk you into doing that much work, then this patch > looks fine: While that does sound like a good idea long-term, I probably won't have time to implement all that before the 2.9 branch date. I just committed this as r126647. For now this code should work fine, and we can easily rip it back out if a more general solution is implemented. From geek4civic at gmail.com Mon Feb 28 03:59:00 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Mon, 28 Feb 2011 18:59:00 +0900 Subject: [llvm-commits] Console input should be opened in binary mode on Windows (Python setting) In-Reply-To: <6AE1604EE3EC5F4296C096518C6B77EE17E1229176@mail.accesssoftek.com> References: <6AE1604EE3EC5F4296C096518C6B77EE17E1229176@mail.accesssoftek.com> Message-ID: Danil, It is good, as long as the scripts would be used only to tests, thank you. FYI I have another patch for this issue. But anyway, I have not met this without msys bash. I don't know why. ...Takumi -------------- next part -------------- commit 9101791704dd602e6999bb5f126ed61fa8c2bf26 Author: NAKAMURA Takumi Date: Mon Nov 1 14:47:16 2010 +0900 test/Scripts/coff-dump.py, elf-dump, macho-dump: Set setmode(O_BINARY) for stdin. diff --git a/test/Scripts/coff-dump.py b/test/Scripts/coff-dump.py index 36ec539..80cef87 100755 --- a/test/Scripts/coff-dump.py +++ b/test/Scripts/coff-dump.py @@ -579,6 +579,9 @@ def handle_element(entry): if len(sys.argv) <= 1 or sys.argv[1] == '-': import StringIO + if sys.platform == "win32": + import os, msvcrt + msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) Input = StringIO.StringIO(sys.stdin.read()) else: Input = open (sys.argv[1], "rb") diff --git a/test/Scripts/elf-dump b/test/Scripts/elf-dump index 76cdbf9..18f030c 100755 --- a/test/Scripts/elf-dump +++ b/test/Scripts/elf-dump @@ -226,6 +226,9 @@ if __name__ == "__main__": if not args: args.append('-') + if sys.platform == "win32": + import os, msvcrt + msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) for arg in args: dumpELF(arg, opts) diff --git a/test/Scripts/macho-dumpx b/test/Scripts/macho-dumpx index 71e06d8..13053da 100755 --- a/test/Scripts/macho-dumpx +++ b/test/Scripts/macho-dumpx @@ -286,6 +286,9 @@ def main(): if not args: args.append('-') + if sys.platform == "win32": + import os, msvcrt + msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) for arg in args: dumpmacho(arg, opts) From baldrick at free.fr Mon Feb 28 04:52:52 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 28 Feb 2011 11:52:52 +0100 Subject: [llvm-commits] [llvm] r126637 - /llvm/trunk/lib/Analysis/ValueTracking.cpp In-Reply-To: <4D6B68CA.5040203@mxc.ca> References: <20110228065212.74D6C2A6C12C@llvm.org> <4D6B6586.9060708@free.fr> <4D6B68CA.5040203@mxc.ca> Message-ID: <4D6B7E84.7010307@free.fr> On 28/02/11 10:20, Nick Lewycky wrote: > Duncan Sands wrote: >> Hi Nick, -10 srem -10 is zero, so has a sign bit of zero regardless of the >> fact that -10 has a sign bit of one. > > Hrm, the LangRef states that the srem instruction returns a result that "has the > same sign as the dividend, op1". That's not confusing at all. > > I'm backing out r126637 and the relevant part of r126635. Thanks Nick! How about correcting the LangRef too, otherwise this is sure to happen again. Ciao, Duncan. From geek4civic at gmail.com Mon Feb 28 06:14:45 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Mon, 28 Feb 2011 21:14:45 +0900 Subject: [llvm-commits] [cfe-dev] [PATCH] Windows improvements In-Reply-To: <97510B8DF78E714D91EB4A27850A17DA0C3EACB911@winserv02.hansoft.local> References: <97510B8DF78E714D91EB4A27850A17DA0C3EACB8DC@winserv02.hansoft.local> <97510B8DF78E714D91EB4A27850A17DA0C3EACB911@winserv02.hansoft.local> Message-ID: Good evening, Erik, On Mon, Feb 28, 2011 at 7:44 PM, Erik Olofsson wrote: > From HandleLLVMOptions.cmake > ?if(CYGWIN) > ? ?set(LLVM_ON_WIN32 0) > ? ?set(LLVM_ON_UNIX 1) > ?else(CYGWIN) > ? ?set(LLVM_ON_WIN32 1) > ? ?set(LLVM_ON_UNIX 0) > endif(CYGWIN) > > This can filter out Cygwin with (defined(LLVM_ON_WIN32) && !defined(LLVM_ON_UNIX)), but I guess mingw would have to be filtered out in another way. I assume Cygwin could be treated as unix-variant in common context. (Cygwin gcc does not define _WIN32 by default) In contrast, mingw should be treated as "Win32 development environment". Mingw provides MSVCRT.DLL-compatible standard headers and w32api. Of course, I know we have to distinguish msc and mingw in some cases. > If there is no existing way I could add: > ?if(MSVC) > ? ?set(LLVM_ON_WIN32MSVC 1) > ?endif(MSVC) In C/C++ sources, we may detect MSVC with _MSC_VER, I suppose. IMO I don't need to introduce LLVM_ON_WIN32MSVC. Rather, I think LLVM_ON_**** could be deprecated. It should be enough with _WIN32. >> Please split clang's patch by functionality. > > Ok, so split into three patches? > * refactor llvm::outs()/errs() > * cc1 invocation without a new process > * output diagnostics as debug string Sure. And "cosmetic changes (eg. reindentation, 80-col wrap, untabify &c)" might be split out, please. >> "/MP" works better for me functionally, though, it would be dubious for >> style. >> Oscar, do you have any opinions? >> >> FYI, I am using /m with msbuild.exe. > > 'msbuild /m' and 'cl /MP' works well together giving the most amount of parallelism with both projects and individual translation units being compiled in parallel. Good to hear. :D ...Takumi From baldrick at free.fr Mon Feb 28 06:13:25 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 28 Feb 2011 12:13:25 -0000 Subject: [llvm-commits] [dragonegg] r126649 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <20110228121325.E69C92A6C12C@llvm.org> Author: baldrick Date: Mon Feb 28 06:13:25 2011 New Revision: 126649 URL: http://llvm.org/viewvc/llvm-project?rev=126649&view=rev Log: If a register input is smaller than a tied output then we extend the input to the type of the output, and on big endian machines perform a shift on the extended value. This shift doesn't make any sense to me, so remove it. Note that clang does not perform a shift in its corresponding logic. Modified: dragonegg/trunk/llvm-convert.cpp Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=126649&r1=126648&r2=126649&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Mon Feb 28 06:13:25 2011 @@ -7092,11 +7092,6 @@ } Op = CastToAnyType(Op, IsSigned, OTy, CallResultTypes[OutputIndex].second); - if (BYTES_BIG_ENDIAN) { - Constant *ShAmt = ConstantInt::get(Op->getType(), - OTyBits-OpTyBits); - Op = Builder.CreateLShr(Op, ShAmt); - } } } } From baldrick at free.fr Mon Feb 28 06:30:47 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 28 Feb 2011 12:30:47 -0000 Subject: [llvm-commits] [llvm] r126650 - in /llvm/trunk/test/CodeGen: Generic/2011-02-27-Fpextend.ll X86/2011-02-27-Fpextend.ll Message-ID: <20110228123047.C9E9E2A6C12C@llvm.org> Author: baldrick Date: Mon Feb 28 06:30:47 2011 New Revision: 126650 URL: http://llvm.org/viewvc/llvm-project?rev=126650&view=rev Log: Make this test x86 specific because the ARM backend can't handle it. Added: llvm/trunk/test/CodeGen/X86/2011-02-27-Fpextend.ll - copied, changed from r126574, llvm/trunk/test/CodeGen/Generic/2011-02-27-Fpextend.ll Removed: llvm/trunk/test/CodeGen/Generic/2011-02-27-Fpextend.ll Removed: llvm/trunk/test/CodeGen/Generic/2011-02-27-Fpextend.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/2011-02-27-Fpextend.ll?rev=126649&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Generic/2011-02-27-Fpextend.ll (original) +++ llvm/trunk/test/CodeGen/Generic/2011-02-27-Fpextend.ll (removed) @@ -1,7 +0,0 @@ -; RUN: llc < %s -; PR9309 - -define <4 x double> @f_fu(<4 x float>) nounwind { - %float2double.i = fpext <4 x float> %0 to <4 x double> - ret <4 x double> %float2double.i -} Copied: llvm/trunk/test/CodeGen/X86/2011-02-27-Fpextend.ll (from r126574, llvm/trunk/test/CodeGen/Generic/2011-02-27-Fpextend.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2011-02-27-Fpextend.ll?p2=llvm/trunk/test/CodeGen/X86/2011-02-27-Fpextend.ll&p1=llvm/trunk/test/CodeGen/Generic/2011-02-27-Fpextend.ll&r1=126574&r2=126650&rev=126650&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Generic/2011-02-27-Fpextend.ll (original) +++ llvm/trunk/test/CodeGen/X86/2011-02-27-Fpextend.ll Mon Feb 28 06:30:47 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s +; RUN: llc -march=x86-64 < %s ; PR9309 define <4 x double> @f_fu(<4 x float>) nounwind { From geek4civic at gmail.com Mon Feb 28 06:40:33 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Mon, 28 Feb 2011 21:40:33 +0900 Subject: [llvm-commits] [Review Request] Target/X86: Tweak va_arg for Win64 not to miss taking va_start when number of fixed args > 4. In-Reply-To: References: Message-ID: Ping. On Fri, Feb 18, 2011 at 4:07 PM, NAKAMURA Takumi wrote: > --- > ?lib/Target/X86/X86ISelLowering.cpp | ? ?8 +++++--- > ?test/CodeGen/X86/win64_vararg.ll ? | ? 33 +++++++++++++++++++++++++++++++++ > ?2 files changed, 38 insertions(+), 3 deletions(-) > --- > > It just works for me, though, I am not confident of its way. > Let me know whoever would know better way, thank you. > > ...Takumi > From geek4civic at gmail.com Mon Feb 28 06:41:12 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Mon, 28 Feb 2011 21:41:12 +0900 Subject: [llvm-commits] [Review Request] Target/X86: Tweak alloca and add a testcase for mingw64 and msvcrt on Win64. [PR8778] In-Reply-To: References: Message-ID: Ping. On Fri, Feb 18, 2011 at 4:30 PM, NAKAMURA Takumi wrote: > --- > ?lib/Target/X86/X86FrameLowering.cpp ? ? ? ?| ? 19 +++++++-- > ?lib/Target/X86/X86ISelLowering.cpp ? ? ? ? | ? 57 +++++++++++++++++++-------- > ?lib/Target/X86/X86InstrControl.td ? ? ? ? ?| ? 10 +++++ > ?test/CodeGen/X86/win64_alloca_dynalloca.ll | ? 55 +++++++++++++++++++++++++++ > ?test/CodeGen/X86/win_chkstk.ll ? ? ? ? ? ? | ? ?2 +- > ?5 files changed, 120 insertions(+), 23 deletions(-) > ?create mode 100644 test/CodeGen/X86/win64_alloca_dynalloca.ll > -- > > It introduces W64ALLOCA. > I would attempt to rework, if there is a way to avoid W64ALLOCA. > > It is incompatible to TDM-GCC. > > ...Takumi > From geek4civic at gmail.com Mon Feb 28 06:41:39 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Mon, 28 Feb 2011 21:41:39 +0900 Subject: [llvm-commits] [Review Request] lib/MC/WinCOFFStreamer.cpp: [PR8354] Emit .bss as .bss${foobar} instead of .bss$linkonce_{foobar} and emit local storage without IMAGE_SCN_LNK_COMDAT. In-Reply-To: References: Message-ID: Ping. On Fri, Feb 18, 2011 at 9:34 PM, NAKAMURA Takumi wrote: > --- > ?lib/MC/WinCOFFStreamer.cpp | ? ?7 ++++--- > ?1 files changed, 4 insertions(+), 3 deletions(-) > --- > > I had used the patch in bugs. > http://llvm.org/bugs/show_bug.cgi?id=8354#c2 > > It is improved version. WinCOFFStreamer::AddCommonSymbol() can emit > symbols's alignment as section alignment, though, .lcomm's alignment > is not emitted for now. > > Now, each common symbols would be emitted as individual section .bss${foobar}. > It might be overkill. :p > > Checked with 3-stage clang build on Windows x64. > > > ...Takumi > From geek4civic at gmail.com Mon Feb 28 06:44:34 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Mon, 28 Feb 2011 21:44:34 +0900 Subject: [llvm-commits] [PATCH][Review request] Tweak tests for Mingw MSYS bash In-Reply-To: References: Message-ID: Ping. Daniel, how are you? http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20110207/116319.html http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20110207/116320.html http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20110207/116321.html http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20110207/116322.html ...Takumi On Thu, Feb 10, 2011 at 5:01 PM, NAKAMURA Takumi wrote: > Hello Daniel, > > I will send following 4 patches for LLVM and 2 patches for clang. > > ?- Working with MSYS bash and Python/w32 together. > ? ?To tweak DOSish pathstring quirk. > ?- Capability for lit to execute bash tests on Python/w32. > > Please take a look into them, thank you. > > Checked on my hosts for months! > > ...Takumi > > > [llvm] > https://github.com/chapuni/LLVM/commits/msys-bash/20110210/ > NAKAMURA Takumi (4): > ?utils/lit/lit/TestRunner.py: bash is available with MSYS on > ? ?Python/W32. Then we can execute "bash tests". > ?Makefile.rules: Introduce $(ECHOPATH) to print DOSish path string on > ? ?MSYS bash for alternative of $(ECHO). > ?test/Makefile: Use $(ECHOPATH) to make lit.site.cfg(s). > ?Use $(ECHOPATH) to make llvm-lit from llvm-lit.in. > > ?Makefile.rules ? ? ? ? ? ? ?| ? 18 ++++++++++++++++++ > ?test/Makefile ? ? ? ? ? ? ? | ? 34 ++++++++++++++++++---------------- > ?utils/lit/lit/TestRunner.py | ? 15 ++++++++++----- > ?utils/llvm-lit/Makefile ? ? | ? ?9 +++++---- > ?4 files changed, 51 insertions(+), 25 deletions(-) > > [clang] > https://github.com/chapuni/clang/commits/msys-bash/20110210/ > NAKAMURA Takumi (2): > ?test/Makefile: Use $(ECHOPATH) to make lit.site.cfg(s). > ?test/lit.cfg: bash is available on MSYS. > > ?test/Makefile | ? 42 ++++++++++++++++++++++-------------------- > ?test/lit.cfg ?| ? ?5 +++-- > ?2 files changed, 25 insertions(+), 22 deletions(-) > From anton at korobeynikov.info Mon Feb 28 06:47:28 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Mon, 28 Feb 2011 15:47:28 +0300 Subject: [llvm-commits] [Review Request] Target/X86: Tweak va_arg for Win64 not to miss taking va_start when number of fixed args > 4. In-Reply-To: References: Message-ID: Hello Takumi > It just works for me, though, I am not confident of its way. > Let me know whoever would know better way, thank you. Please clarify the following comment in the code, right now it's pretty pointless: + // FIXME: It is dirty hack but works. Ok with this fix. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From anton at korobeynikov.info Mon Feb 28 06:50:01 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Mon, 28 Feb 2011 15:50:01 +0300 Subject: [llvm-commits] [Review Request] Target/X86: Tweak alloca and add a testcase for mingw64 and msvcrt on Win64. [PR8778] In-Reply-To: References: Message-ID: Hi Takumi, > It introduces W64ALLOCA. > I would attempt to rework, if there is a way to avoid W64ALLOCA. In msvcrt case the __chkstk invocation is just an ordinary function call. Or I'm missing something? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From anton at korobeynikov.info Mon Feb 28 06:51:46 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Mon, 28 Feb 2011 15:51:46 +0300 Subject: [llvm-commits] [cfe-commits] [cfe-dev] [PATCH] Windows improvements In-Reply-To: <97510B8DF78E714D91EB4A27850A17DA0C3EACB91A@winserv02.hansoft.local> References: <97510B8DF78E714D91EB4A27850A17DA0C3EACB8DC@winserv02.hansoft.local> <97510B8DF78E714D91EB4A27850A17DA0C3EACB911@winserv02.hansoft.local> <97510B8DF78E714D91EB4A27850A17DA0C3EACB91A@winserv02.hansoft.local> Message-ID: Hi Erik > But what about if you then use a clang compiled in mingw to host itself. I assume we need ms extensions enabled, and then _MSC_VER will be defined. I think we need to split these entities. Clearly one might want to have vcpp-like diagnostics even w/o MS extensions enabled (consider e.g. I'm targeting some arch and want to integrate with visual studio). -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From geek4civic at gmail.com Mon Feb 28 07:11:13 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Mon, 28 Feb 2011 22:11:13 +0900 Subject: [llvm-commits] [Review Request] Target/X86: Tweak alloca and add a testcase for mingw64 and msvcrt on Win64. [PR8778] In-Reply-To: References: Message-ID: Hello Anton, On Mon, Feb 28, 2011 at 9:50 PM, Anton Korobeynikov wrote: > In msvcrt case the __chkstk invocation is just an ordinary function > call. Or I'm missing something? http://msdn.microsoft.com/en-us/library/tawsa7cb.aspx Yeah, __chkstk does not manipulate stack pointer, though, __chkstk is also expected not to modify argument registers (cx dx r8 r9 xmm...). I have no idea to implement __chkstk with CALL64, for now. Please see also win64_alloca_dynalloca.ll. Thank you, ...Takumi From Renato.Golin at arm.com Mon Feb 28 07:34:40 2011 From: Renato.Golin at arm.com (Renato Golin) Date: Mon, 28 Feb 2011 13:34:40 +0000 Subject: [llvm-commits] ARM .fpu attribute Message-ID: <4D6BA470.1020105@arm.com> Hi all, This is a patch to fig bug: http://llvm.org/bugs/show_bug.cgi?id=8931 Rationale: The ARM asm backend wasn't printing the .fpu attribute when NEON was available (of VFP for that matter) and the linker was getting confused on which instructions were available or not. This patch fix this by printing the .fpu attribute whenever in assembly mode and when VFP/NEON is available, exporting both numeric and text versions. thanks, --renato -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. -------------- next part -------------- A non-text attachment was scrubbed... Name: fpu-printing.patch Type: text/x-patch Size: 2770 bytes Desc: fpu-printing.patch Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110228/f56cdcb7/attachment.bin From kalle.raiskila at nokia.com Mon Feb 28 08:08:24 2011 From: kalle.raiskila at nokia.com (Kalle Raiskila) Date: Mon, 28 Feb 2011 14:08:24 -0000 Subject: [llvm-commits] [llvm] r126651 - in /llvm/trunk/lib/Target/CellSPU: SPUAsmPrinter.cpp SPUInstrFormats.td SPUInstrInfo.cpp SPUInstrInfo.td Message-ID: <20110228140824.8131D2A6C12C@llvm.org> Author: kraiskil Date: Mon Feb 28 08:08:24 2011 New Revision: 126651 URL: http://llvm.org/viewvc/llvm-project?rev=126651&view=rev Log: Add branch hinting for SPU. The implemented algorithm is overly simplistic (just speculate all branches are taken)- this is work in progress. Modified: llvm/trunk/lib/Target/CellSPU/SPUAsmPrinter.cpp llvm/trunk/lib/Target/CellSPU/SPUInstrFormats.td llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td Modified: llvm/trunk/lib/Target/CellSPU/SPUAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUAsmPrinter.cpp?rev=126651&r1=126650&r2=126651&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUAsmPrinter.cpp Mon Feb 28 08:08:24 2011 @@ -182,6 +182,10 @@ printOp(MI->getOperand(OpNo), O); } + void printHBROperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O) { + printOp(MI->getOperand(OpNo), O); + } + void printPCRelativeOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O) { // Used to generate a ".-", but it turns out that the assembler // really wants the target. @@ -279,6 +283,9 @@ } O << *Mang->getSymbol(MO.getGlobal()); return; + case MachineOperand::MO_MCSymbol: + O << *(MO.getMCSymbol()); + return; default: O << ""; return; Modified: llvm/trunk/lib/Target/CellSPU/SPUInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUInstrFormats.td?rev=126651&r1=126650&r2=126651&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUInstrFormats.td (original) +++ llvm/trunk/lib/Target/CellSPU/SPUInstrFormats.td Mon Feb 28 08:08:24 2011 @@ -296,3 +296,25 @@ let Pattern = pattern; let Inst{31-0} = 0; } + +//===----------------------------------------------------------------------===// +// Branch hint formats +//===----------------------------------------------------------------------===// +// For hbrr and hbra +class HBI16Form opcode, dag IOL, string asmstr> + : Instruction { + field bits<32> Inst; + bits<16>i16; + bits<9>RO; + + let Namespace = "SPU"; + let InOperandList = IOL; + let OutOperandList = (outs); //no output + let AsmString = asmstr; + let Itinerary = BranchHints; + + let Inst{0-6} = opcode; + let Inst{7-8} = RO{8-7}; + let Inst{9-24} = i16; + let Inst{25-31} = RO{6-0}; +} Modified: llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp?rev=126651&r1=126650&r2=126651&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp Mon Feb 28 08:08:24 2011 @@ -21,6 +21,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/MC/MCContext.h" using namespace llvm; @@ -281,9 +282,20 @@ return true; } +// search MBB for branch hint labels and branch hit ops +static void removeHBR( MachineBasicBlock &MBB) { + for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ++I){ + if (I->getOpcode() == SPU::HBRA || + I->getOpcode() == SPU::HBR_LABEL){ + I=MBB.erase(I); + } + } +} + unsigned SPUInstrInfo::RemoveBranch(MachineBasicBlock &MBB) const { MachineBasicBlock::iterator I = MBB.end(); + removeHBR(MBB); if (I == MBB.begin()) return 0; --I; @@ -314,6 +326,23 @@ return 2; } +/** Find the optimal position for a hint branch instruction in a basic block. + * This should take into account: + * -the branch hint delays + * -congestion of the memory bus + * -dual-issue scheduling (i.e. avoid insertion of nops) + * Current implementation is rather simplistic. + */ +static MachineBasicBlock::iterator findHBRPosition(MachineBasicBlock &MBB) +{ + MachineBasicBlock::iterator J = MBB.end(); + for( int i=0; i<8; i++) { + if( J == MBB.begin() ) return J; + J--; + } + return J; +} + unsigned SPUInstrInfo::InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, @@ -324,32 +353,61 @@ assert((Cond.size() == 2 || Cond.size() == 0) && "SPU branch conditions have two components!"); + MachineInstrBuilder MIB; + //TODO: make a more accurate algorithm. + bool haveHBR = MBB.size()>8; + + removeHBR(MBB); + MCSymbol *branchLabel = MBB.getParent()->getContext().CreateTempSymbol(); + // Add a label just before the branch + if (haveHBR) + MIB = BuildMI(&MBB, DL, get(SPU::HBR_LABEL)).addSym(branchLabel); + // One-way branch. if (FBB == 0) { if (Cond.empty()) { // Unconditional branch - MachineInstrBuilder MIB = BuildMI(&MBB, DL, get(SPU::BR)); + MIB = BuildMI(&MBB, DL, get(SPU::BR)); MIB.addMBB(TBB); DEBUG(errs() << "Inserted one-way uncond branch: "); DEBUG((*MIB).dump()); + + // basic blocks have just one branch so it is safe to add the hint a its + if (haveHBR) { + MIB = BuildMI( MBB, findHBRPosition(MBB), DL, get(SPU::HBRA)); + MIB.addSym(branchLabel); + MIB.addMBB(TBB); + } } else { // Conditional branch - MachineInstrBuilder MIB = BuildMI(&MBB, DL, get(Cond[0].getImm())); + MIB = BuildMI(&MBB, DL, get(Cond[0].getImm())); MIB.addReg(Cond[1].getReg()).addMBB(TBB); + if (haveHBR) { + MIB = BuildMI(MBB, findHBRPosition(MBB), DL, get(SPU::HBRA)); + MIB.addSym(branchLabel); + MIB.addMBB(TBB); + } + DEBUG(errs() << "Inserted one-way cond branch: "); DEBUG((*MIB).dump()); } return 1; } else { - MachineInstrBuilder MIB = BuildMI(&MBB, DL, get(Cond[0].getImm())); + MIB = BuildMI(&MBB, DL, get(Cond[0].getImm())); MachineInstrBuilder MIB2 = BuildMI(&MBB, DL, get(SPU::BR)); // Two-way Conditional Branch. MIB.addReg(Cond[1].getReg()).addMBB(TBB); MIB2.addMBB(FBB); + if (haveHBR) { + MIB = BuildMI( MBB, findHBRPosition(MBB), DL, get(SPU::HBRA)); + MIB.addSym(branchLabel); + MIB.addMBB(FBB); + } + DEBUG(errs() << "Inserted conditional branch: "); DEBUG((*MIB).dump()); DEBUG(errs() << "part 2: "); Modified: llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td?rev=126651&r1=126650&r2=126651&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td (original) +++ llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td Mon Feb 28 08:08:24 2011 @@ -28,6 +28,8 @@ def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm_i32:$amt), "${:comment} ADJCALLSTACKUP", [(callseq_end timm:$amt)]>; + def HBR_LABEL : Pseudo<(outs), (ins hbrtarget:$targ), + "$targ:\t${:comment}branch hint target",[ ]>; } //===----------------------------------------------------------------------===// @@ -4208,8 +4210,8 @@ //===----------------------------------------------------------------------===// // Hint for branch instructions: //===----------------------------------------------------------------------===// - -/* def HBR : SPUInstr<(outs), (ins), "hbr\t" */ +def HBRA : + HBI16Form<0b0001001,(ins hbrtarget:$brinst, brtarget:$btarg), "hbra\t$brinst, $btarg">; //===----------------------------------------------------------------------===// // Execution, Load NOP (execute NOPs belong in even pipeline, load NOPs belong From baldrick at free.fr Mon Feb 28 08:22:09 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 28 Feb 2011 14:22:09 -0000 Subject: [llvm-commits] [llvm] r126652 - /llvm/trunk/test/CodeGen/X86/2011-02-27-Fpextend.ll Message-ID: <20110228142209.1C5A12A6C12C@llvm.org> Author: baldrick Date: Mon Feb 28 08:22:08 2011 New Revision: 126652 URL: http://llvm.org/viewvc/llvm-project?rev=126652&view=rev Log: Windows codegen also dies on this, so restrict to the platform it was actually tested on. Modified: llvm/trunk/test/CodeGen/X86/2011-02-27-Fpextend.ll Modified: llvm/trunk/test/CodeGen/X86/2011-02-27-Fpextend.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2011-02-27-Fpextend.ll?rev=126652&r1=126651&r2=126652&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2011-02-27-Fpextend.ll (original) +++ llvm/trunk/test/CodeGen/X86/2011-02-27-Fpextend.ll Mon Feb 28 08:22:08 2011 @@ -1,4 +1,4 @@ -; RUN: llc -march=x86-64 < %s +; RUN: llc -mtriple=x86_64-pc-linux < %s ; PR9309 define <4 x double> @f_fu(<4 x float>) nounwind { From grosser at fim.uni-passau.de Mon Feb 28 10:35:06 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 28 Feb 2011 11:35:06 -0500 Subject: [llvm-commits] Patch for simplifying regions In-Reply-To: References: <4D4882FC.8060102@fim.uni-passau.de> Message-ID: <4D6BCEBA.9080609@fim.uni-passau.de> On 02/01/2011 07:37 PM, Vu Le wrote: > Hi Tobias, I would like to get this one in LLVM 2.9. Do you happen to have an updated patch available? > +void RegionSimplify::print(raw_ostream&O, const Module *M) const { > + BasicBlock *enteringBlock; > + BasicBlock *exitingBlock; > + > + if (modified) { > + enteringBlock = CR->getEnteringBlock(); > + exitingBlock = CR->getExitingBlock(); > + > + O<< "\nRegion: ["<< CR->getNameStr()<< "] Edges:\n"; > + if (enteringBlock) > + O<< " Entry: ]"<< enteringBlock->getNameStr()<< " => " > +<< enteringBlock->getNameStr()<< "]\n"; > + if (exitingBlock) > + O<< " Exit: ["<< exitingBlock->getNameStr()<< " => " > +<< exitingBlock->getNameStr()<< "[\n"; > > Can you use CR->getNameStr() instead of formatting this yourself? > > > This is is Andreas' code. Do you mean if the region is modified, we just > print CR->getNameStr()? OK. I did not get that you add additional information. This is fine. I would just format it like this: void RegionSimplify::print(raw_ostream &O, const Module *M) const { if (!modified) return; BasicBlock *enteringBlock = CR->getEnteringBlock(); BasicBlock *exitingBlock = CR->getExitingBlock(); [...] > + > + O<< "\n"; > + } > +} > + > +void RegionSimplify::getAnalysisUsage(AnalysisUsage&AU) const { > + AU.addPreserved (); > + AU.addRequired (); > > Does this transformation preserve RegionInfo? > > > Yes, I think RegionInfo is also preserved. OK. So let's state that we preserve it. > +// createSingleEntryEdge - Split the entry BasicBlock of the given > +// region after the last PHINode to form a single entry edge. > +// This is similar to CodeExtractor::severSplitPHINodes > +BasicBlock *RegionSimplify::createSingleEntryEdge(Region *R) { > + Function *f = R->getEntry()->getParent(); > + if (&f->getEntryBlock() == R->getEntry()) > + return NULL; // Entry node is the function's entry blocks > > Why do you need a special case for this? AS the entry node as never > any predecessors, I would imaging there would automatically be no > splitting. > > > I thought that we should not split regions whose entry is the function > entry. But I was wrong. We can split those. But I don't quite understand > what you mean. LLVM does not allow to have jumps directly to the entry basic block of a function. This function has never any predeccessor and consequently does not need to be splitted. > + > + BasicBlock *oldEntry = R->getEntry(); > + PHINode *PN = dyn_cast (oldEntry->begin()); > + if (!PN) > + return NULL; // No PHI nodes. > + > + BasicBlock::iterator AfterPHIs = oldEntry->getFirstNonPHI(); > + BasicBlock *newEntry = oldEntry->splitBasicBlock(AfterPHIs, > + oldEntry->getName() + ".simregentry"); > > 'simregionentry' sounds wrong. What about '.single_region_entry', > 'singleentry', ...? > > + > + // Okay, update dominator sets. > > // Update dominator tree. > > + if (DominatorTree *DT = > getAnalysisIfAvailable()) { > + succ_iterator secondSucc = succ_begin(newEntry) + 1; > + if (secondSucc == succ_end(newEntry)) //newEntry has 1 > successor > + DT->splitBlock(newEntry); > + else { // newEntry has more than 1 successor, update DT > manually > + // oldEntry dominates newEntry. > + // newEntry node dominates all other nodes dominated by > oldEntry. > + DomTreeNode *OldNode = DT->getNode(oldEntry); > + if (OldNode) { // don't bother if oldEntry doesn't > dominates any node > + std::vector Children; > + for (DomTreeNode::iterator I = OldNode->begin(), E = > OldNode->end(); I > + != E; ++I) > + Children.push_back(*I); > + > + DomTreeNode *NewNode = DT->addNewBlock(newEntry, oldEntry); > + for (std::vector::iterator I = > Children.begin(), E = > + Children.end(); I != E; ++I) > + DT->changeImmediateDominator(*I, NewNode); > + } > + } > + } > + > + // Loop over all of the predecessors of the old entry that > are in the region, > + // changing them to branch to the new entry instead of the > old one > + for (pred_iterator PI = pred_begin(oldEntry), PE = > pred_end(oldEntry); PI > + != PE; ++PI) { > + if (R->contains(*PI)) { > + TerminatorInst *TI = (*PI)->getTerminator(); > + TI->replaceUsesOfWith(oldEntry, newEntry); > + } > + } > + // just have to update the PHI nodes now, inserting PHI nodes > into NewBB. > + for (BasicBlock::iterator PI = oldEntry->begin(); > isa (PI); ++PI) { > + PHINode *PN = cast (PI); > + // Create a new PHI node in the new region, which has an > incoming value > + // from oldEntry of PN. > + PHINode *NewPN = PHINode::Create(PN->getType(), > PN->getName() + ".ph", > + newEntry->begin()); > + > + NewPN->addIncoming(PN, oldEntry); > + > + // Loop over all of the incoming value in PN, moving them > to NewPN if they > + // are from the region. > + for (unsigned i = 0; i != PN->getNumIncomingValues(); ++i) { > + BasicBlock *HasValToPN = PN->getIncomingBlock(i); > + if (R->contains(HasValToPN)) { > + NewPN->addIncoming(PN->getIncomingValue(i), HasValToPN); > + PN->removeIncomingValue(i); > + --i; > + } > + } > + } > > Do you think we can use splitBlockPredecessors to simplify all this? > > I guess yes. The different here is if we use splitBlockPredecessors, > Entry is split into NewNode->Entry. The entry node of R is not still Entry. > > We only need to update regions whose exit is Entry. > Their exit must be changed into NewNode. > I'm not quite sure how to do that. You are right. I just thought about this again and it seems to be better to split Entry->NewNode. We cannot change anything that is outside of the region. > + return newEntry; > +} > + > +// createSingleExitEdge - Split the exit BasicBlock of the > given region > +// to form a single exit edge. > +// This does not update RegionInfo analysis. > +BasicBlock *RegionSimplify::createSingleExitEdge(Region *R) { > + BasicBlock *BB = R->getExit(); > + > + SmallVector Preds; > + for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI > != PE; ++PI) > + if (R->contains(*PI)) > + Preds.push_back(*PI); > + > + return SplitBlockPredecessors(BB, Preds.data(), Preds.size(), > ".simregexit", > + this); > > I propose to update RegionInfo here. Copying the setRegionFor from > runOnRegion will not be sufficient. You need to update all regions > whose entry node was the old exit node of this region. > > > Why would we do that? > Suppose another region X has entry oldExit. > In region R, oldExit is split into (NewExit->oldExit). > R is now the smallest region containing NewExit. > > I think it's still OK if the entry of X is oldExit. Agreed. Forget about the comment. > +bool RegionSimplify::runOnRegion(Region *R, RGPassManager&RGM) { > + RegionInfo *RI =&getAnalysis (); > + modified = false; > + > + CR = R; > + if (!R->isTopLevelRegion()) { > + BasicBlock *newBB; > + BasicBlock *oldBB; > + > + if (!(R->getEnteringBlock())) { > + oldBB = R->getEntry(); > + > + newBB = createSingleEntryEdge(R); > + if (newBB) { // update RegionInfo only if we split entry > successfully > + RI->splitBlock(newBB, oldBB); > > I would put this into createSingleEntryEdge(), as you also update > the dominance information there. > > > OK. > > > + > + modified |= true; > + ++NumEntries; > + } > + } > + > + if (!(R->getExitingBlock())) { > + oldBB = R->getExit(); > + newBB = createSingleExitEdge(R); > + > + RI->setRegionFor(newBB, R); > > I would update the RI in the createSingleExitEdge as you also update > the regioninto there. > > OK. > > > + > + modified |= true; > + ++NumExits; > + } > + } > + > + return modified; > +} > diff --git a/lib/Transforms/Scalar/Scalar.cpp > b/lib/Transforms/Scalar/Scalar.cpp > index bf9ca6d..5d18f22 100644 > --- a/lib/Transforms/Scalar/Scalar.cpp > +++ b/lib/Transforms/Scalar/Scalar.cpp > @@ -51,6 +51,7 @@ void > llvm::initializeScalarOpts(PassRegistry&Registry) { > initializeMemCpyOptPass(Registry); > initializeReassociatePass(Registry); > initializeRegToMemPass(Registry); > + initializeRegionSimplifyPass(Registry); > initializeSCCPPass(Registry); > initializeIPSCCPPass(Registry); > initializeSROA_DTPass(Registry); > > > Furthermore, you should add a couple of test cases for the different > branches. > > I tested with mysql code. Do you know how to verify that our pass > preserves the semantics of the program? You can compile some code in the LLVM test-suite with it. However, I believe it is fine if you generate a bunch of test cases for which you make sure it is doing the right thing. Cheers Tobi From Erik.Olofsson at hansoft.se Mon Feb 28 04:44:58 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Mon, 28 Feb 2011 11:44:58 +0100 Subject: [llvm-commits] [cfe-dev] [PATCH] Windows improvements In-Reply-To: References: <97510B8DF78E714D91EB4A27850A17DA0C3EACB8DC@winserv02.hansoft.local> Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACB911@winserv02.hansoft.local> Hello Takumi, > It seems it would be better functionally. But please remember Microsoft's > toolchain would not be the only one. > Also mingw depends on LLVM_ON_WIN32. (in llvm side). >From HandleLLVMOptions.cmake if(CYGWIN) set(LLVM_ON_WIN32 0) set(LLVM_ON_UNIX 1) else(CYGWIN) set(LLVM_ON_WIN32 1) set(LLVM_ON_UNIX 0) endif(CYGWIN) This can filter out Cygwin with (defined(LLVM_ON_WIN32) && !defined(LLVM_ON_UNIX)), but I guess mingw would have to be filtered out in another way. If there is no existing way I could add: if(MSVC) set(LLVM_ON_WIN32MSVC 1) endif(MSVC) > Please split clang's patch by functionality. Ok, so split into three patches? * refactor llvm::outs()/errs() * cc1 invocation without a new process * output diagnostics as debug string > "/MP" works better for me functionally, though, it would be dubious for > style. > Oscar, do you have any opinions? > > FYI, I am using /m with msbuild.exe. 'msbuild /m' and 'cl /MP' works well together giving the most amount of parallelism with both projects and individual translation units being compiled in parallel. Regards, Erik > -----Original Message----- > From: NAKAMURA Takumi [mailto:geek4civic at gmail.com] > Sent: den 28 februari 2011 10:25 > To: Erik Olofsson; Douglas Gregor > Cc: llvm-commits; cfe-commits; llvmdev > Subject: Re: [cfe-dev] [PATCH] Windows improvements > > Hello Erik, > > > Thank you to work. I have not checked to build them, though, I can tell you > some comments, excuse me. > > * General > > - Please post patches to cfe-commits and to llvm-commits, too. > (IMHO it would not be needed to split articles apart each lists as long as > each would be related.) > - If you can, please attach files w/o CRLF(dos encodings), or with attached > text/plain. > - You may split and post an article if your patches were not "series of > patches" but "set of functionally individual patches". > > > > llvm-msvc10-fix-warnings.patch: > > clang-msvc10-fix-warnings.patch: > > Fixes compiler warnings. > > Looks good to me. They could be applied when gtest guys said ok. > > > > llvm-msvc-format-diagnostics.patch: > > clang-msvc-format-diagnostics.patch: > > > > Complete support for msvc style diagnostics parsable by Visual Studio. > > Added column support for msvc locations. I also added indentation so > > you can easily see the grouping of errors, include stacks and notes > > (msvc mode only). > > It seems it would be better functionally. But please remember Microsoft's > toolchain would not be the only one. > Also mingw depends on LLVM_ON_WIN32. (in llvm side). > > For now, I don't have better answer. > > > > llvm-outputdebugstring-support.patch: > > clang-visual-studio-debuggability.patch: > > > > Visual Studio has no good way of getting stdout and stderr output into > > its Output Window. Getting these into the Output Window can be really > > helpful for debugging as you can go to diagnostics locations directly from > there. > > It's also helpful to actually see the compiler output while breaking > > into the code. To allow this I have added support for > > OutputDebugString in llvm raw_ostream. I then use this from the driver > > where you can redirect stdout and stderr to OutputDebugString with > > -output-diagnostics-as-debug-string > > option. > > Windows/OutputDebugString.inc would be dubious. > > > #include "Windows.h" > > It would be better with small letter "windows.h", to be compiled cross on > case-sensitive filesystem. > > > namespace llvm { > > void llvm::output_debug_string(const char *String) { > > OutputDebugString(String); > > } > > } > > Either outer "namespace llvm" or inner specifier "llvm::" might be > redundant. > It cannot be compiled with g++-4.4.0. > > > > I have also added a shortcut when invoking cc1 so it doesn't actually > > start a new process. This is because Visual Studio does not support > > automatically attaching to child processes, and doing -### every time > > you change a command line option and copying the results is > > cumbersome. It should also have the added benefit of speeding up > > compilation. I don't know enough about clang to know if this is safe > > in all instances, and the way it's implemented might not be optimal. Let > me know if this could be done in a better way. > > Please split clang's patch by functionality. > > > > clang-pragma-message.patch: > > > > Make pragma message just output the message ignoring location (in msvc > > mode) and include stack information (always). This makes #pragma > > message usable in the same way when using clang as when using msvc and > gcc. > > Excuse me, I have no idea. > > > > llvm-msvc-multi-processor-compilation.patch: > > > > Make use of multiple processors when compiling one project in > > msbuild/Visual Studio. This greatly decreases turnaround time when > changing headers. > > "/MP" works better for me functionally, though, it would be dubious for > style. > Oscar, do you have any opinions? > > FYI, I am using /m with msbuild.exe. > > > > llvm-temp-test-file-fail-on-win32.patch: > > > > Fix Windows python issue where open temporary files cannot be opened > again. > > Needed for clang-c++tests. > > Looks good to me. Daniel, would it be enough? > > > > clang-missing-builtins.patch: > > llvm-interrupt-builtin.patch: > > > > Add builtins needed to implement __debugbreak and _byteswap_ushort > > from intrin.h. Before implementing everything else needed for intrin.h > > I need to know if this is the correct way? > > I have no idea, excuse me. :( > > > > clang-msvc10-fix-mm_malloc-error.patch: > > > > mm_malloc is implemented in Visual Studio 2010, this fixes the compile > > error resulting from it being a macro. > > Also mingw-w64 provides _mm_malloc stuff. > I suggest not to tweak _mm_malloc, but rely on provided _mm_malloc. > > I will work on it, too. I expect it could be possible on known plaforms. > #ifdef _mm_malloc > static inline void *_mm_malloc() { ... > #endif > > > ...Takumi > > > On Mon, Feb 28, 2011 at 1:15 PM, Erik Olofsson > wrote: > > With GCC being a dead end and hard to use for universal binaries on > > OSX and Microsoft refusing to fix bugs in their compiler I thought it > > would good idea to get clang compiling our code base. > > > > > > > > Before I start fixing bugs and missing features in clang I have > > created these patches to make it easier to debug and develop clang on > > Windows. After this is done what is needed is reimplementing > > from Visual Studio > > 2010 includes and fixing any bugs that I find in the compiler. Finally > > I need lambda expressions which we already use heavily. > > > > > > > > llvm-msvc10-fix-warnings.patch: > > > > clang-msvc10-fix-warnings.patch: > > > > Fixes compiler warnings. > > > > > > > > llvm-msvc-format-diagnostics.patch: > > > > clang-msvc-format-diagnostics.patch: > > > > Complete support for msvc style diagnostics parsable by Visual Studio. > > Added column support for msvc locations. I also added indentation so > > you can easily see the grouping of errors, include stacks and notes > > (msvc mode only). > > > > > > > > llvm-outputdebugstring-support.patch: > > > > clang-visual-studio-debuggability.patch: > > > > Visual Studio has no good way of getting stdout and stderr output into > > its Output Window. Getting these into the Output Window can be really > > helpful for debugging as you can go to diagnostics locations directly from > there. > > It's also helpful to actually see the compiler output while breaking > > into the code. To allow this I have added support for > > OutputDebugString in llvm raw_ostream. I then use this from the driver > > where you can redirect stdout and stderr to OutputDebugString with > > -output-diagnostics-as-debug-string > > option. > > > > > > > > I have also added a shortcut when invoking cc1 so it doesn't actually > > start a new process. This is because Visual Studio does not support > > automatically attaching to child processes, and doing -### every time > > you change a command line option and copying the results is > > cumbersome. It should also have the added benefit of speeding up > > compilation. I don't know enough about clang to know if this is safe > > in all instances, and the way it's implemented might not be optimal. Let > me know if this could be done in a better way. > > > > > > > > clang-pragma-message.patch: > > > > Make pragma message just output the message ignoring location (in msvc > > mode) and include stack information (always). This makes #pragma > > message usable in the same way when using clang as when using msvc and > gcc. > > > > > > > > llvm-msvc-multi-processor-compilation.patch: > > > > Make use of multiple processors when compiling one project in > > msbuild/Visual Studio. This greatly decreases turnaround time when > changing headers. > > > > > > > > llvm-temp-test-file-fail-on-win32.patch: > > > > Fix Windows python issue where open temporary files cannot be opened > again. > > Needed for clang-c++tests. > > > > > > > > clang-missing-builtins.patch: > > > > llvm-interrupt-builtin.patch: > > > > Add builtins needed to implement __debugbreak and _byteswap_ushort > > from intrin.h. Before implementing everything else needed for intrin.h > > I need to know if this is the correct way? > > > > > > > > clang-msvc10-fix-mm_malloc-error.patch: > > > > mm_malloc is implemented in Visual Studio 2010, this fixes the compile > > error resulting from it being a macro. > > > > > > > > I have ran check-all on OSX and Visual Studio 2010 and made sure that > > there aren't any regressions on these platforms. I would add tests for > > the OutputDebugString functionality, but capturing this probably needs > > extra support in the testing framework. Let me know what you think of > > these patches and I will start fixing more things if they are accepted. > > > > > > > > Thanks, > > > > Erik From Erik.Olofsson at hansoft.se Mon Feb 28 06:46:31 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Mon, 28 Feb 2011 13:46:31 +0100 Subject: [llvm-commits] [cfe-dev] [PATCH] Windows improvements In-Reply-To: References: <97510B8DF78E714D91EB4A27850A17DA0C3EACB8DC@winserv02.hansoft.local> <97510B8DF78E714D91EB4A27850A17DA0C3EACB911@winserv02.hansoft.local> Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACB91A@winserv02.hansoft.local> Hello Takumi, > In C/C++ sources, we may detect MSVC with _MSC_VER, I suppose. > IMO I don't need to introduce LLVM_ON_WIN32MSVC. > > Rather, I think LLVM_ON_**** could be deprecated. It should be enough > with _WIN32. But what about if you then use a clang compiled in mingw to host itself. I assume we need ms extensions enabled, and then _MSC_VER will be defined. Regards, Erik From stuart at apple.com Mon Feb 28 11:17:53 2011 From: stuart at apple.com (Stuart Hastings) Date: Mon, 28 Feb 2011 17:17:53 -0000 Subject: [llvm-commits] [llvm] r126655 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/CodeGen/CallingConvLower.cpp lib/Target/ARM/ARMCallingConv.td lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h Message-ID: <20110228171753.7DB6D2A6C12C@llvm.org> Author: stuart Date: Mon Feb 28 11:17:53 2011 New Revision: 126655 URL: http://llvm.org/viewvc/llvm-project?rev=126655&view=rev Log: Support for byval parameters on ARM. Will be enabled by a forthcoming patch to the front-end. Radar 7662569. Modified: llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/lib/CodeGen/CallingConvLower.cpp llvm/trunk/lib/Target/ARM/ARMCallingConv.td llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=126655&r1=126654&r2=126655&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Mon Feb 28 11:17:53 2011 @@ -39,6 +39,7 @@ class AllocaInst; class APFloat; class CallInst; + class CCState; class Function; class FastISel; class FunctionLoweringInfo; @@ -1258,6 +1259,9 @@ return SDValue(); // this is here to silence compiler errors } + /// HandleByVal - Target-specific cleanup for formal ByVal parameters. + virtual void HandleByVal(CCState *) const {}; + /// CanLowerReturn - This hook should be implemented to check whether the /// return values described by the Outs array can fit into the return /// registers. If false is returned, an sret-demotion is performed. Modified: llvm/trunk/lib/CodeGen/CallingConvLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CallingConvLower.cpp?rev=126655&r1=126654&r2=126655&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CallingConvLower.cpp (original) +++ llvm/trunk/lib/CodeGen/CallingConvLower.cpp Mon Feb 28 11:17:53 2011 @@ -19,6 +19,7 @@ #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetLowering.h" using namespace llvm; CCState::CCState(CallingConv::ID CC, bool isVarArg, const TargetMachine &tm, @@ -47,6 +48,7 @@ unsigned Offset = AllocateStack(Size, Align); addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo)); + TM.getTargetLowering()->HandleByVal(const_cast(this)); } /// MarkAllocated - Mark a register and all of its aliases as allocated. Modified: llvm/trunk/lib/Target/ARM/ARMCallingConv.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCallingConv.td?rev=126655&r1=126654&r2=126655&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCallingConv.td (original) +++ llvm/trunk/lib/Target/ARM/ARMCallingConv.td Mon Feb 28 11:17:53 2011 @@ -22,6 +22,9 @@ //===----------------------------------------------------------------------===// def CC_ARM_APCS : CallingConv<[ + // Handles byval parameters. + CCIfByVal>, + CCIfType<[i8, i16], CCPromoteToType>, // Handle all vector types as either f64 or v2f64. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=126655&r1=126654&r2=126655&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Mon Feb 28 11:17:53 2011 @@ -1253,6 +1253,7 @@ CCValAssign &VA = ArgLocs[i]; SDValue Arg = OutVals[realArgIdx]; ISD::ArgFlagsTy Flags = Outs[realArgIdx].Flags; + bool isByVal = Flags.isByVal(); // Promote the value if needed. switch (VA.getLocInfo()) { @@ -1299,7 +1300,7 @@ } } else if (VA.isRegLoc()) { RegsToPass.push_back(std::make_pair(VA.getLocReg(), Arg)); - } else if (!IsSibCall) { + } else if (!IsSibCall || isByVal) { assert(VA.isMemLoc()); MemOpChains.push_back(LowerMemOpCallTo(Chain, StackPtr, Arg, @@ -1492,6 +1493,17 @@ dl, DAG, InVals); } +/// HandleByVal - Every parameter *after* a byval parameter is passed +/// on the stack. Confiscate all the parameter registers to insure +/// this. +void +llvm::ARMTargetLowering::HandleByVal(CCState *State) const { + static const unsigned RegList1[] = { + ARM::R0, ARM::R1, ARM::R2, ARM::R3 + }; + do {} while (State->AllocateReg(RegList1, 4)); +} + /// MatchingStackOffset - Return true if the given stack call argument is /// already available in the same position (relatively) of the caller's /// incoming argument stack. @@ -2280,7 +2292,9 @@ isVarArg)); SmallVector ArgValues; + int lastInsIndex = -1; + SDValue ArgValue; for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) { CCValAssign &VA = ArgLocs[i]; @@ -2288,7 +2302,6 @@ if (VA.isRegLoc()) { EVT RegVT = VA.getLocVT(); - SDValue ArgValue; if (VA.needsCustom()) { // f64 and vector types are split up into multiple registers or // combinations of registers and stack slots. @@ -2364,14 +2377,33 @@ assert(VA.isMemLoc()); assert(VA.getValVT() != MVT::i64 && "i64 should already be lowered"); - unsigned ArgSize = VA.getLocVT().getSizeInBits()/8; - int FI = MFI->CreateFixedObject(ArgSize, VA.getLocMemOffset(), true); + int index = ArgLocs[i].getValNo(); + + // Some Ins[] entries become multiple ArgLoc[] entries. + // Process them only once. + if (index != lastInsIndex) + { + ISD::ArgFlagsTy Flags = Ins[index].Flags; + // FIXME: For now, all byval parameter objects are marked mutable. This can be + // changed with more analysis. + // In case of tail call optimization mark all arguments mutable. Since they + // could be overwritten by lowering of arguments in case of a tail call. + if (Flags.isByVal()) { + int FI = MFI->CreateFixedObject(Flags.getByValSize(), + VA.getLocMemOffset(), false); + InVals.push_back(DAG.getFrameIndex(FI, getPointerTy())); + } else { + int FI = MFI->CreateFixedObject(VA.getLocVT().getSizeInBits()/8, + VA.getLocMemOffset(), true); - // Create load nodes to retrieve arguments from the stack. - SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); - InVals.push_back(DAG.getLoad(VA.getValVT(), dl, Chain, FIN, - MachinePointerInfo::getFixedStack(FI), - false, false, 0)); + // Create load nodes to retrieve arguments from the stack. + SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); + InVals.push_back(DAG.getLoad(VA.getValVT(), dl, Chain, FIN, + MachinePointerInfo::getFixedStack(FI), + false, false, 0)); + } + lastInsIndex = index; + } } } Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=126655&r1=126654&r2=126655&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Mon Feb 28 11:17:53 2011 @@ -435,6 +435,9 @@ DebugLoc dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const; + /// HandleByVal - Target-specific cleanup for ByVal support. + virtual void HandleByVal(CCState *) const; + /// IsEligibleForTailCallOptimization - Check whether the call is eligible /// for tail call optimization. Targets which want to do tail call /// optimization should implement this function. From aggarwa4 at illinois.edu Mon Feb 28 11:45:15 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Mon, 28 Feb 2011 17:45:15 -0000 Subject: [llvm-commits] [poolalloc] r126660 - /poolalloc/trunk/lib/DSA/Local.cpp Message-ID: <20110228174515.43DF32A6C12C@llvm.org> Author: aggarwa4 Date: Mon Feb 28 11:45:15 2011 New Revision: 126660 URL: http://llvm.org/viewvc/llvm-project?rev=126660&view=rev Log: 1. Make GraphBuilder depend on LocalDataStructure, instead of DataStructure, as that is the only pass that uses it. 2. Create a DSNode, even if a GEP is not used. Modified: poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=126660&r1=126659&r2=126660&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Mon Feb 28 11:45:15 2011 @@ -68,7 +68,7 @@ class GraphBuilder : InstVisitor { DSGraph &G; Function* FB; - DataStructures* DS; + LocalDataStructures* DS; const TargetData& TD; //////////////////////////////////////////////////////////////////////////// @@ -135,7 +135,7 @@ void visitVAStartNode(DSNode* N); public: - GraphBuilder(Function &f, DSGraph &g, DataStructures& DSi) + GraphBuilder(Function &f, DSGraph &g, LocalDataStructures& DSi) : G(g), FB(&f), DS(&DSi), TD(g.getTargetData()) { // Create scalar nodes for all pointer arguments... for (Function::arg_iterator I = f.arg_begin(), E = f.arg_end(); @@ -499,8 +499,6 @@ return; } - if(GEP.use_empty()) - return; // // Okay, no easy way out. Calculate the offset into the object being // indexed. @@ -571,7 +569,6 @@ if((Value.getOffset() || Offset != 0) || (!isa(CurTy) && (Value.getNode()->getSize() != TD.getTypeAllocSize(CurTy)))) { - Value.getNode()->foldNodeCompletely(); Value.getNode(); Offset = 0; @@ -1172,7 +1169,6 @@ GGB.mergeInGlobalInitializer(I); } // Add Functions to the globals graph. - // FIXME: Write a separate pass to handle address taken property better. for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI){ if(addrAnalysis->hasAddressTaken(FI)) { GGB.mergeFunction(FI); From jan_sjodin at yahoo.com Mon Feb 28 11:49:22 2011 From: jan_sjodin at yahoo.com (Jan Sjodin) Date: Mon, 28 Feb 2011 09:49:22 -0800 (PST) Subject: [llvm-commits] Code refactoring of MCELFStreamer.cpp and ELFObjectWriter.cpp In-Reply-To: <4D6917D8.6030506@gmail.com> References: <960821.36942.qm@web55604.mail.re4.yahoo.com> <4D680702.2040101@gmail.com> <470208.84552.qm@web55602.mail.re4.yahoo.com> <4D68461F.2090807@gmail.com> <267631.76534.qm@web55603.mail.re4.yahoo.com> <4D6917D8.6030506@gmail.com> Message-ID: <677486.27153.qm@web55604.mail.re4.yahoo.com> I was trying to commit my change, but something is wrong. It was the first time I tried to commit anything so something was bound to not work. :) I will try to get some help, but if you want to commit it, go ahead. - Jan ----- Original Message ---- > From: Rafael ?vila de Esp?ndola > To: Jan Sjodin > Cc: llvm-commits at cs.uiuc.edu > Sent: Sat, February 26, 2011 10:10:16 AM > Subject: Re: [llvm-commits] Code refactoring of MCELFStreamer.cpp and >ELFObjectWriter.cpp > > On 11-02-25 8:54 PM, Jan Sjodin wrote: > > The JIT implementation I am working on (MCJIT which was renamed to JunkJIT) > > became a lot nicer when I decided to inherit MCELFStreamer and >ELFObjectWriter. > > This was needed to make the debug information available to gdb since it >expects > > ELF format. I basically reuse everything, the only thing that differs is >that I > > use a mem_raw_outstream to emit code to memory and make sure that all >sections > > are created before or during the post layout binding so that when > > RecordRelocation is called all symbol addresses are known. In the > > ELFObjectWriter, the code in WriteObject that creates sections is moved to >the > > post layout binding, and the code that emits the object stays in place. This >is > > perhaps not very clean, since it is not formalized in the interface, but it > > works okay and I only need to shuffle around the code a little. You could > > imagine that if section creation was restricted by the interface to only > > happenen before/during post layout, then a generic JunkJIT could be written >for > > any object format. Each object writer would be required to compute offsets >for > > the sections. I am currently not aiming to do this since the MCJIT proposal >by > > Daniel separates the Streamer/ObjectWriter from figuring out relocations and > > external symbols. However, the code refactoring patches I have/will submit >are > > fairly benign and enable a JIT (without lazy compilation) using the MC > > framework. > > Cool. The rafactoring patch is OK. > > > - Jan > > > > Cheers, > Rafael > From evan.cheng at apple.com Mon Feb 28 12:45:28 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 28 Feb 2011 18:45:28 -0000 Subject: [llvm-commits] [llvm] r126661 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp test/CodeGen/ARM/fcopysign.ll Message-ID: <20110228184528.25B112A6C12C@llvm.org> Author: evancheng Date: Mon Feb 28 12:45:27 2011 New Revision: 126661 URL: http://llvm.org/viewvc/llvm-project?rev=126661&view=rev Log: Fix a typo which cause dag combine crash. rdar://9059537. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/test/CodeGen/ARM/fcopysign.ll Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=126661&r1=126660&r2=126661&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Mon Feb 28 12:45:27 2011 @@ -2905,7 +2905,7 @@ SDValue Res = DAG.getNode(ISD::OR, dl, OpVT, DAG.getNode(ISD::AND, dl, OpVT, Tmp1, Mask), DAG.getNode(ISD::AND, dl, OpVT, Tmp0, MaskNot)); - if (SrcVT == MVT::f32) { + if (VT == MVT::f32) { Res = DAG.getNode(ISD::BITCAST, dl, MVT::v2f32, Res); Res = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, MVT::f32, Res, DAG.getConstant(0, MVT::i32)); Modified: llvm/trunk/test/CodeGen/ARM/fcopysign.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fcopysign.ll?rev=126661&r1=126660&r2=126661&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fcopysign.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fcopysign.ll Mon Feb 28 12:45:27 2011 @@ -40,5 +40,19 @@ ret double %1 } +; rdar://9059537 +define i32 @test4() ssp { +entry: +; SOFT: test4: +; SOFT: vcvt.f32.f64 s0, +; SOFT: vmov.i32 [[REG4:(d[0-9]+)]], #0x80000000 +; SOFT: vbic [[REG5:(d[0-9]+))], d0, [[REG4]] +; SOFT: vorr d0, [[REG4]], [[REG5]] + %call80 = tail call double @copysign(double 1.000000e+00, double undef) + %conv81 = fptrunc double %call80 to float + %tmp88 = bitcast float %conv81 to i32 + ret i32 %tmp88 +} + declare double @copysign(double, double) nounwind declare float @copysignf(float, float) nounwind From enderby at apple.com Mon Feb 28 12:46:32 2011 From: enderby at apple.com (Kevin Enderby) Date: Mon, 28 Feb 2011 18:46:32 -0000 Subject: [llvm-commits] [llvm] r126662 - in /llvm/trunk: lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h test/MC/Disassembler/ARM/thumb-tests.txt Message-ID: <20110228184632.1654B2A6C12C@llvm.org> Author: enderby Date: Mon Feb 28 12:46:31 2011 New Revision: 126662 URL: http://llvm.org/viewvc/llvm-project?rev=126662&view=rev Log: Fix the arm's disassembler for blx that was building an MCInst without the needed two predicate operands before the imm operand. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h?rev=126662&r1=126661&r2=126662&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Mon Feb 28 12:46:31 2011 @@ -1719,6 +1719,17 @@ return true; } + // Some instructions have predicate operands first before the immediate. + if(Opcode == ARM::tBLXi_r9 || Opcode == ARM::tBLr9) { + // Handling the two predicate operands before the imm operand. + if (B->DoPredicateOperands(MI, Opcode, insn, NumOps)) + NumOpsAdded += 2; + else { + DEBUG(errs() << "Expected predicate operands not found.\n"); + return false; + } + } + // Add the imm operand. int Offset = 0; @@ -1745,7 +1756,8 @@ // to compensate. MI.addOperand(MCOperand::CreateImm(Offset + 4)); - NumOpsAdded = 1; + // This is an increment as some predicate operands may have been added first. + NumOpsAdded += 1; return true; } Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=126662&r1=126661&r2=126662&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Mon Feb 28 12:46:31 2011 @@ -118,3 +118,6 @@ # CHECK: msr cpsr_fc, r0 0x80 0xf3 0x00 0x89 + +# CHECK: blx #0 +0xff 0xf7 0xfe 0xef From rafael.espindola at gmail.com Mon Feb 28 12:54:23 2011 From: rafael.espindola at gmail.com (Rafael Avila de Espindola) Date: Mon, 28 Feb 2011 13:54:23 -0500 Subject: [llvm-commits] [patch][lto] Use MC to scan for symbol definitions and uses In-Reply-To: <4D692112.5030707@gmail.com> References: <4D692112.5030707@gmail.com> Message-ID: <4D6BEF5F.7030903@gmail.com> I have updated the patch to also create llvm.compiler.used with the uses it finds in inline assembly. This lets me build Firefox without moving the assembly to a .s file *or* adding __attribute__((used)) :-) I will give you some more testing/cleanup and try to add it after 2.9 branches. Cheers, Rafael -------------- next part -------------- A non-text attachment was scrubbed... Name: used.patch Type: text/x-patch Size: 22258 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110228/b578e0ad/attachment.bin From jasonwkim at google.com Mon Feb 28 12:59:58 2011 From: jasonwkim at google.com (Jason Kim) Date: Mon, 28 Feb 2011 10:59:58 -0800 Subject: [llvm-commits] ARM .fpu attribute In-Reply-To: <4D6BA470.1020105@arm.com> References: <4D6BA470.1020105@arm.com> Message-ID: HI Renato, Patch looks good. Please commit. I am unsure about the lowercase/uppercase difference between .s and .o for textual attributes. AFAIK, it is required for .cpu attribute to be lowercase in .s and uppercase in .o. Is it also required (or at least harmless) for .fpu attr as well? Thanks! -jason On Mon, Feb 28, 2011 at 5:34 AM, Renato Golin wrote: > Hi all, > > This is a patch to fig bug: > > http://llvm.org/bugs/show_bug.cgi?id=8931 > > Rationale: > > The ARM asm backend wasn't printing the .fpu attribute when NEON was > available (of VFP for that matter) and the linker was getting confused > on which instructions were available or not. > > This patch fix this by printing the .fpu attribute whenever in assembly > mode and when VFP/NEON is available, exporting both numeric and text > versions. > > thanks, > --renato > > -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. ?Thank you. From viridia at gmail.com Mon Feb 28 13:02:31 2011 From: viridia at gmail.com (Talin) Date: Mon, 28 Feb 2011 11:02:31 -0800 Subject: [llvm-commits] [PATCH] Add "END_WITH_NULL" creator for ConstantStruct Message-ID: This is similar to the patch I offered earlier, but removes the iterator-pair methods which were objected to. Can someone please review? Thanks. -- -- Talin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110228/e7775f71/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: ConstantStruct.patch Type: text/x-patch Size: 1850 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110228/e7775f71/attachment.bin From greened at obbligato.org Mon Feb 28 13:06:56 2011 From: greened at obbligato.org (David Greene) Date: Mon, 28 Feb 2011 19:06:56 -0000 Subject: [llvm-commits] [llvm] r126664 - in /llvm/trunk/lib/Target/X86: InstPrinter/X86InstComments.cpp Utils/X86ShuffleDecode.cpp Utils/X86ShuffleDecode.h X86ISelLowering.cpp Message-ID: <20110228190656.A4A352A6C12C@llvm.org> Author: greened Date: Mon Feb 28 13:06:56 2011 New Revision: 126664 URL: http://llvm.org/viewvc/llvm-project?rev=126664&view=rev Log: [AVX] Add decode support for VUNPCKLPS/D instructions, both 128-bit and 256-bit forms. Because the number of elements in a vector does not determine the vector type (4 elements could be v4f32 or v4f64), pass the full type of the vector to decode routines. Modified: llvm/trunk/lib/Target/X86/InstPrinter/X86InstComments.cpp llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.h llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/InstPrinter/X86InstComments.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/InstPrinter/X86InstComments.cpp?rev=126664&r1=126663&r2=126664&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/InstPrinter/X86InstComments.cpp (original) +++ llvm/trunk/lib/Target/X86/InstPrinter/X86InstComments.cpp Mon Feb 28 13:06:56 2011 @@ -111,28 +111,28 @@ // FALL THROUGH. case X86::PUNPCKLBWrm: Src1Name = getRegName(MI->getOperand(0).getReg()); - DecodePUNPCKLMask(16, ShuffleMask); + DecodePUNPCKLBWMask(16, ShuffleMask); break; case X86::PUNPCKLWDrr: Src2Name = getRegName(MI->getOperand(2).getReg()); // FALL THROUGH. case X86::PUNPCKLWDrm: Src1Name = getRegName(MI->getOperand(0).getReg()); - DecodePUNPCKLMask(8, ShuffleMask); + DecodePUNPCKLWDMask(8, ShuffleMask); break; case X86::PUNPCKLDQrr: Src2Name = getRegName(MI->getOperand(2).getReg()); // FALL THROUGH. case X86::PUNPCKLDQrm: Src1Name = getRegName(MI->getOperand(0).getReg()); - DecodePUNPCKLMask(4, ShuffleMask); + DecodePUNPCKLDQMask(4, ShuffleMask); break; case X86::PUNPCKLQDQrr: Src2Name = getRegName(MI->getOperand(2).getReg()); // FALL THROUGH. case X86::PUNPCKLQDQrm: Src1Name = getRegName(MI->getOperand(0).getReg()); - DecodePUNPCKLMask(2, ShuffleMask); + DecodePUNPCKLQDQMask(2, ShuffleMask); break; case X86::SHUFPDrri: @@ -153,16 +153,44 @@ Src2Name = getRegName(MI->getOperand(2).getReg()); // FALL THROUGH. case X86::UNPCKLPDrm: - DecodeUNPCKLPMask(2, ShuffleMask); + DecodeUNPCKLPDMask(2, ShuffleMask); Src1Name = getRegName(MI->getOperand(0).getReg()); break; + case X86::VUNPCKLPDrr: + Src2Name = getRegName(MI->getOperand(2).getReg()); + // FALL THROUGH. + case X86::VUNPCKLPDrm: + DecodeUNPCKLPDMask(2, ShuffleMask); + Src1Name = getRegName(MI->getOperand(1).getReg()); + break; + case X86::VUNPCKLPDYrr: + Src2Name = getRegName(MI->getOperand(2).getReg()); + // FALL THROUGH. + case X86::VUNPCKLPDYrm: + DecodeUNPCKLPDMask(4, ShuffleMask); + Src1Name = getRegName(MI->getOperand(1).getReg()); + break; case X86::UNPCKLPSrr: Src2Name = getRegName(MI->getOperand(2).getReg()); // FALL THROUGH. case X86::UNPCKLPSrm: - DecodeUNPCKLPMask(4, ShuffleMask); + DecodeUNPCKLPSMask(4, ShuffleMask); Src1Name = getRegName(MI->getOperand(0).getReg()); break; + case X86::VUNPCKLPSrr: + Src2Name = getRegName(MI->getOperand(2).getReg()); + // FALL THROUGH. + case X86::VUNPCKLPSrm: + DecodeUNPCKLPSMask(4, ShuffleMask); + Src1Name = getRegName(MI->getOperand(1).getReg()); + break; + case X86::VUNPCKLPSYrr: + Src2Name = getRegName(MI->getOperand(2).getReg()); + // FALL THROUGH. + case X86::VUNPCKLPSYrm: + DecodeUNPCKLPSMask(8, ShuffleMask); + Src1Name = getRegName(MI->getOperand(1).getReg()); + break; case X86::UNPCKHPDrr: Src2Name = getRegName(MI->getOperand(2).getReg()); // FALL THROUGH. Modified: llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp?rev=126664&r1=126663&r2=126664&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp (original) +++ llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp Mon Feb 28 13:06:56 2011 @@ -1,4 +1,4 @@ -//===-- X86ShuffleDecode.h - X86 shuffle decode logic ---------------------===// +//===-- X86ShuffleDecode.cpp - X86 shuffle decode logic -------------------===// // // The LLVM Compiler Infrastructure // @@ -95,12 +95,29 @@ ShuffleMask.push_back(7); } -void DecodePUNPCKLMask(unsigned NElts, +void DecodePUNPCKLBWMask(unsigned NElts, + SmallVectorImpl &ShuffleMask) { + DecodeUNPCKLPMask(MVT::getVectorVT(MVT::i8, NElts), ShuffleMask); +} + +void DecodePUNPCKLWDMask(unsigned NElts, + SmallVectorImpl &ShuffleMask) { + DecodeUNPCKLPMask(MVT::getVectorVT(MVT::i16, NElts), ShuffleMask); +} + +void DecodePUNPCKLDQMask(unsigned NElts, + SmallVectorImpl &ShuffleMask) { + DecodeUNPCKLPMask(MVT::getVectorVT(MVT::i32, NElts), ShuffleMask); +} + +void DecodePUNPCKLQDQMask(unsigned NElts, + SmallVectorImpl &ShuffleMask) { + DecodeUNPCKLPMask(MVT::getVectorVT(MVT::i64, NElts), ShuffleMask); +} + +void DecodePUNPCKLMask(EVT VT, SmallVectorImpl &ShuffleMask) { - for (unsigned i = 0; i != NElts/2; ++i) { - ShuffleMask.push_back(i); - ShuffleMask.push_back(i+NElts); - } + DecodeUNPCKLPMask(VT, ShuffleMask); } void DecodePUNPCKHMask(unsigned NElts, @@ -133,12 +150,24 @@ } } +void DecodeUNPCKLPSMask(unsigned NElts, + SmallVectorImpl &ShuffleMask) { + DecodeUNPCKLPMask(MVT::getVectorVT(MVT::i32, NElts), ShuffleMask); +} + +void DecodeUNPCKLPDMask(unsigned NElts, + SmallVectorImpl &ShuffleMask) { + DecodeUNPCKLPMask(MVT::getVectorVT(MVT::i64, NElts), ShuffleMask); +} /// DecodeUNPCKLPMask - This decodes the shuffle masks for unpcklps/unpcklpd -/// etc. NElts indicates the number of elements in the vector allowing it to -/// handle different datatypes and vector widths. -void DecodeUNPCKLPMask(unsigned NElts, +/// etc. VT indicates the type of the vector allowing it to handle different +/// datatypes and vector widths. +void DecodeUNPCKLPMask(EVT VT, SmallVectorImpl &ShuffleMask) { + + int NElts = VT.getVectorNumElements(); + for (unsigned i = 0; i != NElts/2; ++i) { ShuffleMask.push_back(i); // Reads from dest ShuffleMask.push_back(i+NElts); // Reads from src Modified: llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.h?rev=126664&r1=126663&r2=126664&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.h (original) +++ llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.h Mon Feb 28 13:06:56 2011 @@ -16,6 +16,7 @@ #define X86_SHUFFLE_DECODE_H #include "llvm/ADT/SmallVector.h" +#include "llvm/CodeGen/ValueTypes.h" //===----------------------------------------------------------------------===// // Vector Mask Decoding @@ -45,7 +46,19 @@ void DecodePSHUFLWMask(unsigned Imm, SmallVectorImpl &ShuffleMask); -void DecodePUNPCKLMask(unsigned NElts, +void DecodePUNPCKLBWMask(unsigned NElts, + SmallVectorImpl &ShuffleMask); + +void DecodePUNPCKLWDMask(unsigned NElts, + SmallVectorImpl &ShuffleMask); + +void DecodePUNPCKLDQMask(unsigned NElts, + SmallVectorImpl &ShuffleMask); + +void DecodePUNPCKLQDQMask(unsigned NElts, + SmallVectorImpl &ShuffleMask); + +void DecodePUNPCKLMask(EVT VT, SmallVectorImpl &ShuffleMask); void DecodePUNPCKHMask(unsigned NElts, @@ -57,11 +70,16 @@ void DecodeUNPCKHPMask(unsigned NElts, SmallVectorImpl &ShuffleMask); +void DecodeUNPCKLPSMask(unsigned NElts, + SmallVectorImpl &ShuffleMask); + +void DecodeUNPCKLPDMask(unsigned NElts, + SmallVectorImpl &ShuffleMask); /// DecodeUNPCKLPMask - This decodes the shuffle masks for unpcklps/unpcklpd -/// etc. NElts indicates the number of elements in the vector allowing it to -/// handle different datatypes and vector widths. -void DecodeUNPCKLPMask(unsigned NElts, +/// etc. VT indicates the type of the vector allowing it to handle different +/// datatypes and vector widths. +void DecodeUNPCKLPMask(EVT VT, SmallVectorImpl &ShuffleMask); } // llvm namespace Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=126664&r1=126663&r2=126664&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Feb 28 13:06:56 2011 @@ -3895,11 +3895,15 @@ case X86ISD::PUNPCKLWD: case X86ISD::PUNPCKLDQ: case X86ISD::PUNPCKLQDQ: - DecodePUNPCKLMask(NumElems, ShuffleMask); + DecodePUNPCKLMask(VT, ShuffleMask); break; case X86ISD::UNPCKLPS: case X86ISD::UNPCKLPD: - DecodeUNPCKLPMask(NumElems, ShuffleMask); + case X86ISD::VUNPCKLPS: + case X86ISD::VUNPCKLPD: + case X86ISD::VUNPCKLPSY: + case X86ISD::VUNPCKLPDY: + DecodeUNPCKLPMask(VT, ShuffleMask); break; case X86ISD::MOVHLPS: DecodeMOVHLPSMask(NumElems, ShuffleMask); @@ -5263,6 +5267,7 @@ // Break it into (shuffle shuffle_hi, shuffle_lo). Locs.clear(); + Locs.resize(4); SmallVector LoMask(4U, -1); SmallVector HiMask(4U, -1); @@ -5508,12 +5513,16 @@ X86::getShuffleSHUFImmediate(SVOp), DAG); } -static inline unsigned getUNPCKLOpcode(EVT VT) { +static inline unsigned getUNPCKLOpcode(EVT VT, const X86Subtarget *Subtarget) { switch(VT.getSimpleVT().SimpleTy) { case MVT::v4i32: return X86ISD::PUNPCKLDQ; case MVT::v2i64: return X86ISD::PUNPCKLQDQ; - case MVT::v4f32: return X86ISD::UNPCKLPS; - case MVT::v2f64: return X86ISD::UNPCKLPD; + case MVT::v4f32: + return Subtarget->hasAVX() ? X86ISD::VUNPCKLPS : X86ISD::UNPCKLPS; + case MVT::v2f64: + return Subtarget->hasAVX() ? X86ISD::VUNPCKLPD : X86ISD::UNPCKLPD; + case MVT::v8f32: return X86ISD::VUNPCKLPSY; + case MVT::v4f64: return X86ISD::VUNPCKLPDY; case MVT::v16i8: return X86ISD::PUNPCKLBW; case MVT::v8i16: return X86ISD::PUNPCKLWD; default: @@ -5641,7 +5650,7 @@ // unpckh_undef). Only use pshufd if speed is more important than size. if (OptForSize && X86::isUNPCKL_v_undef_Mask(SVOp)) if (VT != MVT::v2i64 && VT != MVT::v2f64) - return getTargetShuffleNode(getUNPCKLOpcode(VT), dl, VT, V1, V1, DAG); + return getTargetShuffleNode(getUNPCKLOpcode(VT, getSubtarget()), dl, VT, V1, V1, DAG); if (OptForSize && X86::isUNPCKH_v_undef_Mask(SVOp)) if (VT != MVT::v2i64 && VT != MVT::v2f64) return getTargetShuffleNode(getUNPCKHOpcode(VT), dl, VT, V1, V1, DAG); @@ -5762,7 +5771,8 @@ } if (X86::isUNPCKLMask(SVOp)) - return getTargetShuffleNode(getUNPCKLOpcode(VT), dl, VT, V1, V2, DAG); + return getTargetShuffleNode(getUNPCKLOpcode(VT, getSubtarget()), + dl, VT, V1, V2, DAG); if (X86::isUNPCKHMask(SVOp)) return getTargetShuffleNode(getUNPCKHOpcode(VT), dl, VT, V1, V2, DAG); @@ -5789,7 +5799,8 @@ ShuffleVectorSDNode *NewSVOp = cast(NewOp); if (X86::isUNPCKLMask(NewSVOp)) - return getTargetShuffleNode(getUNPCKLOpcode(VT), dl, VT, V2, V1, DAG); + return getTargetShuffleNode(getUNPCKLOpcode(VT, getSubtarget()), + dl, VT, V2, V1, DAG); if (X86::isUNPCKHMask(NewSVOp)) return getTargetShuffleNode(getUNPCKHOpcode(VT), dl, VT, V2, V1, DAG); @@ -5812,8 +5823,11 @@ if (ShuffleVectorSDNode::isSplatMask(&M[0], VT) && SVOp->getSplatIndex() == 0 && V2IsUndef) { - if (VT == MVT::v2f64) - return getTargetShuffleNode(X86ISD::UNPCKLPD, dl, VT, V1, V1, DAG); + if (VT == MVT::v2f64) { + X86ISD::NodeType Opcode = + getSubtarget()->hasAVX() ? X86ISD::VUNPCKLPD : X86ISD::UNPCKLPD; + return getTargetShuffleNode(Opcode, dl, VT, V1, V1, DAG); + } if (VT == MVT::v2i64) return getTargetShuffleNode(X86ISD::PUNPCKLQDQ, dl, VT, V1, V1, DAG); } @@ -5840,7 +5854,8 @@ if (X86::isUNPCKL_v_undef_Mask(SVOp)) if (VT != MVT::v2i64 && VT != MVT::v2f64) - return getTargetShuffleNode(getUNPCKLOpcode(VT), dl, VT, V1, V1, DAG); + return getTargetShuffleNode(getUNPCKLOpcode(VT, getSubtarget()), + dl, VT, V1, V1, DAG); if (X86::isUNPCKH_v_undef_Mask(SVOp)) if (VT != MVT::v2i64 && VT != MVT::v2f64) return getTargetShuffleNode(getUNPCKHOpcode(VT), dl, VT, V1, V1, DAG); From stoklund at 2pi.dk Mon Feb 28 13:18:59 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 28 Feb 2011 19:18:59 -0000 Subject: [llvm-commits] [llvm] r126666 - /llvm/trunk/test/CodeGen/ARM/fcopysign.ll Message-ID: <20110228191859.4F3302A6C12C@llvm.org> Author: stoklund Date: Mon Feb 28 13:18:59 2011 New Revision: 126666 URL: http://llvm.org/viewvc/llvm-project?rev=126666&view=rev Log: Fix typo introduced by r126661: "Fix a typo which ..." Modified: llvm/trunk/test/CodeGen/ARM/fcopysign.ll Modified: llvm/trunk/test/CodeGen/ARM/fcopysign.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fcopysign.ll?rev=126666&r1=126665&r2=126666&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fcopysign.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fcopysign.ll Mon Feb 28 13:18:59 2011 @@ -46,7 +46,7 @@ ; SOFT: test4: ; SOFT: vcvt.f32.f64 s0, ; SOFT: vmov.i32 [[REG4:(d[0-9]+)]], #0x80000000 -; SOFT: vbic [[REG5:(d[0-9]+))], d0, [[REG4]] +; SOFT: vbic [[REG5:(d[0-9]+)]], d0, [[REG4]] ; SOFT: vorr d0, [[REG4]], [[REG5]] %call80 = tail call double @copysign(double 1.000000e+00, double undef) %conv81 = fptrunc double %call80 to float From aggarwa4 at illinois.edu Mon Feb 28 13:32:04 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Mon, 28 Feb 2011 19:32:04 -0000 Subject: [llvm-commits] [poolalloc] r126667 - in /poolalloc/trunk/include/dsa: AddressTakenAnalysis.h DataStructure.h Message-ID: <20110228193204.D5D772A6C12C@llvm.org> Author: aggarwa4 Date: Mon Feb 28 13:32:04 2011 New Revision: 126667 URL: http://llvm.org/viewvc/llvm-project?rev=126667&view=rev Log: Formatting Changes. Also, since DSA now preserves all, we dont need to explicitly say PreservesCFG. Modified: poolalloc/trunk/include/dsa/AddressTakenAnalysis.h poolalloc/trunk/include/dsa/DataStructure.h Modified: poolalloc/trunk/include/dsa/AddressTakenAnalysis.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/AddressTakenAnalysis.h?rev=126667&r1=126666&r2=126667&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/AddressTakenAnalysis.h (original) +++ poolalloc/trunk/include/dsa/AddressTakenAnalysis.h Mon Feb 28 13:32:04 2011 @@ -1,4 +1,4 @@ -//===-- AddressTakenAnalysis.h - Entry point Finding Pass -------------------===// +//===-- AddressTakenAnalysis.h - Identify address Taken Values-------------===// // // The LLVM Compiler Infrastructure // @@ -42,7 +42,5 @@ } - - #endif /* _ADDRESSTAKENANALYSIS_H */ Modified: poolalloc/trunk/include/dsa/DataStructure.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=126667&r1=126666&r2=126667&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DataStructure.h (original) +++ poolalloc/trunk/include/dsa/DataStructure.h Mon Feb 28 13:32:04 2011 @@ -208,7 +208,6 @@ /// virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); - AU.setPreservesCFG(); AU.setPreservesAll(); } }; @@ -243,7 +242,6 @@ virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); - AU.setPreservesCFG(); AU.setPreservesAll(); } @@ -292,7 +290,6 @@ virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); - AU.setPreservesCFG(); AU.setPreservesAll(); } @@ -317,7 +314,6 @@ virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); - AU.setPreservesCFG(); AU.setPreservesAll(); } @@ -375,7 +371,6 @@ AU.addRequired(); AU.addPreserved(); } - AU.setPreservesCFG(); AU.setPreservesAll(); } From gohman at apple.com Mon Feb 28 13:37:59 2011 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Feb 2011 19:37:59 -0000 Subject: [llvm-commits] [llvm] r126668 - in /llvm/trunk: include/llvm/Analysis/LiveValues.h include/llvm/Analysis/Passes.h include/llvm/InitializePasses.h include/llvm/LinkAllPasses.h lib/Analysis/Analysis.cpp lib/Analysis/LiveValues.cpp Message-ID: <20110228193759.8EAD72A6C12C@llvm.org> Author: djg Date: Mon Feb 28 13:37:59 2011 New Revision: 126668 URL: http://llvm.org/viewvc/llvm-project?rev=126668&view=rev Log: Delete the LiveValues pass. I won't get get back to the project it was started for in the foreseeable future. Removed: llvm/trunk/include/llvm/Analysis/LiveValues.h llvm/trunk/lib/Analysis/LiveValues.cpp Modified: llvm/trunk/include/llvm/Analysis/Passes.h llvm/trunk/include/llvm/InitializePasses.h llvm/trunk/include/llvm/LinkAllPasses.h llvm/trunk/lib/Analysis/Analysis.cpp Removed: llvm/trunk/include/llvm/Analysis/LiveValues.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LiveValues.h?rev=126667&view=auto ============================================================================== --- llvm/trunk/include/llvm/Analysis/LiveValues.h (original) +++ llvm/trunk/include/llvm/Analysis/LiveValues.h (removed) @@ -1,99 +0,0 @@ -//===- LiveValues.h - Liveness information for LLVM IR Values. ------------===// -// -// 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 interface for the LLVM IR Value liveness -// analysis pass. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_ANALYSIS_LIVEVALUES_H -#define LLVM_ANALYSIS_LIVEVALUES_H - -#include "llvm/Pass.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/SmallPtrSet.h" - -namespace llvm { - -class DominatorTree; -class LoopInfo; -class Value; - -/// LiveValues - Analysis that provides liveness information for -/// LLVM IR Values. -/// -class LiveValues : public FunctionPass { - DominatorTree *DT; - LoopInfo *LI; - - /// Memo - A bunch of state to be associated with a value. - /// - struct Memo { - /// Used - The set of blocks which contain a use of the value. - /// - SmallPtrSet Used; - - /// LiveThrough - A conservative approximation of the set of blocks in - /// which the value is live-through, meaning blocks properly dominated - /// by the definition, and from which blocks containing uses of the - /// value are reachable. - /// - SmallPtrSet LiveThrough; - - /// Killed - A conservative approximation of the set of blocks in which - /// the value is used and not live-out. - /// - SmallPtrSet Killed; - }; - - /// Memos - Remembers the Memo for each Value. This is populated on - /// demand. - /// - DenseMap Memos; - - /// getMemo - Retrieve an existing Memo for the given value if one - /// is available, otherwise compute a new one. - /// - Memo &getMemo(const Value *V); - - /// compute - Compute a new Memo for the given value. - /// - Memo &compute(const Value *V); - -public: - static char ID; - LiveValues(); - - virtual void getAnalysisUsage(AnalysisUsage &AU) const; - virtual bool runOnFunction(Function &F); - virtual void releaseMemory(); - - /// isUsedInBlock - Test if the given value is used in the given block. - /// - bool isUsedInBlock(const Value *V, const BasicBlock *BB); - - /// isLiveThroughBlock - Test if the given value is known to be - /// live-through the given block, meaning that the block is properly - /// dominated by the value's definition, and there exists a block - /// reachable from it that contains a use. This uses a conservative - /// approximation that errs on the side of returning false. - /// - bool isLiveThroughBlock(const Value *V, const BasicBlock *BB); - - /// isKilledInBlock - Test if the given value is known to be killed in - /// the given block, meaning that the block contains a use of the value, - /// and no blocks reachable from the block contain a use. This uses a - /// conservative approximation that errs on the side of returning false. - /// - bool isKilledInBlock(const Value *V, const BasicBlock *BB); -}; - -} // end namespace llvm - -#endif Modified: llvm/trunk/include/llvm/Analysis/Passes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Passes.h?rev=126668&r1=126667&r2=126668&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/Passes.h (original) +++ llvm/trunk/include/llvm/Analysis/Passes.h Mon Feb 28 13:37:59 2011 @@ -159,12 +159,6 @@ //===--------------------------------------------------------------------===// // - // createLiveValuesPass - This creates an instance of the LiveValues pass. - // - FunctionPass *createLiveValuesPass(); - - //===--------------------------------------------------------------------===// - // /// createLazyValueInfoPass - This creates an instance of the LazyValueInfo /// pass. FunctionPass *createLazyValueInfoPass(); Modified: llvm/trunk/include/llvm/InitializePasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=126668&r1=126667&r2=126668&view=diff ============================================================================== --- llvm/trunk/include/llvm/InitializePasses.h (original) +++ llvm/trunk/include/llvm/InitializePasses.h Mon Feb 28 13:37:59 2011 @@ -123,7 +123,6 @@ void initializeLiveDebugVariablesPass(PassRegistry&); void initializeLiveIntervalsPass(PassRegistry&); void initializeLiveStacksPass(PassRegistry&); -void initializeLiveValuesPass(PassRegistry&); void initializeLiveVariablesPass(PassRegistry&); void initializeLoaderPassPass(PassRegistry&); void initializePathProfileLoaderPassPass(PassRegistry&); Modified: llvm/trunk/include/llvm/LinkAllPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllPasses.h?rev=126668&r1=126667&r2=126668&view=diff ============================================================================== --- llvm/trunk/include/llvm/LinkAllPasses.h (original) +++ llvm/trunk/include/llvm/LinkAllPasses.h Mon Feb 28 13:37:59 2011 @@ -84,7 +84,6 @@ (void) llvm::createLCSSAPass(); (void) llvm::createLICMPass(); (void) llvm::createLazyValueInfoPass(); - (void) llvm::createLiveValuesPass(); (void) llvm::createLoopDependenceAnalysisPass(); (void) llvm::createLoopExtractorPass(); (void) llvm::createLoopSimplifyPass(); Modified: llvm/trunk/lib/Analysis/Analysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Analysis.cpp?rev=126668&r1=126667&r2=126668&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/Analysis.cpp (original) +++ llvm/trunk/lib/Analysis/Analysis.cpp Mon Feb 28 13:37:59 2011 @@ -43,7 +43,6 @@ initializeLazyValueInfoPass(Registry); initializeLibCallAliasAnalysisPass(Registry); initializeLintPass(Registry); - initializeLiveValuesPass(Registry); initializeLoopDependenceAnalysisPass(Registry); initializeLoopInfoPass(Registry); initializeMemDepPrinterPass(Registry); Removed: llvm/trunk/lib/Analysis/LiveValues.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LiveValues.cpp?rev=126667&view=auto ============================================================================== --- llvm/trunk/lib/Analysis/LiveValues.cpp (original) +++ llvm/trunk/lib/Analysis/LiveValues.cpp (removed) @@ -1,200 +0,0 @@ -//===- LiveValues.cpp - Liveness information for LLVM IR Values. ----------===// -// -// 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 implementation for the LLVM IR Value liveness -// analysis pass. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Analysis/LiveValues.h" -#include "llvm/Instructions.h" -#include "llvm/Analysis/Dominators.h" -#include "llvm/Analysis/LoopInfo.h" -using namespace llvm; - -namespace llvm { - FunctionPass *createLiveValuesPass() { return new LiveValues(); } -} - -char LiveValues::ID = 0; -INITIALIZE_PASS_BEGIN(LiveValues, "live-values", - "Value Liveness Analysis", false, true) -INITIALIZE_PASS_DEPENDENCY(DominatorTree) -INITIALIZE_PASS_DEPENDENCY(LoopInfo) -INITIALIZE_PASS_END(LiveValues, "live-values", - "Value Liveness Analysis", false, true) - -LiveValues::LiveValues() : FunctionPass(ID) { - initializeLiveValuesPass(*PassRegistry::getPassRegistry()); -} - -void LiveValues::getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired(); - AU.addRequired(); - AU.setPreservesAll(); -} - -bool LiveValues::runOnFunction(Function &F) { - DT = &getAnalysis(); - LI = &getAnalysis(); - - // This pass' values are computed lazily, so there's nothing to do here. - - return false; -} - -void LiveValues::releaseMemory() { - Memos.clear(); -} - -/// isUsedInBlock - Test if the given value is used in the given block. -/// -bool LiveValues::isUsedInBlock(const Value *V, const BasicBlock *BB) { - Memo &M = getMemo(V); - return M.Used.count(BB); -} - -/// isLiveThroughBlock - Test if the given value is known to be -/// live-through the given block, meaning that the block is properly -/// dominated by the value's definition, and there exists a block -/// reachable from it that contains a use. This uses a conservative -/// approximation that errs on the side of returning false. -/// -bool LiveValues::isLiveThroughBlock(const Value *V, - const BasicBlock *BB) { - Memo &M = getMemo(V); - return M.LiveThrough.count(BB); -} - -/// isKilledInBlock - Test if the given value is known to be killed in -/// the given block, meaning that the block contains a use of the value, -/// and no blocks reachable from the block contain a use. This uses a -/// conservative approximation that errs on the side of returning false. -/// -bool LiveValues::isKilledInBlock(const Value *V, const BasicBlock *BB) { - Memo &M = getMemo(V); - return M.Killed.count(BB); -} - -/// getMemo - Retrieve an existing Memo for the given value if one -/// is available, otherwise compute a new one. -/// -LiveValues::Memo &LiveValues::getMemo(const Value *V) { - DenseMap::iterator I = Memos.find(V); - if (I != Memos.end()) - return I->second; - return compute(V); -} - -/// getImmediateDominator - A handy utility for the specific DominatorTree -/// query that we need here. -/// -static const BasicBlock *getImmediateDominator(const BasicBlock *BB, - const DominatorTree *DT) { - DomTreeNode *Node = DT->getNode(const_cast(BB))->getIDom(); - return Node ? Node->getBlock() : 0; -} - -/// compute - Compute a new Memo for the given value. -/// -LiveValues::Memo &LiveValues::compute(const Value *V) { - Memo &M = Memos[V]; - - // Determine the block containing the definition. - const BasicBlock *DefBB; - // Instructions define values with meaningful live ranges. - if (const Instruction *I = dyn_cast(V)) - DefBB = I->getParent(); - // Arguments can be analyzed as values defined in the entry block. - else if (const Argument *A = dyn_cast(V)) - DefBB = &A->getParent()->getEntryBlock(); - // Constants and other things aren't meaningful here, so just - // return having computed an empty Memo so that we don't come - // here again. The assumption here is that client code won't - // be asking about such values very often. - else - return M; - - // Determine if the value is defined inside a loop. This is used - // to track whether the value is ever used outside the loop, so - // it'll be set to null if the value is either not defined in a - // loop or used outside the loop in which it is defined. - const Loop *L = LI->getLoopFor(DefBB); - - // Track whether the value is used anywhere outside of the block - // in which it is defined. - bool LiveOutOfDefBB = false; - - // Examine each use of the value. - for (Value::const_use_iterator I = V->use_begin(), E = V->use_end(); - I != E; ++I) { - const User *U = *I; - const BasicBlock *UseBB = cast(U)->getParent(); - - // Note the block in which this use occurs. - M.Used.insert(UseBB); - - // If the use block doesn't have successors, the value can be - // considered killed. - if (succ_begin(UseBB) == succ_end(UseBB)) - M.Killed.insert(UseBB); - - // Observe whether the value is used outside of the loop in which - // it is defined. Switch to an enclosing loop if necessary. - for (; L; L = L->getParentLoop()) - if (L->contains(UseBB)) - break; - - // Search for live-through blocks. - const BasicBlock *BB; - if (const PHINode *PHI = dyn_cast(U)) { - // For PHI nodes, start the search at the incoming block paired with the - // incoming value, which must be dominated by the definition. - unsigned Num = PHI->getIncomingValueNumForOperand(I.getOperandNo()); - BB = PHI->getIncomingBlock(Num); - - // A PHI-node use means the value is live-out of it's defining block - // even if that block also contains the only use. - LiveOutOfDefBB = true; - } else { - // Otherwise just start the search at the use. - BB = UseBB; - - // Note if the use is outside the defining block. - LiveOutOfDefBB |= UseBB != DefBB; - } - - // Climb the immediate dominator tree from the use to the definition - // and mark all intermediate blocks as live-through. - for (; BB != DefBB; BB = getImmediateDominator(BB, DT)) { - if (BB != UseBB && !M.LiveThrough.insert(BB)) - break; - } - } - - // If the value is defined inside a loop and is not live outside - // the loop, then each exit block of the loop in which the value - // is used is a kill block. - if (L) { - SmallVector ExitingBlocks; - L->getExitingBlocks(ExitingBlocks); - for (unsigned i = 0, e = ExitingBlocks.size(); i != e; ++i) { - const BasicBlock *ExitingBlock = ExitingBlocks[i]; - if (M.Used.count(ExitingBlock)) - M.Killed.insert(ExitingBlock); - } - } - - // If the value was never used outside the block in which it was - // defined, it's killed in that block. - if (!LiveOutOfDefBB) - M.Killed.insert(DefBB); - - return M; -} From gohman at apple.com Mon Feb 28 13:41:14 2011 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Feb 2011 19:41:14 -0000 Subject: [llvm-commits] [llvm] r126669 - in /llvm/trunk: include/llvm/InitializePasses.h include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/Scalar.cpp lib/Transforms/Scalar/SimplifyHalfPowrLibCalls.cpp Message-ID: <20110228194114.494CB2A6C12C@llvm.org> Author: djg Date: Mon Feb 28 13:41:14 2011 New Revision: 126669 URL: http://llvm.org/viewvc/llvm-project?rev=126669&view=rev Log: Delete the SimplifyHalfPowrLibCalls pass, which was unused, and only existed as the result of a misunderstanding. Removed: llvm/trunk/lib/Transforms/Scalar/SimplifyHalfPowrLibCalls.cpp Modified: llvm/trunk/include/llvm/InitializePasses.h llvm/trunk/include/llvm/LinkAllPasses.h llvm/trunk/include/llvm/Transforms/Scalar.h llvm/trunk/lib/Transforms/Scalar/Scalar.cpp Modified: llvm/trunk/include/llvm/InitializePasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=126669&r1=126668&r2=126669&view=diff ============================================================================== --- llvm/trunk/include/llvm/InitializePasses.h (original) +++ llvm/trunk/include/llvm/InitializePasses.h Mon Feb 28 13:41:14 2011 @@ -202,7 +202,6 @@ void initializeScalarEvolutionPass(PassRegistry&); void initializeSimpleInlinerPass(PassRegistry&); void initializeSimpleRegisterCoalescingPass(PassRegistry&); -void initializeSimplifyHalfPowrLibCallsPass(PassRegistry&); void initializeSimplifyLibCallsPass(PassRegistry&); void initializeSingleLoopExtractorPass(PassRegistry&); void initializeSinkingPass(PassRegistry&); Modified: llvm/trunk/include/llvm/LinkAllPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllPasses.h?rev=126669&r1=126668&r2=126669&view=diff ============================================================================== --- llvm/trunk/include/llvm/LinkAllPasses.h (original) +++ llvm/trunk/include/llvm/LinkAllPasses.h Mon Feb 28 13:41:14 2011 @@ -118,7 +118,6 @@ (void) llvm::createSCCPPass(); (void) llvm::createScalarReplAggregatesPass(); (void) llvm::createSimplifyLibCallsPass(); - (void) llvm::createSimplifyHalfPowrLibCallsPass(); (void) llvm::createSingleLoopExtractorPass(); (void) llvm::createStripSymbolsPass(); (void) llvm::createStripNonDebugSymbolsPass(); Modified: llvm/trunk/include/llvm/Transforms/Scalar.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=126669&r1=126668&r2=126669&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Scalar.h (original) +++ llvm/trunk/include/llvm/Transforms/Scalar.h Mon Feb 28 13:41:14 2011 @@ -301,12 +301,6 @@ //===----------------------------------------------------------------------===// // -/// createSimplifyHalfPowrLibCallsPass - This is an experimental pass that -/// optimizes specific half_pow functions. -FunctionPass *createSimplifyHalfPowrLibCallsPass(); - -//===----------------------------------------------------------------------===// -// // CodeGenPrepare - This pass prepares a function for instruction selection. // FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0); Modified: llvm/trunk/lib/Transforms/Scalar/Scalar.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Scalar.cpp?rev=126669&r1=126668&r2=126669&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/Scalar.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/Scalar.cpp Mon Feb 28 13:41:14 2011 @@ -56,7 +56,6 @@ initializeSROA_DTPass(Registry); initializeSROA_SSAUpPass(Registry); initializeCFGSimplifyPassPass(Registry); - initializeSimplifyHalfPowrLibCallsPass(Registry); initializeSimplifyLibCallsPass(Registry); initializeSinkingPass(Registry); initializeTailDupPass(Registry); Removed: llvm/trunk/lib/Transforms/Scalar/SimplifyHalfPowrLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyHalfPowrLibCalls.cpp?rev=126668&view=auto ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyHalfPowrLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyHalfPowrLibCalls.cpp (removed) @@ -1,160 +0,0 @@ -//===- SimplifyHalfPowrLibCalls.cpp - Optimize specific half_powr calls ---===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements a simple pass that applies an experimental -// transformation on calls to specific functions. -// -//===----------------------------------------------------------------------===// - -#define DEBUG_TYPE "simplify-libcalls-halfpowr" -#include "llvm/Transforms/Scalar.h" -#include "llvm/Instructions.h" -#include "llvm/Intrinsics.h" -#include "llvm/Module.h" -#include "llvm/Pass.h" -#include "llvm/Transforms/Utils/BasicBlockUtils.h" -#include "llvm/Transforms/Utils/Cloning.h" -#include "llvm/Target/TargetData.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/Support/Debug.h" -using namespace llvm; - -namespace { - /// This pass optimizes well half_powr function calls. - /// - class SimplifyHalfPowrLibCalls : public FunctionPass { - const TargetData *TD; - public: - static char ID; // Pass identification - SimplifyHalfPowrLibCalls() : FunctionPass(ID) { - initializeSimplifyHalfPowrLibCallsPass(*PassRegistry::getPassRegistry()); - } - - bool runOnFunction(Function &F); - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - } - - Instruction * - InlineHalfPowrs(const std::vector &HalfPowrs, - Instruction *InsertPt); - }; - char SimplifyHalfPowrLibCalls::ID = 0; -} // end anonymous namespace. - -INITIALIZE_PASS(SimplifyHalfPowrLibCalls, "simplify-libcalls-halfpowr", - "Simplify half_powr library calls", false, false) - -// Public interface to the Simplify HalfPowr LibCalls pass. -FunctionPass *llvm::createSimplifyHalfPowrLibCallsPass() { - return new SimplifyHalfPowrLibCalls(); -} - -/// InlineHalfPowrs - Inline a sequence of adjacent half_powr calls, rearranging -/// their control flow to better facilitate subsequent optimization. -Instruction * -SimplifyHalfPowrLibCalls:: -InlineHalfPowrs(const std::vector &HalfPowrs, - Instruction *InsertPt) { - std::vector Bodies; - BasicBlock *NewBlock = 0; - - for (unsigned i = 0, e = HalfPowrs.size(); i != e; ++i) { - CallInst *Call = cast(HalfPowrs[i]); - Function *Callee = Call->getCalledFunction(); - - // Minimally sanity-check the CFG of half_powr to ensure that it contains - // the kind of code we expect. If we're running this pass, we have - // reason to believe it will be what we expect. - Function::iterator I = Callee->begin(); - BasicBlock *Prologue = I++; - if (I == Callee->end()) break; - BasicBlock *SubnormalHandling = I++; - if (I == Callee->end()) break; - BasicBlock *Body = I++; - if (I != Callee->end()) break; - if (SubnormalHandling->getSinglePredecessor() != Prologue) - break; - BranchInst *PBI = dyn_cast(Prologue->getTerminator()); - if (!PBI || !PBI->isConditional()) - break; - BranchInst *SNBI = dyn_cast(SubnormalHandling->getTerminator()); - if (!SNBI || SNBI->isConditional()) - break; - if (!isa(Body->getTerminator())) - break; - - Instruction *NextInst = llvm::next(BasicBlock::iterator(Call)); - - // Inline the call, taking care of what code ends up where. - NewBlock = SplitBlock(NextInst->getParent(), NextInst, this); - - InlineFunctionInfo IFI(0, TD); - bool B = InlineFunction(Call, IFI); - assert(B && "half_powr didn't inline?"); - (void)B; - - BasicBlock *NewBody = NewBlock->getSinglePredecessor(); - assert(NewBody); - Bodies.push_back(NewBody); - } - - if (!NewBlock) - return InsertPt; - - // Put the code for all the bodies into one block, to facilitate - // subsequent optimization. - (void)SplitEdge(NewBlock->getSinglePredecessor(), NewBlock, this); - for (unsigned i = 0, e = Bodies.size(); i != e; ++i) { - BasicBlock *Body = Bodies[i]; - Instruction *FNP = Body->getFirstNonPHI(); - // Splice the insts from body into NewBlock. - NewBlock->getInstList().splice(NewBlock->begin(), Body->getInstList(), - FNP, Body->getTerminator()); - } - - return NewBlock->begin(); -} - -/// runOnFunction - Top level algorithm. -/// -bool SimplifyHalfPowrLibCalls::runOnFunction(Function &F) { - TD = getAnalysisIfAvailable(); - - bool Changed = false; - std::vector HalfPowrs; - for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { - for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { - // Look for calls. - bool IsHalfPowr = false; - if (CallInst *CI = dyn_cast(I)) { - // Look for direct calls and calls to non-external functions. - Function *Callee = CI->getCalledFunction(); - if (Callee && Callee->hasExternalLinkage()) { - // Look for calls with well-known names. - if (Callee->getName() == "__half_powrf4") - IsHalfPowr = true; - } - } - if (IsHalfPowr) - HalfPowrs.push_back(I); - // We're looking for sequences of up to three such calls, which we'll - // simplify as a group. - if ((!IsHalfPowr && !HalfPowrs.empty()) || HalfPowrs.size() == 3) { - I = InlineHalfPowrs(HalfPowrs, I); - E = I->getParent()->end(); - HalfPowrs.clear(); - Changed = true; - } - } - assert(HalfPowrs.empty() && "Block had no terminator!"); - } - - return Changed; -} From gohman at apple.com Mon Feb 28 13:47:47 2011 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Feb 2011 19:47:47 -0000 Subject: [llvm-commits] [llvm] r126671 - in /llvm/trunk: include/llvm/InitializePasses.h include/llvm/LinkAllPasses.h lib/CodeGen/LLVMTargetMachine.cpp lib/Transforms/Scalar/GEPSplitter.cpp lib/Transforms/Scalar/Scalar.cpp Message-ID: <20110228194747.DC6B52A6C12C@llvm.org> Author: djg Date: Mon Feb 28 13:47:47 2011 New Revision: 126671 URL: http://llvm.org/viewvc/llvm-project?rev=126671&view=rev Log: Delete the GEPSplitter experiment. Removed: llvm/trunk/lib/Transforms/Scalar/GEPSplitter.cpp Modified: llvm/trunk/include/llvm/InitializePasses.h llvm/trunk/include/llvm/LinkAllPasses.h llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp llvm/trunk/lib/Transforms/Scalar/Scalar.cpp Modified: llvm/trunk/include/llvm/InitializePasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=126671&r1=126670&r2=126671&view=diff ============================================================================== --- llvm/trunk/include/llvm/InitializePasses.h (original) +++ llvm/trunk/include/llvm/InitializePasses.h Mon Feb 28 13:47:47 2011 @@ -99,7 +99,6 @@ void initializeFindUsedTypesPass(PassRegistry&); void initializeFunctionAttrsPass(PassRegistry&); void initializeGCModuleInfoPass(PassRegistry&); -void initializeGEPSplitterPass(PassRegistry&); void initializeGVNPass(PassRegistry&); void initializeGlobalDCEPass(PassRegistry&); void initializeGlobalOptPass(PassRegistry&); Modified: llvm/trunk/include/llvm/LinkAllPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllPasses.h?rev=126671&r1=126670&r2=126671&view=diff ============================================================================== --- llvm/trunk/include/llvm/LinkAllPasses.h (original) +++ llvm/trunk/include/llvm/LinkAllPasses.h Mon Feb 28 13:47:47 2011 @@ -143,7 +143,6 @@ (void) llvm::createDbgInfoPrinterPass(); (void) llvm::createModuleDebugInfoPrinterPass(); (void) llvm::createPartialInliningPass(); - (void) llvm::createGEPSplitterPass(); (void) llvm::createLintPass(); (void) llvm::createSinkingPass(); (void) llvm::createLowerAtomicPass(); Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=126671&r1=126670&r2=126671&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Mon Feb 28 13:47:47 2011 @@ -98,12 +98,6 @@ EnableFastISelOption("fast-isel", cl::Hidden, cl::desc("Enable the \"fast\" instruction selector")); -// Enable or disable an experimental optimization to split GEPs -// and run a special GVN pass which does not examine loads, in -// an effort to factor out redundancy implicit in complex GEPs. -static cl::opt EnableSplitGEPGVN("split-gep-gvn", cl::Hidden, - cl::desc("Split GEPs and run no-load GVN")); - LLVMTargetMachine::LLVMTargetMachine(const Target &T, const std::string &Triple) : TargetMachine(T), TargetTriple(Triple) { @@ -272,12 +266,6 @@ if (!DisableVerify) PM.add(createVerifierPass()); - // Optionally, tun split-GEPs and no-load GVN. - if (EnableSplitGEPGVN) { - PM.add(createGEPSplitterPass()); - PM.add(createGVNPass(/*NoLoads=*/true)); - } - // Run loop strength reduction before anything else. if (OptLevel != CodeGenOpt::None && !DisableLSR) { PM.add(createLoopStrengthReducePass(getTargetLowering())); Removed: llvm/trunk/lib/Transforms/Scalar/GEPSplitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GEPSplitter.cpp?rev=126670&view=auto ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GEPSplitter.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GEPSplitter.cpp (removed) @@ -1,83 +0,0 @@ -//===- GEPSplitter.cpp - Split complex GEPs into simple ones --------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This function breaks GEPs with more than 2 non-zero operands into smaller -// GEPs each with no more than 2 non-zero operands. This exposes redundancy -// between GEPs with common initial operand sequences. -// -//===----------------------------------------------------------------------===// - -#define DEBUG_TYPE "split-geps" -#include "llvm/Transforms/Scalar.h" -#include "llvm/Constants.h" -#include "llvm/Function.h" -#include "llvm/Instructions.h" -#include "llvm/Pass.h" -using namespace llvm; - -namespace { - class GEPSplitter : public FunctionPass { - virtual bool runOnFunction(Function &F); - virtual void getAnalysisUsage(AnalysisUsage &AU) const; - public: - static char ID; // Pass identification, replacement for typeid - explicit GEPSplitter() : FunctionPass(ID) { - initializeGEPSplitterPass(*PassRegistry::getPassRegistry()); - } - }; -} - -char GEPSplitter::ID = 0; -INITIALIZE_PASS(GEPSplitter, "split-geps", - "split complex GEPs into simple GEPs", false, false) - -FunctionPass *llvm::createGEPSplitterPass() { - return new GEPSplitter(); -} - -bool GEPSplitter::runOnFunction(Function &F) { - bool Changed = false; - - // Visit each GEP instruction. - for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) - for (BasicBlock::iterator II = I->begin(), IE = I->end(); II != IE; ) - if (GetElementPtrInst *GEP = dyn_cast(II++)) { - unsigned NumOps = GEP->getNumOperands(); - // Ignore GEPs which are already simple. - if (NumOps <= 2) - continue; - bool FirstIndexIsZero = isa(GEP->getOperand(1)) && - cast(GEP->getOperand(1))->isZero(); - if (NumOps == 3 && FirstIndexIsZero) - continue; - // The first index is special and gets expanded with a 2-operand GEP - // (unless it's zero, in which case we can skip this). - Value *NewGEP = FirstIndexIsZero ? - GEP->getOperand(0) : - GetElementPtrInst::Create(GEP->getOperand(0), GEP->getOperand(1), - "tmp", GEP); - // All remaining indices get expanded with a 3-operand GEP with zero - // as the second operand. - Value *Idxs[2]; - Idxs[0] = ConstantInt::get(Type::getInt64Ty(F.getContext()), 0); - for (unsigned i = 2; i != NumOps; ++i) { - Idxs[1] = GEP->getOperand(i); - NewGEP = GetElementPtrInst::Create(NewGEP, Idxs, Idxs+2, "tmp", GEP); - } - GEP->replaceAllUsesWith(NewGEP); - GEP->eraseFromParent(); - Changed = true; - } - - return Changed; -} - -void GEPSplitter::getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesCFG(); -} Modified: llvm/trunk/lib/Transforms/Scalar/Scalar.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Scalar.cpp?rev=126671&r1=126670&r2=126671&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/Scalar.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/Scalar.cpp Mon Feb 28 13:47:47 2011 @@ -34,7 +34,6 @@ initializeDCEPass(Registry); initializeDeadInstEliminationPass(Registry); initializeDSEPass(Registry); - initializeGEPSplitterPass(Registry); initializeGVNPass(Registry); initializeEarlyCSEPass(Registry); initializeIndVarSimplifyPass(Registry); From stuart at apple.com Mon Feb 28 13:48:00 2011 From: stuart at apple.com (Stuart Hastings) Date: Mon, 28 Feb 2011 19:48:00 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r126672 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <20110228194800.B507F2A6C12C@llvm.org> Author: stuart Date: Mon Feb 28 13:48:00 2011 New Revision: 126672 URL: http://llvm.org/viewvc/llvm-project?rev=126672&view=rev Log: Skip anonymous union fields when initializing. Radar 9055247. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=126672&r1=126671&r2=126672&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Feb 28 13:48:00 2011 @@ -8582,10 +8582,10 @@ // Convert the constant itself. Constant *Val = Convert(VEC_index(constructor_elt, elt, 0)->value); - // Unions are initialized using the first member field. Find it. + // Unions are initialized using the first non-anonymous member field. Find it. tree Field = TYPE_FIELDS(TREE_TYPE(exp)); assert(Field && "cannot initialize union with no fields"); - while (TREE_CODE(Field) != FIELD_DECL) { + while (TREE_CODE(Field) != FIELD_DECL || DECL_NAME(Field) == NULL_TREE) { Field = TREE_CHAIN(Field); assert(Field && "cannot initialize union with no fields"); } From resistor at mac.com Mon Feb 28 13:58:06 2011 From: resistor at mac.com (Owen Anderson) Date: Mon, 28 Feb 2011 19:58:06 -0000 Subject: [llvm-commits] [llvm] r126679 - /llvm/trunk/include/llvm/Target/TargetLowering.h Message-ID: <20110228195806.594DF2A6C12C@llvm.org> Author: resistor Date: Mon Feb 28 13:58:06 2011 New Revision: 126679 URL: http://llvm.org/viewvc/llvm-project?rev=126679&view=rev Log: Fix warning when building with clang++. Modified: llvm/trunk/include/llvm/Target/TargetLowering.h Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=126679&r1=126678&r2=126679&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Mon Feb 28 13:58:06 2011 @@ -1260,7 +1260,7 @@ } /// HandleByVal - Target-specific cleanup for formal ByVal parameters. - virtual void HandleByVal(CCState *) const {}; + virtual void HandleByVal(CCState *) const {} /// CanLowerReturn - This hook should be implemented to check whether the /// return values described by the Outs array can fit into the return From gohman at apple.com Mon Feb 28 13:58:14 2011 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Feb 2011 19:58:14 -0000 Subject: [llvm-commits] [llvm] r126680 - /llvm/trunk/test/Transforms/SimplifyLibCalls/half-powr.ll Message-ID: <20110228195814.8EC2F2A6C12C@llvm.org> Author: djg Date: Mon Feb 28 13:58:14 2011 New Revision: 126680 URL: http://llvm.org/viewvc/llvm-project?rev=126680&view=rev Log: Delete obsolete test. Removed: llvm/trunk/test/Transforms/SimplifyLibCalls/half-powr.ll Removed: llvm/trunk/test/Transforms/SimplifyLibCalls/half-powr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/half-powr.ll?rev=126679&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/half-powr.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/half-powr.ll (removed) @@ -1,46 +0,0 @@ -; RUN: opt -simplify-libcalls-halfpowr %s -S | FileCheck %s - -define float @__half_powrf4(float %f, float %g) nounwind readnone { -entry: - %0 = fcmp olt float %f, 2.000000e+00 ; [#uses=1] - br i1 %0, label %bb, label %bb1 - -bb: ; preds = %entry - %1 = fdiv float %f, 3.000000e+00 ; [#uses=1] - br label %bb1 - -bb1: ; preds = %bb, %entry - %f_addr.0 = phi float [ %1, %bb ], [ %f, %entry ] ; [#uses=1] - %2 = fmul float %f_addr.0, %g ; [#uses=1] -; CHECK: fmul float %f_addr -; CHECK: fmul float %f_addr -; CHECK: fmul float %f_addr -; CHECK: fmul float %f_addr - - ret float %2 -} - -define void @foo(float* %p) nounwind { -entry: - %0 = load float* %p, align 4 ; [#uses=1] - %1 = getelementptr float* %p, i32 1 ; [#uses=1] - %2 = load float* %1, align 4 ; [#uses=1] - %3 = getelementptr float* %p, i32 2 ; [#uses=1] - %4 = load float* %3, align 4 ; [#uses=1] - %5 = getelementptr float* %p, i32 3 ; [#uses=1] - %6 = load float* %5, align 4 ; [#uses=1] - %7 = getelementptr float* %p, i32 4 ; [#uses=1] - %8 = load float* %7, align 4 ; [#uses=1] - %9 = getelementptr float* %p, i32 5 ; [#uses=1] - %10 = load float* %9, align 4 ; [#uses=1] - %11 = tail call float @__half_powrf4(float %0, float %6) nounwind ; [#uses=1] - %12 = tail call float @__half_powrf4(float %2, float %8) nounwind ; [#uses=1] - %13 = tail call float @__half_powrf4(float %4, float %10) nounwind ; [#uses=1] - %14 = getelementptr float* %p, i32 6 ; [#uses=1] - store float %11, float* %14, align 4 - %15 = getelementptr float* %p, i32 7 ; [#uses=1] - store float %12, float* %15, align 4 - %16 = getelementptr float* %p, i32 8 ; [#uses=1] - store float %13, float* %16, align 4 - ret void -} From justin.holewinski at gmail.com Mon Feb 28 14:52:19 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Mon, 28 Feb 2011 15:52:19 -0500 Subject: [llvm-commits] [PATCH] Extend initial support for primitive types in PTX backend Message-ID: The following patch provides support for i16, i64, and double types within the PTX backend, in addition to the already-supported i32 and float data types. No new instructions are supported; instead, this patch provides much of the infrastructure needed to support basic operations on all primitive types, not just the basic i32 and float types. Note: the kernel parameter PTX generator still assumes 32-bit addresses for pointer types. This will be fixed in a following patch. -- Thanks, Justin Holewinski -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110228/f4215a0d/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Extend-initial-support-for-primitive-types-in-PTX-ba.patch Type: text/x-patch Size: 70719 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110228/f4215a0d/attachment-0001.bin From sabre at nondot.org Mon Feb 28 14:50:35 2011 From: sabre at nondot.org (Chris Lattner) Date: Mon, 28 Feb 2011 20:50:35 -0000 Subject: [llvm-commits] [llvm] r126682 - /llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp Message-ID: <20110228205035.3416C2A6C12C@llvm.org> Author: lattner Date: Mon Feb 28 14:50:35 2011 New Revision: 126682 URL: http://llvm.org/viewvc/llvm-project?rev=126682&view=rev Log: fix a signed comparison warning. Modified: llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp Modified: llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp?rev=126682&r1=126681&r2=126682&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp (original) +++ llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp Mon Feb 28 14:50:35 2011 @@ -166,7 +166,7 @@ void DecodeUNPCKLPMask(EVT VT, SmallVectorImpl &ShuffleMask) { - int NElts = VT.getVectorNumElements(); + unsigned NElts = VT.getVectorNumElements(); for (unsigned i = 0; i != NElts/2; ++i) { ShuffleMask.push_back(i); // Reads from dest From resistor at mac.com Mon Feb 28 14:57:56 2011 From: resistor at mac.com (Owen Anderson) Date: Mon, 28 Feb 2011 20:57:56 -0000 Subject: [llvm-commits] [llvm] r126683 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Message-ID: <20110228205756.678752A6C12C@llvm.org> Author: resistor Date: Mon Feb 28 14:57:56 2011 New Revision: 126683 URL: http://llvm.org/viewvc/llvm-project?rev=126683&view=rev Log: Clean whitespace. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=126683&r1=126682&r2=126683&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Mon Feb 28 14:57:56 2011 @@ -1428,9 +1428,9 @@ HiOps[2] = Lo.getValue(1); Hi = DAG.getNode(ISD::SUBE, dl, VTList, HiOps, 3); } - return; + return; } - + if (N->getOpcode() == ISD::ADD) { Lo = DAG.getNode(ISD::ADD, dl, NVT, LoOps, 2); Hi = DAG.getNode(ISD::ADD, dl, NVT, HiOps, 2); @@ -2139,7 +2139,7 @@ // non-overflow-checking operation. SDValue Ret = DAG.getNode(ISD::MUL, dl, LHS.getValueType(), LHS, RHS); SplitInteger(Ret, Lo, Hi); - + // Now calculate overflow. SDValue Ofl; if (N->getOpcode() == ISD::UMULO) From evan.cheng at apple.com Mon Feb 28 15:05:31 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 28 Feb 2011 13:05:31 -0800 Subject: [llvm-commits] [llvm] r126666 - /llvm/trunk/test/CodeGen/ARM/fcopysign.ll In-Reply-To: <20110228191859.4F3302A6C12C@llvm.org> References: <20110228191859.4F3302A6C12C@llvm.org> Message-ID: Thanks. I don't know why my own testing didn't catch this. Evan On Feb 28, 2011, at 11:18 AM, Jakob Stoklund Olesen wrote: > Author: stoklund > Date: Mon Feb 28 13:18:59 2011 > New Revision: 126666 > > URL: http://llvm.org/viewvc/llvm-project?rev=126666&view=rev > Log: > Fix typo introduced by r126661: "Fix a typo which ..." > > Modified: > llvm/trunk/test/CodeGen/ARM/fcopysign.ll > > Modified: llvm/trunk/test/CodeGen/ARM/fcopysign.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fcopysign.ll?rev=126666&r1=126665&r2=126666&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/ARM/fcopysign.ll (original) > +++ llvm/trunk/test/CodeGen/ARM/fcopysign.ll Mon Feb 28 13:18:59 2011 > @@ -46,7 +46,7 @@ > ; SOFT: test4: > ; SOFT: vcvt.f32.f64 s0, > ; SOFT: vmov.i32 [[REG4:(d[0-9]+)]], #0x80000000 > -; SOFT: vbic [[REG5:(d[0-9]+))], d0, [[REG4]] > +; SOFT: vbic [[REG5:(d[0-9]+)]], d0, [[REG4]] > ; SOFT: vorr d0, [[REG4]], [[REG5]] > %call80 = tail call double @copysign(double 1.000000e+00, double undef) > %conv81 = fptrunc double %call80 to float > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From resistor at mac.com Mon Feb 28 15:10:10 2011 From: resistor at mac.com (Owen Anderson) Date: Mon, 28 Feb 2011 21:10:10 -0000 Subject: [llvm-commits] [llvm] r126684 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Message-ID: <20110228211010.A2B182A6C12C@llvm.org> Author: resistor Date: Mon Feb 28 15:10:10 2011 New Revision: 126684 URL: http://llvm.org/viewvc/llvm-project?rev=126684&view=rev Log: Use the correct shift amount type. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=126684&r1=126683&r2=126684&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Mon Feb 28 15:10:10 2011 @@ -226,7 +226,7 @@ unsigned DiffBits = NVT.getSizeInBits() - OVT.getSizeInBits(); return DAG.getNode(ISD::SRL, dl, NVT, DAG.getNode(ISD::BSWAP, dl, NVT, Op), - DAG.getConstant(DiffBits, TLI.getPointerTy())); + DAG.getConstant(DiffBits, TLI.getShiftAmountTy(NVT))); } SDValue DAGTypeLegalizer::PromoteIntRes_BUILD_PAIR(SDNode *N) { From dgregor at apple.com Mon Feb 28 15:27:51 2011 From: dgregor at apple.com (Douglas Gregor) Date: Mon, 28 Feb 2011 13:27:51 -0800 Subject: [llvm-commits] [llvm] r126671 - in /llvm/trunk: include/llvm/InitializePasses.h include/llvm/LinkAllPasses.h lib/CodeGen/LLVMTargetMachine.cpp lib/Transforms/Scalar/GEPSplitter.cpp lib/Transforms/Scalar/Scalar.cpp In-Reply-To: <20110228194747.DC6B52A6C12C@llvm.org> References: <20110228194747.DC6B52A6C12C@llvm.org> Message-ID: <5D1E89B2-2F0D-4716-B8DD-5F50BFF31828@apple.com> Please also remove this source file from the corresponding CMakeLists.txt. On Feb 28, 2011, at 11:47 AM, Dan Gohman wrote: > Author: djg > Date: Mon Feb 28 13:47:47 2011 > New Revision: 126671 > > URL: http://llvm.org/viewvc/llvm-project?rev=126671&view=rev > Log: > Delete the GEPSplitter experiment. > > Removed: > llvm/trunk/lib/Transforms/Scalar/GEPSplitter.cpp > Modified: > llvm/trunk/include/llvm/InitializePasses.h > llvm/trunk/include/llvm/LinkAllPasses.h > llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp > llvm/trunk/lib/Transforms/Scalar/Scalar.cpp > > Modified: llvm/trunk/include/llvm/InitializePasses.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=126671&r1=126670&r2=126671&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/InitializePasses.h (original) > +++ llvm/trunk/include/llvm/InitializePasses.h Mon Feb 28 13:47:47 2011 > @@ -99,7 +99,6 @@ > void initializeFindUsedTypesPass(PassRegistry&); > void initializeFunctionAttrsPass(PassRegistry&); > void initializeGCModuleInfoPass(PassRegistry&); > -void initializeGEPSplitterPass(PassRegistry&); > void initializeGVNPass(PassRegistry&); > void initializeGlobalDCEPass(PassRegistry&); > void initializeGlobalOptPass(PassRegistry&); > > Modified: llvm/trunk/include/llvm/LinkAllPasses.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllPasses.h?rev=126671&r1=126670&r2=126671&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/LinkAllPasses.h (original) > +++ llvm/trunk/include/llvm/LinkAllPasses.h Mon Feb 28 13:47:47 2011 > @@ -143,7 +143,6 @@ > (void) llvm::createDbgInfoPrinterPass(); > (void) llvm::createModuleDebugInfoPrinterPass(); > (void) llvm::createPartialInliningPass(); > - (void) llvm::createGEPSplitterPass(); > (void) llvm::createLintPass(); > (void) llvm::createSinkingPass(); > (void) llvm::createLowerAtomicPass(); > > Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=126671&r1=126670&r2=126671&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) > +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Mon Feb 28 13:47:47 2011 > @@ -98,12 +98,6 @@ > EnableFastISelOption("fast-isel", cl::Hidden, > cl::desc("Enable the \"fast\" instruction selector")); > > -// Enable or disable an experimental optimization to split GEPs > -// and run a special GVN pass which does not examine loads, in > -// an effort to factor out redundancy implicit in complex GEPs. > -static cl::opt EnableSplitGEPGVN("split-gep-gvn", cl::Hidden, > - cl::desc("Split GEPs and run no-load GVN")); > - > LLVMTargetMachine::LLVMTargetMachine(const Target &T, > const std::string &Triple) > : TargetMachine(T), TargetTriple(Triple) { > @@ -272,12 +266,6 @@ > if (!DisableVerify) > PM.add(createVerifierPass()); > > - // Optionally, tun split-GEPs and no-load GVN. > - if (EnableSplitGEPGVN) { > - PM.add(createGEPSplitterPass()); > - PM.add(createGVNPass(/*NoLoads=*/true)); > - } > - > // Run loop strength reduction before anything else. > if (OptLevel != CodeGenOpt::None && !DisableLSR) { > PM.add(createLoopStrengthReducePass(getTargetLowering())); > > Removed: llvm/trunk/lib/Transforms/Scalar/GEPSplitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GEPSplitter.cpp?rev=126670&view=auto > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/GEPSplitter.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/GEPSplitter.cpp (removed) > @@ -1,83 +0,0 @@ > -//===- GEPSplitter.cpp - Split complex GEPs into simple ones --------------===// > -// > -// The LLVM Compiler Infrastructure > -// > -// This file is distributed under the University of Illinois Open Source > -// License. See LICENSE.TXT for details. > -// > -//===----------------------------------------------------------------------===// > -// > -// This function breaks GEPs with more than 2 non-zero operands into smaller > -// GEPs each with no more than 2 non-zero operands. This exposes redundancy > -// between GEPs with common initial operand sequences. > -// > -//===----------------------------------------------------------------------===// > - > -#define DEBUG_TYPE "split-geps" > -#include "llvm/Transforms/Scalar.h" > -#include "llvm/Constants.h" > -#include "llvm/Function.h" > -#include "llvm/Instructions.h" > -#include "llvm/Pass.h" > -using namespace llvm; > - > -namespace { > - class GEPSplitter : public FunctionPass { > - virtual bool runOnFunction(Function &F); > - virtual void getAnalysisUsage(AnalysisUsage &AU) const; > - public: > - static char ID; // Pass identification, replacement for typeid > - explicit GEPSplitter() : FunctionPass(ID) { > - initializeGEPSplitterPass(*PassRegistry::getPassRegistry()); > - } > - }; > -} > - > -char GEPSplitter::ID = 0; > -INITIALIZE_PASS(GEPSplitter, "split-geps", > - "split complex GEPs into simple GEPs", false, false) > - > -FunctionPass *llvm::createGEPSplitterPass() { > - return new GEPSplitter(); > -} > - > -bool GEPSplitter::runOnFunction(Function &F) { > - bool Changed = false; > - > - // Visit each GEP instruction. > - for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) > - for (BasicBlock::iterator II = I->begin(), IE = I->end(); II != IE; ) > - if (GetElementPtrInst *GEP = dyn_cast(II++)) { > - unsigned NumOps = GEP->getNumOperands(); > - // Ignore GEPs which are already simple. > - if (NumOps <= 2) > - continue; > - bool FirstIndexIsZero = isa(GEP->getOperand(1)) && > - cast(GEP->getOperand(1))->isZero(); > - if (NumOps == 3 && FirstIndexIsZero) > - continue; > - // The first index is special and gets expanded with a 2-operand GEP > - // (unless it's zero, in which case we can skip this). > - Value *NewGEP = FirstIndexIsZero ? > - GEP->getOperand(0) : > - GetElementPtrInst::Create(GEP->getOperand(0), GEP->getOperand(1), > - "tmp", GEP); > - // All remaining indices get expanded with a 3-operand GEP with zero > - // as the second operand. > - Value *Idxs[2]; > - Idxs[0] = ConstantInt::get(Type::getInt64Ty(F.getContext()), 0); > - for (unsigned i = 2; i != NumOps; ++i) { > - Idxs[1] = GEP->getOperand(i); > - NewGEP = GetElementPtrInst::Create(NewGEP, Idxs, Idxs+2, "tmp", GEP); > - } > - GEP->replaceAllUsesWith(NewGEP); > - GEP->eraseFromParent(); > - Changed = true; > - } > - > - return Changed; > -} > - > -void GEPSplitter::getAnalysisUsage(AnalysisUsage &AU) const { > - AU.setPreservesCFG(); > -} > > Modified: llvm/trunk/lib/Transforms/Scalar/Scalar.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Scalar.cpp?rev=126671&r1=126670&r2=126671&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/Scalar.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/Scalar.cpp Mon Feb 28 13:47:47 2011 > @@ -34,7 +34,6 @@ > initializeDCEPass(Registry); > initializeDeadInstEliminationPass(Registry); > initializeDSEPass(Registry); > - initializeGEPSplitterPass(Registry); > initializeGVNPass(Registry); > initializeEarlyCSEPass(Registry); > initializeIndVarSimplifyPass(Registry); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From Renato.Golin at arm.com Mon Feb 28 15:31:37 2011 From: Renato.Golin at arm.com (Renato Golin) Date: Mon, 28 Feb 2011 21:31:37 +0000 Subject: [llvm-commits] ARM .fpu attribute In-Reply-To: References: <4D6BA470.1020105@arm.com>, Message-ID: The .fpu will never show in ELF, and is a hack that GAS has that has nothing to do with build attributes. But printing them allows GAS/LD to correctly choose the instructions. I'd like GAS to understand VFP/NEON build attributes directly, but that's another story... ;) cheers, --renato ________________________________________ From: Jason Kim [jasonwkim at google.com] Sent: 28 February 2011 18:59 To: Renato Golin Cc: llvm-commits at cs.uiuc.edu; siarhei.siamashka at gmail.com Subject: Re: ARM .fpu attribute HI Renato, Patch looks good. Please commit. I am unsure about the lowercase/uppercase difference between .s and .o for textual attributes. AFAIK, it is required for .cpu attribute to be lowercase in .s and uppercase in .o. Is it also required (or at least harmless) for .fpu attr as well? Thanks! -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. From enderby at apple.com Mon Feb 28 15:45:12 2011 From: enderby at apple.com (Kevin Enderby) Date: Mon, 28 Feb 2011 21:45:12 -0000 Subject: [llvm-commits] [llvm] r126687 - /llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Message-ID: <20110228214512.EE3702A6C12C@llvm.org> Author: enderby Date: Mon Feb 28 15:45:12 2011 New Revision: 126687 URL: http://llvm.org/viewvc/llvm-project?rev=126687&view=rev Log: Add missing whitespace in the formatting. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h?rev=126687&r1=126686&r2=126687&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Mon Feb 28 15:45:12 2011 @@ -1720,7 +1720,7 @@ } // Some instructions have predicate operands first before the immediate. - if(Opcode == ARM::tBLXi_r9 || Opcode == ARM::tBLr9) { + if (Opcode == ARM::tBLXi_r9 || Opcode == ARM::tBLr9) { // Handling the two predicate operands before the imm operand. if (B->DoPredicateOperands(MI, Opcode, insn, NumOps)) NumOpsAdded += 2; From jan_sjodin at yahoo.com Mon Feb 28 15:52:53 2011 From: jan_sjodin at yahoo.com (Jan Sjodin) Date: Mon, 28 Feb 2011 13:52:53 -0800 (PST) Subject: [llvm-commits] Code refactoring of MCELFStreamer.cpp and ELFObjectWriter.cpp In-Reply-To: <677486.27153.qm@web55604.mail.re4.yahoo.com> References: <960821.36942.qm@web55604.mail.re4.yahoo.com> <4D680702.2040101@gmail.com> <470208.84552.qm@web55602.mail.re4.yahoo.com> <4D68461F.2090807@gmail.com> <267631.76534.qm@web55603.mail.re4.yahoo.com> <4D6917D8.6030506@gmail.com> <677486.27153.qm@web55604.mail.re4.yahoo.com> Message-ID: <777775.92945.qm@web55603.mail.re4.yahoo.com> I got help. Thank you Daniel. Committed the patch, revision 126686. - Jan ----- Original Message ---- > From: Jan Sjodin > To: Rafael ?vila de Esp?ndola > Cc: llvm-commits at cs.uiuc.edu > Sent: Mon, February 28, 2011 12:49:22 PM > Subject: Re: [llvm-commits] Code refactoring of MCELFStreamer.cpp and >ELFObjectWriter.cpp > > I was trying to commit my change, but something is wrong. It was the first time > > I tried to commit anything so something was bound to not work. :) I will try >to > > get some help, but if you want to commit it, go ahead. > > - Jan > > > > ----- Original Message ---- > > From: Rafael ?vila de Esp?ndola > > To: Jan Sjodin > > Cc: llvm-commits at cs.uiuc.edu > > Sent: Sat, February 26, 2011 10:10:16 AM > > Subject: Re: [llvm-commits] Code refactoring of MCELFStreamer.cpp and > >ELFObjectWriter.cpp > > > > On 11-02-25 8:54 PM, Jan Sjodin wrote: > > > The JIT implementation I am working on (MCJIT which was renamed to >JunkJIT) > > > became a lot nicer when I decided to inherit MCELFStreamer and > >ELFObjectWriter. > > > This was needed to make the debug information available to gdb since it > >expects > > > ELF format. I basically reuse everything, the only thing that differs is > > >that I > > > use a mem_raw_outstream to emit code to memory and make sure that all > >sections > > > are created before or during the post layout binding so that when > > > RecordRelocation is called all symbol addresses are known. In the > > > ELFObjectWriter, the code in WriteObject that creates sections is moved >to > > >the > > > post layout binding, and the code that emits the object stays in place. >This > > >is > > > perhaps not very clean, since it is not formalized in the interface, but >it > > > works okay and I only need to shuffle around the code a little. You >could > > > imagine that if section creation was restricted by the interface to only > > > happenen before/during post layout, then a generic JunkJIT could be >written > > >for > > > any object format. Each object writer would be required to compute >offsets > > >for > > > the sections. I am currently not aiming to do this since the MCJIT >proposal > > >by > > > Daniel separates the Streamer/ObjectWriter from figuring out relocations > and > > > external symbols. However, the code refactoring patches I have/will >submit > > >are > > > fairly benign and enable a JIT (without lazy compilation) using the MC > > > framework. > > > > Cool. The rafactoring patch is OK. > > > > > - Jan > > > > > > > Cheers, > > Rafael > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From renato.golin at arm.com Mon Feb 28 16:04:27 2011 From: renato.golin at arm.com (Renato Golin) Date: Mon, 28 Feb 2011 22:04:27 -0000 Subject: [llvm-commits] [llvm] r126689 - /llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Message-ID: <20110228220428.04FE02A6C12C@llvm.org> Author: rengolin Date: Mon Feb 28 16:04:27 2011 New Revision: 126689 URL: http://llvm.org/viewvc/llvm-project?rev=126689&view=rev Log: Fix .fpu printing in ARM assembly, regarding bug http://llvm.org/bugs/show_bug.cgi?id=8931 Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=126689&r1=126688&r2=126689&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Mon Feb 28 16:04:27 2011 @@ -88,6 +88,11 @@ case ARMBuildAttrs::CPU_name: Streamer.EmitRawText(StringRef("\t.cpu ") + LowercaseString(String)); break; + /* GAS requires .fpu to be emitted regardless of EABI attribute */ + case ARMBuildAttrs::Advanced_SIMD_arch: + case ARMBuildAttrs::VFP_arch: + Streamer.EmitRawText(StringRef("\t.fpu ") + LowercaseString(String)); + break; default: assert(0 && "Unsupported Text attribute in ASM Mode"); break; } } @@ -453,10 +458,13 @@ emitARMAttributeSection(); + /* GAS expect .fpu to be emitted, regardless of VFP build attribute */ + bool emitFPU = false; AttributeEmitter *AttrEmitter; - if (OutStreamer.hasRawTextSupport()) + if (OutStreamer.hasRawTextSupport()) { AttrEmitter = new AsmAttributeEmitter(OutStreamer); - else { + emitFPU = true; + } else { MCObjectStreamer &O = static_cast(OutStreamer); AttrEmitter = new ObjectAttributeEmitter(O); } @@ -490,10 +498,36 @@ ARMBuildAttrs::Allowed); } - // FIXME: Emit FPU type - if (Subtarget->hasVFP2()) + if (Subtarget->hasNEON()) { + /* NEON is not exactly a VFP architecture, but GAS emit one of + * neon/vfpv3/vfpv2 for .fpu parameters */ + AttrEmitter->EmitTextAttribute(ARMBuildAttrs::Advanced_SIMD_arch, "neon"); + /* If emitted for NEON, omit from VFP below, since you can have both + * NEON and VFP in build attributes but only one .fpu */ + emitFPU = false; + } + + /* VFPv3 + .fpu */ + if (Subtarget->hasVFP3()) { + AttrEmitter->EmitAttribute(ARMBuildAttrs::VFP_arch, + ARMBuildAttrs::AllowFPv3A); + if (emitFPU) + AttrEmitter->EmitTextAttribute(ARMBuildAttrs::VFP_arch, "vfpv3"); + + /* VFPv2 + .fpu */ + } else if (Subtarget->hasVFP2()) { AttrEmitter->EmitAttribute(ARMBuildAttrs::VFP_arch, ARMBuildAttrs::AllowFPv2); + if (emitFPU) + AttrEmitter->EmitTextAttribute(ARMBuildAttrs::VFP_arch, "vfpv2"); + } + + /* TODO: ARMBuildAttrs::Allowed is not completely accurate, + * since NEON can have 1 (allowed) or 2 (fused MAC operations) */ + if (Subtarget->hasNEON()) { + AttrEmitter->EmitAttribute(ARMBuildAttrs::Advanced_SIMD_arch, + ARMBuildAttrs::Allowed); + } // Signal various FP modes. if (!UnsafeFPMath) { From clattner at apple.com Mon Feb 28 16:47:29 2011 From: clattner at apple.com (Chris Lattner) Date: Mon, 28 Feb 2011 14:47:29 -0800 Subject: [llvm-commits] [PATCH] Add "END_WITH_NULL" creator for ConstantStruct In-Reply-To: References: Message-ID: On Feb 28, 2011, at 11:02 AM, Talin wrote: > This is similar to the patch I offered earlier, but removes the iterator-pair methods which were objected to. Can someone please review? Thanks. Looks fine to me, please commit. -Chris From sabre at nondot.org Mon Feb 28 16:45:25 2011 From: sabre at nondot.org (Chris Lattner) Date: Mon, 28 Feb 2011 22:45:25 -0000 Subject: [llvm-commits] [llvm] r126694 - /llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt Message-ID: <20110228224525.6EE6A2A6C12C@llvm.org> Author: lattner Date: Mon Feb 28 16:45:25 2011 New Revision: 126694 URL: http://llvm.org/viewvc/llvm-project?rev=126694&view=rev Log: update cmake Modified: llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt Modified: llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt?rev=126694&r1=126693&r2=126694&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt (original) +++ llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt Mon Feb 28 16:45:25 2011 @@ -7,7 +7,6 @@ DCE.cpp DeadStoreElimination.cpp EarlyCSE.cpp - GEPSplitter.cpp GVN.cpp IndVarSimplify.cpp JumpThreading.cpp From aggarwa4 at illinois.edu Mon Feb 28 17:01:09 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Mon, 28 Feb 2011 23:01:09 -0000 Subject: [llvm-commits] [poolalloc] r126708 - /poolalloc/trunk/lib/DSA/DataStructureStats.cpp Message-ID: <20110228230109.6EE382A6C12C@llvm.org> Author: aggarwa4 Date: Mon Feb 28 17:01:09 2011 New Revision: 126708 URL: http://llvm.org/viewvc/llvm-project?rev=126708&view=rev Log: Use DSCall graph to count the callees. Also, accomated functions, that are aliases of other internal functions, as direct calls. Modified: poolalloc/trunk/lib/DSA/DataStructureStats.cpp Modified: poolalloc/trunk/lib/DSA/DataStructureStats.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructureStats.cpp?rev=126708&r1=126707&r2=126708&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DataStructureStats.cpp (original) +++ poolalloc/trunk/lib/DSA/DataStructureStats.cpp Mon Feb 28 17:01:09 2011 @@ -52,6 +52,7 @@ class DSGraphStats : public FunctionPass, public InstVisitor { void countCallees(const Function &F); + const TDDataStructures *DS; const DSGraph *TDGraph; DSNodeHandle getNodeHandleForValue(Value *V); @@ -96,12 +97,17 @@ if (CE->isCast()) return isIndirectCallee(CE->getOperand(0)); + if (GlobalAlias *GA = dyn_cast(V)) { + GA->dump(); + return isIndirectCallee(GA->getAliasee()); + } + return true; } void DSGraphStats::countCallees(const Function& F) { - //FIXME:Use callgraph + const DSCallGraph callgraph = DS->getCallGraph(); unsigned numIndirectCalls = 0, totalNumCallees = 0; for (DSGraph::fc_iterator I = TDGraph->fc_begin(), E = TDGraph->fc_end(); @@ -109,7 +115,7 @@ if (isIndirectCallee(I->getCallSite().getCalledValue())) { // This is an indirect function call std::vector Callees; - I->getCalleeNode()->addFullFunctionList(Callees); + callgraph.addFullFunctionList(I->getCallSite(), Callees); if (Callees.size() > 0) { totalNumCallees += Callees.size(); @@ -209,7 +215,8 @@ bool DSGraphStats::runOnFunction(Function& F) { - TDGraph = getAnalysis().getDSGraph(F); + DS = &getAnalysis(); + TDGraph = DS->getDSGraph(F); countCallees(F); visit(F); return true; From aggarwa4 at illinois.edu Mon Feb 28 17:21:48 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Mon, 28 Feb 2011 23:21:48 -0000 Subject: [llvm-commits] [poolalloc] r126710 - /poolalloc/trunk/lib/AssistDS/ArgSimplify.cpp Message-ID: <20110228232148.F2C8E2A6C12C@llvm.org> Author: aggarwa4 Date: Mon Feb 28 17:21:48 2011 New Revision: 126710 URL: http://llvm.org/viewvc/llvm-project?rev=126710&view=rev Log: Change file header. Modified: poolalloc/trunk/lib/AssistDS/ArgSimplify.cpp Modified: poolalloc/trunk/lib/AssistDS/ArgSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/ArgSimplify.cpp?rev=126710&r1=126709&r2=126710&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/ArgSimplify.cpp (original) +++ poolalloc/trunk/lib/AssistDS/ArgSimplify.cpp Mon Feb 28 17:21:48 2011 @@ -1,4 +1,4 @@ -//===-- FuncSpec.cpp - Clone Functions With Constant Function Ptr Args ----===// +//===-- ArgSimplify.cpp - Special case for conditional ptr args ----------===// // // The LLVM Compiler Infrastructure // From aggarwa4 at illinois.edu Mon Feb 28 17:25:32 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Mon, 28 Feb 2011 23:25:32 -0000 Subject: [llvm-commits] [poolalloc] r126712 - /poolalloc/trunk/lib/DSA/DataStructure.cpp Message-ID: <20110228232532.7D7322A6C12C@llvm.org> Author: aggarwa4 Date: Mon Feb 28 17:25:32 2011 New Revision: 126712 URL: http://llvm.org/viewvc/llvm-project?rev=126712&view=rev Log: Fix formatting. Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=126712&r1=126711&r2=126712&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DataStructure.cpp (original) +++ poolalloc/trunk/lib/DSA/DataStructure.cpp Mon Feb 28 17:25:32 2011 @@ -51,16 +51,16 @@ DSNode *DSNodeHandle::HandleForwarding() const { assert(N->isForwarding() && "Can only be invoked if forwarding!"); DEBUG( - { //assert not looping - DSNode* NH = N; - svset seen; - while(NH && NH->isForwarding()) { - assert(seen.find(NH) == seen.end() && "Loop detected"); - seen.insert(NH); - NH = NH->ForwardNH.N; - } - } - ); + { //assert not looping + DSNode* NH = N; + svset seen; + while(NH && NH->isForwarding()) { + assert(seen.find(NH) == seen.end() && "Loop detected"); + seen.insert(NH); + NH = NH->ForwardNH.N; + } + } + ); // Handle node forwarding here! DSNode *Next = N->ForwardNH.getNode(); // Cause recursive shrinkage Offset += N->ForwardNH.getOffset(); @@ -129,20 +129,20 @@ //===----------------------------------------------------------------------===// DSNode::DSNode(DSGraph *G) -: NumReferrers(0), Size(0), ParentGraph(G), NodeType(0) { - // Add the type entry if it is specified... - if (G) G->addNode(this); - ++NumNodeAllocated; -} + : NumReferrers(0), Size(0), ParentGraph(G), NodeType(0) { + // Add the type entry if it is specified... + if (G) G->addNode(this); + ++NumNodeAllocated; + } // DSNode copy constructor... do not copy over the referrers list! DSNode::DSNode(const DSNode &N, DSGraph *G, bool NullLinks) : NumReferrers(0), Size(N.Size), ParentGraph(G), TyMap(N.TyMap), - Globals(N.Globals), NodeType(N.NodeType) { - if (!NullLinks) Links = N.Links; - G->addNode(this); - ++NumNodeAllocated; -} + Globals(N.Globals), NodeType(N.NodeType) { + if (!NullLinks) Links = N.Links; + G->addNode(this); + ++NumNodeAllocated; + } DSNode::~DSNode() { dropAllReferences(); @@ -150,10 +150,10 @@ } void DSNode::assertOK() const { -// assert(((Ty && Ty->getTypeID() != Type::VoidTyID) || -// ((!Ty || Ty->getTypeID() == Type::VoidTyID) && (Size == 0 || -// (NodeType & DSNode::ArrayNode)))) && -// "Node not OK!"); + // assert(((Ty && Ty->getTypeID() != Type::VoidTyID) || + // ((!Ty || Ty->getTypeID() == Type::VoidTyID) && (Size == 0 || + // (NodeType & DSNode::ArrayNode)))) && + // "Node not OK!"); assert(ParentGraph && "Node has no parent?"); const DSScalarMap &SM = ParentGraph->getScalarMap(); @@ -233,7 +233,7 @@ void DSNode::foldNodeCompletely() { if (isNodeCompletelyFolded()) return; // If this node is already folded... -// assert(0 && "Folding is happening"); + // assert(0 && "Folding is happening"); ++NumFolds; @@ -303,7 +303,7 @@ List.push_back(F); } else { for (EquivalenceClasses::member_iterator MI = - EC.member_begin(ECI), E = EC.member_end(); MI != E; ++MI) + EC.member_begin(ECI), E = EC.member_end(); MI != E; ++MI) if (const Function *F = dyn_cast(*MI)) List.push_back(F); } @@ -324,7 +324,7 @@ /// void DSNode::markIntPtrFlags() { // check if the types merged have both int and pointer at the same offset, - + const TargetData &TD = getParentGraph()->getTargetData(); // check all offsets for that node. for(unsigned offset = 0; offset < getSize() ; offset++) { @@ -362,7 +362,7 @@ if(!pointerTy && !integerTy){ continue; } - + // If only either integer or pointer was found, we must see if it // overlaps with any other pointer or integer type at an offset that // comes later. @@ -542,13 +542,13 @@ NOffset = NH.getOffset(); assert(NOffset == 0 && NSize == 1); } - + // FIXME:Add comments. if(NH.getNode()->isArrayNode() && !CurNodeH.getNode()->isArrayNode()) { if(NH.getNode()->getSize() != 0 && CurNodeH.getNode()->getSize() != 0) { if((NH.getNode()->getSize() != CurNodeH.getNode()->getSize() && - (NH.getOffset() != 0 || CurNodeH.getOffset() != 0) - && NH.getNode()->getSize() < CurNodeH.getNode()->getSize())) { + (NH.getOffset() != 0 || CurNodeH.getOffset() != 0) + && NH.getNode()->getSize() < CurNodeH.getNode()->getSize())) { CurNodeH.getNode()->foldNodeCompletely(); NH.getNode()->foldNodeCompletely(); NSize = NH.getNode()->getSize(); @@ -559,8 +559,8 @@ if(!NH.getNode()->isArrayNode() && CurNodeH.getNode()->isArrayNode()) { if(NH.getNode()->getSize() != 0 && CurNodeH.getNode()->getSize() != 0) { if((NH.getNode()->getSize() != CurNodeH.getNode()->getSize() && - (NH.getOffset() != 0 || CurNodeH.getOffset() != 0) - && NH.getNode()->getSize() > CurNodeH.getNode()->getSize())) { + (NH.getOffset() != 0 || CurNodeH.getOffset() != 0) + && NH.getNode()->getSize() > CurNodeH.getNode()->getSize())) { CurNodeH.getNode()->foldNodeCompletely(); NH.getNode()->foldNodeCompletely(); NSize = NH.getNode()->getSize(); @@ -572,13 +572,13 @@ if (CurNodeH.getNode()->isArrayNode() && NH.getNode()->isArrayNode()) { if(NH.getNode()->getSize() != 0 && CurNodeH.getNode()->getSize() != 0 && (NH.getNode()->getSize() != CurNodeH.getNode()->getSize())){ - CurNodeH.getNode()->foldNodeCompletely(); - NH.getNode()->foldNodeCompletely(); - NSize = NH.getNode()->getSize(); - NOffset = NH.getOffset(); + CurNodeH.getNode()->foldNodeCompletely(); + NH.getNode()->foldNodeCompletely(); + NSize = NH.getNode()->getSize(); + NOffset = NH.getOffset(); } } - + DSNode *N = NH.getNode(); if (CurNodeH.getNode() == N || N == 0) return; @@ -609,7 +609,7 @@ // recursive merging, we must make sure to merge in all remaining // links at offset zero. unsigned MergeOffset = 0; - DSNode *CN = CurNodeH.getNode(); + DSNode *CN = CurNodeH.getNode(); if (CN->Size != 1) MergeOffset = (ii->first + NOffset) % CN->getSize(); CN->addEdgeTo(MergeOffset, ii->second); @@ -716,7 +716,7 @@ DSNode *NHN = NH.getNode(); return DSNodeHandle(NHN, NH.getOffset() + SrcNH.getOffset()); } - + // If SrcNH has globals and the destination graph has one of the same globals, // merge this node with the destination node, which is much more efficient. if (SN->globals_begin() != SN->globals_end()) { @@ -774,7 +774,7 @@ DSNodeHandle &DestGNH = NodeMap[SrcGNH.getNode()]; assert(DestGNH.getNode() == NH.getNode() &&"Global mapping inconsistent"); Dest->getNodeForValue(GV).mergeWith(DSNodeHandle(DestGNH.getNode(), - DestGNH.getOffset()+SrcGNH.getOffset())); + DestGNH.getOffset()+SrcGNH.getOffset())); } NH.getNode()->mergeGlobals(*SN); @@ -831,14 +831,14 @@ } #endif } - - + + // FIXME:Add comments. if(!DN->isArrayNode() && SN->isArrayNode()) { if(DN->getSize() != 0 && SN->getSize() != 0) { if((DN->getSize() != SN->getSize() && - (NH.getOffset() != 0 || SrcNH.getOffset() != 0) - && DN->getSize() > SN->getSize())) { + (NH.getOffset() != 0 || SrcNH.getOffset() != 0) + && DN->getSize() > SN->getSize())) { DN->foldNodeCompletely(); DN = NH.getNode(); } @@ -847,8 +847,8 @@ if(!SN->isArrayNode() && DN->isArrayNode()) { if(DN->getSize() != 0 && SN->getSize() != 0) { if((DN->getSize() != SN->getSize() && - (NH.getOffset() != 0 || SrcNH.getOffset() != 0) - && DN->getSize() < SN->getSize())) { + (NH.getOffset() != 0 || SrcNH.getOffset() != 0) + && DN->getSize() < SN->getSize())) { DN->foldNodeCompletely(); DN = NH.getNode(); } @@ -858,8 +858,8 @@ if (SN->isArrayNode() && DN->isArrayNode()) { if((SN->getSize() != DN->getSize()) && (SN->getSize() != 0) && DN->getSize() != 0) { - DN->foldNodeCompletely(); - DN = NH.getNode(); + DN->foldNodeCompletely(); + DN = NH.getNode(); } } if (!DN->isNodeCompletelyFolded() && DN->getSize() < SN->getSize()) @@ -889,13 +889,13 @@ // Update the scalar map for the graph we are merging the source node // into. for (DSNode::globals_iterator I = SN->globals_begin(), - E = SN->globals_end(); I != E; ++I) { + E = SN->globals_end(); I != E; ++I) { const GlobalValue *GV = *I; const DSNodeHandle &SrcGNH = Src->getNodeForValue(GV); DSNodeHandle &DestGNH = NodeMap[SrcGNH.getNode()]; assert(DestGNH.getNode()==NH.getNode() &&"Global mapping inconsistent"); Dest->getNodeForValue(GV).mergeWith(DSNodeHandle(DestGNH.getNode(), - DestGNH.getOffset()+SrcGNH.getOffset())); + DestGNH.getOffset()+SrcGNH.getOffset())); } NH.getNode()->mergeGlobals(*SN); } @@ -920,14 +920,14 @@ // If the source node contained any globals, make sure to create entries // in the scalar map for them! for (DSNode::globals_iterator I = SN->globals_begin(), - E = SN->globals_end(); I != E; ++I) { + E = SN->globals_end(); I != E; ++I) { const GlobalValue *GV = *I; const DSNodeHandle &SrcGNH = Src->getNodeForValue(GV); DSNodeHandle &DestGNH = NodeMap[SrcGNH.getNode()]; assert(DestGNH.getNode()==NH.getNode() &&"Global mapping inconsistent"); assert(SrcGNH.getNode() == SN && "Global mapping inconsistent"); Dest->getNodeForValue(GV).mergeWith(DSNodeHandle(DestGNH.getNode(), - DestGNH.getOffset()+SrcGNH.getOffset())); + DestGNH.getOffset()+SrcGNH.getOffset())); } } @@ -1038,7 +1038,7 @@ } else { CalleeFuncType = dyn_cast(CalleeType->getElementType()); assert(CalleeFuncType && - "Call through pointer to non-function?"); + "Call through pointer to non-function?"); } return CalleeFuncType; @@ -1233,15 +1233,15 @@ //Base DataStructures impl: //////////////////////////////////////////////////////////////////////////////// -static const Function *getFnForValue(const Value *V) { - if (const Instruction *I = dyn_cast(V)) - return I->getParent()->getParent(); - else if (const Argument *A = dyn_cast(V)) - return A->getParent(); - else if (const BasicBlock *BB = dyn_cast(V)) - return BB->getParent(); - return 0; -} + static const Function *getFnForValue(const Value *V) { + if (const Instruction *I = dyn_cast(V)) + return I->getParent()->getParent(); + else if (const Argument *A = dyn_cast(V)) + return A->getParent(); + else if (const BasicBlock *BB = dyn_cast(V)) + return BB->getParent(); + return 0; + } /// deleteValue/copyValue - Interfaces to update the DSGraphs in the program. /// These correspond to the interfaces defined in the AliasAnalysis class. @@ -1253,7 +1253,7 @@ getDSGraph(*F)->getScalarMap().eraseIfExists(V); return; } - + if (Function *F = dyn_cast(V)) { DSGraph *G = getDSGraph(*F); if (G->getReturnNodes().size() == 1) { @@ -1277,7 +1277,7 @@ return; } - + assert(!isa(V) && "Do not know how to delete GV's yet!"); assert(0 && "Unrecognized value!"); @@ -1291,7 +1291,7 @@ getDSGraph(*F)->getScalarMap().copyScalarIfExists(From, To); return; } - + if (Function *FromF = dyn_cast(From)) { Function *ToF = cast(To); assert(!DSInfo.count(ToF) && "New Function already exists!"); @@ -1324,12 +1324,12 @@ return; } - + if (const Function *F = getFnForValue(To)) { getDSGraph(*F)->getScalarMap().copyScalarIfExists(From, To); return; } - + errs() << *From; errs() << *To; assert(0 && "Do not know how to copy this yet!"); @@ -1355,11 +1355,11 @@ } G->setUseAuxCalls(); G->setGlobalsGraph(GlobalsGraph); - + // Note that this graph is the graph for ALL of the function in the SCC, not // just F. for (DSGraph::retnodes_iterator RI = G->retnodes_begin(), - E = G->retnodes_end(); RI != E; ++RI) + E = G->retnodes_end(); RI != E; ++RI) if (RI->first != F) DSInfo[RI->first] = G; } @@ -1395,7 +1395,7 @@ if (!ECGlobals.empty()) { DEBUG(errs() << "Eliminating " << ECGlobals.size() << " EC Globals!\n"); for (DSInfoTy::iterator I = DSInfo.begin(), - E = DSInfo.end(); I != E; ++I) + E = DSInfo.end(); I != E; ++I) eliminateUsesOfECGlobals(*I->second, ECGlobals); } } @@ -1409,7 +1409,7 @@ DSScalarMap &SM = GlobalsGraph->getScalarMap(); EquivalenceClasses &GlobalECs = SM.getGlobalECs(); for (DSGraph::node_iterator I = GlobalsGraph->node_begin(), - E = GlobalsGraph->node_end(); + E = GlobalsGraph->node_end(); I != E; ++I) { if (I->numGlobals() <= 1) continue; @@ -1512,7 +1512,7 @@ // Clone everything reachable from globals in the function graph into the // globals graph. for (DSScalarMap::global_iterator I = MainSM.global_begin(), - E = MainSM.global_end(); I != E; ++I) + E = MainSM.global_end(); I != E; ++I) RC.getClonedNH(MainSM[*I]); } @@ -1530,7 +1530,7 @@ GlobalECs = D->getGlobalECs(); GlobalsGraph = new DSGraph(D->getGlobalsGraph(), GlobalECs, *TypeSS, copyGlobalAuxCalls? DSGraph::CloneAuxCallNodes - :DSGraph::DontCloneAuxCallNodes); + :DSGraph::DontCloneAuxCallNodes); if (useAuxCalls) GlobalsGraph->setUseAuxCalls(); // @@ -1573,8 +1573,7 @@ // Empty map so next time memory is released, data structures are not // re-deleted. DSInfo.clear(); - //FIXME: -// callgraph.clear(); + delete GlobalsGraph; GlobalsGraph = 0; } From viridia at gmail.com Mon Feb 28 17:53:27 2011 From: viridia at gmail.com (Talin) Date: Mon, 28 Feb 2011 23:53:27 -0000 Subject: [llvm-commits] [llvm] r126714 - in /llvm/trunk: include/llvm/Constants.h lib/VMCore/Constants.cpp Message-ID: <20110228235327.6DF072A6C12C@llvm.org> Author: talin Date: Mon Feb 28 17:53:27 2011 New Revision: 126714 URL: http://llvm.org/viewvc/llvm-project?rev=126714&view=rev Log: Add an END_WITH_NULL accessor for ConstantStruct. Modified: llvm/trunk/include/llvm/Constants.h llvm/trunk/lib/VMCore/Constants.cpp Modified: llvm/trunk/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=126714&r1=126713&r2=126714&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constants.h (original) +++ llvm/trunk/include/llvm/Constants.h Mon Feb 28 17:53:27 2011 @@ -425,6 +425,8 @@ const std::vector &V, bool Packed); static Constant *get(LLVMContext &Context, Constant *const *Vals, unsigned NumVals, bool Packed); + static Constant *get(LLVMContext &Context, bool Packed, + Constant * Val, ...) END_WITH_NULL; /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=126714&r1=126713&r2=126714&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Mon Feb 28 17:53:27 2011 @@ -33,6 +33,7 @@ #include "llvm/ADT/SmallVector.h" #include #include +#include using namespace llvm; //===----------------------------------------------------------------------===// @@ -596,8 +597,6 @@ return get(ATy, ElementVals); } - - ConstantStruct::ConstantStruct(const StructType *T, const std::vector &V) : Constant(T, ConstantStructVal, @@ -644,6 +643,18 @@ return get(Context, std::vector(Vals, Vals+NumVals), Packed); } +Constant* ConstantStruct::get(LLVMContext &Context, bool Packed, + Constant * Val, ...) { + va_list ap; + std::vector Values; + va_start(ap, Val); + while (Val) { + Values.push_back(Val); + Val = va_arg(ap, llvm::Constant*); + } + return get(Context, Values, Packed); +} + ConstantVector::ConstantVector(const VectorType *T, const std::vector &V) : Constant(T, ConstantVectorVal, From kremenek at apple.com Mon Feb 28 17:56:33 2011 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 28 Feb 2011 23:56:33 -0000 Subject: [llvm-commits] [llvm] r126715 - /llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt Message-ID: <20110228235633.45BC72A6C12C@llvm.org> Author: kremenek Date: Mon Feb 28 17:56:33 2011 New Revision: 126715 URL: http://llvm.org/viewvc/llvm-project?rev=126715&view=rev Log: Unbreak CMake build. Modified: llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt Modified: llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt?rev=126715&r1=126714&r2=126715&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt (original) +++ llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt Mon Feb 28 17:56:33 2011 @@ -26,7 +26,6 @@ Scalar.cpp ScalarReplAggregates.cpp SimplifyCFGPass.cpp - SimplifyHalfPowrLibCalls.cpp SimplifyLibCalls.cpp Sink.cpp TailDuplication.cpp From kremenek at apple.com Mon Feb 28 18:02:51 2011 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 01 Mar 2011 00:02:51 -0000 Subject: [llvm-commits] [llvm] r126717 - /llvm/trunk/lib/Analysis/CMakeLists.txt Message-ID: <20110301000251.873362A6C12C@llvm.org> Author: kremenek Date: Mon Feb 28 18:02:51 2011 New Revision: 126717 URL: http://llvm.org/viewvc/llvm-project?rev=126717&view=rev Log: Unbreak CMake build. Modified: llvm/trunk/lib/Analysis/CMakeLists.txt Modified: llvm/trunk/lib/Analysis/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CMakeLists.txt?rev=126717&r1=126716&r2=126717&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/CMakeLists.txt (original) +++ llvm/trunk/lib/Analysis/CMakeLists.txt Mon Feb 28 18:02:51 2011 @@ -9,11 +9,11 @@ CFGPrinter.cpp CaptureTracking.cpp ConstantFolding.cpp + DIBuilder.cpp DbgInfoPrinter.cpp DebugInfo.cpp - DIBuilder.cpp - DominanceFrontier.cpp DomPrinter.cpp + DominanceFrontier.cpp IVUsers.cpp InlineCost.cpp InstCount.cpp @@ -24,7 +24,6 @@ LibCallAliasAnalysis.cpp LibCallSemantics.cpp Lint.cpp - LiveValues.cpp Loads.cpp LoopDependenceAnalysis.cpp LoopInfo.cpp @@ -33,11 +32,11 @@ MemoryBuiltins.cpp MemoryDependenceAnalysis.cpp ModuleDebugInfoPrinter.cpp + NoAliasAnalysis.cpp + PHITransAddr.cpp PathNumbering.cpp PathProfileInfo.cpp PathProfileVerifier.cpp - NoAliasAnalysis.cpp - PHITransAddr.cpp PostDominators.cpp ProfileEstimatorPass.cpp ProfileInfo.cpp From sabre at nondot.org Mon Feb 28 18:24:51 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 01 Mar 2011 00:24:51 -0000 Subject: [llvm-commits] [llvm] r126719 - /llvm/trunk/lib/Target/README.txt Message-ID: <20110301002452.06EA52A6C12C@llvm.org> Author: lattner Date: Mon Feb 28 18:24:51 2011 New Revision: 126719 URL: http://llvm.org/viewvc/llvm-project?rev=126719&view=rev Log: add a note Modified: llvm/trunk/lib/Target/README.txt Modified: llvm/trunk/lib/Target/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=126719&r1=126718&r2=126719&view=diff ============================================================================== --- llvm/trunk/lib/Target/README.txt (original) +++ llvm/trunk/lib/Target/README.txt Mon Feb 28 18:24:51 2011 @@ -1325,6 +1325,21 @@ //===---------------------------------------------------------------------===// +simplifylibcalls should turn these snprintf idioms into memcpy (GCC PR47917) + +char buf1[6], buf2[6], buf3[4], buf4[4]; +int i; + +int foo (void) { + int ret = snprintf (buf1, sizeof buf1, "abcde"); + ret += snprintf (buf2, sizeof buf2, "abcdef") * 16; + ret += snprintf (buf3, sizeof buf3, "%s", i++ < 6 ? "abc" : "def") * 256; + ret += snprintf (buf4, sizeof buf4, "%s", i++ > 10 ? "abcde" : "defgh")*4096; + return ret; +} + +//===---------------------------------------------------------------------===// + "gas" uses this idiom: else if (strchr ("+-/*%|&^:[]()~", *intel_parser.op_string)) .. From eli.friedman at gmail.com Mon Feb 28 18:33:47 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 01 Mar 2011 00:33:47 -0000 Subject: [llvm-commits] [llvm] r126720 - in /llvm/trunk: lib/Transforms/IPO/DeadArgumentElimination.cpp test/Transforms/DeadArgElim/deadexternal.ll Message-ID: <20110301003347.961F02A6C12C@llvm.org> Author: efriedma Date: Mon Feb 28 18:33:47 2011 New Revision: 126720 URL: http://llvm.org/viewvc/llvm-project?rev=126720&view=rev Log: Add an obvious missing safety check to DAE::RemoveDeadArgumentsFromCallers. Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp llvm/trunk/test/Transforms/DeadArgElim/deadexternal.ll Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=126720&r1=126719&r2=126720&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Mon Feb 28 18:33:47 2011 @@ -294,7 +294,7 @@ /// instead. bool DAE::RemoveDeadArgumentsFromCallers(Function &Fn) { - if (Fn.isDeclaration()) + if (Fn.isDeclaration() || Fn.mayBeOverridden()) return false; // Functions with local linkage should already have been handled. Modified: llvm/trunk/test/Transforms/DeadArgElim/deadexternal.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadArgElim/deadexternal.ll?rev=126720&r1=126719&r2=126720&view=diff ============================================================================== --- llvm/trunk/test/Transforms/DeadArgElim/deadexternal.ll (original) +++ llvm/trunk/test/Transforms/DeadArgElim/deadexternal.ll Mon Feb 28 18:33:47 2011 @@ -37,3 +37,16 @@ call void @f(i32 %tmp) ret void } + +; Check that callers are not transformed for weak definitions. +define weak i32 @weak_f(i32 %x) nounwind { +entry: + ret i32 0 +} +define void @weak_f_caller() nounwind { +entry: +; CHECK: call i32 @weak_f(i32 10) + %call = tail call i32 @weak_f(i32 10) + ret void +} + From isanbard at gmail.com Mon Feb 28 19:01:00 2011 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 01 Mar 2011 01:01:00 -0000 Subject: [llvm-commits] [llvm] r126723 - in /llvm/trunk: lib/Target/ARM/ARMCodeEmitter.cpp lib/Target/ARM/ARMInstrFormats.td lib/Target/ARM/ARMInstrNEON.td lib/Target/ARM/ARMMCCodeEmitter.cpp test/CodeGen/ARM/neon_shift.ll test/MC/ARM/neon-shift-encoding.s utils/TableGen/EDEmitter.cpp Message-ID: <20110301010100.304892A6C12C@llvm.org> Author: void Date: Mon Feb 28 19:00:59 2011 New Revision: 126723 URL: http://llvm.org/viewvc/llvm-project?rev=126723&view=rev Log: Narrow right shifts need to encode their immediates differently from a normal shift. 16-bit: imm6<5:3> = '001', 8 - is encded in imm6<2:0> 32-bit: imm6<5:4> = '01',16 - is encded in imm6<3:0> 64-bit: imm6<5> = '1', 32 - is encded in imm6<4:0> Added: llvm/trunk/test/CodeGen/ARM/neon_shift.ll Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/ARMInstrNEON.td llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp llvm/trunk/test/MC/ARM/neon-shift-encoding.s llvm/trunk/utils/TableGen/EDEmitter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=126723&r1=126722&r2=126723&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Mon Feb 28 19:00:59 2011 @@ -312,6 +312,13 @@ unsigned getRegisterListOpValue(const MachineInstr &MI, unsigned Op) const { return 0; } + unsigned getNarrowShiftRight16Imm(const MachineInstr &MI, unsigned Op) + const { return 0; } + unsigned getNarrowShiftRight32Imm(const MachineInstr &MI, unsigned Op) + const { return 0; } + unsigned getNarrowShiftRight64Imm(const MachineInstr &MI, unsigned Op) + const { return 0; } + /// getMovi32Value - Return binary encoding of operand for movw/movt. If the /// machine operand requires relocation, record the relocation and return /// zero. Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=126723&r1=126722&r2=126723&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Mon Feb 28 19:00:59 2011 @@ -221,6 +221,22 @@ let PrintMethod = "printNegZeroOperand"; } +// Narrow Shift Right Immediate - A narrow shift right immediate is encoded +// differently from other shift immediates. The imm6 field is encoded like so: +// +// 16-bit: imm6<5:3> = '001', 8 - is encded in imm6<2:0> +// 32-bit: imm6<5:4> = '01',16 - is encded in imm6<3:0> +// 64-bit: imm6<5> = '1', 32 - is encded in imm6<4:0> +def nsr16_imm : Operand { + let EncoderMethod = "getNarrowShiftRight16Imm"; +} +def nsr32_imm : Operand { + let EncoderMethod = "getNarrowShiftRight32Imm"; +} +def nsr64_imm : Operand { + let EncoderMethod = "getNarrowShiftRight64Imm"; +} + //===----------------------------------------------------------------------===// // ARM Instruction templates. // Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=126723&r1=126722&r2=126723&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Mon Feb 28 19:00:59 2011 @@ -2315,9 +2315,9 @@ // Narrow shift by immediate. class N2VNSh op11_8, bit op7, bit op6, bit op4, InstrItinClass itin, string OpcodeStr, string Dt, - ValueType ResTy, ValueType OpTy, SDNode OpNode> + ValueType ResTy, ValueType OpTy, Operand ImmTy, SDNode OpNode> : N2VImm; @@ -3153,15 +3153,18 @@ bit op4, InstrItinClass itin, string OpcodeStr, string Dt, SDNode OpNode> { def v8i8 : N2VNSh { + OpcodeStr, !strconcat(Dt, "16"), + v8i8, v8i16, nsr16_imm, OpNode> { let Inst{21-19} = 0b001; // imm6 = 001xxx } def v4i16 : N2VNSh { + OpcodeStr, !strconcat(Dt, "32"), + v4i16, v4i32, nsr32_imm, OpNode> { let Inst{21-20} = 0b01; // imm6 = 01xxxx } def v2i32 : N2VNSh { + OpcodeStr, !strconcat(Dt, "64"), + v2i32, v2i64, nsr64_imm, OpNode> { let Inst{21} = 0b1; // imm6 = 1xxxxx } } Modified: llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp?rev=126723&r1=126722&r2=126723&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp Mon Feb 28 19:00:59 2011 @@ -278,6 +278,13 @@ unsigned getAddrMode6OffsetOpValue(const MCInst &MI, unsigned Op, SmallVectorImpl &Fixups) const; + unsigned getNarrowShiftRight16Imm(const MCInst &MI, unsigned Op, + SmallVectorImpl &Fixups) const; + unsigned getNarrowShiftRight32Imm(const MCInst &MI, unsigned Op, + SmallVectorImpl &Fixups) const; + unsigned getNarrowShiftRight64Imm(const MCInst &MI, unsigned Op, + SmallVectorImpl &Fixups) const; + unsigned NEONThumb2DataIPostEncoder(const MCInst &MI, unsigned EncodedValue) const; unsigned NEONThumb2LoadStorePostEncoder(const MCInst &MI, @@ -1201,6 +1208,24 @@ return MO.getReg(); } +unsigned ARMMCCodeEmitter:: +getNarrowShiftRight16Imm(const MCInst &MI, unsigned Op, + SmallVectorImpl &Fixups) const { + return 8 - MI.getOperand(Op).getImm(); +} + +unsigned ARMMCCodeEmitter:: +getNarrowShiftRight32Imm(const MCInst &MI, unsigned Op, + SmallVectorImpl &Fixups) const { + return 16 - MI.getOperand(Op).getImm(); +} + +unsigned ARMMCCodeEmitter:: +getNarrowShiftRight64Imm(const MCInst &MI, unsigned Op, + SmallVectorImpl &Fixups) const { + return 32 - MI.getOperand(Op).getImm(); +} + void ARMMCCodeEmitter:: EncodeInstruction(const MCInst &MI, raw_ostream &OS, SmallVectorImpl &Fixups) const { Added: llvm/trunk/test/CodeGen/ARM/neon_shift.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/neon_shift.ll?rev=126723&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/neon_shift.ll (added) +++ llvm/trunk/test/CodeGen/ARM/neon_shift.ll Mon Feb 28 19:00:59 2011 @@ -0,0 +1,11 @@ +; RUN: llc < %s -march=arm -mattr=+neon | FileCheck %s + +; +define <4 x i16> @t1(<4 x i32> %a) nounwind { +entry: +; CHECK: vqrshrn.s32 d{{[0-9]+}}, q{{[0-9]*}}, #13 + %x = tail call <4 x i16> @llvm.arm.neon.vqrshiftns.v4i16(<4 x i32> %a, <4 x i32> ) + ret <4 x i16> %x +} + +declare <4 x i16> @llvm.arm.neon.vqrshiftns.v4i16(<4 x i32>, <4 x i32>) nounwind readnone Modified: llvm/trunk/test/MC/ARM/neon-shift-encoding.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/neon-shift-encoding.s?rev=126723&r1=126722&r2=126723&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/neon-shift-encoding.s (original) +++ llvm/trunk/test/MC/ARM/neon-shift-encoding.s Mon Feb 28 19:00:59 2011 @@ -158,3 +158,5 @@ vrshrn.i32 d16, q8, #16 @ CHECK: vrshrn.i64 d16, q8, #32 @ encoding: [0x70,0x08,0xe0,0xf2] vrshrn.i64 d16, q8, #32 +@ CHECK: vqrshrn.s32 d16, q8, #13 @ encoding: [0x70,0x09,0xd3,0xf2] + vqrshrn.s32 d16, q8, #13 Modified: llvm/trunk/utils/TableGen/EDEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/EDEmitter.cpp?rev=126723&r1=126722&r2=126723&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/EDEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/EDEmitter.cpp Mon Feb 28 19:00:59 2011 @@ -598,6 +598,9 @@ IMM("t2adrlabel"); IMM("shift_imm"); IMM("neon_vcvt_imm32"); + IMM("nsr16_imm"); + IMM("nsr32_imm"); + IMM("nsr64_imm"); MISC("brtarget", "kOperandTypeARMBranchTarget"); // ? MISC("uncondbrtarget", "kOperandTypeARMBranchTarget"); // ? From grosbach at apple.com Mon Feb 28 19:37:19 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 01 Mar 2011 01:37:19 -0000 Subject: [llvm-commits] [llvm] r126731 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGISel.h lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp utils/TableGen/DAGISelEmitter.cpp utils/TableGen/DAGISelMatcher.h utils/TableGen/DAGISelMatcherEmitter.cpp Message-ID: <20110301013720.113E02A6C12C@llvm.org> Author: grosbach Date: Mon Feb 28 19:37:19 2011 New Revision: 126731 URL: http://llvm.org/viewvc/llvm-project?rev=126731&view=rev Log: Generalize the register matching code in DAGISel a bit. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/trunk/utils/TableGen/DAGISelEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcher.h llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h?rev=126731&r1=126730&r2=126731&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h Mon Feb 28 19:37:19 2011 @@ -127,6 +127,7 @@ OPC_EmitInteger, OPC_EmitRegister, + OPC_EmitRegister2, OPC_EmitConvertToTarget, OPC_EmitMergeInputChains, OPC_EmitMergeInputChains1_0, Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=126731&r1=126730&r2=126731&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Feb 28 19:37:19 2011 @@ -2392,6 +2392,18 @@ CurDAG->getRegister(RegNo, VT), (SDNode*)0)); continue; } + case OPC_EmitRegister2: { + // For targets w/ more than 256 register names, the register enum + // values are stored in two bytes in the matcher table (just like + // opcodes). + MVT::SimpleValueType VT = + (MVT::SimpleValueType)MatcherTable[MatcherIndex++]; + unsigned RegNo = MatcherTable[MatcherIndex++]; + RegNo |= MatcherTable[MatcherIndex++] << 8; + RecordedNodes.push_back(std::pair( + CurDAG->getRegister(RegNo, VT), (SDNode*)0)); + continue; + } case OPC_EmitConvertToTarget: { // Convert from IMM/FPIMM to target version. Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=126731&r1=126730&r2=126731&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Mon Feb 28 19:37:19 2011 @@ -148,8 +148,12 @@ Matcher *TheMatcher = new ScopeMatcher(&PatternMatchers[0], PatternMatchers.size()); + CodeGenTarget Target(Records); + const std::vector &Registers = Target.getRegisters(); + bool useEmitRegister2 = Registers.size() > 255; + TheMatcher = OptimizeMatcher(TheMatcher, CGP); //Matcher->dump(); - EmitMatcherTable(TheMatcher, CGP, OS); + EmitMatcherTable(TheMatcher, CGP, useEmitRegister2, OS); delete TheMatcher; } Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=126731&r1=126730&r2=126731&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Mon Feb 28 19:37:19 2011 @@ -29,7 +29,7 @@ const CodeGenDAGPatterns &CGP); Matcher *OptimizeMatcher(Matcher *Matcher, const CodeGenDAGPatterns &CGP); void EmitMatcherTable(const Matcher *Matcher, const CodeGenDAGPatterns &CGP, - raw_ostream &OS); + bool useEmitRegister2, raw_ostream &OS); /// Matcher - Base class for all the the DAG ISel Matcher representation Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=126731&r1=126730&r2=126731&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Mon Feb 28 19:37:19 2011 @@ -43,8 +43,11 @@ DenseMap NodeXFormMap; std::vector NodeXForms; + bool useEmitRegister2; + public: - MatcherTableEmitter(const CodeGenDAGPatterns &cgp) : CGP(cgp) {} + MatcherTableEmitter(const CodeGenDAGPatterns &cgp, bool _useEmitRegister2) + : CGP(cgp), useEmitRegister2(_useEmitRegister2) {} unsigned EmitMatcherList(const Matcher *N, unsigned Indent, unsigned StartIdx, formatted_raw_ostream &OS); @@ -255,7 +258,7 @@ } case Matcher::CheckOpcode: - OS << "OPC_CheckOpcode, TARGET_OPCODE(" + OS << "OPC_CheckOpcode, TARGET_VAL(" << cast(N)->getOpcode().getEnumName() << "),\n"; return 3; @@ -321,7 +324,7 @@ OS << ' '; if (const SwitchOpcodeMatcher *SOM = dyn_cast(N)) - OS << "TARGET_OPCODE(" << SOM->getCaseOpcode(i).getEnumName() << "),"; + OS << "TARGET_VAL(" << SOM->getCaseOpcode(i).getEnumName() << "),"; else OS << getEnumName(cast(N)->getCaseType(i)) << ','; @@ -429,17 +432,31 @@ } case Matcher::EmitRegister: - OS << "OPC_EmitRegister, " - << getEnumName(cast(N)->getVT()) << ", "; - if (Record *R = cast(N)->getReg()) - OS << getQualifiedName(R) << ",\n"; - else { - OS << "0 "; - if (!OmitComments) - OS << "/*zero_reg*/"; - OS << ",\n"; + if (useEmitRegister2) { + OS << "OPC_EmitRegister2, " + << getEnumName(cast(N)->getVT()) << ", "; + if (Record *R = cast(N)->getReg()) + OS << "TARGET_VAL(" << getQualifiedName(R) << "),\n"; + else { + OS << "TARGET_VAL(0) "; + if (!OmitComments) + OS << "/*zero_reg*/"; + OS << ",\n"; + } + return 4; + } else { + OS << "OPC_EmitRegister, " + << getEnumName(cast(N)->getVT()) << ", "; + if (Record *R = cast(N)->getReg()) + OS << getQualifiedName(R) << ",\n"; + else { + OS << "0 "; + if (!OmitComments) + OS << "/*zero_reg*/"; + OS << ",\n"; + } + return 3; } - return 3; case Matcher::EmitConvertToTarget: OS << "OPC_EmitConvertToTarget, " @@ -482,7 +499,7 @@ case Matcher::MorphNodeTo: { const EmitNodeMatcherCommon *EN = cast(N); OS << (isa(EN) ? "OPC_EmitNode" : "OPC_MorphNodeTo"); - OS << ", TARGET_OPCODE(" << EN->getOpcodeName() << "), 0"; + OS << ", TARGET_VAL(" << EN->getOpcodeName() << "), 0"; if (EN->hasChain()) OS << "|OPFL_Chain"; if (EN->hasInFlag()) OS << "|OPFL_GlueInput"; @@ -782,23 +799,26 @@ void llvm::EmitMatcherTable(const Matcher *TheMatcher, - const CodeGenDAGPatterns &CGP, raw_ostream &O) { + const CodeGenDAGPatterns &CGP, + bool useEmitRegister2, + raw_ostream &O) { formatted_raw_ostream OS(O); OS << "// The main instruction selector code.\n"; OS << "SDNode *SelectCode(SDNode *N) {\n"; - MatcherTableEmitter MatcherEmitter(CGP); + MatcherTableEmitter MatcherEmitter(CGP, useEmitRegister2); - OS << " // Opcodes are emitted as 2 bytes, TARGET_OPCODE handles this.\n"; - OS << " #define TARGET_OPCODE(X) X & 255, unsigned(X) >> 8\n"; + OS << " // Some target values are emitted as 2 bytes, TARGET_VAL handles\n"; + OS << " // this.\n"; + OS << " #define TARGET_VAL(X) X & 255, unsigned(X) >> 8\n"; OS << " static const unsigned char MatcherTable[] = {\n"; unsigned TotalSize = MatcherEmitter.EmitMatcherList(TheMatcher, 5, 0, OS); OS << " 0\n }; // Total Array size is " << (TotalSize+1) << " bytes\n\n"; MatcherEmitter.EmitHistogram(TheMatcher, OS); - OS << " #undef TARGET_OPCODE\n"; + OS << " #undef TARGET_VAL\n"; OS << " return SelectCodeCommon(N, MatcherTable,sizeof(MatcherTable));\n}\n"; OS << '\n'; From grosbach at apple.com Mon Feb 28 19:39:05 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 01 Mar 2011 01:39:05 -0000 Subject: [llvm-commits] [llvm] r126733 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp utils/TableGen/DAGISelEmitter.cpp utils/TableGen/DAGISelMatcherEmitter.cpp Message-ID: <20110301013905.449472A6C12D@llvm.org> Author: grosbach Date: Mon Feb 28 19:39:05 2011 New Revision: 126733 URL: http://llvm.org/viewvc/llvm-project?rev=126733&view=rev Log: trailing whitespace. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/trunk/utils/TableGen/DAGISelEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=126733&r1=126732&r2=126733&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Feb 28 19:39:05 2011 @@ -764,7 +764,7 @@ "The only use of the vreg must be a use, we haven't emitted the def!"); MachineInstr *User = &*RI; - + // Set the insertion point properly. Folding the load can cause generation of // other random instructions (like sign extends) for addressing modes, make // sure they get inserted in a logical place before the new instruction. Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=126733&r1=126732&r2=126733&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Mon Feb 28 19:39:05 2011 @@ -27,7 +27,7 @@ static unsigned getResultPatternCost(TreePatternNode *P, CodeGenDAGPatterns &CGP) { if (P->isLeaf()) return 0; - + unsigned Cost = 0; Record *Op = P->getOperator(); if (Op->isSubClassOf("Instruction")) { @@ -43,7 +43,7 @@ /// getResultPatternCodeSize - Compute the code size of instructions for this /// pattern. -static unsigned getResultPatternSize(TreePatternNode *P, +static unsigned getResultPatternSize(TreePatternNode *P, CodeGenDAGPatterns &CGP) { if (P->isLeaf()) return 0; @@ -64,21 +64,21 @@ struct PatternSortingPredicate { PatternSortingPredicate(CodeGenDAGPatterns &cgp) : CGP(cgp) {} CodeGenDAGPatterns &CGP; - + bool operator()(const PatternToMatch *LHS, const PatternToMatch *RHS) { const TreePatternNode *LHSSrc = LHS->getSrcPattern(); const TreePatternNode *RHSSrc = RHS->getSrcPattern(); - + if (LHSSrc->getNumTypes() != 0 && RHSSrc->getNumTypes() != 0 && LHSSrc->getType(0) != RHSSrc->getType(0)) { MVT::SimpleValueType V1 = LHSSrc->getType(0), V2 = RHSSrc->getType(0); if (MVT(V1).isVector() != MVT(V2).isVector()) return MVT(V2).isVector(); - + if (MVT(V1).isFloatingPoint() != MVT(V2).isFloatingPoint()) return MVT(V2).isFloatingPoint(); } - + // Otherwise, if the patterns might both match, sort based on complexity, // which means that we prefer to match patterns that cover more nodes in the // input over nodes that cover fewer. @@ -86,18 +86,18 @@ unsigned RHSSize = RHS->getPatternComplexity(CGP); if (LHSSize > RHSSize) return true; // LHS -> bigger -> less cost if (LHSSize < RHSSize) return false; - + // If the patterns have equal complexity, compare generated instruction cost unsigned LHSCost = getResultPatternCost(LHS->getDstPattern(), CGP); unsigned RHSCost = getResultPatternCost(RHS->getDstPattern(), CGP); if (LHSCost < RHSCost) return true; if (LHSCost > RHSCost) return false; - + unsigned LHSPatSize = getResultPatternSize(LHS->getDstPattern(), CGP); unsigned RHSPatSize = getResultPatternSize(RHS->getDstPattern(), CGP); if (LHSPatSize < RHSPatSize) return true; if (LHSPatSize > RHSPatSize) return false; - + // Sort based on the UID of the pattern, giving us a deterministic ordering // if all other sorting conditions fail. assert(LHS == RHS || LHS->ID != RHS->ID); @@ -110,7 +110,7 @@ void DAGISelEmitter::run(raw_ostream &OS) { EmitSourceFileHeader("DAG Instruction Selector for the " + CGP.getTargetInfo().getName() + " target", OS); - + OS << "// *** NOTE: This file is #included into the middle of the target\n" << "// *** instruction selector class. These functions are really " << "methods.\n\n"; @@ -132,8 +132,8 @@ // We want to process the matches in order of minimal cost. Sort the patterns // so the least cost one is at the start. std::sort(Patterns.begin(), Patterns.end(), PatternSortingPredicate(CGP)); - - + + // Convert each variant of each pattern into a Matcher. std::vector PatternMatchers; for (unsigned i = 0, e = Patterns.size(); i != e; ++i) { @@ -144,7 +144,7 @@ break; } } - + Matcher *TheMatcher = new ScopeMatcher(&PatternMatchers[0], PatternMatchers.size()); Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=126733&r1=126732&r2=126733&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Mon Feb 28 19:39:05 2011 @@ -51,14 +51,14 @@ unsigned EmitMatcherList(const Matcher *N, unsigned Indent, unsigned StartIdx, formatted_raw_ostream &OS); - + void EmitPredicateFunctions(formatted_raw_ostream &OS); - + void EmitHistogram(const Matcher *N, formatted_raw_ostream &OS); private: unsigned EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx, formatted_raw_ostream &OS); - + unsigned getNodePredicate(StringRef PredName) { unsigned &Entry = NodePredicateMap[PredName]; if (Entry == 0) { @@ -75,7 +75,7 @@ } return Entry-1; } - + unsigned getComplexPat(const ComplexPattern &P) { unsigned &Entry = ComplexPatternMap[&P]; if (Entry == 0) { @@ -84,7 +84,7 @@ } return Entry-1; } - + unsigned getNodeXFormID(Record *Rec) { unsigned &Entry = NodeXFormMap[Rec]; if (Entry == 0) { @@ -93,13 +93,13 @@ } return Entry-1; } - + }; } // end anonymous namespace. static unsigned GetVBRSize(unsigned Val) { if (Val <= 127) return 1; - + unsigned NumBytes = 0; while (Val >= 128) { Val >>= 7; @@ -115,7 +115,7 @@ OS << Val << ", "; return 1; } - + uint64_t InVal = Val; unsigned NumBytes = 0; while (Val >= 128) { @@ -136,14 +136,14 @@ EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx, formatted_raw_ostream &OS) { OS.PadToColumn(Indent*2); - + switch (N->getKind()) { case Matcher::Scope: { const ScopeMatcher *SM = cast(N); assert(SM->getNext() == 0 && "Shouldn't have next after scope"); - + unsigned StartIdx = CurrentIdx; - + // Emit all of the children. for (unsigned i = 0, e = SM->getNumChildren(); i != e; ++i) { if (i == 0) { @@ -167,29 +167,29 @@ unsigned VBRSize = 0; do { VBRSize = GetVBRSize(ChildSize); - + TmpBuf.clear(); raw_svector_ostream OS(TmpBuf); formatted_raw_ostream FOS(OS); ChildSize = EmitMatcherList(SM->getChild(i), Indent+1, CurrentIdx+VBRSize, FOS); } while (GetVBRSize(ChildSize) != VBRSize); - + assert(ChildSize != 0 && "Should not have a zero-sized child!"); - + CurrentIdx += EmitVBRValue(ChildSize, OS); if (!OmitComments) { OS << "/*->" << CurrentIdx+ChildSize << "*/"; - + if (i == 0) OS.PadToColumn(CommentIndent) << "// " << SM->getNumChildren() << " children in Scope"; } - + OS << '\n' << TmpBuf.str(); CurrentIdx += ChildSize; } - + // Emit a zero as a sentinel indicating end of 'Scope'. if (!OmitComments) OS << "/*" << CurrentIdx << "*/"; @@ -199,7 +199,7 @@ OS << '\n'; return CurrentIdx - StartIdx + 1; } - + case Matcher::RecordNode: OS << "OPC_RecordNode,"; if (!OmitComments) @@ -218,23 +218,23 @@ << cast(N)->getWhatFor(); OS << '\n'; return 1; - + case Matcher::RecordMemRef: OS << "OPC_RecordMemRef,\n"; return 1; - + case Matcher::CaptureGlueInput: OS << "OPC_CaptureGlueInput,\n"; return 1; - + case Matcher::MoveChild: OS << "OPC_MoveChild, " << cast(N)->getChildNo() << ",\n"; return 2; - + case Matcher::MoveParent: OS << "OPC_MoveParent,\n"; return 1; - + case Matcher::CheckSame: OS << "OPC_CheckSame, " << cast(N)->getMatchNumber() << ",\n"; @@ -261,11 +261,11 @@ OS << "OPC_CheckOpcode, TARGET_VAL(" << cast(N)->getOpcode().getEnumName() << "),\n"; return 3; - + case Matcher::SwitchOpcode: case Matcher::SwitchType: { unsigned StartIdx = CurrentIdx; - + unsigned NumCases; if (const SwitchOpcodeMatcher *SOM = dyn_cast(N)) { OS << "OPC_SwitchOpcode "; @@ -279,7 +279,7 @@ OS << "/*" << NumCases << " cases */"; OS << ", "; ++CurrentIdx; - + // For each case we emit the size, then the opcode, then the matcher. for (unsigned i = 0, e = NumCases; i != e; ++i) { const Matcher *Child; @@ -291,7 +291,7 @@ Child = cast(N)->getCaseMatcher(i); IdxSize = 1; // size of type in table is 1 byte. } - + // We need to encode the opcode and the offset of the case code before // emitting the case code. Handle this by buffering the output into a // string while we get the size. Unfortunately, the offset of the @@ -302,26 +302,26 @@ unsigned VBRSize = 0; do { VBRSize = GetVBRSize(ChildSize); - + TmpBuf.clear(); raw_svector_ostream OS(TmpBuf); formatted_raw_ostream FOS(OS); ChildSize = EmitMatcherList(Child, Indent+1, CurrentIdx+VBRSize+IdxSize, FOS); } while (GetVBRSize(ChildSize) != VBRSize); - + assert(ChildSize != 0 && "Should not have a zero-sized child!"); - + if (i != 0) { OS.PadToColumn(Indent*2); if (!OmitComments) OS << (isa(N) ? "/*SwitchOpcode*/ " : "/*SwitchType*/ "); } - + // Emit the VBR. CurrentIdx += EmitVBRValue(ChildSize, OS); - + OS << ' '; if (const SwitchOpcodeMatcher *SOM = dyn_cast(N)) OS << "TARGET_VAL(" << SOM->getCaseOpcode(i).getEnumName() << "),"; @@ -354,13 +354,13 @@ OS << "OPC_CheckType, " << getEnumName(cast(N)->getType()) << ",\n"; return 2; - + case Matcher::CheckChildType: OS << "OPC_CheckChild" << cast(N)->getChildNo() << "Type, " << getEnumName(cast(N)->getType()) << ",\n"; return 2; - + case Matcher::CheckInteger: { OS << "OPC_CheckInteger, "; unsigned Bytes=1+EmitVBRValue(cast(N)->getValue(), OS); @@ -371,7 +371,7 @@ OS << "OPC_CheckCondCode, ISD::" << cast(N)->getCondCodeName() << ",\n"; return 2; - + case Matcher::CheckValueType: OS << "OPC_CheckValueType, MVT::" << cast(N)->getTypeName() << ",\n"; @@ -382,20 +382,20 @@ const ComplexPattern &Pattern = CCPM->getPattern(); OS << "OPC_CheckComplexPat, /*CP*/" << getComplexPat(Pattern) << ", /*#*/" << CCPM->getMatchNumber() << ','; - + if (!OmitComments) { OS.PadToColumn(CommentIndent) << "// " << Pattern.getSelectFunc(); OS << ":$" << CCPM->getName(); for (unsigned i = 0, e = Pattern.getNumOperands(); i != e; ++i) OS << " #" << CCPM->getFirstResult()+i; - + if (Pattern.hasProperty(SDNPHasChain)) OS << " + chain result"; } OS << '\n'; return 3; } - + case Matcher::CheckAndImm: { OS << "OPC_CheckAndImm, "; unsigned Bytes=1+EmitVBRValue(cast(N)->getValue(), OS); @@ -409,11 +409,11 @@ OS << '\n'; return Bytes; } - + case Matcher::CheckFoldableChainNode: OS << "OPC_CheckFoldableChainNode,\n"; return 1; - + case Matcher::EmitInteger: { int64_t Val = cast(N)->getValue(); OS << "OPC_EmitInteger, " @@ -430,7 +430,7 @@ << Val << ",\n"; return 3; } - + case Matcher::EmitRegister: if (useEmitRegister2) { OS << "OPC_EmitRegister2, " @@ -457,22 +457,22 @@ } return 3; } - + case Matcher::EmitConvertToTarget: OS << "OPC_EmitConvertToTarget, " << cast(N)->getSlot() << ",\n"; return 2; - + case Matcher::EmitMergeInputChains: { const EmitMergeInputChainsMatcher *MN = cast(N); - + // Handle the specialized forms OPC_EmitMergeInputChains1_0 and 1_1. if (MN->getNumNodes() == 1 && MN->getNode(0) < 2) { OS << "OPC_EmitMergeInputChains1_" << MN->getNode(0) << ",\n"; return 1; } - + OS << "OPC_EmitMergeInputChains, " << MN->getNumNodes() << ", "; for (unsigned i = 0, e = MN->getNumNodes(); i != e; ++i) OS << MN->getNode(i) << ", "; @@ -494,13 +494,13 @@ OS <<'\n'; return 3; } - + case Matcher::EmitNode: case Matcher::MorphNodeTo: { const EmitNodeMatcherCommon *EN = cast(N); OS << (isa(EN) ? "OPC_EmitNode" : "OPC_MorphNodeTo"); OS << ", TARGET_VAL(" << EN->getOpcodeName() << "), 0"; - + if (EN->hasChain()) OS << "|OPFL_Chain"; if (EN->hasInFlag()) OS << "|OPFL_GlueInput"; if (EN->hasOutFlag()) OS << "|OPFL_GlueOutput"; @@ -508,7 +508,7 @@ if (EN->getNumFixedArityOperands() != -1) OS << "|OPFL_Variadic" << EN->getNumFixedArityOperands(); OS << ",\n"; - + OS.PadToColumn(Indent*2+4) << EN->getNumVTs(); if (!OmitComments) OS << "/*#VTs*/"; @@ -523,7 +523,7 @@ unsigned NumOperandBytes = 0; for (unsigned i = 0, e = EN->getNumOperands(); i != e; ++i) NumOperandBytes += EmitVBRValue(EN->getOperand(i), OS); - + if (!OmitComments) { // Print the result #'s for EmitNode. if (const EmitNodeMatcher *E = dyn_cast(EN)) { @@ -538,14 +538,14 @@ if (const MorphNodeToMatcher *SNT = dyn_cast(N)) { OS.PadToColumn(Indent*2) << "// Src: " - << *SNT->getPattern().getSrcPattern() << " - Complexity = " + << *SNT->getPattern().getSrcPattern() << " - Complexity = " << SNT->getPattern().getPatternComplexity(CGP) << '\n'; OS.PadToColumn(Indent*2) << "// Dst: " << *SNT->getPattern().getDstPattern() << '\n'; } } else OS << '\n'; - + return 6+EN->getNumVTs()+NumOperandBytes; } case Matcher::MarkGlueResults: { @@ -566,7 +566,7 @@ OS << '\n'; if (!OmitComments) { OS.PadToColumn(Indent*2) << "// Src: " - << *CM->getPattern().getSrcPattern() << " - Complexity = " + << *CM->getPattern().getSrcPattern() << " - Complexity = " << CM->getPattern().getPatternComplexity(CGP) << '\n'; OS.PadToColumn(Indent*2) << "// Dst: " << *CM->getPattern().getDstPattern(); @@ -590,7 +590,7 @@ unsigned MatcherSize = EmitMatcher(N, Indent, CurrentIdx, OS); Size += MatcherSize; CurrentIdx += MatcherSize; - + // If there are other nodes in this list, iterate to them, otherwise we're // done. N = N->getNext(); @@ -609,15 +609,15 @@ OS << " }\n"; OS << "}\n\n"; } - + // Emit Node predicates. // FIXME: Annoyingly, these are stored by name, which we never even emit. Yay? StringMap PFsByName; - + for (CodeGenDAGPatterns::pf_iterator I = CGP.pf_begin(), E = CGP.pf_end(); I != E; ++I) PFsByName[I->first->getName()] = I->second; - + if (!NodePredicates.empty()) { OS << "bool CheckNodePredicate(SDNode *Node, unsigned PredNo) const {\n"; OS << " switch (PredNo) {\n"; @@ -626,7 +626,7 @@ // FIXME: Storing this by name is horrible. TreePattern *P =PFsByName[NodePredicates[i].substr(strlen("Predicate_"))]; assert(P && "Unknown name?"); - + // Emit the predicate code corresponding to this pattern. std::string Code = P->getRecord()->getValueAsCode("Predicate"); assert(!Code.empty() && "No code in this predicate"); @@ -646,7 +646,7 @@ OS << " }\n"; OS << "}\n\n"; } - + // Emit CompletePattern matchers. // FIXME: This should be const. if (!ComplexPatterns.empty()) { @@ -662,7 +662,7 @@ if (P.hasProperty(SDNPHasChain)) ++NumOps; // Get the chained node too. - + OS << " case " << i << ":\n"; OS << " Result.resize(NextRes+" << NumOps << ");\n"; OS << " return " << P.getSelectFunc(); @@ -672,12 +672,12 @@ // first argument. if (P.hasProperty(SDNPWantRoot)) OS << "Root, "; - + // If the complex pattern wants the parent of the operand being matched, // pass it in as the next argument. if (P.hasProperty(SDNPWantParent)) OS << "Parent, "; - + OS << "N"; for (unsigned i = 0; i != NumOps; ++i) OS << ", Result[NextRes+" << i << "].first"; @@ -686,28 +686,28 @@ OS << " }\n"; OS << "}\n\n"; } - - + + // Emit SDNodeXForm handlers. // FIXME: This should be const. if (!NodeXForms.empty()) { OS << "SDValue RunSDNodeXForm(SDValue V, unsigned XFormNo) {\n"; OS << " switch (XFormNo) {\n"; OS << " default: assert(0 && \"Invalid xform # in table?\");\n"; - + // FIXME: The node xform could take SDValue's instead of SDNode*'s. for (unsigned i = 0, e = NodeXForms.size(); i != e; ++i) { const CodeGenDAGPatterns::NodeXForm &Entry = CGP.getSDNodeTransform(NodeXForms[i]); - + Record *SDNode = Entry.first; const std::string &Code = Entry.second; - + OS << " case " << i << ": { "; if (!OmitComments) OS << "// " << NodeXForms[i]->getName(); OS << '\n'; - + std::string ClassName = CGP.getSDNodeInfo(SDNode).getSDClassName(); if (ClassName == "SDNode") OS << " SDNode *N = V.getNode();\n"; @@ -727,12 +727,12 @@ if (unsigned(M->getKind()) >= OpcodeFreq.size()) OpcodeFreq.resize(M->getKind()+1); OpcodeFreq[M->getKind()]++; - + // Handle recursive nodes. if (const ScopeMatcher *SM = dyn_cast(M)) { for (unsigned i = 0, e = SM->getNumChildren(); i != e; ++i) BuildHistogram(SM->getChild(i), OpcodeFreq); - } else if (const SwitchOpcodeMatcher *SOM = + } else if (const SwitchOpcodeMatcher *SOM = dyn_cast(M)) { for (unsigned i = 0, e = SOM->getNumCases(); i != e; ++i) BuildHistogram(SOM->getCaseMatcher(i), OpcodeFreq); @@ -747,16 +747,16 @@ formatted_raw_ostream &OS) { if (OmitComments) return; - + std::vector OpcodeFreq; BuildHistogram(M, OpcodeFreq); - + OS << " // Opcode Histogram:\n"; for (unsigned i = 0, e = OpcodeFreq.size(); i != e; ++i) { OS << " // #"; switch ((Matcher::KindTy)i) { - case Matcher::Scope: OS << "OPC_Scope"; break; - case Matcher::RecordNode: OS << "OPC_RecordNode"; break; + case Matcher::Scope: OS << "OPC_Scope"; break; + case Matcher::RecordNode: OS << "OPC_RecordNode"; break; case Matcher::RecordChild: OS << "OPC_RecordChild"; break; case Matcher::RecordMemRef: OS << "OPC_RecordMemRef"; break; case Matcher::CaptureGlueInput: OS << "OPC_CaptureGlueInput"; break; @@ -789,9 +789,9 @@ case Matcher::MorphNodeTo: OS << "OPC_MorphNodeTo"; break; case Matcher::EmitNodeXForm: OS << "OPC_EmitNodeXForm"; break; case Matcher::MarkGlueResults: OS << "OPC_MarkGlueResults"; break; - case Matcher::CompleteMatch: OS << "OPC_CompleteMatch"; break; + case Matcher::CompleteMatch: OS << "OPC_CompleteMatch"; break; } - + OS.PadToColumn(40) << " = " << OpcodeFreq[i] << '\n'; } OS << '\n'; @@ -803,7 +803,7 @@ bool useEmitRegister2, raw_ostream &O) { formatted_raw_ostream OS(O); - + OS << "// The main instruction selector code.\n"; OS << "SDNode *SelectCode(SDNode *N) {\n"; @@ -815,13 +815,13 @@ OS << " static const unsigned char MatcherTable[] = {\n"; unsigned TotalSize = MatcherEmitter.EmitMatcherList(TheMatcher, 5, 0, OS); OS << " 0\n }; // Total Array size is " << (TotalSize+1) << " bytes\n\n"; - + MatcherEmitter.EmitHistogram(TheMatcher, OS); - + OS << " #undef TARGET_VAL\n"; OS << " return SelectCodeCommon(N, MatcherTable,sizeof(MatcherTable));\n}\n"; OS << '\n'; - + // Next up, emit the function for node and pattern predicates: MatcherEmitter.EmitPredicateFunctions(OS); } From lstask at gmail.com Mon Feb 28 12:39:43 2011 From: lstask at gmail.com (Liam Staskawicz) Date: Mon, 28 Feb 2011 10:39:43 -0800 Subject: [llvm-commits] [PATCH] sys::fs::can_read() and sys::fs::can_write() for Unix Message-ID: <103727D28EE14102ABAB90CE3ED8DE80@gmail.com> Hi - the attached patch provides implementations and tests for sys::fs::can_read() and sys::fs::can_write() for Unix. These were adapted from the previous implementations in lib/Support/Unix/Path.inc. can_execute() could be implemented quite similarly, but I wasn't sure where the best place to add a test for it would be, so left it out for now. Thanks, Liam -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110228/5e259464/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: pathsupport.diff Type: application/octet-stream Size: 1687 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110228/5e259464/attachment.obj From vmle at ucdavis.edu Mon Feb 28 13:52:17 2011 From: vmle at ucdavis.edu (Vu Le) Date: Mon, 28 Feb 2011 11:52:17 -0800 Subject: [llvm-commits] Patch for simplifying regions In-Reply-To: <4D6BCEBA.9080609@fim.uni-passau.de> References: <4D4882FC.8060102@fim.uni-passau.de> <4D6BCEBA.9080609@fim.uni-passau.de> Message-ID: Hi Tobias, I did make some changes to use splitBlockPredecessors in splitting entry nodes. I tested it with coreutils and MySQL together with region-extractor pass. If you're still interested in region-extractor pass, I'll make a patch. Vu On Mon, Feb 28, 2011 at 8:35 AM, Tobias Grosser wrote: > On 02/01/2011 07:37 PM, Vu Le wrote: > >> Hi Tobias, >> > > I would like to get this one in LLVM 2.9. Do you happen to have an updated > patch available? > > +void RegionSimplify::print(raw_ostream&O, const Module *M) const { >> + BasicBlock *enteringBlock; >> + BasicBlock *exitingBlock; >> + >> + if (modified) { >> + enteringBlock = CR->getEnteringBlock(); >> + exitingBlock = CR->getExitingBlock(); >> + >> + O<< "\nRegion: ["<< CR->getNameStr()<< "] Edges:\n"; >> + if (enteringBlock) >> + O<< " Entry: ]"<< enteringBlock->getNameStr()<< " => " >> +<< enteringBlock->getNameStr()<< "]\n"; >> + if (exitingBlock) >> + O<< " Exit: ["<< exitingBlock->getNameStr()<< " => " >> +<< exitingBlock->getNameStr()<< "[\n"; >> >> Can you use CR->getNameStr() instead of formatting this yourself? >> >> >> This is is Andreas' code. Do you mean if the region is modified, we just >> print CR->getNameStr()? >> > > OK. I did not get that you add additional information. This is fine. I > would just format it like this: > > void RegionSimplify::print(raw_ostream &O, const Module *M) const { > if (!modified) > return; > > > BasicBlock *enteringBlock = CR->getEnteringBlock(); > BasicBlock *exitingBlock = CR->getExitingBlock(); > > [...] > > + >> + O<< "\n"; >> + } >> +} >> + >> +void RegionSimplify::getAnalysisUsage(AnalysisUsage&AU) const { >> + AU.addPreserved (); >> + AU.addRequired (); >> >> Does this transformation preserve RegionInfo? >> >> >> Yes, I think RegionInfo is also preserved. >> > OK. So let's state that we preserve it. > > > +// createSingleEntryEdge - Split the entry BasicBlock of the given >> +// region after the last PHINode to form a single entry edge. >> +// This is similar to CodeExtractor::severSplitPHINodes >> +BasicBlock *RegionSimplify::createSingleEntryEdge(Region *R) { >> + Function *f = R->getEntry()->getParent(); >> + if (&f->getEntryBlock() == R->getEntry()) >> + return NULL; // Entry node is the function's entry blocks >> >> Why do you need a special case for this? AS the entry node as never >> any predecessors, I would imaging there would automatically be no >> splitting. >> >> >> I thought that we should not split regions whose entry is the function >> entry. But I was wrong. We can split those. But I don't quite understand >> what you mean. >> > > LLVM does not allow to have jumps directly to the entry basic block of a > function. This function has never any predeccessor and consequently does not > need to be splitted. > > + >> + BasicBlock *oldEntry = R->getEntry(); >> + PHINode *PN = dyn_cast (oldEntry->begin()); >> + if (!PN) >> + return NULL; // No PHI nodes. >> + >> + BasicBlock::iterator AfterPHIs = oldEntry->getFirstNonPHI(); >> + BasicBlock *newEntry = oldEntry->splitBasicBlock(AfterPHIs, >> + oldEntry->getName() + ".simregentry"); >> >> 'simregionentry' sounds wrong. What about '.single_region_entry', >> 'singleentry', ...? >> >> + >> + // Okay, update dominator sets. >> >> // Update dominator tree. >> >> + if (DominatorTree *DT = >> getAnalysisIfAvailable()) { >> + succ_iterator secondSucc = succ_begin(newEntry) + 1; >> + if (secondSucc == succ_end(newEntry)) //newEntry has 1 >> successor >> + DT->splitBlock(newEntry); >> + else { // newEntry has more than 1 successor, update DT >> manually >> + // oldEntry dominates newEntry. >> + // newEntry node dominates all other nodes dominated by >> oldEntry. >> + DomTreeNode *OldNode = DT->getNode(oldEntry); >> + if (OldNode) { // don't bother if oldEntry doesn't >> dominates any node >> + std::vector Children; >> + for (DomTreeNode::iterator I = OldNode->begin(), E = >> OldNode->end(); I >> + != E; ++I) >> + Children.push_back(*I); >> + >> + DomTreeNode *NewNode = DT->addNewBlock(newEntry, >> oldEntry); >> + for (std::vector::iterator I = >> Children.begin(), E = >> + Children.end(); I != E; ++I) >> + DT->changeImmediateDominator(*I, NewNode); >> + } >> + } >> + } >> + >> + // Loop over all of the predecessors of the old entry that >> are in the region, >> + // changing them to branch to the new entry instead of the >> old one >> + for (pred_iterator PI = pred_begin(oldEntry), PE = >> pred_end(oldEntry); PI >> + != PE; ++PI) { >> + if (R->contains(*PI)) { >> + TerminatorInst *TI = (*PI)->getTerminator(); >> + TI->replaceUsesOfWith(oldEntry, newEntry); >> + } >> + } >> + // just have to update the PHI nodes now, inserting PHI nodes >> into NewBB. >> + for (BasicBlock::iterator PI = oldEntry->begin(); >> isa (PI); ++PI) { >> + PHINode *PN = cast (PI); >> + // Create a new PHI node in the new region, which has an >> incoming value >> + // from oldEntry of PN. >> + PHINode *NewPN = PHINode::Create(PN->getType(), >> PN->getName() + ".ph", >> + newEntry->begin()); >> + >> + NewPN->addIncoming(PN, oldEntry); >> + >> + // Loop over all of the incoming value in PN, moving them >> to NewPN if they >> + // are from the region. >> + for (unsigned i = 0; i != PN->getNumIncomingValues(); ++i) { >> + BasicBlock *HasValToPN = PN->getIncomingBlock(i); >> + if (R->contains(HasValToPN)) { >> + NewPN->addIncoming(PN->getIncomingValue(i), HasValToPN); >> + PN->removeIncomingValue(i); >> + --i; >> + } >> + } >> + } >> >> Do you think we can use splitBlockPredecessors to simplify all this? >> >> I guess yes. The different here is if we use splitBlockPredecessors, >> Entry is split into NewNode->Entry. The entry node of R is not still >> Entry. >> >> We only need to update regions whose exit is Entry. >> Their exit must be changed into NewNode. >> I'm not quite sure how to do that. >> > > You are right. I just thought about this again and it seems to be better to > split Entry->NewNode. We cannot change anything that is outside of the > region. > > + return newEntry; >> +} >> + >> +// createSingleExitEdge - Split the exit BasicBlock of the >> given region >> +// to form a single exit edge. >> +// This does not update RegionInfo analysis. >> +BasicBlock *RegionSimplify::createSingleExitEdge(Region *R) { >> + BasicBlock *BB = R->getExit(); >> + >> + SmallVector Preds; >> + for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI >> != PE; ++PI) >> + if (R->contains(*PI)) >> + Preds.push_back(*PI); >> + >> + return SplitBlockPredecessors(BB, Preds.data(), Preds.size(), >> ".simregexit", >> + this); >> >> I propose to update RegionInfo here. Copying the setRegionFor from >> runOnRegion will not be sufficient. You need to update all regions >> whose entry node was the old exit node of this region. >> >> >> Why would we do that? >> Suppose another region X has entry oldExit. >> In region R, oldExit is split into (NewExit->oldExit). >> R is now the smallest region containing NewExit. >> >> I think it's still OK if the entry of X is oldExit. >> > Agreed. Forget about the comment. > > +bool RegionSimplify::runOnRegion(Region *R, RGPassManager&RGM) { >> + RegionInfo *RI =&getAnalysis (); >> + modified = false; >> + >> + CR = R; >> + if (!R->isTopLevelRegion()) { >> + BasicBlock *newBB; >> + BasicBlock *oldBB; >> + >> + if (!(R->getEnteringBlock())) { >> + oldBB = R->getEntry(); >> + >> + newBB = createSingleEntryEdge(R); >> + if (newBB) { // update RegionInfo only if we split entry >> successfully >> + RI->splitBlock(newBB, oldBB); >> >> I would put this into createSingleEntryEdge(), as you also update >> the dominance information there. >> >> >> OK. >> >> >> + >> + modified |= true; >> + ++NumEntries; >> + } >> + } >> + >> + if (!(R->getExitingBlock())) { >> + oldBB = R->getExit(); >> + newBB = createSingleExitEdge(R); >> + >> + RI->setRegionFor(newBB, R); >> >> I would update the RI in the createSingleExitEdge as you also update >> the regioninto there. >> >> OK. >> >> >> + >> + modified |= true; >> + ++NumExits; >> + } >> + } >> + >> + return modified; >> +} >> diff --git a/lib/Transforms/Scalar/Scalar.cpp >> b/lib/Transforms/Scalar/Scalar.cpp >> index bf9ca6d..5d18f22 100644 >> --- a/lib/Transforms/Scalar/Scalar.cpp >> +++ b/lib/Transforms/Scalar/Scalar.cpp >> @@ -51,6 +51,7 @@ void >> llvm::initializeScalarOpts(PassRegistry&Registry) { >> initializeMemCpyOptPass(Registry); >> initializeReassociatePass(Registry); >> initializeRegToMemPass(Registry); >> + initializeRegionSimplifyPass(Registry); >> initializeSCCPPass(Registry); >> initializeIPSCCPPass(Registry); >> initializeSROA_DTPass(Registry); >> >> >> Furthermore, you should add a couple of test cases for the different >> branches. >> >> I tested with mysql code. Do you know how to verify that our pass >> preserves the semantics of the program? >> > > You can compile some code in the LLVM test-suite with it. However, I > believe it is fine if you generate a bunch of test cases for which you make > sure it is doing the right thing. > > Cheers > Tobi > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110228/98f37d3f/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: simplifyregion.patch Type: text/x-patch Size: 12166 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110228/98f37d3f/attachment.bin From louisfeng.list at gmail.com Mon Feb 28 15:09:59 2011 From: louisfeng.list at gmail.com (Louis) Date: Mon, 28 Feb 2011 13:09:59 -0800 Subject: [llvm-commits] llvm/lib/Analysis and Transforms/Scalar CMakeLists.txt patches Message-ID: Recent commits (126668-126671) on the trunk broke the cmake build on windows. Here are the patches. Cheers, Louis -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110228/4db322b8/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: cmake_patch1.diff Type: application/octet-stream Size: 351 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110228/4db322b8/attachment.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: cmake_patch2.diff Type: application/octet-stream Size: 538 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110228/4db322b8/attachment-0001.obj From fvbommel at gmail.com Tue Mar 1 01:19:09 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Tue, 1 Mar 2011 08:19:09 +0100 Subject: [llvm-commits] [llvm] r126714 - in /llvm/trunk: include/llvm/Constants.h lib/VMCore/Constants.cpp In-Reply-To: <20110228235327.6DF072A6C12C@llvm.org> References: <20110228235327.6DF072A6C12C@llvm.org> Message-ID: On Tue, Mar 1, 2011 at 12:53 AM, Talin wrote: > +Constant* ConstantStruct::get(LLVMContext &Context, bool Packed, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Constant * Val, ...) { > + ?va_list ap; > + ?std::vector Values; > + ?va_start(ap, Val); > + ?while (Val) { > + ? ?Values.push_back(Val); > + ? ?Val = va_arg(ap, llvm::Constant*); > + ?} Shouldn't there technically be a va_end right about here? I'm not aware of any platform where that actually does anything, but it can't hurt either... > + ?return get(Context, Values, Packed); > +} From nicholas at mxc.ca Tue Mar 1 02:15:51 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 01 Mar 2011 08:15:51 -0000 Subject: [llvm-commits] [llvm] r126741 - in /llvm/trunk: lib/Analysis/InstructionSimplify.cpp test/Transforms/InstSimplify/compare.ll Message-ID: <20110301081551.280092A6C12E@llvm.org> Author: nicholas Date: Tue Mar 1 02:15:50 2011 New Revision: 126741 URL: http://llvm.org/viewvc/llvm-project?rev=126741&view=rev Log: Optimize "icmp pred (urem X, Y), Y" --> true/false depending on pred. There's more work to do here, "icmp ult (urem X, 10), 11" doesn't optimize away yet. Fixes example 3 from PR9343! Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp llvm/trunk/test/Transforms/InstSimplify/compare.ll Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=126741&r1=126740&r2=126741&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original) +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Tue Mar 1 02:15:50 2011 @@ -1434,6 +1434,9 @@ return ConstantInt::getTrue(CI->getContext()); break; } + + // TODO: integer div and rem with constant RHS all produce values in a + // constant range. We should check whether the comparison is a tautology. } // Compare of cast, for example (zext X) != 0 -> X != 0 @@ -1644,6 +1647,21 @@ } } + if (LBO && match(LBO, m_URem(m_Value(), m_Specific(RHS)))) { + switch (Pred) { + default: + break; + case ICmpInst::ICMP_EQ: + case ICmpInst::ICMP_UGT: + case ICmpInst::ICMP_UGE: + return ConstantInt::getFalse(RHS->getContext()); + case ICmpInst::ICMP_NE: + case ICmpInst::ICMP_ULT: + case ICmpInst::ICMP_ULE: + return ConstantInt::getTrue(RHS->getContext()); + } + } + // If the comparison is with the result of a select instruction, check whether // comparing with either branch of the select always yields the same value. if (isa(LHS) || isa(RHS)) Modified: llvm/trunk/test/Transforms/InstSimplify/compare.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/compare.ll?rev=126741&r1=126740&r2=126741&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstSimplify/compare.ll (original) +++ llvm/trunk/test/Transforms/InstSimplify/compare.ll Tue Mar 1 02:15:50 2011 @@ -187,3 +187,19 @@ ret i1 %c ; CHECK: ret i1 %cond } + +define i1 @urem1(i32 %X, i32 %Y) { +; CHECK: @urem1 + %A = urem i32 %X, %Y + %B = icmp ult i32 %A, %Y + ret i1 %B +; CHECK: ret i1 true +} + +define i1 @urem2(i32 %X, i32 %Y) { +; CHECK: @urem2 + %A = urem i32 %X, %Y + %B = icmp eq i32 %A, %Y + ret i1 %B +; CHECK ret i1 false +} From sabre at nondot.org Tue Mar 1 02:36:21 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 01 Mar 2011 08:36:21 -0000 Subject: [llvm-commits] [llvm] r126742 - /llvm/trunk/include/llvm/Support/SourceMgr.h Message-ID: <20110301083621.6433A2A6C12D@llvm.org> Author: lattner Date: Tue Mar 1 02:36:21 2011 New Revision: 126742 URL: http://llvm.org/viewvc/llvm-project?rev=126742&view=rev Log: add a missing const qualifier for consistency. Modified: llvm/trunk/include/llvm/Support/SourceMgr.h Modified: llvm/trunk/include/llvm/Support/SourceMgr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/SourceMgr.h?rev=126742&r1=126741&r2=126742&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/SourceMgr.h (original) +++ llvm/trunk/include/llvm/Support/SourceMgr.h Tue Mar 1 02:36:21 2011 @@ -171,7 +171,7 @@ const SourceMgr *getSourceMgr() const { return SM; } SMLoc getLoc() const { return Loc; } - const std::string &getFilename() { return Filename; } + const std::string &getFilename() const { return Filename; } int getLineNo() const { return LineNo; } int getColumnNo() const { return ColumnNo; } const std::string &getMessage() const { return Message; } From ofv at wanadoo.es Tue Mar 1 05:19:13 2011 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=) Date: Tue, 01 Mar 2011 12:19:13 +0100 Subject: [llvm-commits] llvm/lib/Analysis and Transforms/Scalar CMakeLists.txt patches References: Message-ID: <87d3mb1426.fsf@wanadoo.es> Louis writes: > Recent commits (126668-126671) on the trunk broke the cmake build on > windows. Here are the patches. The build works fine at r126733. Someone else already fixed the problem. Thanks. From baldrick at free.fr Tue Mar 1 02:54:10 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Mar 2011 09:54:10 +0100 Subject: [llvm-commits] [llvm] r126714 - in /llvm/trunk: include/llvm/Constants.h lib/VMCore/Constants.cpp In-Reply-To: <20110228235327.6DF072A6C12C@llvm.org> References: <20110228235327.6DF072A6C12C@llvm.org> Message-ID: <4D6CB432.5080303@free.fr> Hi Talin, > + static Constant *get(LLVMContext&Context, bool Packed, > + Constant * Val, ...) END_WITH_NULL; extraneous space between "Constant *" and Val. > #include > #include > +#include Not added in alphabetical order. > +Constant* ConstantStruct::get(LLVMContext&Context, bool Packed, > + Constant * Val, ...) { Extraneous space between "Constant *" and Val. Ciao, Duncan. From baldrick at free.fr Tue Mar 1 02:59:43 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Mar 2011 09:59:43 +0100 Subject: [llvm-commits] [llvm] r126684 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp In-Reply-To: <20110228211010.A2B182A6C12C@llvm.org> References: <20110228211010.A2B182A6C12C@llvm.org> Message-ID: <4D6CB57F.6030203@free.fr> Hi Owen, > Use the correct shift amount type. it's only the correct type after type legalization. The problem is that getShiftAmountTy can return a small type (eg: i8 on x86) that is not big enough to hold the shift value. This matters if the bwap is of i345678 integers or something like that. Using the pointer type here is a trick to reduce the amount of work type legalization does (because the pointer type is always legal). So please revert this patch. Thanks, Duncan. > > Modified: > llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=126684&r1=126683&r2=126684&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Mon Feb 28 15:10:10 2011 > @@ -226,7 +226,7 @@ > > unsigned DiffBits = NVT.getSizeInBits() - OVT.getSizeInBits(); > return DAG.getNode(ISD::SRL, dl, NVT, DAG.getNode(ISD::BSWAP, dl, NVT, Op), > - DAG.getConstant(DiffBits, TLI.getPointerTy())); > + DAG.getConstant(DiffBits, TLI.getShiftAmountTy(NVT))); > } > > SDValue DAGTypeLegalizer::PromoteIntRes_BUILD_PAIR(SDNode *N) { > > > _______________________________________________ > 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 Mar 1 03:01:55 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Mar 2011 10:01:55 +0100 Subject: [llvm-commits] [llvm-gcc-4.2] r126672 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <20110228194800.B507F2A6C12C@llvm.org> References: <20110228194800.B507F2A6C12C@llvm.org> Message-ID: <4D6CB603.4080600@free.fr> Hi Stuart, > Skip anonymous union fields when initializing. Radar 9055247. please add a testcase. > - // Unions are initialized using the first member field. Find it. > + // Unions are initialized using the first non-anonymous member field. Find it. I'm curious to know what this is based on? Does the C standard say this? Thanks, Duncan. > tree Field = TYPE_FIELDS(TREE_TYPE(exp)); > assert(Field&& "cannot initialize union with no fields"); > - while (TREE_CODE(Field) != FIELD_DECL) { > + while (TREE_CODE(Field) != FIELD_DECL || DECL_NAME(Field) == NULL_TREE) { > Field = TREE_CHAIN(Field); > assert(Field&& "cannot initialize union with no fields"); > } > > > _______________________________________________ > 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 Mar 1 04:29:30 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Mar 2011 11:29:30 +0100 Subject: [llvm-commits] Fold() function on TargetFolder class - removal of redundant constantexpr In-Reply-To: <4D675A94.9060403@mxc.ca> References: <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FED@base.imrc.kist.re.kr> <4D638055.6080201@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FF4@base.imrc.kist.re.kr> <4D639C52.2060401@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FF6@base.imrc.kist.re.kr> <4D63AA79.60904@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FF7@base.imrc.kist.re.kr> <4D63B86D.7000203@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FF8@base.imrc.kist.re.kr>, <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FFA@base.imrc.kist.re.kr>, <4D64BE54.8090603@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FFC@base.imrc.kist.re.kr>, <4D64CC05.2050802@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FFD@base.imrc.kist.re.kr>, <4D6745F8.10305@mxc.ca> <3E94D039A2B82544B3E7D48F924B0B25DFA3D88000@base.imrc.kist.re.kr>, <4D674CBB.4050302@mxc.ca> <3E94D039A2B82544B3E7D48F924B0B25DFA3D88002@base.imrc.kist.re.kr> <4D675A94.9060403@mxc.ca> Message-ID: <4D6CCA8A.7060006@free.fr> Hi Nick, > Okay, I follow you now. I just committed a fix to llvm to make the NoFolder work > with the IRBuilder again, and I'm doing a build of llvm-gcc with the NoFolder now. it would be nice if this (folding vs no folding) could be controlled with a runtime flag. If it was I would probably add it permanently to dragonegg. Unfortunately the way IRBuilder is declared to take the folder as a template parameter makes this hard. Any ideas for how to achieve this? Ciao, Duncan. From grosser at fim.uni-passau.de Tue Mar 1 07:49:37 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 01 Mar 2011 08:49:37 -0500 Subject: [llvm-commits] Patch for simplifying regions In-Reply-To: References: <4D4882FC.8060102@fim.uni-passau.de> <4D6BCEBA.9080609@fim.uni-passau.de> Message-ID: <4D6CF971.5050300@fim.uni-passau.de> On 02/28/2011 02:52 PM, Vu Le wrote: > Hi Tobias, > I did make some changes to use splitBlockPredecessors in splitting > entry nodes. Thanks for your fast reaction. The patch looks very nice. Though I have some comments that we need to fix before committing it. > I tested it with coreutils and MySQL together with region-extractor pass. Nice. > If you're still interested in region-extractor pass, I'll make a patch. Yes. I am extremely interested. > diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h > index 02dbfbd..0591845 100644 > --- a/include/llvm/InitializePasses.h > +++ b/include/llvm/InitializePasses.h > @@ -192,6 +192,7 @@ void initializeRegionInfoPass(PassRegistry&); > void initializeRegionOnlyPrinterPass(PassRegistry&); > void initializeRegionOnlyViewerPass(PassRegistry&); > void initializeRegionPrinterPass(PassRegistry&); > +void initializeRegionSimplifyPass(PassRegistry&); > void initializeRegionViewerPass(PassRegistry&); > void initializeRegisterCoalescerAnalysisGroup(PassRegistry&); > void initializeRenderMachineFunctionPass(PassRegistry&); > diff --git a/include/llvm/LinkAllPasses.h b/include/llvm/LinkAllPasses.h > index 69e1bd9..ea1faec 100644 > --- a/include/llvm/LinkAllPasses.h > +++ b/include/llvm/LinkAllPasses.h > @@ -114,7 +114,8 @@ namespace { > (void) llvm::createRegionInfoPass(); > (void) llvm::createRegionOnlyPrinterPass(); > (void) llvm::createRegionOnlyViewerPass(); > - (void) llvm::createRegionPrinterPass(); > + (void) llvm::createRegionPrinterPass(); This change does not seem to be needed. Please remove it. > + (void) llvm::createRegionSimplifyPass(); > (void) llvm::createRegionViewerPass(); > (void) llvm::createSCCPPass(); > (void) llvm::createScalarReplAggregatesPass(); > diff --git a/include/llvm/Transforms/Scalar.h b/include/llvm/Transforms/Scalar.h > index 6f2a38e..e3ca06a 100644 > --- a/include/llvm/Transforms/Scalar.h > +++ b/include/llvm/Transforms/Scalar.h > @@ -349,6 +349,12 @@ Pass *createCorrelatedValuePropagationPass(); > FunctionPass *createInstructionSimplifierPass(); > extern char&InstructionSimplifierID; > > +//===----------------------------------------------------------------------===// > +// > +// RegionSimplify - Simplify refined regions, if possible. Are there cases when it is not possible? Would be interesting to mention those. > +Pass *createRegionSimplifyPass(); > + > } // End llvm namespace > > #endif > diff --git a/lib/Transforms/Scalar/CMakeLists.txt b/lib/Transforms/Scalar/CMakeLists.txt > index 106fb8f..53fcf69 100644 > --- a/lib/Transforms/Scalar/CMakeLists.txt > +++ b/lib/Transforms/Scalar/CMakeLists.txt > @@ -23,6 +23,7 @@ add_llvm_library(LLVMScalarOpts > MemCpyOptimizer.cpp > Reassociate.cpp > Reg2Mem.cpp > + RegionSimplify.cpp > SCCP.cpp > Scalar.cpp > ScalarReplAggregates.cpp > diff --git a/lib/Transforms/Scalar/RegionSimplify.cpp b/lib/Transforms/Scalar/RegionSimplify.cpp > new file mode 100644 > index 0000000..65e4d5c > --- /dev/null > +++ b/lib/Transforms/Scalar/RegionSimplify.cpp > @@ -0,0 +1,185 @@ > +//===- SeSeRegionInfo.cpp -------------------------------------------------===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > +// > +// This file converts refined regions detected by the RegionInfo analysis > +// into simple regions. > +// > +//===----------------------------------------------------------------------===// > + > +#include "llvm/Instructions.h" > +#include "llvm/ADT/Statistic.h" > +#include "llvm/Analysis/Dominators.h" > +#include "llvm/Analysis/RegionPass.h" > +#include "llvm/Analysis/RegionInfo.h" > +#include "llvm/Transforms/Utils/BasicBlockUtils.h" > + > +#define DEBUG_TYPE "regionsimplify" Can we call the pass "region-simplify"? Like "loop-simplify" (The name was recently changed) > +using namespace llvm; > + > +STATISTIC(NumEntries, "The # of created entry edges"); > +STATISTIC(NumExits, "The # of created exit edges"); > + > +namespace { > +class RegionSimplify: public RegionPass { > + bool modified; > + Region *CR; > + void createSingleEntryEdge(Region *R); > + void createSingleExitEdge(Region *R); > +public: > + static char ID; > + explicit RegionSimplify() : > + RegionPass(ID) { > + initializeRegionSimplifyPass(*PassRegistry::getPassRegistry()); > + } > + > + virtual void print(raw_ostream&O, const Module *M) const; > + > + virtual bool runOnRegion(Region *R, RGPassManager&RGM); > + virtual void getAnalysisUsage(AnalysisUsage&AU) const; > +}; > +} > + > +INITIALIZE_PASS(RegionSimplify, "regionsimplify", "regionsimplify" -> "region-simplify" > + "Transform refined regions into simple regions", false, false) > + > +char RegionSimplify::ID = 0; > +namespace llvm { > +Pass *createRegionSimplifyPass() { > + return new RegionSimplify(); > +} > +} > + > +void RegionSimplify::print(raw_ostream&O, const Module *M) const { > + if (!modified) > + return; > + > + BasicBlock *enteringBlock = CR->getEnteringBlock(); > + BasicBlock *exitingBlock = CR->getExitingBlock(); > + > + O<< "\nRegion: ["<< CR->getNameStr()<< "] Edges:\n"; > + if (enteringBlock) > + O<< " Entry: ]"<< enteringBlock->getNameStr()<< " => " > +<< enteringBlock->getNameStr()<< "]\n"; > + if (exitingBlock) > + O<< " Exit: ["<< exitingBlock->getNameStr()<< " => " > +<< exitingBlock->getNameStr()<< "[\n"; > + > + O<< "\n"; > +} > + > +void RegionSimplify::getAnalysisUsage(AnalysisUsage&AU) const { > + AU.addPreserved (); > + AU.addPreserved (); > + AU.addRequired (); > +} > + > +// createSingleEntryEdge - Split the entry basic block of the given > +// region after the last PHINode to form a single entry edge. > +void RegionSimplify::createSingleEntryEdge(Region *R) { > + BasicBlock *oldEntry = R->getEntry(); > + SmallVector Preds; > + for (pred_iterator PI = pred_begin(oldEntry), PE = pred_end(oldEntry); > + PI != PE; ++PI) > + if (!R->contains(*PI)) > + Preds.push_back(*PI); > + > + if (Preds.size()==0) > + return; Can we change this to an assert? assert(Preds.size() && "This region has already a single entry edge"); > + > + BasicBlock *newEntry = SplitBlockPredecessors(oldEntry, > + Preds.data(), Preds.size(), > + ".single_entry", this); > + > + RegionInfo *RI =&getAnalysis (); > + // We do not update entry node for children of this region. > + // This make it easier to extract children regions because they do not share > + // the entry node with their parents. > + // all parent regions whose entry is oldEntry are updated with newEntry > + Region *r = R->getParent(); > + while (r->getEntry() == oldEntry&& !r->isTopLevelRegion()) { > + r->replaceEntry(newEntry); > + r = r->getParent(); > + } > + > + // We do not update exit node for children of this region for the same reason > + // of not updating entry node. > + // All other regions whose exit is oldEntry are updated with new exit node > + r = RI->getTopLevelRegion(); r = r->getParent() should be enough? > + std::deque RQ; std::vector is probably simpler > + RQ.push_back(r); > + while (!RQ.empty()){ > + r = RQ.front(); > + for (Region::const_iterator RI = r->begin(), RE = r->end(); RI!=RE; ++RI) > + RQ.push_back(*RI); > + if (r->getExit() == oldEntry&& !R->contains(r)) > + r->replaceExit(newEntry); > + RQ.pop_front(); > + } I need to think about this part (Will send feedback later). > + > + modified |= true; I do not believe this is part of creating the edges. 'modified' is part of the status tracking of the pass and should probably be put into runOnRegion(). > + ++NumEntries; Dito. Please put in runOnRegion(). > +} > + > +// createSingleExitEdge - Split the exit basic of the given region > +// to form a single exit edge. > +void RegionSimplify::createSingleExitEdge(Region *R) { > + BasicBlock *oldExit = R->getExit(); > + > + SmallVector Preds; > + for (pred_iterator PI = pred_begin(oldExit), PE = pred_end(oldExit); > + PI != PE; ++PI) > + if (R->contains(*PI)) > + Preds.push_back(*PI); > + > + BasicBlock *newExit = SplitBlockPredecessors(oldExit, > + Preds.data(), Preds.size(), > + ".single_exit", this); > + RegionInfo *RI =&getAnalysis (); > + > + // We do not need to update entry nodes because this split happens inside > + // this region and it affects only this region and all of its children. > + // The new split node belongs to this region > + RI->setRegionFor(newExit,R); > + > + // all children of this region whose exit is oldExit is changed to newExit > + std::deque RQ; > + for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; ++RI) > + RQ.push_back(*RI); > + while (!RQ.empty()){ > + R = RQ.front(); > + for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; ++RI) > + RQ.push_back(*RI); > + > + if (R->getExit() == oldExit) > + R->replaceExit(newExit); > + RQ.pop_front(); > + } A vector is probably simpler. We also do not need to add child regions for regions that do not have an exit matching oldExit. What about this code? std::vector RQ; while (!RQ.empty()){ R = RQ.back(); RQ.pop_back(); if (R->getExit() != oldExit) continue; R->replaceExit(newExit); for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; ++RI) RQ.push_back(*RI); } > + > + modified |= true; This function always modifies the CFG. So no need to put additional logic here. > + ++NumExits; Dito. > +} > + > +bool RegionSimplify::runOnRegion(Region *R, RGPassManager&RGM) { > + modified = false; > + > + CR = R; > + if (!R->isTopLevelRegion()) { > + > + if (!(R->getEnteringBlock())) { > + createSingleEntryEdge(R); > + } if (!(R->getEnteringBlock())) { createSingleEntryEdge(R); ++NumEntries; modified = true. } > + > + if (!(R->getExitingBlock())) { > + modified |= createSingleExitEdge(R); if (!(R->getExitingBlock())) { createSingleExitEdge(R); ++NumExits; modified = true; } > + } > + } > + > + return modified; > +} > diff --git a/lib/Transforms/Scalar/Scalar.cpp b/lib/Transforms/Scalar/Scalar.cpp > index bf9ca6d..5d18f22 100644 > --- a/lib/Transforms/Scalar/Scalar.cpp > +++ b/lib/Transforms/Scalar/Scalar.cpp > @@ -51,6 +51,7 @@ void llvm::initializeScalarOpts(PassRegistry&Registry) { > initializeMemCpyOptPass(Registry); > initializeReassociatePass(Registry); > initializeRegToMemPass(Registry); > + initializeRegionSimplifyPass(Registry); > initializeSCCPPass(Registry); > initializeIPSCCPPass(Registry); > initializeSROA_DTPass(Registry); > diff --git a/test/Transforms/RegionSimplify/dg.exp b/test/Transforms/RegionSimplify/dg.exp > new file mode 100644 > index 0000000..f200589 > --- /dev/null > +++ b/test/Transforms/RegionSimplify/dg.exp > @@ -0,0 +1,3 @@ > +load_lib llvm.exp > + > +RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] > diff --git a/test/Transforms/RegionSimplify/multi_exits.ll b/test/Transforms/RegionSimplify/multi_exits.ll > new file mode 100644 > index 0000000..024971c > --- /dev/null > +++ b/test/Transforms/RegionSimplify/multi_exits.ll > @@ -0,0 +1,15 @@ > +; RUN: opt -regionsimplify Did you test this test case. I believe you should use a line like: ; RUN: opt -regionsimplify %s Furthermore, we should also check the generated output. ; RUN: opt -regionsimplify %s | FileCheck %s > +define void @f() nounwind { ; CHECK: @f() ; CHECK: br label %"1" ... Add after the CHECK lines the output you expect. The same comments apply to the other test files. I would also be interested to have some test files that include PHI-Nodes. Can you send out an updated patch? Thanks a lot Tobi From fvbommel at gmail.com Tue Mar 1 08:38:46 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Tue, 1 Mar 2011 15:38:46 +0100 Subject: [llvm-commits] Fold() function on TargetFolder class - removal of redundant constantexpr In-Reply-To: <4D6CCA8A.7060006@free.fr> References: <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FED@base.imrc.kist.re.kr> <4D638055.6080201@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FF4@base.imrc.kist.re.kr> <4D639C52.2060401@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FF6@base.imrc.kist.re.kr> <4D63AA79.60904@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FF7@base.imrc.kist.re.kr> <4D63B86D.7000203@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FF8@base.imrc.kist.re.kr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FFA@base.imrc.kist.re.kr> <4D64BE54.8090603@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FFC@base.imrc.kist.re.kr> <4D64CC05.2050802@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FFD@base.imrc.kist.re.kr> <4D6745F8.10305@mxc.ca> <3E94D039A2B82544B3E7D48F924B0B25DFA3D88000@base.imrc.kist.re.kr> <4D674CBB.4050302@mxc.ca> <3E94D039A2B82544B3E7D48F924B0B25DFA3D88002@base.imrc.kist.re.kr> <4D675A94.9060403@mxc.ca> <4D6CCA8A.7060006@free.fr> Message-ID: On Tue, Mar 1, 2011 at 11:29 AM, Duncan Sands wrote: >> Okay, I follow you now. I just committed a fix to llvm to make the NoFolder work >> with the IRBuilder again, and I'm doing a build of llvm-gcc with the NoFolder now. > > it would be nice if this (folding vs no folding) could be controlled with a > runtime flag. ?If it was I would probably add it permanently to dragonegg. > Unfortunately the way IRBuilder is declared to take the folder as a template > parameter makes this hard. ?Any ideas for how to achieve this? If it's just about folding versus not folding in the IRBuilder, a simple solution might be to just add a boolean property 'FoldingEnabled' (defaulting to true) to IRBuilder, and add an 'if (FoldingEnabled)' around all the 'if (Constant *Foo = dyn_cast(...))' instances. Then at runtime the user of IRBuilder could just call 'Builder.setFoldingEnabled(false)', for example in response to some command-line flag. From baldrick at free.fr Tue Mar 1 08:40:33 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Mar 2011 15:40:33 +0100 Subject: [llvm-commits] Fold() function on TargetFolder class - removal of redundant constantexpr In-Reply-To: References: <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FED@base.imrc.kist.re.kr> <4D639C52.2060401@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FF6@base.imrc.kist.re.kr> <4D63AA79.60904@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FF7@base.imrc.kist.re.kr> <4D63B86D.7000203@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FF8@base.imrc.kist.re.kr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FFA@base.imrc.kist.re.kr> <4D64BE54.8090603@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FFC@base.imrc.kist.re.kr> <4D64CC05.2050802@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FFD@base.imrc.kist.re.kr> <4D6745F8.10305@mxc.ca> <3E94D039A2B82544B3E7D48F924B0B25DFA3D88000@base.imrc.kist.re.kr> <4D674CBB.4050302@mxc.ca> <3E94D039A2B82544B3E7D48F924B0B25DFA3D88002@base.imrc.kist.re.kr> <4D675A94.9060403@mxc.ca> <4D6CCA8A.7060006@free.fr> Message-ID: <4D6D0561.3020907@free.fr> Hi Frits, > On Tue, Mar 1, 2011 at 11:29 AM, Duncan Sands wrote: >>> Okay, I follow you now. I just committed a fix to llvm to make the NoFolder work >>> with the IRBuilder again, and I'm doing a build of llvm-gcc with the NoFolder now. >> >> it would be nice if this (folding vs no folding) could be controlled with a >> runtime flag. If it was I would probably add it permanently to dragonegg. >> Unfortunately the way IRBuilder is declared to take the folder as a template >> parameter makes this hard. Any ideas for how to achieve this? > > If it's just about folding versus not folding in the IRBuilder, a > simple solution might be to just add a boolean property > 'FoldingEnabled' (defaulting to true) to IRBuilder, and add an 'if > (FoldingEnabled)' around all the 'if (Constant *Foo = > dyn_cast(...))' instances. > Then at runtime the user of IRBuilder could just call > 'Builder.setFoldingEnabled(false)', for example in response to some > command-line flag. thanks for the suggestion. I guess another way of doing this is to create a new folder class that dispatches to a target folder or a no folder depending on the value of some flag. Ciao, Duncan. From fvbommel at gmail.com Tue Mar 1 08:43:48 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Tue, 1 Mar 2011 15:43:48 +0100 Subject: [llvm-commits] Fold() function on TargetFolder class - removal of redundant constantexpr In-Reply-To: <4D6D0561.3020907@free.fr> References: <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FED@base.imrc.kist.re.kr> <4D639C52.2060401@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FF6@base.imrc.kist.re.kr> <4D63AA79.60904@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FF7@base.imrc.kist.re.kr> <4D63B86D.7000203@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FF8@base.imrc.kist.re.kr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FFA@base.imrc.kist.re.kr> <4D64BE54.8090603@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FFC@base.imrc.kist.re.kr> <4D64CC05.2050802@free.fr> <3E94D039A2B82544B3E7D48F924B0B25DFA3D87FFD@base.imrc.kist.re.kr> <4D6745F8.10305@mxc.ca> <3E94D039A2B82544B3E7D48F924B0B25DFA3D88000@base.imrc.kist.re.kr> <4D674CBB.4050302@mxc.ca> <3E94D039A2B82544B3E7D48F924B0B25DFA3D88002@base.imrc.kist.re.kr> <4D675A94.9060403@mxc.ca> <4D6CCA8A.7060006@free.fr> <4D6D0561.3020907@free.fr> Message-ID: On Tue, Mar 1, 2011 at 3:40 PM, Duncan Sands wrote: >> On Tue, Mar 1, 2011 at 11:29 AM, Duncan Sands ?wrote: >> If it's just about folding versus not folding in the IRBuilder, a >> simple solution might be to just add a boolean property >> 'FoldingEnabled' (defaulting to true) to IRBuilder, and add an 'if >> (FoldingEnabled)' around all the 'if (Constant *Foo = >> dyn_cast(...))' instances. >> Then at runtime the user of IRBuilder could just call >> 'Builder.setFoldingEnabled(false)', for example in response to some >> command-line flag. > > thanks for the suggestion. ?I guess another way of doing this is to create a > new > folder class that dispatches to a target folder or a no folder depending on > the > value of some flag. A MaybeFolder? :) Yeah, that could work. It would certainly be a nice way to make sure there's no overhead unless the client intends to use it. From justin.holewinski at gmail.com Tue Mar 1 08:53:07 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Tue, 1 Mar 2011 09:53:07 -0500 Subject: [llvm-commits] [PATCH] Add 64-bit addressing to PTX backend Message-ID: This patch adds a new sub-target option to the PTX backend: 64bit. When this option is enabled, the generated PTX code will use a 64-bit pointer size, instead of the default 32-bit pointer size. This patch also fixes an issue with the function parameter ordering in PTX code. (NOTE: This patch requires the previous PTX backend patch I submitted yesterday to be applied.) -- Thanks, Justin Holewinski -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/939296bf/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Add-64-bit-addressing-to-PTX-backend.patch Type: text/x-patch Size: 15653 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/939296bf/attachment.bin From andersca at mac.com Tue Mar 1 09:05:01 2011 From: andersca at mac.com (Anders Carlsson) Date: Tue, 01 Mar 2011 15:05:01 -0000 Subject: [llvm-commits] [llvm] r126744 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp test/Transforms/InstCombine/and2.ll Message-ID: <20110301150501.C78762A6C12C@llvm.org> Author: andersca Date: Tue Mar 1 09:05:01 2011 New Revision: 126744 URL: http://llvm.org/viewvc/llvm-project?rev=126744&view=rev Log: Make InstCombiner::FoldAndOfICmps create a ConstantRange that's the intersection of the LHS and RHS ConstantRanges and return "false" when the range is empty. This simplifies some code and catches some extra cases. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp llvm/trunk/test/Transforms/InstCombine/and2.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=126744&r1=126743&r2=126744&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Tue Mar 1 09:05:01 2011 @@ -14,6 +14,7 @@ #include "InstCombine.h" #include "llvm/Intrinsics.h" #include "llvm/Analysis/InstructionSimplify.h" +#include "llvm/Support/ConstantRange.h" #include "llvm/Support/PatternMatch.h" using namespace llvm; using namespace PatternMatch; @@ -767,7 +768,17 @@ LHSCC == ICmpInst::ICMP_SGE || LHSCC == ICmpInst::ICMP_SLE || RHSCC == ICmpInst::ICMP_SGE || RHSCC == ICmpInst::ICMP_SLE) return 0; - + + // Make a constant range that's the intersection of the two icmp ranges. + // If the intersection is empty, we know that the result is false. + ConstantRange LHSRange = + ConstantRange::makeICmpRegion(LHSCC, LHSCst->getValue()); + ConstantRange RHSRange = + ConstantRange::makeICmpRegion(RHSCC, RHSCst->getValue()); + + if (LHSRange.intersectWith(RHSRange).isEmptySet()) + return ConstantInt::get(CmpInst::makeCmpResultType(LHS->getType()), 0); + // We can't fold (ugt x, C) & (sgt x, C2). if (!PredicatesFoldable(LHSCC, RHSCC)) return 0; @@ -800,10 +811,6 @@ case ICmpInst::ICMP_EQ: switch (RHSCC) { default: llvm_unreachable("Unknown integer condition code!"); - case ICmpInst::ICMP_EQ: // (X == 13 & X == 15) -> false - case ICmpInst::ICMP_UGT: // (X == 13 & X > 15) -> false - case ICmpInst::ICMP_SGT: // (X == 13 & X > 15) -> false - return ConstantInt::get(CmpInst::makeCmpResultType(LHS->getType()), 0); case ICmpInst::ICMP_NE: // (X == 13 & X != 15) -> X == 13 case ICmpInst::ICMP_ULT: // (X == 13 & X < 15) -> X == 13 case ICmpInst::ICMP_SLT: // (X == 13 & X < 15) -> X == 13 @@ -851,9 +858,6 @@ case ICmpInst::ICMP_SLT: switch (RHSCC) { default: llvm_unreachable("Unknown integer condition code!"); - case ICmpInst::ICMP_EQ: // (X s< 13 & X == 15) -> false - case ICmpInst::ICMP_SGT: // (X s< 13 & X s> 15) -> false - return ConstantInt::get(CmpInst::makeCmpResultType(LHS->getType()), 0); case ICmpInst::ICMP_UGT: // (X s< 13 & X u> 15) -> no change break; case ICmpInst::ICMP_NE: // (X s< 13 & X != 15) -> X < 13 Modified: llvm/trunk/test/Transforms/InstCombine/and2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/and2.ll?rev=126744&r1=126743&r2=126744&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/and2.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/and2.ll Tue Mar 1 09:05:01 2011 @@ -26,3 +26,12 @@ ; CHECK-NEXT: and i32 %X, %Y ; CHECK-NEXT: ret } + +define i1 @test4(i32 %X) { + %a = icmp ult i32 %X, 31 + %b = icmp slt i32 %X, 0 + %c = and i1 %a, %b + ret i1 %c +; CHECK: @test4 +; CHECK-NEXT: ret i1 false +} From baldrick at free.fr Tue Mar 1 09:15:44 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Mar 2011 15:15:44 -0000 Subject: [llvm-commits] [llvm] r126745 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Message-ID: <20110301151544.0F0202A6C12C@llvm.org> Author: baldrick Date: Tue Mar 1 09:15:43 2011 New Revision: 126745 URL: http://llvm.org/viewvc/llvm-project?rev=126745&view=rev Log: Add a few missed unary cases when legalizing vector results. Put some cases in alphabetical order. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=126745&r1=126744&r2=126745&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Tue Mar 1 09:15:43 2011 @@ -63,27 +63,33 @@ case ISD::VECTOR_SHUFFLE: R = ScalarizeVecRes_VECTOR_SHUFFLE(N); break; case ISD::VSETCC: R = ScalarizeVecRes_VSETCC(N); break; + case ISD::ANY_EXTEND: case ISD::CTLZ: case ISD::CTPOP: case ISD::CTTZ: case ISD::FABS: + case ISD::FCEIL: case ISD::FCOS: + case ISD::FEXP: + case ISD::FEXP2: + case ISD::FFLOOR: + case ISD::FLOG: + case ISD::FLOG10: + case ISD::FLOG2: + case ISD::FNEARBYINT: case ISD::FNEG: + case ISD::FP_EXTEND: case ISD::FP_TO_SINT: case ISD::FP_TO_UINT: + case ISD::FRINT: case ISD::FSIN: case ISD::FSQRT: case ISD::FTRUNC: - case ISD::FFLOOR: - case ISD::FCEIL: - case ISD::FRINT: - case ISD::FNEARBYINT: - case ISD::UINT_TO_FP: + case ISD::SIGN_EXTEND: case ISD::SINT_TO_FP: case ISD::TRUNCATE: - case ISD::SIGN_EXTEND: + case ISD::UINT_TO_FP: case ISD::ZERO_EXTEND: - case ISD::ANY_EXTEND: R = ScalarizeVecRes_UnaryOp(N); break; @@ -427,33 +433,33 @@ SplitVecRes_VECTOR_SHUFFLE(cast(N), Lo, Hi); break; - case ISD::CTTZ: + case ISD::ANY_EXTEND: case ISD::CTLZ: case ISD::CTPOP: - case ISD::FNEG: + case ISD::CTTZ: case ISD::FABS: - case ISD::FSQRT: - case ISD::FSIN: + case ISD::FCEIL: case ISD::FCOS: - case ISD::FTRUNC: + case ISD::FEXP: + case ISD::FEXP2: case ISD::FFLOOR: - case ISD::FCEIL: - case ISD::FRINT: + case ISD::FLOG: + case ISD::FLOG10: + case ISD::FLOG2: case ISD::FNEARBYINT: + case ISD::FNEG: case ISD::FP_EXTEND: case ISD::FP_TO_SINT: case ISD::FP_TO_UINT: + case ISD::FRINT: + case ISD::FSIN: + case ISD::FSQRT: + case ISD::FTRUNC: + case ISD::SIGN_EXTEND: case ISD::SINT_TO_FP: - case ISD::UINT_TO_FP: case ISD::TRUNCATE: - case ISD::SIGN_EXTEND: + case ISD::UINT_TO_FP: case ISD::ZERO_EXTEND: - case ISD::ANY_EXTEND: - case ISD::FEXP: - case ISD::FEXP2: - case ISD::FLOG: - case ISD::FLOG2: - case ISD::FLOG10: SplitVecRes_UnaryOp(N, Lo, Hi); break; @@ -990,11 +996,11 @@ case ISD::CTTZ: case ISD::CTLZ: case ISD::CTPOP: + case ISD::FP_EXTEND: case ISD::FP_TO_SINT: case ISD::FP_TO_UINT: case ISD::SINT_TO_FP: case ISD::UINT_TO_FP: - case ISD::FP_EXTEND: case ISD::FTRUNC: case ISD::TRUNCATE: case ISD::SIGN_EXTEND: @@ -1271,15 +1277,16 @@ Res = WidenVecRes_Shift(N); break; + case ISD::ANY_EXTEND: + case ISD::FP_EXTEND: case ISD::FP_ROUND: case ISD::FP_TO_SINT: case ISD::FP_TO_UINT: + case ISD::SIGN_EXTEND: case ISD::SINT_TO_FP: - case ISD::UINT_TO_FP: case ISD::TRUNCATE: - case ISD::SIGN_EXTEND: + case ISD::UINT_TO_FP: case ISD::ZERO_EXTEND: - case ISD::ANY_EXTEND: Res = WidenVecRes_Convert(N); break; @@ -1287,15 +1294,20 @@ case ISD::CTPOP: case ISD::CTTZ: case ISD::FABS: + case ISD::FCEIL: case ISD::FCOS: - case ISD::FNEG: - case ISD::FSIN: - case ISD::FSQRT: case ISD::FEXP: case ISD::FEXP2: + case ISD::FFLOOR: case ISD::FLOG: - case ISD::FLOG2: case ISD::FLOG10: + case ISD::FLOG2: + case ISD::FNEARBYINT: + case ISD::FNEG: + case ISD::FRINT: + case ISD::FSIN: + case ISD::FSQRT: + case ISD::FTRUNC: Res = WidenVecRes_Unary(N); break; } @@ -2005,8 +2017,8 @@ case ISD::EXTRACT_VECTOR_ELT: Res = WidenVecOp_EXTRACT_VECTOR_ELT(N); break; case ISD::STORE: Res = WidenVecOp_STORE(N); break; - case ISD::FP_ROUND: case ISD::FP_EXTEND: + case ISD::FP_ROUND: case ISD::FP_TO_SINT: case ISD::FP_TO_UINT: case ISD::SINT_TO_FP: From baldrick at free.fr Tue Mar 1 09:43:49 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Mar 2011 15:43:49 -0000 Subject: [llvm-commits] [dragonegg] r126747 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <20110301154349.BFAB92A6C12C@llvm.org> Author: baldrick Date: Tue Mar 1 09:43:49 2011 New Revision: 126747 URL: http://llvm.org/viewvc/llvm-project?rev=126747&view=rev Log: Have a few places that really want to fold constants use the TargetFolder directly. This is in case someone switches the builder to use a NoFolder. Modified: dragonegg/trunk/llvm-convert.cpp Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=126747&r1=126746&r2=126747&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Mar 1 09:43:49 2011 @@ -608,9 +608,8 @@ // If a previous proto existed with the wrong type, replace any uses of it // with the actual function and delete the proto. if (FnEntry) { - FnEntry->replaceAllUsesWith( - Builder.getFolder().CreateBitCast(Fn, FnEntry->getType()) - ); + FnEntry->replaceAllUsesWith + (TheFolder->CreateBitCast(Fn, FnEntry->getType())); changeLLVMConstant(FnEntry, Fn); FnEntry->eraseFromParent(); } @@ -1724,7 +1723,7 @@ ConstantInt::get(Type::getInt32Ty(Context), DECL_SOURCE_LINE(decl)); Constant *file = ConvertMetadataStringToGV(DECL_SOURCE_FILE(decl)); const Type *SBP = Type::getInt8PtrTy(Context); - file = Builder.getFolder().CreateBitCast(file, SBP); + file = TheFolder->CreateBitCast(file, SBP); // There may be multiple annotate attributes. Pass return of lookup_attr // to successive lookups. @@ -4067,7 +4066,7 @@ //TODO Constant *lineNo = ConstantInt::get(Type::getInt32Ty, LOCATION_LINE(locus)); //TODO Constant *file = ConvertMetadataStringToGV(LOCATION_FILE(locus)); //TODO const Type *SBP= Type::getInt8PtrTy(Context); -//TODO file = Builder.getFolder().CreateBitCast(file, SBP); +//TODO file = TheFolder->CreateBitCast(file, SBP); //TODO //TODO // Get arguments. //TODO tree arglist = CALL_EXPR_ARGS(stmt); @@ -4823,9 +4822,9 @@ " using zero"); ReadWrite = 0; } else { - ReadWrite = Builder.getFolder().CreateIntCast(cast(ReadWrite), - Type::getInt32Ty(Context), - /*isSigned*/false); + ReadWrite = TheFolder->CreateIntCast(cast(ReadWrite), + Type::getInt32Ty(Context), + /*isSigned*/false); } if (gimple_call_num_args(stmt) > 2) { @@ -4837,9 +4836,9 @@ warning(0, "invalid third argument to %<__builtin_prefetch%>; using 3"); Locality = 0; } else { - Locality = Builder.getFolder().CreateIntCast(cast(Locality), - Type::getInt32Ty(Context), - /*isSigned*/false); + Locality = TheFolder->CreateIntCast(cast(Locality), + Type::getInt32Ty(Context), + /*isSigned*/false); } } } From viridia at gmail.com Tue Mar 1 09:53:44 2011 From: viridia at gmail.com (Talin) Date: Tue, 1 Mar 2011 07:53:44 -0800 Subject: [llvm-commits] [llvm] r126714 - in /llvm/trunk: include/llvm/Constants.h lib/VMCore/Constants.cpp In-Reply-To: References: <20110228235327.6DF072A6C12C@llvm.org> Message-ID: Ah, good catch. Thanks On Mon, Feb 28, 2011 at 11:19 PM, Frits van Bommel wrote: > On Tue, Mar 1, 2011 at 12:53 AM, Talin wrote: > > +Constant* ConstantStruct::get(LLVMContext &Context, bool Packed, > > + Constant * Val, ...) { > > + va_list ap; > > + std::vector Values; > > + va_start(ap, Val); > > + while (Val) { > > + Values.push_back(Val); > > + Val = va_arg(ap, llvm::Constant*); > > + } > > Shouldn't there technically be a va_end right about here? > I'm not aware of any platform where that actually does anything, but > it can't hurt either... > > > + return get(Context, Values, Packed); > > +} > -- -- Talin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/95cddc98/attachment.html From Erik.Olofsson at hansoft.se Tue Mar 1 10:40:42 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Tue, 1 Mar 2011 17:40:42 +0100 Subject: [llvm-commits] [cfe-commits] [cfe-dev] [PATCH] Windows improvements In-Reply-To: References: <97510B8DF78E714D91EB4A27850A17DA0C3EACB8DC@winserv02.hansoft.local> <97510B8DF78E714D91EB4A27850A17DA0C3EACB911@winserv02.hansoft.local> <97510B8DF78E714D91EB4A27850A17DA0C3EACB91A@winserv02.hansoft.local> Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACBA93@winserv02.hansoft.local> > I think we need to split these entities. Clearly one might want to have vcpp- > like diagnostics even w/o MS extensions enabled (consider e.g. I'm > targeting some arch and want to integrate with visual studio). Ok, I will add a cmake option LLVM_ENABLE_MSVCSTYLEDIAGNOSTICS enabled by default on MSVC for this. It will choose the style of diagnostics at configure time. It could then be extended to be the default for a command line option choosing the style of diagnostics. I will send each patch separately to llvm-commits and cfe-commits as appropriate. Regards, Erik > -----Original Message----- > From: Anton Korobeynikov [mailto:anton at korobeynikov.info] > Sent: den 28 februari 2011 13:52 > To: Erik Olofsson > Cc: NAKAMURA Takumi; llvm-commits; cfe-commits > Subject: Re: [cfe-commits] [cfe-dev] [PATCH] Windows improvements > > Hi Erik > > > But what about if you then use a clang compiled in mingw to host itself. I > assume we need ms extensions enabled, and then _MSC_VER will be > defined. > I think we need to split these entities. Clearly one might want to have vcpp- > like diagnostics even w/o MS extensions enabled (consider e.g. I'm > targeting some arch and want to integrate with visual studio). > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University From fvbommel at gmail.com Tue Mar 1 10:59:44 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Tue, 1 Mar 2011 17:59:44 +0100 Subject: [llvm-commits] [llvm] r126744 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp test/Transforms/InstCombine/and2.ll In-Reply-To: <20110301150501.C78762A6C12C@llvm.org> References: <20110301150501.C78762A6C12C@llvm.org> Message-ID: On Tue, Mar 1, 2011 at 4:05 PM, Anders Carlsson wrote: > Log: > Make InstCombiner::FoldAndOfICmps create a ConstantRange that's the > intersection of the LHS and RHS ConstantRanges and return "false" when > the range is empty. > > This simplifies some code and catches some extra cases. This could be in SimplifyInstruction(), right? From stuart at apple.com Tue Mar 1 10:58:00 2011 From: stuart at apple.com (Stuart Hastings) Date: Tue, 01 Mar 2011 16:58:00 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r126750 - in /llvm-gcc-4.2/trunk/gcc/config/arm: llvm-arm-target.h llvm-arm.cpp Message-ID: <20110301165800.338FC2A6C12C@llvm.org> Author: stuart Date: Tue Mar 1 10:58:00 2011 New Revision: 126750 URL: http://llvm.org/viewvc/llvm-project?rev=126750&view=rev Log: Turn on ARM byval support in LLVM-GCC; followup to r126655. Radar 7662569. Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h?rev=126750&r1=126749&r2=126750&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h Tue Mar 1 10:58:00 2011 @@ -98,6 +98,13 @@ #define LLVM_SHOULD_NOT_USE_SHADOW_RETURN(X, CC) \ llvm_arm_should_pass_or_return_aggregate_in_regs((X), (CC)) +extern +bool llvm_arm_should_pass_aggregate_in_memory(tree, const Type *); + +#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY) \ + (llvm_arm_should_pass_aggregate_in_memory((X), (TY))) + + /* Vectors bigger than 128 are returned using sret. */ #define LLVM_SHOULD_RETURN_VECTOR_AS_SHADOW(X, isBuiltin) \ (TREE_INT_CST_LOW(TYPE_SIZE(X)) > 128) Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp?rev=126750&r1=126749&r2=126750&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Tue Mar 1 10:58:00 2011 @@ -2880,4 +2880,14 @@ return result && !TREE_ADDRESSABLE(TreeType); } +/* Target hook for llvm-abi.h. It returns true if an aggregate of the + specified type should be passed in memory. */ +bool llvm_arm_should_pass_aggregate_in_memory(tree TreeType, const Type *Ty) { + enum machine_mode Mode = TYPE_MODE(TreeType); + HOST_WIDE_INT Bytes = + (Mode == BLKmode) ? int_size_in_bytes(TreeType) : (int) GET_MODE_SIZE(Mode); + + return Bytes > 32; +} + /* LLVM LOCAL end (ENTIRE FILE!) */ From richard at xmos.com Tue Mar 1 11:05:20 2011 From: richard at xmos.com (Richard Osborne) Date: Tue, 1 Mar 2011 17:05:20 +0000 Subject: [llvm-commits] [PATCH] Optimize printf -> iprintf if there are no floating point arguments Message-ID: <4D6D2750.6020501@xmos.com> This patch adds an optimization to SimplifyLibCalls which transforms calls to printf into iprintf calls. iprintf is a restricted version of printf provided by newlib without floating-point formatting (see http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-February/037832.html). This patch uses TargetLibraryInfo to determine whether iprintf is available. Currently it is only marked as available on the XCore target. I intend to add similar optimizations for sprintf / fprintf once this patch is accepted. Please let me know if this is OK to commit. Thanks, Richard -- Richard Osborne | XMOS http://www.xmos.com -------------- next part -------------- A non-text attachment was scrubbed... Name: iprintf.patch Type: text/x-patch Size: 7934 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/70a38ac8/attachment.bin From viridia at gmail.com Tue Mar 1 12:00:49 2011 From: viridia at gmail.com (Talin) Date: Tue, 01 Mar 2011 18:00:49 -0000 Subject: [llvm-commits] [llvm] r126759 - in /llvm/trunk: cmake/modules/LLVMLibDeps.cmake lib/VMCore/Constants.cpp Message-ID: <20110301180049.7B7672A6C12F@llvm.org> Author: talin Date: Tue Mar 1 12:00:49 2011 New Revision: 126759 URL: http://llvm.org/viewvc/llvm-project?rev=126759&view=rev Log: Added missing va_end(). Modified: llvm/trunk/cmake/modules/LLVMLibDeps.cmake llvm/trunk/lib/VMCore/Constants.cpp Modified: llvm/trunk/cmake/modules/LLVMLibDeps.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMLibDeps.cmake?rev=126759&r1=126758&r2=126759&view=diff ============================================================================== --- llvm/trunk/cmake/modules/LLVMLibDeps.cmake (original) +++ llvm/trunk/cmake/modules/LLVMLibDeps.cmake Tue Mar 1 12:00:49 2011 @@ -61,7 +61,7 @@ set(MSVC_LIB_DEPS_LLVMX86CodeGen LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget LLVMX86AsmPrinter LLVMX86Info LLVMX86Utils) set(MSVC_LIB_DEPS_LLVMX86Disassembler LLVMMC LLVMSupport LLVMX86Info) set(MSVC_LIB_DEPS_LLVMX86Info LLVMMC LLVMSupport) -set(MSVC_LIB_DEPS_LLVMX86Utils LLVMSupport) +set(MSVC_LIB_DEPS_LLVMX86Utils LLVMCore LLVMSupport) set(MSVC_LIB_DEPS_LLVMXCoreCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget LLVMXCoreInfo) set(MSVC_LIB_DEPS_LLVMXCoreInfo LLVMMC LLVMSupport) set(MSVC_LIB_DEPS_LLVMipa LLVMAnalysis LLVMCore LLVMSupport) Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=126759&r1=126758&r2=126759&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Tue Mar 1 12:00:49 2011 @@ -652,6 +652,7 @@ Values.push_back(Val); Val = va_arg(ap, llvm::Constant*); } + va_end(ap); return get(Context, Values, Packed); } From david_dean at apple.com Tue Mar 1 12:12:02 2011 From: david_dean at apple.com (David Dean) Date: Tue, 01 Mar 2011 18:12:02 -0000 Subject: [llvm-commits] [zorg] r126764 - /zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py Message-ID: <20110301181202.741E12A6C12C@llvm.org> Author: ddean Date: Tue Mar 1 12:12:02 2011 New Revision: 126764 URL: http://llvm.org/viewvc/llvm-project?rev=126764&view=rev Log: Add new method to LLVMGCCBuilder.py to package and upload llvm-gcc artifacts after build. Add new parameter to getLLVMGCCBuildFactory() to enable using new method. Add call to new method into getLLVMGCCBuildFactory() when new parameter is set. Modified: zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py Modified: zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py?rev=126764&r1=126763&r2=126764&view=diff ============================================================================== --- zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py (original) +++ zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py Tue Mar 1 12:12:02 2011 @@ -15,7 +15,7 @@ stage2_config='Release+Asserts', make='make', extra_configure_args=[], extra_languages=None, verbose=False, env = {}, defaultBranch='trunk', - timeout=20): + timeout=20, package_dst=None): if build or host or target: if not build or not host or not target: raise ValueError,"Must specify all of 'build', 'host', 'target' if used." @@ -259,6 +259,34 @@ "llvm-gcc", "(stage 2)"], workdir="llvm-gcc.obj.2", env=env)) + if package_dst: + addPackageStep(f, package_dst, obj_path='llvm-gcc.install.2') return f +import os +def addPackageStep(f, package_dst, + obj_path, + project = '%(builder)s', + info_string='r%(got_revision)s'): + + # Package and upload. + name = WithProperties( + os.path.join("%(builddir)s", obj_path, + "%s-%s-b%%(buildnumber)s.tar.gz" % (project, info_string))) + f.addStep(ShellCommand(name='pkg.tar', + description="tar root", + command=["tar", "zcvf", name, "./"], + workdir=os.path.join(obj_path, "%s.roots" % project, + "%s~dst" % project), + warnOnFailure=True, + flunkOnFailure=False, + haltOnFailure=False)) + f.addStep(ShellCommand(name='pkg.upload', + description="upload root", + command=["scp", name, package_dst], + workdir=".", + warnOnFailure=True, + flunkOnFailure=False, + haltOnFailure=False)) + From fvbommel at gmail.com Tue Mar 1 12:38:28 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Tue, 1 Mar 2011 19:38:28 +0100 Subject: [llvm-commits] [PATCH] Optimize printf -> iprintf if there are no floating point arguments In-Reply-To: <4D6D2750.6020501@xmos.com> References: <4D6D2750.6020501@xmos.com> Message-ID: Your second test doesn't check what you think it does. Check for '@printf', not just 'printf'. 'iprintf' contains 'printf' too. From bob.wilson at apple.com Tue Mar 1 13:21:00 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 1 Mar 2011 11:21:00 -0800 Subject: [llvm-commits] [llvm] r126655 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/CodeGen/CallingConvLower.cpp lib/Target/ARM/ARMCallingConv.td lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h In-Reply-To: <20110228171753.7DB6D2A6C12C@llvm.org> References: <20110228171753.7DB6D2A6C12C@llvm.org> Message-ID: On Feb 28, 2011, at 9:17 AM, Stuart Hastings wrote: > Author: stuart > Date: Mon Feb 28 11:17:53 2011 > New Revision: 126655 > > URL: http://llvm.org/viewvc/llvm-project?rev=126655&view=rev > Log: > Support for byval parameters on ARM. Will be enabled by a forthcoming > patch to the front-end. Radar 7662569. > > Modified: llvm/trunk/lib/Target/ARM/ARMCallingConv.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCallingConv.td?rev=126655&r1=126654&r2=126655&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMCallingConv.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMCallingConv.td Mon Feb 28 11:17:53 2011 > @@ -22,6 +22,9 @@ > //===----------------------------------------------------------------------===// > def CC_ARM_APCS : CallingConv<[ > > + // Handles byval parameters. > + CCIfByVal>, This should only require 4-byte alignment. The extra alignment here is causing unnecessary dynamic realignment. Beyond that, the patch is not correct because it doesn't follow the ABI, at least for APCS -- I didn't check AAPCS. If there are unused argument registers, the beginning of the aggregate needs to be passed in them, with the remainder passed byval on the stack. With the patch as it is now, it just puts the entire aggregate on the stack regardless of whether any argument registers are available. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/c6a95584/attachment.html From stuart at apple.com Tue Mar 1 13:24:31 2011 From: stuart at apple.com (Stuart Hastings) Date: Tue, 1 Mar 2011 11:24:31 -0800 Subject: [llvm-commits] [llvm] r126655 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/CodeGen/CallingConvLower.cpp lib/Target/ARM/ARMCallingConv.td lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h In-Reply-To: References: <20110228171753.7DB6D2A6C12C@llvm.org> Message-ID: On Mar 1, 2011, at 11:21 AM, Bob Wilson wrote: > > On Feb 28, 2011, at 9:17 AM, Stuart Hastings wrote: > >> Author: stuart >> Date: Mon Feb 28 11:17:53 2011 >> New Revision: 126655 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=126655&view=rev >> Log: >> Support for byval parameters on ARM. Will be enabled by a forthcoming >> patch to the front-end. Radar 7662569. >> >> Modified: llvm/trunk/lib/Target/ARM/ARMCallingConv.td >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCallingConv.td?rev=126655&r1=126654&r2=126655&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/ARM/ARMCallingConv.td (original) >> +++ llvm/trunk/lib/Target/ARM/ARMCallingConv.td Mon Feb 28 11:17:53 2011 >> @@ -22,6 +22,9 @@ >> //===----------------------------------------------------------------------===// >> def CC_ARM_APCS : CallingConv<[ >> >> + // Handles byval parameters. >> + CCIfByVal>, > > This should only require 4-byte alignment. The extra alignment here is causing unnecessary dynamic realignment. O.K. > Beyond that, the patch is not correct because it doesn't follow the ABI, at least for APCS -- I didn't check AAPCS. If there are unused argument registers, the beginning of the aggregate needs to be passed in them, with the remainder passed byval on the stack. With the patch as it is now, it just puts the entire aggregate on the stack regardless of whether any argument registers are available. I'll revert. Thanks, stuart -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/35426987/attachment.html From stuart at apple.com Tue Mar 1 13:29:11 2011 From: stuart at apple.com (Stuart Hastings) Date: Tue, 01 Mar 2011 19:29:11 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r126771 - in /llvm-gcc-4.2/trunk/gcc/config/arm: llvm-arm-target.h llvm-arm.cpp Message-ID: <20110301192911.2D7DF2A6C12C@llvm.org> Author: stuart Date: Tue Mar 1 13:29:10 2011 New Revision: 126771 URL: http://llvm.org/viewvc/llvm-project?rev=126771&view=rev Log: Revert 126750 for now, disabling ARM byval support, in order to address ABI issues. Radar 7662569. Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h?rev=126771&r1=126770&r2=126771&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h Tue Mar 1 13:29:10 2011 @@ -98,13 +98,6 @@ #define LLVM_SHOULD_NOT_USE_SHADOW_RETURN(X, CC) \ llvm_arm_should_pass_or_return_aggregate_in_regs((X), (CC)) -extern -bool llvm_arm_should_pass_aggregate_in_memory(tree, const Type *); - -#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY) \ - (llvm_arm_should_pass_aggregate_in_memory((X), (TY))) - - /* Vectors bigger than 128 are returned using sret. */ #define LLVM_SHOULD_RETURN_VECTOR_AS_SHADOW(X, isBuiltin) \ (TREE_INT_CST_LOW(TYPE_SIZE(X)) > 128) Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp?rev=126771&r1=126770&r2=126771&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Tue Mar 1 13:29:10 2011 @@ -2880,14 +2880,4 @@ return result && !TREE_ADDRESSABLE(TreeType); } -/* Target hook for llvm-abi.h. It returns true if an aggregate of the - specified type should be passed in memory. */ -bool llvm_arm_should_pass_aggregate_in_memory(tree TreeType, const Type *Ty) { - enum machine_mode Mode = TYPE_MODE(TreeType); - HOST_WIDE_INT Bytes = - (Mode == BLKmode) ? int_size_in_bytes(TreeType) : (int) GET_MODE_SIZE(Mode); - - return Bytes > 32; -} - /* LLVM LOCAL end (ENTIRE FILE!) */ From gohman at apple.com Tue Mar 1 13:50:55 2011 From: gohman at apple.com (Dan Gohman) Date: Tue, 01 Mar 2011 19:50:55 -0000 Subject: [llvm-commits] [llvm] r126773 - in /llvm/trunk: include/llvm/Bitcode/Archive.h lib/Archive/ArchiveWriter.cpp Message-ID: <20110301195055.A623C2A6C12D@llvm.org> Author: djg Date: Tue Mar 1 13:50:55 2011 New Revision: 126773 URL: http://llvm.org/viewvc/llvm-project?rev=126773&view=rev Log: Revert PathV2 changes, as sys::fs::unique_file is not finished yet. Modified: llvm/trunk/include/llvm/Bitcode/Archive.h llvm/trunk/lib/Archive/ArchiveWriter.cpp Modified: llvm/trunk/include/llvm/Bitcode/Archive.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Archive.h?rev=126773&r1=126772&r2=126773&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/Archive.h (original) +++ llvm/trunk/include/llvm/Bitcode/Archive.h Tue Mar 1 13:50:55 2011 @@ -25,7 +25,6 @@ namespace llvm { class MemoryBuffer; - class raw_ostream; // Forward declare classes class Module; // From VMCore @@ -483,7 +482,7 @@ bool loadSymbolTable(std::string* ErrMessage); /// @brief Write the symbol table to an ofstream. - void writeSymbolTable(raw_ostream& ARFile); + void writeSymbolTable(std::ofstream& ARFile); /// Writes one ArchiveMember to an ofstream. If an error occurs, returns /// false, otherwise true. If an error occurs and error is non-null then @@ -492,7 +491,7 @@ /// @returns true Writing member failed, \p error set to error message bool writeMember( const ArchiveMember& member, ///< The member to be written - raw_ostream& ARFile, ///< The file to write member onto + std::ofstream& ARFile, ///< The file to write member onto bool CreateSymbolTable, ///< Should symbol table be created? bool TruncateNames, ///< Should names be truncated to 11 chars? bool ShouldCompress, ///< Should the member be compressed? Modified: llvm/trunk/lib/Archive/ArchiveWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Archive/ArchiveWriter.cpp?rev=126773&r1=126772&r2=126773&view=diff ============================================================================== --- llvm/trunk/lib/Archive/ArchiveWriter.cpp (original) +++ llvm/trunk/lib/Archive/ArchiveWriter.cpp Tue Mar 1 13:50:55 2011 @@ -18,7 +18,6 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Process.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/Support/Signals.h" #include "llvm/Support/system_error.h" #include @@ -28,7 +27,7 @@ // Write an integer using variable bit rate encoding. This saves a few bytes // per entry in the symbol table. -static inline void writeInteger(unsigned num, raw_ostream& ARFile) { +static inline void writeInteger(unsigned num, std::ofstream& ARFile) { while (1) { if (num < 0x80) { // done? ARFile << (unsigned char)num; @@ -202,14 +201,14 @@ bool Archive::writeMember( const ArchiveMember& member, - raw_ostream& ARFile, + std::ofstream& ARFile, bool CreateSymbolTable, bool TruncateNames, bool ShouldCompress, std::string* ErrMsg ) { - unsigned filepos = ARFile.tell(); + unsigned filepos = ARFile.tellp(); filepos -= 8; // Get the data and its size either from the @@ -282,7 +281,7 @@ ARFile.write(data,fSize); // Make sure the member is an even length - if ((ARFile.tell() & 1) == 1) + if ((ARFile.tellp() & 1) == 1) ARFile << ARFILE_PAD; // Close the mapped file if it was opened @@ -292,7 +291,7 @@ // Write out the LLVM symbol table as an archive member to the file. void -Archive::writeSymbolTable(raw_ostream& ARFile) { +Archive::writeSymbolTable(std::ofstream& ARFile) { // Construct the symbol table's header ArchiveMemberHeader Hdr; @@ -316,7 +315,7 @@ #ifndef NDEBUG // Save the starting position of the symbol tables data content. - unsigned startpos = ARFile.tell(); + unsigned startpos = ARFile.tellp(); #endif // Write out the symbols sequentially @@ -333,7 +332,7 @@ #ifndef NDEBUG // Now that we're done with the symbol table, get the ending file position - unsigned endpos = ARFile.tell(); + unsigned endpos = ARFile.tellp(); #endif // Make sure that the amount we wrote is what we pre-computed. This is @@ -362,20 +361,25 @@ } // Create a temporary file to store the archive in - SmallString<128> TempArchivePath; - int ArchFD; - if (error_code ec = - sys::fs::unique_file("%%-%%-%%-%%-" + sys::path::filename(archPath.str()), - ArchFD, TempArchivePath)) { - if (ErrMsg) *ErrMsg = ec.message(); + sys::Path TmpArchive = archPath; + if (TmpArchive.createTemporaryFileOnDisk(ErrMsg)) return true; - } // Make sure the temporary gets removed if we crash - sys::RemoveFileOnSignal(sys::Path(TempArchivePath.str())); + sys::RemoveFileOnSignal(TmpArchive); // Create archive file for output. - raw_fd_ostream ArchiveFile(ArchFD, true); + std::ios::openmode io_mode = std::ios::out | std::ios::trunc | + std::ios::binary; + std::ofstream ArchiveFile(TmpArchive.c_str(), io_mode); + + // Check for errors opening or creating archive file. + if (!ArchiveFile.is_open() || ArchiveFile.bad()) { + TmpArchive.eraseFromDisk(); + if (ErrMsg) + *ErrMsg = "Error opening archive file: " + archPath.str(); + return true; + } // If we're creating a symbol table, reset it now if (CreateSymbolTable) { @@ -391,9 +395,8 @@ for (MembersList::iterator I = begin(), E = end(); I != E; ++I) { if (writeMember(*I, ArchiveFile, CreateSymbolTable, TruncateNames, Compress, ErrMsg)) { + TmpArchive.eraseFromDisk(); ArchiveFile.close(); - bool existed; - sys::fs::remove(TempArchivePath.str(), existed); return true; } } @@ -408,12 +411,12 @@ // ensure compatibility with other archivers we need to put the symbol // table first in the file. Unfortunately, this means mapping the file // we just wrote back in and copying it to the destination file. - SmallString<128> TempArchiveWithSymbolTablePath; + sys::Path FinalFilePath = archPath; // Map in the archive we just wrote. { OwningPtr arch; - if (error_code ec = MemoryBuffer::getFile(TempArchivePath.c_str(), arch)) { + if (error_code ec = MemoryBuffer::getFile(TmpArchive.c_str(), arch)) { if (ErrMsg) *ErrMsg = ec.message(); return true; @@ -422,15 +425,17 @@ // Open another temporary file in order to avoid invalidating the // mmapped data - if (error_code ec = - sys::fs::unique_file("%%-%%-%%-%%-" + sys::path::filename(archPath.str()), - ArchFD, TempArchiveWithSymbolTablePath)) { - if (ErrMsg) *ErrMsg = ec.message(); + if (FinalFilePath.createTemporaryFileOnDisk(ErrMsg)) return true; - } - sys::RemoveFileOnSignal(sys::Path(TempArchiveWithSymbolTablePath.str())); + sys::RemoveFileOnSignal(FinalFilePath); - raw_fd_ostream FinalFile(ArchFD, true); + std::ofstream FinalFile(FinalFilePath.c_str(), io_mode); + if (!FinalFile.is_open() || FinalFile.bad()) { + TmpArchive.eraseFromDisk(); + if (ErrMsg) + *ErrMsg = "Error opening archive file: " + FinalFilePath.str(); + return true; + } // Write the file magic number FinalFile << ARFILE_MAGIC; @@ -443,8 +448,7 @@ if (foreignST) { if (writeMember(*foreignST, FinalFile, false, false, false, ErrMsg)) { FinalFile.close(); - bool existed; - sys::fs::remove(TempArchiveWithSymbolTablePath.str(), existed); + TmpArchive.eraseFromDisk(); return true; } } @@ -462,11 +466,8 @@ } // free arch. // Move the final file over top of TmpArchive - if (error_code ec = sys::fs::rename(TempArchiveWithSymbolTablePath.str(), - TempArchivePath.str())) { - if (ErrMsg) *ErrMsg = ec.message(); + if (FinalFilePath.renamePathOnDisk(TmpArchive, ErrMsg)) return true; - } } // Before we replace the actual archive, we need to forget all the @@ -474,11 +475,8 @@ // this because we cannot replace an open file on Windows. cleanUpMemory(); - if (error_code ec = sys::fs::rename(TempArchivePath.str(), - archPath.str())) { - if (ErrMsg) *ErrMsg = ec.message(); + if (TmpArchive.renamePathOnDisk(archPath, ErrMsg)) return true; - } // Set correct read and write permissions after temporary file is moved // to final destination path. From evan.cheng at apple.com Tue Mar 1 13:56:00 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 1 Mar 2011 11:56:00 -0800 Subject: [llvm-commits] [llvm] r126655 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/CodeGen/CallingConvLower.cpp lib/Target/ARM/ARMCallingConv.td lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h In-Reply-To: References: <20110228171753.7DB6D2A6C12C@llvm.org> Message-ID: <1023AD3E-AA0F-4C33-88EE-C6355838881B@apple.com> On Mar 1, 2011, at 11:21 AM, Bob Wilson wrote: > > On Feb 28, 2011, at 9:17 AM, Stuart Hastings wrote: > >> Author: stuart >> Date: Mon Feb 28 11:17:53 2011 >> New Revision: 126655 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=126655&view=rev >> Log: >> Support for byval parameters on ARM. Will be enabled by a forthcoming >> patch to the front-end. Radar 7662569. >> >> Modified: llvm/trunk/lib/Target/ARM/ARMCallingConv.td >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCallingConv.td?rev=126655&r1=126654&r2=126655&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/ARM/ARMCallingConv.td (original) >> +++ llvm/trunk/lib/Target/ARM/ARMCallingConv.td Mon Feb 28 11:17:53 2011 >> @@ -22,6 +22,9 @@ >> //===----------------------------------------------------------------------===// >> def CC_ARM_APCS : CallingConv<[ >> >> + // Handles byval parameters. >> + CCIfByVal>, > > This should only require 4-byte alignment. The extra alignment here is causing unnecessary dynamic realignment. > > Beyond that, the patch is not correct because it doesn't follow the ABI, at least for APCS -- I didn't check AAPCS. If there are unused argument registers, the beginning of the aggregate needs to be passed in them, with the remainder passed byval on the stack. With the patch as it is now, it just puts the entire aggregate on the stack regardless of whether any argument registers are available. Is that a frontend or backend issue? For x86, llvm-gcc is responsible for making sure ABI conformance. Evan > > _______________________________________________ > 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/20110301/eb03b005/attachment.html From bob.wilson at apple.com Tue Mar 1 14:01:43 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 1 Mar 2011 12:01:43 -0800 Subject: [llvm-commits] [llvm] r126655 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/CodeGen/CallingConvLower.cpp lib/Target/ARM/ARMCallingConv.td lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h In-Reply-To: <1023AD3E-AA0F-4C33-88EE-C6355838881B@apple.com> References: <20110228171753.7DB6D2A6C12C@llvm.org> <1023AD3E-AA0F-4C33-88EE-C6355838881B@apple.com> Message-ID: <6BF345E5-98C3-46CD-94EA-FD1DDCF80C3D@apple.com> On Mar 1, 2011, at 11:56 AM, Evan Cheng wrote: > > On Mar 1, 2011, at 11:21 AM, Bob Wilson wrote: > >> >> On Feb 28, 2011, at 9:17 AM, Stuart Hastings wrote: >> >>> Author: stuart >>> Date: Mon Feb 28 11:17:53 2011 >>> New Revision: 126655 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=126655&view=rev >>> Log: >>> Support for byval parameters on ARM. Will be enabled by a forthcoming >>> patch to the front-end. Radar 7662569. >>> >>> Modified: llvm/trunk/lib/Target/ARM/ARMCallingConv.td >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCallingConv.td?rev=126655&r1=126654&r2=126655&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Target/ARM/ARMCallingConv.td (original) >>> +++ llvm/trunk/lib/Target/ARM/ARMCallingConv.td Mon Feb 28 11:17:53 2011 >>> @@ -22,6 +22,9 @@ >>> //===----------------------------------------------------------------------===// >>> def CC_ARM_APCS : CallingConv<[ >>> >>> + // Handles byval parameters. >>> + CCIfByVal>, >> >> This should only require 4-byte alignment. The extra alignment here is causing unnecessary dynamic realignment. >> >> Beyond that, the patch is not correct because it doesn't follow the ABI, at least for APCS -- I didn't check AAPCS. If there are unused argument registers, the beginning of the aggregate needs to be passed in them, with the remainder passed byval on the stack. With the patch as it is now, it just puts the entire aggregate on the stack regardless of whether any argument registers are available. > > Is that a frontend or backend issue? For x86, llvm-gcc is responsible for making sure ABI conformance. It could be done either way. Currently llvm-gcc for ARM tracks register usage only for VFP registers when using the hard float variant of AAPCS. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/6e747c8f/attachment.html From stuart at apple.com Tue Mar 1 14:02:24 2011 From: stuart at apple.com (Stuart Hastings) Date: Tue, 1 Mar 2011 12:02:24 -0800 Subject: [llvm-commits] [llvm] r126655 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/CodeGen/CallingConvLower.cpp lib/Target/ARM/ARMCallingConv.td lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h In-Reply-To: <1023AD3E-AA0F-4C33-88EE-C6355838881B@apple.com> References: <20110228171753.7DB6D2A6C12C@llvm.org> <1023AD3E-AA0F-4C33-88EE-C6355838881B@apple.com> Message-ID: On Mar 1, 2011, at 11:56 AM, Evan Cheng wrote: > > On Mar 1, 2011, at 11:21 AM, Bob Wilson wrote: > >> >> On Feb 28, 2011, at 9:17 AM, Stuart Hastings wrote: >> >>> Author: stuart >>> Date: Mon Feb 28 11:17:53 2011 >>> New Revision: 126655 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=126655&view=rev >>> Log: >>> Support for byval parameters on ARM. Will be enabled by a forthcoming >>> patch to the front-end. Radar 7662569. >>> >>> Modified: llvm/trunk/lib/Target/ARM/ARMCallingConv.td >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCallingConv.td?rev=126655&r1=126654&r2=126655&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Target/ARM/ARMCallingConv.td (original) >>> +++ llvm/trunk/lib/Target/ARM/ARMCallingConv.td Mon Feb 28 11:17:53 2011 >>> @@ -22,6 +22,9 @@ >>> //===----------------------------------------------------------------------===// >>> def CC_ARM_APCS : CallingConv<[ >>> >>> + // Handles byval parameters. >>> + CCIfByVal>, >> >> This should only require 4-byte alignment. The extra alignment here is causing unnecessary dynamic realignment. >> >> Beyond that, the patch is not correct because it doesn't follow the ABI, at least for APCS -- I didn't check AAPCS. If there are unused argument registers, the beginning of the aggregate needs to be passed in them, with the remainder passed byval on the stack. With the patch as it is now, it just puts the entire aggregate on the stack regardless of whether any argument registers are available. > > Is that a frontend or backend issue? For x86, llvm-gcc is responsible for making sure ABI conformance. Back-end. I haven't reverted/tweaked the back-end parts of the patch because they're harmless without the front-end part. It's "turned off" for now, while I work on addressing Bob's comments. stuart > Evan > >> >> _______________________________________________ >> 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/20110301/4ec4fd75/attachment.html From vmle at ucdavis.edu Tue Mar 1 14:12:29 2011 From: vmle at ucdavis.edu (Vu Le) Date: Tue, 1 Mar 2011 12:12:29 -0800 Subject: [llvm-commits] Patch for simplifying regions In-Reply-To: <4D6CF971.5050300@fim.uni-passau.de> References: <4D4882FC.8060102@fim.uni-passau.de> <4D6BCEBA.9080609@fim.uni-passau.de> <4D6CF971.5050300@fim.uni-passau.de> Message-ID: Hi Tobias, Thanks for the feedback. On Tue, Mar 1, 2011 at 5:49 AM, Tobias Grosser wrote: > On 02/28/2011 02:52 PM, Vu Le wrote: > >> Hi Tobias, >> >> I did make some changes to use splitBlockPredecessors in splitting >> entry nodes. >> > > Thanks for your fast reaction. The patch looks very nice. Though I have > some comments that we need to fix before committing it. > > Thank you. > > I tested it with coreutils and MySQL together with region-extractor pass. >> > Nice. > > > If you're still interested in region-extractor pass, I'll make a patch. >> > Yes. I am extremely interested. > > diff --git a/include/llvm/InitializePasses.h >> b/include/llvm/InitializePasses.h >> index 02dbfbd..0591845 100644 >> --- a/include/llvm/InitializePasses.h >> +++ b/include/llvm/InitializePasses.h >> @@ -192,6 +192,7 @@ void initializeRegionInfoPass(PassRegistry&); >> void initializeRegionOnlyPrinterPass(PassRegistry&); >> void initializeRegionOnlyViewerPass(PassRegistry&); >> void initializeRegionPrinterPass(PassRegistry&); >> +void initializeRegionSimplifyPass(PassRegistry&); >> void initializeRegionViewerPass(PassRegistry&); >> void initializeRegisterCoalescerAnalysisGroup(PassRegistry&); >> void initializeRenderMachineFunctionPass(PassRegistry&); >> diff --git a/include/llvm/LinkAllPasses.h b/include/llvm/LinkAllPasses.h >> index 69e1bd9..ea1faec 100644 >> --- a/include/llvm/LinkAllPasses.h >> +++ b/include/llvm/LinkAllPasses.h >> @@ -114,7 +114,8 @@ namespace { >> (void) llvm::createRegionInfoPass(); >> (void) llvm::createRegionOnlyPrinterPass(); >> (void) llvm::createRegionOnlyViewerPass(); >> - (void) llvm::createRegionPrinterPass(); >> + (void) llvm::createRegionPrinterPass(); >> > This change does not seem to be needed. Please remove it. > > OK > + (void) llvm::createRegionSimplifyPass(); >> (void) llvm::createRegionViewerPass(); >> (void) llvm::createSCCPPass(); >> (void) llvm::createScalarReplAggregatesPass(); >> diff --git a/include/llvm/Transforms/Scalar.h >> b/include/llvm/Transforms/Scalar.h >> index 6f2a38e..e3ca06a 100644 >> --- a/include/llvm/Transforms/Scalar.h >> +++ b/include/llvm/Transforms/Scalar.h >> @@ -349,6 +349,12 @@ Pass *createCorrelatedValuePropagationPass(); >> FunctionPass *createInstructionSimplifierPass(); >> extern char&InstructionSimplifierID; >> >> >> +//===----------------------------------------------------------------------===// >> +// >> +// RegionSimplify - Simplify refined regions, if possible. >> > Are there cases when it is not possible? Would be interesting to mention > those. > > It is when a region has function entry as its entry and a single edge exit. But then it is a simple region, I suppose. I'll remove the "if possible" part. +Pass *createRegionSimplifyPass(); >> + >> } // End llvm namespace >> >> #endif >> diff --git a/lib/Transforms/Scalar/CMakeLists.txt >> b/lib/Transforms/Scalar/CMakeLists.txt >> index 106fb8f..53fcf69 100644 >> --- a/lib/Transforms/Scalar/CMakeLists.txt >> +++ b/lib/Transforms/Scalar/CMakeLists.txt >> @@ -23,6 +23,7 @@ add_llvm_library(LLVMScalarOpts >> MemCpyOptimizer.cpp >> Reassociate.cpp >> Reg2Mem.cpp >> + RegionSimplify.cpp >> SCCP.cpp >> Scalar.cpp >> ScalarReplAggregates.cpp >> diff --git a/lib/Transforms/Scalar/RegionSimplify.cpp >> b/lib/Transforms/Scalar/RegionSimplify.cpp >> new file mode 100644 >> index 0000000..65e4d5c >> --- /dev/null >> +++ b/lib/Transforms/Scalar/RegionSimplify.cpp >> @@ -0,0 +1,185 @@ >> +//===- SeSeRegionInfo.cpp >> -------------------------------------------------===// >> +// >> +// The LLVM Compiler Infrastructure >> +// >> +// This file is distributed under the University of Illinois Open Source >> +// License. See LICENSE.TXT for details. >> +// >> >> +//===----------------------------------------------------------------------===// >> +// >> +// This file converts refined regions detected by the RegionInfo analysis >> +// into simple regions. >> +// >> >> +//===----------------------------------------------------------------------===// >> + >> +#include "llvm/Instructions.h" >> +#include "llvm/ADT/Statistic.h" >> +#include "llvm/Analysis/Dominators.h" >> +#include "llvm/Analysis/RegionPass.h" >> +#include "llvm/Analysis/RegionInfo.h" >> +#include "llvm/Transforms/Utils/BasicBlockUtils.h" >> + >> +#define DEBUG_TYPE "regionsimplify" >> > Can we call the pass "region-simplify"? Like "loop-simplify" (The name was > recently changed) > > Sure > +using namespace llvm; >> + >> +STATISTIC(NumEntries, "The # of created entry edges"); >> +STATISTIC(NumExits, "The # of created exit edges"); >> + >> +namespace { >> +class RegionSimplify: public RegionPass { >> + bool modified; >> + Region *CR; >> + void createSingleEntryEdge(Region *R); >> + void createSingleExitEdge(Region *R); >> +public: >> + static char ID; >> + explicit RegionSimplify() : >> + RegionPass(ID) { >> + initializeRegionSimplifyPass(*PassRegistry::getPassRegistry()); >> + } >> + >> + virtual void print(raw_ostream&O, const Module *M) const; >> + >> + virtual bool runOnRegion(Region *R, RGPassManager&RGM); >> + virtual void getAnalysisUsage(AnalysisUsage&AU) const; >> +}; >> +} >> + >> +INITIALIZE_PASS(RegionSimplify, "regionsimplify", >> > "regionsimplify" -> "region-simplify" > OK > > + "Transform refined regions into simple regions", false, false) >> + >> +char RegionSimplify::ID = 0; >> +namespace llvm { >> +Pass *createRegionSimplifyPass() { >> + return new RegionSimplify(); >> +} >> +} >> + >> +void RegionSimplify::print(raw_ostream&O, const Module *M) const { >> >> + if (!modified) >> + return; >> + >> + BasicBlock *enteringBlock = CR->getEnteringBlock(); >> + BasicBlock *exitingBlock = CR->getExitingBlock(); >> + >> + O<< "\nRegion: ["<< CR->getNameStr()<< "] Edges:\n"; >> + if (enteringBlock) >> + O<< " Entry: ]"<< enteringBlock->getNameStr()<< " => " >> +<< enteringBlock->getNameStr()<< "]\n"; >> + if (exitingBlock) >> + O<< " Exit: ["<< exitingBlock->getNameStr()<< " => " >> +<< exitingBlock->getNameStr()<< "[\n"; >> + >> + O<< "\n"; >> +} >> + >> +void RegionSimplify::getAnalysisUsage(AnalysisUsage&AU) const { >> + AU.addPreserved (); >> + AU.addPreserved (); >> + AU.addRequired (); >> +} >> + >> +// createSingleEntryEdge - Split the entry basic block of the given >> >> +// region after the last PHINode to form a single entry edge. >> +void RegionSimplify::createSingleEntryEdge(Region *R) { >> + BasicBlock *oldEntry = R->getEntry(); >> + SmallVector Preds; >> >> + for (pred_iterator PI = pred_begin(oldEntry), PE = pred_end(oldEntry); >> + PI != PE; ++PI) >> + if (!R->contains(*PI)) >> + Preds.push_back(*PI); >> + >> + if (Preds.size()==0) >> + return; >> > Can we change this to an assert? > > assert(Preds.size() && "This region has already a single entry edge"); > Then we have to make sure that R's entry is not the function entry. In runOnRegion if (!(R->getEnteringBlock()) && (pred_begin(R->getEntry()) != pred_end(R->getEntry()))) { createSingleEntryEdge(R); ... > + >> + BasicBlock *newEntry = SplitBlockPredecessors(oldEntry, >> + Preds.data(), >> Preds.size(), >> + ".single_entry", this); >> + >> + RegionInfo *RI =&getAnalysis (); >> + // We do not update entry node for children of this region. >> + // This make it easier to extract children regions because they do not >> share >> + // the entry node with their parents. >> + // all parent regions whose entry is oldEntry are updated with newEntry >> + Region *r = R->getParent(); >> + while (r->getEntry() == oldEntry&& !r->isTopLevelRegion()) { >> + r->replaceEntry(newEntry); >> + r = r->getParent(); >> + } >> + >> + // We do not update exit node for children of this region for the same >> reason >> + // of not updating entry node. >> + // All other regions whose exit is oldEntry are updated with new exit >> node >> + r = RI->getTopLevelRegion(); >> > r = r->getParent() should be enough? > I don't think so. We want to find ALL other regions, not just the regions starting from parent of R. We must start from the top. > > + std::deque RQ; >> > std::vector is probably simpler > > + RQ.push_back(r); >> + while (!RQ.empty()){ >> + r = RQ.front(); >> + for (Region::const_iterator RI = r->begin(), RE = r->end(); RI!=RE; >> ++RI) >> + RQ.push_back(*RI); >> + if (r->getExit() == oldEntry&& !R->contains(r)) >> + r->replaceExit(newEntry); >> + RQ.pop_front(); >> + } >> > I need to think about this part (Will send feedback later). > This is not clean. Here is a cleaner version r = RI->getTopLevelRegion(); std::vector RQ; RQ.push_back(r); while (!RQ.empty()){ r = RQ.back(); RQ.pop_back(); if (r->getExit() != oldEntry || R->contains(r)) continue; r->replaceExit(newEntry); for (Region::const_iterator RI = r->begin(), RE = r->end(); RI!=RE; ++RI) RQ.push_back(*RI); } We cannot make sure that those regions whose exit is OldEntry belong to any particular subregions. That's why we have to iterate over all the regions in the tree. > > + >> + modified |= true; >> > I do not believe this is part of creating the edges. 'modified' is part of > the status tracking of the pass and should probably be put into > runOnRegion(). > > + ++NumEntries; >> > Dito. Please put in runOnRegion(). > Sure. > > +} >> + >> +// createSingleExitEdge - Split the exit basic of the given region >> >> +// to form a single exit edge. >> +void RegionSimplify::createSingleExitEdge(Region *R) { >> + BasicBlock *oldExit = R->getExit(); >> + >> + SmallVector Preds; >> + for (pred_iterator PI = pred_begin(oldExit), PE = pred_end(oldExit); >> >> + PI != PE; ++PI) >> + if (R->contains(*PI)) >> + Preds.push_back(*PI); >> + >> + BasicBlock *newExit = SplitBlockPredecessors(oldExit, >> + Preds.data(), >> Preds.size(), >> + ".single_exit", this); >> + RegionInfo *RI =&getAnalysis (); >> + >> + // We do not need to update entry nodes because this split happens >> inside >> + // this region and it affects only this region and all of its children. >> + // The new split node belongs to this region >> > > + RI->setRegionFor(newExit,R); >> + >> + // all children of this region whose exit is oldExit is changed to >> newExit >> + std::deque RQ; >> + for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; >> ++RI) >> + RQ.push_back(*RI); >> + while (!RQ.empty()){ >> + R = RQ.front(); >> + for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; >> ++RI) >> + RQ.push_back(*RI); >> + >> + if (R->getExit() == oldExit) >> + R->replaceExit(newExit); >> + RQ.pop_front(); >> + } >> > > A vector is probably simpler. We also do not need to add child regions for > regions that do not have an exit matching oldExit. What about this code? > I'm not sure about this. A child might not share the exit with its parent. I think we still need to check. > > std::vector RQ; > > while (!RQ.empty()){ > R = RQ.back(); > RQ.pop_back(); > > if (R->getExit() != oldExit) > continue; > > R->replaceExit(newExit); > > for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; > ++RI) > RQ.push_back(*RI); > > } > > std::vector RQ; for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; ++RI) RQ.push_back(*RI); while (!RQ.empty()){ R = RQ.back(); RQ.pop_back(); for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; ++RI) RQ.push_back(*RI); if (R->getExit() == oldExit) R->replaceExit(newExit); } > > + >> + modified |= true; >> > This function always modifies the CFG. So no need to put additional logic > here. > > + ++NumExits; >> > Dito. > > +} >> >> + >> +bool RegionSimplify::runOnRegion(Region *R, RGPassManager&RGM) { >> + modified = false; >> + >> + CR = R; >> + if (!R->isTopLevelRegion()) { >> + >> + if (!(R->getEnteringBlock())) { >> + createSingleEntryEdge(R); >> + } >> > > if (!(R->getEnteringBlock())) { > createSingleEntryEdge(R); > ++NumEntries; > modified = true. > } > We need to add additional check for the special case where R does not have any predecessor. if (!(R->getEnteringBlock()) && (pred_begin(R->getEntry()) != pred_end(R->getEntry()))) { createSingleEntryEdge(R); modified = true; ++NumEntries; } > > + >> + if (!(R->getExitingBlock())) { >> + modified |= createSingleExitEdge(R); >> > > if (!(R->getExitingBlock())) { > createSingleExitEdge(R); > ++NumExits; > modified = true; > } > > + } >> + } >> + >> + return modified; >> +} >> diff --git a/lib/Transforms/Scalar/Scalar.cpp >> b/lib/Transforms/Scalar/Scalar.cpp >> index bf9ca6d..5d18f22 100644 >> --- a/lib/Transforms/Scalar/Scalar.cpp >> +++ b/lib/Transforms/Scalar/Scalar.cpp >> @@ -51,6 +51,7 @@ void llvm::initializeScalarOpts(PassRegistry&Registry) { >> initializeMemCpyOptPass(Registry); >> initializeReassociatePass(Registry); >> initializeRegToMemPass(Registry); >> + initializeRegionSimplifyPass(Registry); >> initializeSCCPPass(Registry); >> initializeIPSCCPPass(Registry); >> initializeSROA_DTPass(Registry); >> diff --git a/test/Transforms/RegionSimplify/dg.exp >> b/test/Transforms/RegionSimplify/dg.exp >> new file mode 100644 >> index 0000000..f200589 >> --- /dev/null >> +++ b/test/Transforms/RegionSimplify/dg.exp >> @@ -0,0 +1,3 @@ >> +load_lib llvm.exp >> + >> +RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] >> diff --git a/test/Transforms/RegionSimplify/multi_exits.ll >> b/test/Transforms/RegionSimplify/multi_exits.ll >> new file mode 100644 >> index 0000000..024971c >> --- /dev/null >> +++ b/test/Transforms/RegionSimplify/multi_exits.ll >> @@ -0,0 +1,15 @@ >> +; RUN: opt -regionsimplify >> > > Did you test this test case. I believe you should use a line like: > > ; RUN: opt -regionsimplify %s > > Furthermore, we should also check the generated output. > > ; RUN: opt -regionsimplify %s | FileCheck %s > > +define void @f() nounwind { >> > ; CHECK: @f() > ; CHECK: br label %"1" > ... > > Add after the CHECK lines the output you expect. > > The same comments apply to the other test files. I would also be interested > to have some test files that include PHI-Nodes. > > Can you send out an updated patch? > > I'll look at FileCheck and create additional tests. Thank you again for your help ;). > Thanks a lot > Tobi > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/cac664be/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: regionsimplify2.patch Type: text/x-patch Size: 12298 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/cac664be/attachment-0001.bin From vmle at ucdavis.edu Tue Mar 1 14:15:09 2011 From: vmle at ucdavis.edu (Vu Le) Date: Tue, 1 Mar 2011 12:15:09 -0800 Subject: [llvm-commits] Patch for simplifying regions In-Reply-To: References: <4D4882FC.8060102@fim.uni-passau.de> <4D6BCEBA.9080609@fim.uni-passau.de> <4D6CF971.5050300@fim.uni-passau.de> Message-ID: On Tue, Mar 1, 2011 at 12:12 PM, Vu Le wrote: > Hi Tobias, > Thanks for the feedback. > > On Tue, Mar 1, 2011 at 5:49 AM, Tobias Grosser wrote: > >> On 02/28/2011 02:52 PM, Vu Le wrote: >> >>> Hi Tobias, >>> >>> I did make some changes to use splitBlockPredecessors in splitting >>> entry nodes. >>> >> >> Thanks for your fast reaction. The patch looks very nice. Though I have >> some comments that we need to fix before committing it. >> >> Thank you. > >> >> I tested it with coreutils and MySQL together with region-extractor pass. >>> >> Nice. >> >> >> If you're still interested in region-extractor pass, I'll make a patch. >>> >> Yes. I am extremely interested. >> >> diff --git a/include/llvm/InitializePasses.h >>> b/include/llvm/InitializePasses.h >>> index 02dbfbd..0591845 100644 >>> --- a/include/llvm/InitializePasses.h >>> +++ b/include/llvm/InitializePasses.h >>> @@ -192,6 +192,7 @@ void initializeRegionInfoPass(PassRegistry&); >>> void initializeRegionOnlyPrinterPass(PassRegistry&); >>> void initializeRegionOnlyViewerPass(PassRegistry&); >>> void initializeRegionPrinterPass(PassRegistry&); >>> +void initializeRegionSimplifyPass(PassRegistry&); >>> void initializeRegionViewerPass(PassRegistry&); >>> void initializeRegisterCoalescerAnalysisGroup(PassRegistry&); >>> void initializeRenderMachineFunctionPass(PassRegistry&); >>> diff --git a/include/llvm/LinkAllPasses.h b/include/llvm/LinkAllPasses.h >>> index 69e1bd9..ea1faec 100644 >>> --- a/include/llvm/LinkAllPasses.h >>> +++ b/include/llvm/LinkAllPasses.h >>> @@ -114,7 +114,8 @@ namespace { >>> (void) llvm::createRegionInfoPass(); >>> (void) llvm::createRegionOnlyPrinterPass(); >>> (void) llvm::createRegionOnlyViewerPass(); >>> - (void) llvm::createRegionPrinterPass(); >>> + (void) llvm::createRegionPrinterPass(); >>> >> This change does not seem to be needed. Please remove it. >> >> OK > >> + (void) llvm::createRegionSimplifyPass(); >>> (void) llvm::createRegionViewerPass(); >>> (void) llvm::createSCCPPass(); >>> (void) llvm::createScalarReplAggregatesPass(); >>> diff --git a/include/llvm/Transforms/Scalar.h >>> b/include/llvm/Transforms/Scalar.h >>> index 6f2a38e..e3ca06a 100644 >>> --- a/include/llvm/Transforms/Scalar.h >>> +++ b/include/llvm/Transforms/Scalar.h >>> @@ -349,6 +349,12 @@ Pass *createCorrelatedValuePropagationPass(); >>> FunctionPass *createInstructionSimplifierPass(); >>> extern char&InstructionSimplifierID; >>> >>> >>> +//===----------------------------------------------------------------------===// >>> +// >>> +// RegionSimplify - Simplify refined regions, if possible. >>> >> Are there cases when it is not possible? Would be interesting to mention >> those. >> >> It is when a region has function entry as its entry and a single edge > exit. > But then it is a simple region, I suppose. > I'll remove the "if possible" part. > > +Pass *createRegionSimplifyPass(); >>> + >>> } // End llvm namespace >>> >>> #endif >>> diff --git a/lib/Transforms/Scalar/CMakeLists.txt >>> b/lib/Transforms/Scalar/CMakeLists.txt >>> index 106fb8f..53fcf69 100644 >>> --- a/lib/Transforms/Scalar/CMakeLists.txt >>> +++ b/lib/Transforms/Scalar/CMakeLists.txt >>> @@ -23,6 +23,7 @@ add_llvm_library(LLVMScalarOpts >>> MemCpyOptimizer.cpp >>> Reassociate.cpp >>> Reg2Mem.cpp >>> + RegionSimplify.cpp >>> SCCP.cpp >>> Scalar.cpp >>> ScalarReplAggregates.cpp >>> diff --git a/lib/Transforms/Scalar/RegionSimplify.cpp >>> b/lib/Transforms/Scalar/RegionSimplify.cpp >>> new file mode 100644 >>> index 0000000..65e4d5c >>> --- /dev/null >>> +++ b/lib/Transforms/Scalar/RegionSimplify.cpp >>> @@ -0,0 +1,185 @@ >>> +//===- SeSeRegionInfo.cpp >>> -------------------------------------------------===// >>> +// >>> +// The LLVM Compiler Infrastructure >>> +// >>> +// This file is distributed under the University of Illinois Open Source >>> +// License. See LICENSE.TXT for details. >>> +// >>> >>> +//===----------------------------------------------------------------------===// >>> +// >>> +// This file converts refined regions detected by the RegionInfo >>> analysis >>> +// into simple regions. >>> +// >>> >>> +//===----------------------------------------------------------------------===// >>> + >>> +#include "llvm/Instructions.h" >>> +#include "llvm/ADT/Statistic.h" >>> +#include "llvm/Analysis/Dominators.h" >>> +#include "llvm/Analysis/RegionPass.h" >>> +#include "llvm/Analysis/RegionInfo.h" >>> +#include "llvm/Transforms/Utils/BasicBlockUtils.h" >>> + >>> +#define DEBUG_TYPE "regionsimplify" >>> >> Can we call the pass "region-simplify"? Like "loop-simplify" (The name was >> recently changed) >> >> Sure > >> +using namespace llvm; >>> + >>> +STATISTIC(NumEntries, "The # of created entry edges"); >>> +STATISTIC(NumExits, "The # of created exit edges"); >>> + >>> +namespace { >>> +class RegionSimplify: public RegionPass { >>> + bool modified; >>> + Region *CR; >>> + void createSingleEntryEdge(Region *R); >>> + void createSingleExitEdge(Region *R); >>> +public: >>> + static char ID; >>> + explicit RegionSimplify() : >>> + RegionPass(ID) { >>> + initializeRegionSimplifyPass(*PassRegistry::getPassRegistry()); >>> + } >>> + >>> + virtual void print(raw_ostream&O, const Module *M) const; >>> + >>> + virtual bool runOnRegion(Region *R, RGPassManager&RGM); >>> + virtual void getAnalysisUsage(AnalysisUsage&AU) const; >>> +}; >>> +} >>> + >>> +INITIALIZE_PASS(RegionSimplify, "regionsimplify", >>> >> "regionsimplify" -> "region-simplify" >> > OK > >> >> + "Transform refined regions into simple regions", false, false) >>> + >>> +char RegionSimplify::ID = 0; >>> +namespace llvm { >>> +Pass *createRegionSimplifyPass() { >>> + return new RegionSimplify(); >>> +} >>> +} >>> + >>> +void RegionSimplify::print(raw_ostream&O, const Module *M) const { >>> >>> + if (!modified) >>> + return; >>> + >>> + BasicBlock *enteringBlock = CR->getEnteringBlock(); >>> + BasicBlock *exitingBlock = CR->getExitingBlock(); >>> + >>> + O<< "\nRegion: ["<< CR->getNameStr()<< "] Edges:\n"; >>> + if (enteringBlock) >>> + O<< " Entry: ]"<< enteringBlock->getNameStr()<< " => " >>> +<< enteringBlock->getNameStr()<< "]\n"; >>> + if (exitingBlock) >>> + O<< " Exit: ["<< exitingBlock->getNameStr()<< " => " >>> +<< exitingBlock->getNameStr()<< "[\n"; >>> + >>> + O<< "\n"; >>> +} >>> + >>> +void RegionSimplify::getAnalysisUsage(AnalysisUsage&AU) const { >>> + AU.addPreserved (); >>> + AU.addPreserved (); >>> + AU.addRequired (); >>> +} >>> + >>> +// createSingleEntryEdge - Split the entry basic block of the given >>> >>> +// region after the last PHINode to form a single entry edge. >>> +void RegionSimplify::createSingleEntryEdge(Region *R) { >>> + BasicBlock *oldEntry = R->getEntry(); >>> + SmallVector Preds; >>> >>> + for (pred_iterator PI = pred_begin(oldEntry), PE = pred_end(oldEntry); >>> + PI != PE; ++PI) >>> + if (!R->contains(*PI)) >>> + Preds.push_back(*PI); >>> + >>> + if (Preds.size()==0) >>> + return; >>> >> Can we change this to an assert? >> >> assert(Preds.size() && "This region has already a single entry edge"); >> > > Then we have to make sure that R's entry is not the function entry. > In runOnRegion > if (!(R->getEnteringBlock()) > && (pred_begin(R->getEntry()) != pred_end(R->getEntry()))) { > createSingleEntryEdge(R); > ... > > > >> + >>> + BasicBlock *newEntry = SplitBlockPredecessors(oldEntry, >>> + Preds.data(), >>> Preds.size(), >>> + ".single_entry", this); >>> + >>> + RegionInfo *RI =&getAnalysis (); >>> + // We do not update entry node for children of this region. >>> + // This make it easier to extract children regions because they do not >>> share >>> + // the entry node with their parents. >>> + // all parent regions whose entry is oldEntry are updated with >>> newEntry >>> + Region *r = R->getParent(); >>> + while (r->getEntry() == oldEntry&& !r->isTopLevelRegion()) { >>> + r->replaceEntry(newEntry); >>> + r = r->getParent(); >>> + } >>> + >>> + // We do not update exit node for children of this region for the same >>> reason >>> + // of not updating entry node. >>> + // All other regions whose exit is oldEntry are updated with new exit >>> node >>> + r = RI->getTopLevelRegion(); >>> >> r = r->getParent() should be enough? >> > > I don't think so. We want to find ALL other regions, not just the regions > starting from > parent of R. We must start from the top. > >> >> + std::deque RQ; >>> >> std::vector is probably simpler >> >> + RQ.push_back(r); >>> + while (!RQ.empty()){ >>> + r = RQ.front(); >>> + for (Region::const_iterator RI = r->begin(), RE = r->end(); RI!=RE; >>> ++RI) >>> + RQ.push_back(*RI); >>> + if (r->getExit() == oldEntry&& !R->contains(r)) >>> + r->replaceExit(newEntry); >>> + RQ.pop_front(); >>> + } >>> >> I need to think about this part (Will send feedback later). >> > This is not clean. Here is a cleaner version > r = RI->getTopLevelRegion(); > std::vector RQ; > > RQ.push_back(r); > > while (!RQ.empty()){ > r = RQ.back(); > RQ.pop_back(); > > if (r->getExit() != oldEntry || R->contains(r)) > continue; > > r->replaceExit(newEntry); > > > for (Region::const_iterator RI = r->begin(), RE = r->end(); RI!=RE; > ++RI) > RQ.push_back(*RI); > } > Please ignore this code fragment. It should be like this: r = RI->getTopLevelRegion(); std::vector RQ; RQ.push_back(r); while (!RQ.empty()){ r = RQ.back(); RQ.pop_back(); for (Region::const_iterator RI = r->begin(), RE = r->end(); RI!=RE; ++RI) RQ.push_back(*RI); if (r->getExit() == oldEntry && !R->contains(r)) r->replaceExit(newEntry); } > We cannot make sure that those regions whose exit is OldEntry belong to any > particular subregions. That's why we have to iterate over all the regions > in the > tree. > >> >> + >>> + modified |= true; >>> >> I do not believe this is part of creating the edges. 'modified' is part of >> the status tracking of the pass and should probably be put into >> runOnRegion(). >> >> + ++NumEntries; >>> >> Dito. Please put in runOnRegion(). >> > Sure. > >> >> +} >>> + >>> +// createSingleExitEdge - Split the exit basic of the given region >>> >>> +// to form a single exit edge. >>> +void RegionSimplify::createSingleExitEdge(Region *R) { >>> + BasicBlock *oldExit = R->getExit(); >>> + >>> + SmallVector Preds; >>> + for (pred_iterator PI = pred_begin(oldExit), PE = pred_end(oldExit); >>> >>> + PI != PE; ++PI) >>> + if (R->contains(*PI)) >>> + Preds.push_back(*PI); >>> + >>> + BasicBlock *newExit = SplitBlockPredecessors(oldExit, >>> + Preds.data(), >>> Preds.size(), >>> + ".single_exit", this); >>> + RegionInfo *RI =&getAnalysis (); >>> + >>> + // We do not need to update entry nodes because this split happens >>> inside >>> + // this region and it affects only this region and all of its >>> children. >>> + // The new split node belongs to this region >>> >> >> + RI->setRegionFor(newExit,R); >>> + >>> + // all children of this region whose exit is oldExit is changed to >>> newExit >>> + std::deque RQ; >>> + for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; >>> ++RI) >>> + RQ.push_back(*RI); >>> + while (!RQ.empty()){ >>> + R = RQ.front(); >>> + for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; >>> ++RI) >>> + RQ.push_back(*RI); >>> + >>> + if (R->getExit() == oldExit) >>> + R->replaceExit(newExit); >>> + RQ.pop_front(); >>> + } >>> >> >> A vector is probably simpler. We also do not need to add child regions for >> regions that do not have an exit matching oldExit. What about this code? >> > I'm not sure about this. > A child might not share the exit with its parent. > I think we still need to check. > >> >> std::vector RQ; >> >> while (!RQ.empty()){ >> R = RQ.back(); >> RQ.pop_back(); >> >> if (R->getExit() != oldExit) >> continue; >> >> R->replaceExit(newExit); >> >> for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; >> ++RI) >> RQ.push_back(*RI); >> >> } >> >> std::vector RQ; > > for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; ++RI) > RQ.push_back(*RI); > > while (!RQ.empty()){ > R = RQ.back(); > RQ.pop_back(); > > > for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; > ++RI) > RQ.push_back(*RI); > > if (R->getExit() == oldExit) > R->replaceExit(newExit); > } > > >> >> + >>> + modified |= true; >>> >> This function always modifies the CFG. So no need to put additional logic >> here. >> >> + ++NumExits; >>> >> Dito. >> >> +} >>> >>> + >>> +bool RegionSimplify::runOnRegion(Region *R, RGPassManager&RGM) { >>> + modified = false; >>> + >>> + CR = R; >>> + if (!R->isTopLevelRegion()) { >>> + >>> + if (!(R->getEnteringBlock())) { >>> + createSingleEntryEdge(R); >>> + } >>> >> >> if (!(R->getEnteringBlock())) { >> createSingleEntryEdge(R); >> ++NumEntries; >> modified = true. >> } >> > We need to add additional check for the special case where R does not have > any predecessor. > > if (!(R->getEnteringBlock()) > && (pred_begin(R->getEntry()) != pred_end(R->getEntry()))) { > createSingleEntryEdge(R); > modified = true; > ++NumEntries; > } > >> >> + >>> + if (!(R->getExitingBlock())) { >>> + modified |= createSingleExitEdge(R); >>> >> >> if (!(R->getExitingBlock())) { >> createSingleExitEdge(R); >> ++NumExits; >> modified = true; >> } >> >> + } >>> + } >>> + >>> + return modified; >>> +} >>> diff --git a/lib/Transforms/Scalar/Scalar.cpp >>> b/lib/Transforms/Scalar/Scalar.cpp >>> index bf9ca6d..5d18f22 100644 >>> --- a/lib/Transforms/Scalar/Scalar.cpp >>> +++ b/lib/Transforms/Scalar/Scalar.cpp >>> @@ -51,6 +51,7 @@ void llvm::initializeScalarOpts(PassRegistry&Registry) >>> { >>> initializeMemCpyOptPass(Registry); >>> initializeReassociatePass(Registry); >>> initializeRegToMemPass(Registry); >>> + initializeRegionSimplifyPass(Registry); >>> initializeSCCPPass(Registry); >>> initializeIPSCCPPass(Registry); >>> initializeSROA_DTPass(Registry); >>> diff --git a/test/Transforms/RegionSimplify/dg.exp >>> b/test/Transforms/RegionSimplify/dg.exp >>> new file mode 100644 >>> index 0000000..f200589 >>> --- /dev/null >>> +++ b/test/Transforms/RegionSimplify/dg.exp >>> @@ -0,0 +1,3 @@ >>> +load_lib llvm.exp >>> + >>> +RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] >>> diff --git a/test/Transforms/RegionSimplify/multi_exits.ll >>> b/test/Transforms/RegionSimplify/multi_exits.ll >>> new file mode 100644 >>> index 0000000..024971c >>> --- /dev/null >>> +++ b/test/Transforms/RegionSimplify/multi_exits.ll >>> @@ -0,0 +1,15 @@ >>> +; RUN: opt -regionsimplify >>> >> >> Did you test this test case. I believe you should use a line like: >> >> ; RUN: opt -regionsimplify %s >> >> Furthermore, we should also check the generated output. >> >> ; RUN: opt -regionsimplify %s | FileCheck %s >> >> +define void @f() nounwind { >>> >> ; CHECK: @f() >> ; CHECK: br label %"1" >> ... >> >> Add after the CHECK lines the output you expect. >> >> The same comments apply to the other test files. I would also be >> interested to have some test files that include PHI-Nodes. >> >> Can you send out an updated patch? >> >> I'll look at FileCheck and create additional tests. > Thank you again for your help ;). > > >> Thanks a lot >> Tobi >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/4ade05df/attachment.html From aggarwa4 at illinois.edu Tue Mar 1 14:15:57 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Tue, 01 Mar 2011 20:15:57 -0000 Subject: [llvm-commits] [poolalloc] r126777 - /poolalloc/trunk/lib/DSA/DataStructureStats.cpp Message-ID: <20110301201557.CD2EA2A6C12C@llvm.org> Author: aggarwa4 Date: Tue Mar 1 14:15:57 2011 New Revision: 126777 URL: http://llvm.org/viewvc/llvm-project?rev=126777&view=rev Log: Remove debug printing. Modified: poolalloc/trunk/lib/DSA/DataStructureStats.cpp Modified: poolalloc/trunk/lib/DSA/DataStructureStats.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructureStats.cpp?rev=126777&r1=126776&r2=126777&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DataStructureStats.cpp (original) +++ poolalloc/trunk/lib/DSA/DataStructureStats.cpp Tue Mar 1 14:15:57 2011 @@ -98,7 +98,6 @@ return isIndirectCallee(CE->getOperand(0)); if (GlobalAlias *GA = dyn_cast(V)) { - GA->dump(); return isIndirectCallee(GA->getAliasee()); } From aggarwa4 at illinois.edu Tue Mar 1 14:30:20 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Tue, 01 Mar 2011 20:30:20 -0000 Subject: [llvm-commits] [poolalloc] r126778 - /poolalloc/trunk/lib/DSA/StdLibPass.cpp Message-ID: <20110301203020.97B742A6C12C@llvm.org> Author: aggarwa4 Date: Tue Mar 1 14:30:20 2011 New Revision: 126778 URL: http://llvm.org/viewvc/llvm-project?rev=126778&view=rev Log: Handle invoke instructions too. Must refactor. Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/StdLibPass.cpp?rev=126778&r1=126777&r2=126778&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original) +++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Tue Mar 1 14:30:20 2011 @@ -91,6 +91,10 @@ {"setrlimit", {NRET_YARGS, YRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, {"getcwd", {NRET_NYARGS, YRET_YNARGS, NRET_NARGS, YRET_YNARGS, false}}, + {"select", {NRET_YARGS, YRET_YNARGS, NRET_NARGS, NRET_NARGS, false}}, + {"_setjmp", {NRET_YARGS, YRET_YARGS, NRET_NARGS, NRET_NARGS, false}}, + {"longjmp", {NRET_YARGS, NRET_YARGS, NRET_NARGS, NRET_NARGS, false}}, + {"remove", {NRET_YARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, {"rename", {NRET_YARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, {"unlink", {NRET_YARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, @@ -109,6 +113,7 @@ {"fchmod", {NRET_YARGS, YRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, {"kill", {NRET_YARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + {"pipe", {NRET_YARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, {"execl", {NRET_YARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, {"execlp", {NRET_YARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, @@ -252,7 +257,6 @@ {"sc.pool_argvregister", {NRET_NARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, #if 0 - {"pipe", {false, false, false, false, true, false, false, false, false}}, {"wait", {false, false, false, false, true, false, false, false, false}}, {"getrusage", {false, false, false, false, true, false, false, false, false}}, {"getcwd", { true, true, true, true, true, true, false, true, true}}, @@ -292,6 +296,14 @@ << CI->getParent()->getParent()->getNameStr() << "\n"); Graph->removeFunctionCalls(*F); } + }else if (InvokeInst* CI = dyn_cast(ii)){ + if (CI->getOperand(0) == F) { + DSGraph* Graph = getDSGraph(*CI->getParent()->getParent()); + //delete the call + DEBUG(errs() << "Removing " << F->getNameStr() << " from " + << CI->getParent()->getParent()->getNameStr() << "\n"); + Graph->removeFunctionCalls(*F); + } } else if(ConstantExpr *CE = dyn_cast(ii)) { if(CE->isCast()) { for (Value::use_iterator ci = CE->use_begin(), ce = CE->use_end(); @@ -447,6 +459,77 @@ } } + // + // Merge the DSNoes for return values and parameters as + // appropriate. + // + std::vector toMerge; + if (recFuncs[x].action.mergeNodes[0]) + if (isa(CI->getType())) + if (Graph->hasNodeForValue(CI)) + toMerge.push_back(Graph->getNodeForValue(CI)); + for (unsigned y = 1; y < CI->getNumOperands(); ++y) + if (recFuncs[x].action.mergeNodes[y]) + if (isa(CI->getOperand(y)->getType())) + if (Graph->hasNodeForValue(CI->getOperand(y))) + toMerge.push_back(Graph->getNodeForValue(CI->getOperand(y))); + for (unsigned y = 1; y < toMerge.size(); ++y) + toMerge[0].mergeWith(toMerge[y]); + + // + // Collapse (fold) the DSNode of the return value and the actual + // arguments if directed to do so. + // + if (!noStdLibFold && recFuncs[x].action.collapse) { + if (isa(CI->getType())){ + if (Graph->hasNodeForValue(CI)) + Graph->getNodeForValue(CI).getNode()->foldNodeCompletely(); + NumNodesFoldedInStdLib++; + } + for (unsigned y = 1; y < CI->getNumOperands(); ++y){ + if (isa(CI->getOperand(y)->getType())){ + if (Graph->hasNodeForValue(CI->getOperand(y))){ + Graph->getNodeForValue(CI->getOperand(y)).getNode()->foldNodeCompletely(); + NumNodesFoldedInStdLib++; + } + } + } + } + } + } else if (InvokeInst* CI = dyn_cast(ii)){ + if (CI->getOperand(0) == F) { + DSGraph* Graph = getDSGraph(*CI->getParent()->getParent()); + + // + // Set the read, write, and heap markers on the return value + // as appropriate. + // + if(isa((CI)->getType())){ + if(Graph->hasNodeForValue(CI)){ + if (recFuncs[x].action.read[0]) + Graph->getNodeForValue(CI).getNode()->setReadMarker(); + if (recFuncs[x].action.write[0]) + Graph->getNodeForValue(CI).getNode()->setModifiedMarker(); + if (recFuncs[x].action.heap[0]) + Graph->getNodeForValue(CI).getNode()->setHeapMarker(); + } + } + + // + // Set the read, write, and heap markers on the actual arguments + // as appropriate. + // + for (unsigned y = 1; y < CI->getNumOperands(); ++y) + if (isa(CI->getOperand(y)->getType())){ + if (Graph->hasNodeForValue(CI->getOperand(y))){ + if (recFuncs[x].action.read[y]) + Graph->getNodeForValue(CI->getOperand(y)).getNode()->setReadMarker(); + if (recFuncs[x].action.write[y]) + Graph->getNodeForValue(CI->getOperand(y)).getNode()->setModifiedMarker(); + if (recFuncs[x].action.heap[y]) + Graph->getNodeForValue(CI->getOperand(y)).getNode()->setHeapMarker(); + } + } // // Merge the DSNoes for return values and parameters as @@ -489,6 +572,7 @@ if(CE->isCast()) for (Value::use_iterator ci = CE->use_begin(), ce = CE->use_end(); ci != ce; ++ci) { + if (CallInst* CI = dyn_cast(ci)){ if (CI->getOperand(0) == CE) { DSGraph* Graph = getDSGraph(*CI->getParent()->getParent()); @@ -612,5 +696,4 @@ strtoll ctype family open64/fopen64/lseek64 - */ From baldrick at free.fr Tue Mar 1 14:56:50 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Mar 2011 20:56:50 -0000 Subject: [llvm-commits] [llvm] r126780 - /llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Message-ID: <20110301205650.D930D2A6C12D@llvm.org> Author: baldrick Date: Tue Mar 1 14:56:50 2011 New Revision: 126780 URL: http://llvm.org/viewvc/llvm-project?rev=126780&view=rev Log: Add datalayout information for the IEEE quad precision fp128 type. Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=126780&r1=126779&r2=126780&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Tue Mar 1 14:56:50 2011 @@ -96,11 +96,11 @@ const std::string &FS) : X86TargetMachine(T, TT, FS, false), DataLayout(getSubtargetImpl()->isTargetDarwin() ? - "e-p:32:32-f64:32:64-i64:32:64-f80:128:128-n8:16:32" : + "e-p:32:32-f64:32:64-i64:32:64-f80:128:128-f128:128:128-n8:16:32" : (getSubtargetImpl()->isTargetCygMing() || getSubtargetImpl()->isTargetWindows()) ? - "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32" : - "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32"), + "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-f128:128:128-n8:16:32" : + "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-f128:128:128-n8:16:32"), InstrInfo(*this), TSInfo(*this), TLInfo(*this), @@ -111,7 +111,7 @@ X86_64TargetMachine::X86_64TargetMachine(const Target &T, const std::string &TT, const std::string &FS) : X86TargetMachine(T, TT, FS, true), - DataLayout("e-p:64:64-s:64-f64:64:64-i64:64:64-f80:128:128-n8:16:32:64"), + DataLayout("e-p:64:64-s:64-f64:64:64-i64:64:64-f80:128:128-f128:128:128-n8:16:32:64"), InstrInfo(*this), TSInfo(*this), TLInfo(*this), From stoklund at 2pi.dk Tue Mar 1 15:10:07 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 01 Mar 2011 21:10:07 -0000 Subject: [llvm-commits] [llvm] r126781 - /llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Message-ID: <20110301211007.800DA2A6C12C@llvm.org> Author: stoklund Date: Tue Mar 1 15:10:07 2011 New Revision: 126781 URL: http://llvm.org/viewvc/llvm-project?rev=126781&view=rev Log: Keep track of which stage produced a live range, and bypass earlier stages when revisiting. This effectively disables the 'turbo' functionality of the greedy register allocator where all new live ranges created by splitting would be reconsidered as if they were originals. There are two reasons for doing this, 1. It guarantees that the algorithm terminates. Early versions were prone to infinite looping in certain corner cases. 2. It is a 2x speedup. We can skip a lot of unnecessary interference checks that won't lead to good splitting anyway. The problem is that region splitting only gets one shot, so it should probably be changed to target multiple physical registers at once. Local live range splitting is still 'turbo' enabled. It only accounts for a small fraction of compile time, so it is probably not necessary to do anything about that. Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=126781&r1=126780&r2=126781&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Tue Mar 1 15:10:07 2011 @@ -72,11 +72,45 @@ // state std::auto_ptr SpillerInstance; - std::auto_ptr SA; std::priority_queue > Queue; - IndexedMap Generation; + + // Live ranges pass through a number of stages as we try to allocate them. + // Some of the stages may also create new live ranges: + // + // - Region splitting. + // - Per-block splitting. + // - Local splitting. + // - Spilling. + // + // Ranges produced by one of the stages skip the previous stages when they are + // dequeued. This improves performance because we can skip interference checks + // that are unlikely to give any results. It also guarantees that the live + // range splitting algorithm terminates, something that is otherwise hard to + // ensure. + enum LiveRangeStage { + RS_Original, ///< Never seen before, never split. + RS_Second, ///< Second time in the queue. + RS_Region, ///< Produced by region splitting. + RS_Block, ///< Produced by per-block splitting. + RS_Local, ///< Produced by local splitting. + RS_Spill ///< Produced by spilling. + }; + + IndexedMap LRStage; + + LiveRangeStage getStage(const LiveInterval &VirtReg) const { + return LiveRangeStage(LRStage[VirtReg.reg]); + } + + template + void setStage(Iterator Begin, Iterator End, LiveRangeStage NewStage) { + LRStage.resize(MRI->getNumVirtRegs()); + for (;Begin != End; ++Begin) + LRStage[(*Begin)->reg] = NewStage; + } // splitting state. + std::auto_ptr SA; /// All basic blocks where the current register is live. SmallVector SpillConstraints; @@ -143,7 +177,7 @@ return new RAGreedy(); } -RAGreedy::RAGreedy(): MachineFunctionPass(ID) { +RAGreedy::RAGreedy(): MachineFunctionPass(ID), LRStage(RS_Original) { initializeSlotIndexesPass(*PassRegistry::getPassRegistry()); initializeLiveIntervalsPass(*PassRegistry::getPassRegistry()); initializeSlotIndexesPass(*PassRegistry::getPassRegistry()); @@ -187,7 +221,7 @@ void RAGreedy::releaseMemory() { SpillerInstance.reset(0); - Generation.clear(); + LRStage.clear(); RegAllocBase::releaseMemory(); } @@ -198,11 +232,10 @@ const unsigned Reg = LI->reg; assert(TargetRegisterInfo::isVirtualRegister(Reg) && "Can only enqueue virtual registers"); - const unsigned Hint = VRM->getRegAllocPref(Reg); unsigned Prio; - Generation.grow(Reg); - if (++Generation[Reg] == 1) + LRStage.grow(Reg); + if (LRStage[Reg] == RS_Original) // 1st generation ranges are handled first, long -> short. Prio = (1u << 31) + Size; else @@ -210,6 +243,7 @@ Prio = (1u << 30) - Size; // Boost ranges that have a physical register hint. + const unsigned Hint = VRM->getRegAllocPref(Reg); if (TargetRegisterInfo::isPhysicalRegister(Hint)) Prio |= (1u << 30); @@ -926,6 +960,7 @@ return 0; splitAroundRegion(VirtReg, BestReg, BestBundles, NewVRegs); + setStage(NewVRegs.begin(), NewVRegs.end(), RS_Region); return 0; } @@ -1191,6 +1226,7 @@ SE.useIntv(SegStart, SegStop); SE.closeIntv(); SE.finish(); + setStage(NewVRegs.begin(), NewVRegs.end(), RS_Local); ++NumLocalSplits; return 0; @@ -1205,29 +1241,41 @@ /// @return Physreg when VirtReg may be assigned and/or new NewVRegs. unsigned RAGreedy::trySplit(LiveInterval &VirtReg, AllocationOrder &Order, SmallVectorImpl&NewVRegs) { - SA->analyze(&VirtReg); - // Local intervals are handled separately. if (LIS->intervalIsInOneMBB(VirtReg)) { NamedRegionTimer T("Local Splitting", TimerGroupName, TimePassesIsEnabled); + SA->analyze(&VirtReg); return tryLocalSplit(VirtReg, Order, NewVRegs); } NamedRegionTimer T("Global Splitting", TimerGroupName, TimePassesIsEnabled); + // Don't iterate global splitting. + // Move straight to spilling if this range was produced by a global split. + LiveRangeStage Stage = getStage(VirtReg); + if (Stage >= RS_Block) + return 0; + + SA->analyze(&VirtReg); + // First try to split around a region spanning multiple blocks. - unsigned PhysReg = tryRegionSplit(VirtReg, Order, NewVRegs); - if (PhysReg || !NewVRegs.empty()) - return PhysReg; + if (Stage < RS_Region) { + unsigned PhysReg = tryRegionSplit(VirtReg, Order, NewVRegs); + if (PhysReg || !NewVRegs.empty()) + return PhysReg; + } // Then isolate blocks with multiple uses. - SplitAnalysis::BlockPtrSet Blocks; - if (SA->getMultiUseBlocks(Blocks)) { - SmallVector SpillRegs; - LiveRangeEdit LREdit(VirtReg, NewVRegs, SpillRegs); - SplitEditor(*SA, *LIS, *VRM, *DomTree, LREdit).splitSingleBlocks(Blocks); - if (VerifyEnabled) - MF->verify(this, "After splitting live range around basic blocks"); + if (Stage < RS_Block) { + SplitAnalysis::BlockPtrSet Blocks; + if (SA->getMultiUseBlocks(Blocks)) { + SmallVector SpillRegs; + LiveRangeEdit LREdit(VirtReg, NewVRegs, SpillRegs); + SplitEditor(*SA, *LIS, *VRM, *DomTree, LREdit).splitSingleBlocks(Blocks); + setStage(NewVRegs.begin(), NewVRegs.end(), RS_Block); + if (VerifyEnabled) + MF->verify(this, "After splitting live range around basic blocks"); + } } // Don't assign any physregs. @@ -1303,6 +1351,10 @@ unsigned RAGreedy::selectOrSplit(LiveInterval &VirtReg, SmallVectorImpl &NewVRegs) { + LiveRangeStage Stage = getStage(VirtReg); + if (Stage == RS_Original) + LRStage[VirtReg.reg] = RS_Second; + // First try assigning a free register. AllocationOrder Order(VirtReg.reg, *VRM, ReservedRegs); while (unsigned PhysReg = Order.next()) { @@ -1321,11 +1373,13 @@ // The first time we see a live range, don't try to split or spill. // Wait until the second time, when all smaller ranges have been allocated. // This gives a better picture of the interference to split around. - if (Generation[VirtReg.reg] == 1) { + if (Stage == RS_Original) { NewVRegs.push_back(&VirtReg); return 0; } + assert(Stage < RS_Spill && "Cannot allocate after spilling"); + // Try splitting VirtReg or interferences. unsigned PhysReg = trySplit(VirtReg, Order, NewVRegs); if (PhysReg || !NewVRegs.empty()) @@ -1366,6 +1420,8 @@ SpillPlacer = &getAnalysis(); SA.reset(new SplitAnalysis(*VRM, *LIS, *Loops)); + LRStage.clear(); + LRStage.resize(MRI->getNumVirtRegs()); allocatePhysRegs(); addMBBLiveIns(MF); From zwarich at apple.com Tue Mar 1 15:13:54 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Tue, 01 Mar 2011 21:13:54 -0000 Subject: [llvm-commits] [llvm] r126782 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Message-ID: <20110301211354.189E72A6C12C@llvm.org> Author: zwarich Date: Tue Mar 1 15:13:53 2011 New Revision: 126782 URL: http://llvm.org/viewvc/llvm-project?rev=126782&view=rev Log: Stop computing the number of uses twice per value in CodeGenPrepare's sinking of addressing code. On 403.gcc this almost halves CodeGenPrepare time and reduces total llc time by 9.5%. Unfortunately, getNumUses() is still the hottest function in llc. Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=126782&r1=126781&r2=126782&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Tue Mar 1 15:13:53 2011 @@ -701,7 +701,7 @@ // the addressing mode obtained from the non-PHI roots of the graph // are equivalent. Value *Consensus = 0; - unsigned NumUses = 0; + unsigned NumUsesConsensus = 0; SmallVector AddrModeInsts; ExtAddrMode AddrMode; while (!worklist.empty()) { @@ -734,9 +734,10 @@ // such root as representative, select the one with the most uses in order // to keep the cost modeling heuristics in AddressingModeMatcher applicable. if (!Consensus || NewAddrMode == AddrMode) { - if (V->getNumUses() > NumUses) { + unsigned NumUses = V->getNumUses(); + if (NumUses > NumUsesConsensus) { Consensus = V; - NumUses = V->getNumUses(); + NumUsesConsensus = NumUses; AddrMode = NewAddrMode; AddrModeInsts = NewAddrModeInsts; } From jan_sjodin at yahoo.com Tue Mar 1 15:31:26 2011 From: jan_sjodin at yahoo.com (Jan Sjodin) Date: Tue, 1 Mar 2011 13:31:26 -0800 (PST) Subject: [llvm-commits] InitializeNativeAsmParser function. Message-ID: <123802.19838.qm@web55607.mail.re4.yahoo.com> Here is a patch for a new function to initialize the native asm parser. This is needed in the future for MCJIT in case the code contains inline asm. - Jan -------------- next part -------------- A non-text attachment was scrubbed... Name: 0040_nativeasmparser.patch Type: application/octet-stream Size: 3332 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/282abd5e/attachment.obj From Erik.Olofsson at hansoft.se Tue Mar 1 15:59:31 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Tue, 1 Mar 2011 22:59:31 +0100 Subject: [llvm-commits] [PATCH] Cmake fix for option defaults not being set correctly on first run Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACBABE@winserv02.hansoft.local> On the first cmake run before the caches has been updated with the default options, options defined after HandleLLVMOptions are always treated as off inside HandleLLVMOptions. Please review and commit if good. Regards, Erik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/357a4cc8/attachment.html -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: llvm-cmake-option-defaults-not-correct-on-first-run.patch.txt Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/357a4cc8/attachment.txt From gohman at apple.com Tue Mar 1 16:07:09 2011 From: gohman at apple.com (Dan Gohman) Date: Tue, 01 Mar 2011 22:07:09 -0000 Subject: [llvm-commits] [llvm] r126784 - /llvm/trunk/include/llvm/Support/FileSystem.h Message-ID: <20110301220709.F07AC2A6C12C@llvm.org> Author: djg Date: Tue Mar 1 16:07:09 2011 New Revision: 126784 URL: http://llvm.org/viewvc/llvm-project?rev=126784&view=rev Log: Change directory_entry::path() to return a const std::string & instead of a StringRef, for the benefit of clients that want the result as a nul-terminated string. Clients that expect a StringRef will get one via the implicit conversion. Modified: llvm/trunk/include/llvm/Support/FileSystem.h Modified: llvm/trunk/include/llvm/Support/FileSystem.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileSystem.h?rev=126784&r1=126783&r2=126784&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/FileSystem.h (original) +++ llvm/trunk/include/llvm/Support/FileSystem.h Tue Mar 1 16:07:09 2011 @@ -595,7 +595,7 @@ void replace_filename(const Twine &filename, file_status st = file_status(), file_status symlink_st = file_status()); - StringRef path() const { return Path; } + const std::string &path() const { return Path; } error_code status(file_status &result) const; error_code symlink_status(file_status &result) const; From gohman at apple.com Tue Mar 1 16:07:32 2011 From: gohman at apple.com (Dan Gohman) Date: Tue, 01 Mar 2011 22:07:32 -0000 Subject: [llvm-commits] [llvm] r126785 - /llvm/trunk/include/llvm/ADT/DepthFirstIterator.h Message-ID: <20110301220732.684BA2A6C12C@llvm.org> Author: djg Date: Tue Mar 1 16:07:32 2011 New Revision: 126785 URL: http://llvm.org/viewvc/llvm-project?rev=126785&view=rev Log: Simplify this code. Modified: llvm/trunk/include/llvm/ADT/DepthFirstIterator.h Modified: llvm/trunk/include/llvm/ADT/DepthFirstIterator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DepthFirstIterator.h?rev=126785&r1=126784&r2=126785&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/DepthFirstIterator.h (original) +++ llvm/trunk/include/llvm/ADT/DepthFirstIterator.h Tue Mar 1 16:07:32 2011 @@ -143,8 +143,7 @@ static inline _Self end(const GraphT& G, SetType &S) { return _Self(S); } inline bool operator==(const _Self& x) const { - return VisitStack.size() == x.VisitStack.size() && - VisitStack == x.VisitStack; + return VisitStack == x.VisitStack; } inline bool operator!=(const _Self& x) const { return !operator==(x); } From gohman at apple.com Tue Mar 1 16:07:55 2011 From: gohman at apple.com (Dan Gohman) Date: Tue, 01 Mar 2011 22:07:55 -0000 Subject: [llvm-commits] [llvm] r126786 - /llvm/trunk/include/llvm/Support/GraphWriter.h Message-ID: <20110301220755.AB1AD2A6C12C@llvm.org> Author: djg Date: Tue Mar 1 16:07:55 2011 New Revision: 126786 URL: http://llvm.org/viewvc/llvm-project?rev=126786&view=rev Log: Code simplification. Modified: llvm/trunk/include/llvm/Support/GraphWriter.h Modified: llvm/trunk/include/llvm/Support/GraphWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GraphWriter.h?rev=126786&r1=126785&r2=126786&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/GraphWriter.h (original) +++ llvm/trunk/include/llvm/Support/GraphWriter.h Tue Mar 1 16:07:55 2011 @@ -70,7 +70,7 @@ for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) { std::string label = DTraits.getEdgeSourceLabel(Node, EI); - if (label == "") + if (label.empty()) continue; hasEdgeSourceLabels = true; @@ -78,7 +78,7 @@ if (i) O << "|"; - O << "" << DTraits.getEdgeSourceLabel(Node, EI); + O << "" << label; } if (EI != EE && hasEdgeSourceLabels) @@ -235,7 +235,7 @@ DestPort = static_cast(Offset); } - if (DTraits.getEdgeSourceLabel(Node, EI) == "") + if (DTraits.getEdgeSourceLabel(Node, EI).empty()) edgeidx = -1; emitEdge(static_cast(Node), edgeidx, From gohman at apple.com Tue Mar 1 16:11:52 2011 From: gohman at apple.com (Dan Gohman) Date: Tue, 01 Mar 2011 22:11:52 -0000 Subject: [llvm-commits] [llvm] r126787 - /llvm/trunk/include/llvm/Support/SourceMgr.h Message-ID: <20110301221152.E34E72A6C12C@llvm.org> Author: djg Date: Tue Mar 1 16:11:52 2011 New Revision: 126787 URL: http://llvm.org/viewvc/llvm-project?rev=126787&view=rev Log: Remove the showline argument from the SMDiagnostic constructor which constructs a diagnostic with no line to show. Modified: llvm/trunk/include/llvm/Support/SourceMgr.h Modified: llvm/trunk/include/llvm/Support/SourceMgr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/SourceMgr.h?rev=126787&r1=126786&r2=126787&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/SourceMgr.h (original) +++ llvm/trunk/include/llvm/Support/SourceMgr.h Tue Mar 1 16:11:52 2011 @@ -156,10 +156,9 @@ // Null diagnostic. SMDiagnostic() : SM(0), LineNo(0), ColumnNo(0), ShowLine(0) {} // Diagnostic with no location (e.g. file not found, command line arg error). - SMDiagnostic(const std::string &filename, const std::string &Msg, - bool showline = true) + SMDiagnostic(const std::string &filename, const std::string &Msg) : SM(0), Filename(filename), LineNo(-1), ColumnNo(-1), - Message(Msg), ShowLine(showline) {} + Message(Msg), ShowLine(false) {} // Diagnostic with a location. SMDiagnostic(const SourceMgr &sm, SMLoc L, const std::string &FN, From gohman at apple.com Tue Mar 1 16:12:25 2011 From: gohman at apple.com (Dan Gohman) Date: Tue, 01 Mar 2011 22:12:25 -0000 Subject: [llvm-commits] [llvm] r126788 - /llvm/trunk/include/llvm/Support/GraphWriter.h Message-ID: <20110301221225.1D8A62A6C12C@llvm.org> Author: djg Date: Tue Mar 1 16:12:24 2011 New Revision: 126788 URL: http://llvm.org/viewvc/llvm-project?rev=126788&view=rev Log: Escape graph edge labels. Modified: llvm/trunk/include/llvm/Support/GraphWriter.h Modified: llvm/trunk/include/llvm/Support/GraphWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GraphWriter.h?rev=126788&r1=126787&r2=126788&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/GraphWriter.h (original) +++ llvm/trunk/include/llvm/Support/GraphWriter.h Tue Mar 1 16:12:24 2011 @@ -78,7 +78,7 @@ if (i) O << "|"; - O << "" << label; + O << "" << DOT::EscapeString(label); } if (EI != EE && hasEdgeSourceLabels) From jan_sjodin at yahoo.com Tue Mar 1 16:28:02 2011 From: jan_sjodin at yahoo.com (Jan Sjodin) Date: Tue, 1 Mar 2011 14:28:02 -0800 (PST) Subject: [llvm-commits] Split MCELFStreamer and ELFObjectWriter into .h and .cpp Message-ID: <919879.23172.qm@web55601.mail.re4.yahoo.com> This patch splits the MCELFStreamer and ELFObjectWriter into .cpp and .h files so the classes can be used by other components. - Jan -------------- next part -------------- A non-text attachment was scrubbed... Name: 0041_ELFFileSplit.patch Type: application/octet-stream Size: 38178 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/c9ab5ce1/attachment.obj From ofv at wanadoo.es Tue Mar 1 16:31:19 2011 From: ofv at wanadoo.es (Oscar Fuentes) Date: Tue, 01 Mar 2011 22:31:19 -0000 Subject: [llvm-commits] [llvm] r126790 - /llvm/trunk/CMakeLists.txt Message-ID: <20110301223119.C49FC2A6C12C@llvm.org> Author: ofv Date: Tue Mar 1 16:31:19 2011 New Revision: 126790 URL: http://llvm.org/viewvc/llvm-project?rev=126790&view=rev Log: Cmake fix for option defaults not being set correctly on first run On the first cmake run before the caches has been updated with the default options, options defined after HandleLLVMOptions are always treated as off inside HandleLLVMOptions. Patch by Erik Olofsson! Modified: llvm/trunk/CMakeLists.txt Modified: llvm/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=126790&r1=126789&r2=126790&view=diff ============================================================================== --- llvm/trunk/CMakeLists.txt (original) +++ llvm/trunk/CMakeLists.txt Tue Mar 1 16:31:19 2011 @@ -135,9 +135,15 @@ option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON) -include(config-ix) +# MSVC has a gazillion warnings with this. +if( MSVC ) + option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." OFF) +else( MSVC ) + option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON) +endif() -include(HandleLLVMOptions) +option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) +option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) if( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" ) option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF) @@ -145,6 +151,12 @@ option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON) endif() +# All options refered to from HandleLLVMOptions have to be specified +# BEFORE this include, otherwise options will not be correctly set on +# first cmake run +include(config-ix) +include(HandleLLVMOptions) + configure_file( ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/config.h.cmake ${LLVM_BINARY_DIR}/include/llvm/Config/config.h) @@ -161,16 +173,6 @@ set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib ) set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib ) -# MSVC has a gazillion warnings with this. -if( MSVC ) - option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." OFF) -else( MSVC ) - option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON) -endif() - -option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) -option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) - set(CMAKE_INCLUDE_CURRENT_DIR ON) include_directories( ${LLVM_BINARY_DIR}/include ${LLVM_MAIN_INCLUDE_DIR}) From ofv at wanadoo.es Tue Mar 1 16:36:04 2011 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=) Date: Tue, 01 Mar 2011 23:36:04 +0100 Subject: [llvm-commits] [PATCH] Cmake fix for option defaults not being set correctly on first run References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBABE@winserv02.hansoft.local> Message-ID: <87y64yzcx7.fsf@wanadoo.es> Erik Olofsson writes: > On the first cmake run before the caches has been updated with the > default options, options defined after HandleLLVMOptions are always > treated as off inside HandleLLVMOptions. > > Please review and commit if good. Committed as r126790. Thanks! From Erik.Olofsson at hansoft.se Tue Mar 1 17:00:19 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Wed, 2 Mar 2011 00:00:19 +0100 Subject: [llvm-commits] [PATCH] Fix MSVC10 warnings Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC1@winserv02.hansoft.local> Fixes warnings emitted by Visual Studio 2010 compiler. Please review and commit if good. Regards, Erik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/4030b31f/attachment.html -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: llvm-msvc10-fix-warnings.patch.txt Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/4030b31f/attachment.txt From dpatel at apple.com Tue Mar 1 16:58:13 2011 From: dpatel at apple.com (Devang Patel) Date: Tue, 01 Mar 2011 22:58:13 -0000 Subject: [llvm-commits] [llvm] r126793 - in /llvm/trunk: include/llvm/Analysis/DIBuilder.h include/llvm/Analysis/DebugInfo.h lib/Analysis/DIBuilder.cpp Message-ID: <20110301225813.C72AC2A6C12C@llvm.org> Author: dpatel Date: Tue Mar 1 16:58:13 2011 New Revision: 126793 URL: http://llvm.org/viewvc/llvm-project?rev=126793&view=rev Log: Today, the language front ends produces llvm.dbg.* intrinsics, used to encode arguments' debug info, in order any way, most of the times. However, if a front end mix-n-matches llvm.dbg.declare and llvm.dbg.value intrinsics to encode debug info for arguments then code generator needs a way to find argument order. Use 8 bits from line number field to keep track of argument ordering while encoding debug info for an argument. That leaves 24 bit for line no, DebugLoc also allocates 24 bit for line numbers. If a function has more than 255 arguments then rest of the arguments will be ordered by llvm.dbg.* intrinsics' ordering in IR. Modified: llvm/trunk/include/llvm/Analysis/DIBuilder.h llvm/trunk/include/llvm/Analysis/DebugInfo.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=126793&r1=126792&r2=126793&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DIBuilder.h (original) +++ llvm/trunk/include/llvm/Analysis/DIBuilder.h Tue Mar 1 16:58:13 2011 @@ -326,11 +326,14 @@ /// @param AlwaysPreserve Boolean. Set to true if debug info for this /// variable should be preserved in optimized build. /// @param Flags Flags, e.g. artificial variable. + /// @param ArgNo If this variable is an arugment then this argument's + /// number. 1 indicates 1st argument. DIVariable createLocalVariable(unsigned Tag, DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNo, DIType Ty, bool AlwaysPreserve = false, - unsigned Flags = 0); + unsigned Flags = 0, + unsigned ArgNo = 0); /// createComplexVariable - Create a new descriptor for the specified @@ -344,10 +347,12 @@ /// @param Ty Variable Type /// @param Addr A pointer to a vector of complex address operations. /// @param NumAddr Num of address operations in the vector. + /// @param ArgNo If this variable is an arugment then this argument's + /// number. 1 indicates 1st argument. DIVariable createComplexVariable(unsigned Tag, DIDescriptor Scope, StringRef Name, DIFile F, unsigned LineNo, DIType Ty, Value *const *Addr, - unsigned NumAddr); + unsigned NumAddr, unsigned ArgNo = 0); /// createFunction - Create a new descriptor for the specified subprogram. /// See comments in DISubprogram for descriptions of these fields. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=126793&r1=126792&r2=126793&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Tue Mar 1 16:58:13 2011 @@ -564,7 +564,13 @@ DIFile F = getFieldAs(3); return F.getCompileUnit(); } - unsigned getLineNumber() const { return getUnsignedField(4); } + unsigned getLineNumber() const { + return (getUnsignedField(4) << 8) >> 8; + } + unsigned getArgNumber() const { + unsigned L = getUnsignedField(4); + return L >> 24; + } DIType getType() const { return getFieldAs(5); } /// isArtificial - Return true if this variable is marked as "artificial". Modified: llvm/trunk/lib/Analysis/DIBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DIBuilder.cpp?rev=126793&r1=126792&r2=126793&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DIBuilder.cpp (original) +++ llvm/trunk/lib/Analysis/DIBuilder.cpp Tue Mar 1 16:58:13 2011 @@ -586,13 +586,14 @@ DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNo, DIType Ty, - bool AlwaysPreserve, unsigned Flags) { + bool AlwaysPreserve, unsigned Flags, + unsigned ArgNo) { Value *Elts[] = { GetTagConstant(VMContext, Tag), Scope, MDString::get(VMContext, Name), File, - ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + ConstantInt::get(Type::getInt32Ty(VMContext), (LineNo | (ArgNo << 24))), Ty, ConstantInt::get(Type::getInt32Ty(VMContext), Flags) }; @@ -620,13 +621,13 @@ StringRef Name, DIFile F, unsigned LineNo, DIType Ty, Value *const *Addr, - unsigned NumAddr) { + unsigned NumAddr, unsigned ArgNo) { SmallVector Elts; Elts.push_back(GetTagConstant(VMContext, Tag)); Elts.push_back(Scope); Elts.push_back(MDString::get(VMContext, Name)); Elts.push_back(F); - Elts.push_back(ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)); + Elts.push_back(ConstantInt::get(Type::getInt32Ty(VMContext), (LineNo | (ArgNo << 24)))); Elts.push_back(Ty); Elts.append(Addr, Addr+NumAddr); @@ -642,7 +643,6 @@ bool isLocalToUnit, bool isDefinition, unsigned Flags, bool isOptimized, Function *Fn) { - Value *Elts[] = { GetTagConstant(VMContext, dwarf::DW_TAG_subprogram), llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), From dpatel at apple.com Tue Mar 1 16:58:55 2011 From: dpatel at apple.com (Devang Patel) Date: Tue, 01 Mar 2011 22:58:55 -0000 Subject: [llvm-commits] [llvm] r126794 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h Message-ID: <20110301225855.A44272A6C12C@llvm.org> Author: dpatel Date: Tue Mar 1 16:58:55 2011 New Revision: 126794 URL: http://llvm.org/viewvc/llvm-project?rev=126794&view=rev Log: If argument numbering is encoded in metadata then emit arguments' debug info in that order. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=126794&r1=126793&r2=126794&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Mar 1 16:58:55 2011 @@ -1802,6 +1802,14 @@ return NULL; SmallVector Children; + + // Collect arguments for current function. + if (Scope == CurrentFnDbgScope) + for (unsigned i = 0, N = CurrentFnArguments.size(); i < N; ++i) + if (DbgVariable *ArgDV = CurrentFnArguments[i]) + if (DIE *Arg = constructVariableDIE(ArgDV, Scope)) + Children.push_back(Arg); + // Collect lexical scope childrens first. const SmallVector &Variables = Scope->getDbgVariables(); for (unsigned i = 0, N = Variables.size(); i < N; ++i) @@ -2309,6 +2317,25 @@ return AbsDbgVariable; } +/// addCurrentFnArgument - If Var is an current function argument that add +/// it in CurrentFnArguments list. +bool DwarfDebug::addCurrentFnArgument(const MachineFunction *MF, + DbgVariable *Var, DbgScope *Scope) { + if (Scope != CurrentFnDbgScope) + return false; + DIVariable DV = Var->getVariable(); + if (DV.getTag() != dwarf::DW_TAG_arg_variable) + return false; + unsigned ArgNo = DV.getArgNumber(); + if (ArgNo == 0) + return false; + + if (CurrentFnArguments.size() == 0) + CurrentFnArguments.resize(MF->getFunction()->arg_size()); + CurrentFnArguments[ArgNo - 1] = Var; + return true; +} + /// collectVariableInfoFromMMITable - Collect variable information from /// side table maintained by MMI. void @@ -2337,7 +2364,8 @@ DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VP.second); DbgVariable *RegVar = new DbgVariable(DV); recordVariableFrameIndex(RegVar, VP.first); - Scope->addVariable(RegVar); + if (!addCurrentFnArgument(MF, RegVar, Scope)) + Scope->addVariable(RegVar); if (AbsDbgVariable) { recordVariableFrameIndex(AbsDbgVariable, VP.first); VarToAbstractVarMap[RegVar] = AbsDbgVariable; @@ -2409,7 +2437,8 @@ Processed.insert(DV); DbgVariable *RegVar = new DbgVariable(DV); - Scope->addVariable(RegVar); + if (!addCurrentFnArgument(MF, RegVar, Scope)) + Scope->addVariable(RegVar); if (DbgVariable *AbsVar = findAbstractVariable(DV, MInsn->getDebugLoc())) { DbgVariableToDbgInstMap[AbsVar] = MInsn; VarToAbstractVarMap[RegVar] = AbsVar; @@ -2973,6 +3002,7 @@ // Clear debug info CurrentFnDbgScope = NULL; + CurrentFnArguments.clear(); InsnNeedsLabel.clear(); DbgVariableToFrameIndexMap.clear(); VarToAbstractVarMap.clear(); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=126794&r1=126793&r2=126794&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Tue Mar 1 16:58:55 2011 @@ -139,10 +139,13 @@ /// UniqueVector SectionMap; - // CurrentFnDbgScope - Top level scope for the current function. - // + /// CurrentFnDbgScope - Top level scope for the current function. + /// DbgScope *CurrentFnDbgScope; + /// CurrentFnArguments - List of Arguments (DbgValues) for current function. + SmallVector CurrentFnArguments; + /// DbgScopeMap - Tracks the scopes in the current function. Owns the /// contained DbgScope*s. /// @@ -546,6 +549,11 @@ /// and collect DbgScopes. Return true, if atleast one scope was found. bool extractScopeInformation(); + /// addCurrentFnArgument - If Var is an current function argument that add + /// it in CurrentFnArguments list. + bool addCurrentFnArgument(const MachineFunction *MF, + DbgVariable *Var, DbgScope *Scope); + /// collectVariableInfo - Populate DbgScope entries with variables' info. void collectVariableInfo(const MachineFunction *, SmallPtrSet &ProcessedVars); From Erik.Olofsson at hansoft.se Tue Mar 1 17:05:24 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Wed, 2 Mar 2011 00:05:24 +0100 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> Adds a cmake option to compile multiple translation units in parallel for Microsoft compilers. Option is only added for MSVC and is enabled by default. Please review and commit if good. Regards, Erik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/29168e4a/attachment.html -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: llvm-msvc-multi-processor-compilation.patch.txt Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/29168e4a/attachment.txt From ofv at wanadoo.es Tue Mar 1 17:11:57 2011 From: ofv at wanadoo.es (Oscar Fuentes) Date: Tue, 01 Mar 2011 23:11:57 -0000 Subject: [llvm-commits] [llvm] r126796 - in /llvm/trunk: lib/MC/MachObjectWriter.cpp unittests/Support/MathExtrasTest.cpp utils/unittest/googletest/include/gtest/gtest.h Message-ID: <20110301231157.6EB1A2A6C12C@llvm.org> Author: ofv Date: Tue Mar 1 17:11:57 2011 New Revision: 126796 URL: http://llvm.org/viewvc/llvm-project?rev=126796&view=rev Log: Fixes warnings emitted by Visual Studio 2010 compiler. Patch by Erik Olofsson! Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp llvm/trunk/unittests/Support/MathExtrasTest.cpp llvm/trunk/utils/unittest/googletest/include/gtest/gtest.h Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=126796&r1=126795&r2=126796&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Tue Mar 1 17:11:57 2011 @@ -274,8 +274,8 @@ if (is64Bit()) Write32(0); // reserved3 - assert(OS.tell() - Start == is64Bit() ? macho::Section64Size : - macho::Section32Size); + assert(OS.tell() - Start == (is64Bit() ? macho::Section64Size : + macho::Section32Size)); } void WriteSymtabLoadCommand(uint32_t SymbolOffset, uint32_t NumSymbols, Modified: llvm/trunk/unittests/Support/MathExtrasTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/MathExtrasTest.cpp?rev=126796&r1=126795&r2=126796&view=diff ============================================================================== --- llvm/trunk/unittests/Support/MathExtrasTest.cpp (original) +++ llvm/trunk/unittests/Support/MathExtrasTest.cpp Tue Mar 1 17:11:57 2011 @@ -73,7 +73,7 @@ } TEST(MathExtras, FloatBits) { - static const float kValue = 5632.34; + static const float kValue = 5632.34f; EXPECT_FLOAT_EQ(kValue, BitsToFloat(FloatToBits(kValue))); } Modified: llvm/trunk/utils/unittest/googletest/include/gtest/gtest.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/unittest/googletest/include/gtest/gtest.h?rev=126796&r1=126795&r2=126796&view=diff ============================================================================== --- llvm/trunk/utils/unittest/googletest/include/gtest/gtest.h (original) +++ llvm/trunk/utils/unittest/googletest/include/gtest/gtest.h Tue Mar 1 17:11:57 2011 @@ -1258,6 +1258,8 @@ #pragma warning(push) // Saves the current warning state. #pragma warning(disable:4389) // Temporarily disables warning on // signed/unsigned mismatch. +#pragma warning(disable:4805) // Temporarily disables warning on + // unsafe mix of types #endif if (expected == actual) { From ofv at wanadoo.es Tue Mar 1 17:16:13 2011 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=) Date: Wed, 02 Mar 2011 00:16:13 +0100 Subject: [llvm-commits] [PATCH] Fix MSVC10 warnings References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC1@winserv02.hansoft.local> Message-ID: <87sjv6zb2a.fsf@wanadoo.es> Erik Olofsson writes: > Fixes warnings emitted by Visual Studio 2010 compiler. > > Please review and commit if good. Committed as r126796. Thanks. From stoklund at 2pi.dk Tue Mar 1 17:14:48 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 01 Mar 2011 23:14:48 -0000 Subject: [llvm-commits] [llvm] r126798 - /llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Message-ID: <20110301231448.6B4C22A6C12C@llvm.org> Author: stoklund Date: Tue Mar 1 17:14:48 2011 New Revision: 126798 URL: http://llvm.org/viewvc/llvm-project?rev=126798&view=rev Log: Drop RAGreedy::trySpillInterferences(). This is a waste of time since we already know how to evict all interferences which is a better approach anyway. Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=126798&r1=126797&r2=126798&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Tue Mar 1 17:14:48 2011 @@ -145,7 +145,6 @@ bool checkUncachedInterference(LiveInterval&, unsigned); LiveInterval *getSingleInterference(LiveInterval&, unsigned); bool reassignVReg(LiveInterval &InterferingVReg, unsigned OldPhysReg); - float calcInterferenceWeight(LiveInterval&, unsigned); float calcInterferenceInfo(LiveInterval&, unsigned); float calcGlobalSplitCost(const BitVector&); void splitAroundRegion(LiveInterval&, unsigned, const BitVector&, @@ -166,8 +165,6 @@ SmallVectorImpl&); unsigned trySplit(LiveInterval&, AllocationOrder&, SmallVectorImpl&); - unsigned trySpillInterferences(LiveInterval&, AllocationOrder&, - SmallVectorImpl&); }; } // end anonymous namespace @@ -1284,68 +1281,6 @@ //===----------------------------------------------------------------------===// -// Spilling -//===----------------------------------------------------------------------===// - -/// calcInterferenceWeight - Calculate the combined spill weight of -/// interferences when assigning VirtReg to PhysReg. -float RAGreedy::calcInterferenceWeight(LiveInterval &VirtReg, unsigned PhysReg){ - float Sum = 0; - for (const unsigned *AI = TRI->getOverlaps(PhysReg); *AI; ++AI) { - LiveIntervalUnion::Query &Q = query(VirtReg, *AI); - Q.collectInterferingVRegs(); - if (Q.seenUnspillableVReg()) - return HUGE_VALF; - for (unsigned i = 0, e = Q.interferingVRegs().size(); i != e; ++i) - Sum += Q.interferingVRegs()[i]->weight; - } - return Sum; -} - -/// trySpillInterferences - Try to spill interfering registers instead of the -/// current one. Only do it if the accumulated spill weight is smaller than the -/// current spill weight. -unsigned RAGreedy::trySpillInterferences(LiveInterval &VirtReg, - AllocationOrder &Order, - SmallVectorImpl &NewVRegs) { - NamedRegionTimer T("Spill Interference", TimerGroupName, TimePassesIsEnabled); - unsigned BestPhys = 0; - float BestWeight = 0; - - Order.rewind(); - while (unsigned PhysReg = Order.next()) { - float Weight = calcInterferenceWeight(VirtReg, PhysReg); - if (Weight == HUGE_VALF || Weight >= VirtReg.weight) - continue; - if (!BestPhys || Weight < BestWeight) - BestPhys = PhysReg, BestWeight = Weight; - } - - // No candidates found. - if (!BestPhys) - return 0; - - // Collect all interfering registers. - SmallVector Spills; - for (const unsigned *AI = TRI->getOverlaps(BestPhys); *AI; ++AI) { - LiveIntervalUnion::Query &Q = query(VirtReg, *AI); - Spills.append(Q.interferingVRegs().begin(), Q.interferingVRegs().end()); - for (unsigned i = 0, e = Q.interferingVRegs().size(); i != e; ++i) { - LiveInterval *VReg = Q.interferingVRegs()[i]; - unassign(*VReg, *AI); - } - } - - // Spill them all. - DEBUG(dbgs() << "spilling " << Spills.size() << " interferences with weight " - << BestWeight << '\n'); - for (unsigned i = 0, e = Spills.size(); i != e; ++i) - spiller().spill(Spills[i], NewVRegs, Spills); - return BestPhys; -} - - -//===----------------------------------------------------------------------===// // Main Entry Point //===----------------------------------------------------------------------===// @@ -1385,11 +1320,6 @@ if (PhysReg || !NewVRegs.empty()) return PhysReg; - // Try to spill another interfering reg with less spill weight. - PhysReg = trySpillInterferences(VirtReg, Order, NewVRegs); - if (PhysReg) - return PhysReg; - // Finally spill VirtReg itself. NamedRegionTimer T("Spiller", TimerGroupName, TimePassesIsEnabled); SmallVector pendingSpills; From stoklund at 2pi.dk Tue Mar 1 17:14:51 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 01 Mar 2011 23:14:51 -0000 Subject: [llvm-commits] [llvm] r126799 - in /llvm/trunk/lib/CodeGen: SplitKit.cpp SplitKit.h Message-ID: <20110301231451.271D72A6C12D@llvm.org> Author: stoklund Date: Tue Mar 1 17:14:50 2011 New Revision: 126799 URL: http://llvm.org/viewvc/llvm-project?rev=126799&view=rev Log: Delete dead code. Local live range splitting is better driven by interference. This code was just guessing. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=126799&r1=126798&r2=126799&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Tue Mar 1 17:14:50 2011 @@ -973,72 +973,3 @@ } finish(); } - - -//===----------------------------------------------------------------------===// -// Sub Block Splitting -//===----------------------------------------------------------------------===// - -/// getBlockForInsideSplit - If CurLI is contained inside a single basic block, -/// and it wou pay to subdivide the interval inside that block, return it. -/// Otherwise return NULL. The returned block can be passed to -/// SplitEditor::splitInsideBlock. -const MachineBasicBlock *SplitAnalysis::getBlockForInsideSplit() { - // The interval must be exclusive to one block. - if (UsingBlocks.size() != 1) - return 0; - // Don't to this for less than 4 instructions. We want to be sure that - // splitting actually reduces the instruction count per interval. - if (UsingInstrs.size() < 4) - return 0; - return UsingBlocks.begin()->first; -} - -/// splitInsideBlock - Split CurLI into multiple intervals inside MBB. -void SplitEditor::splitInsideBlock(const MachineBasicBlock *MBB) { - SmallVector Uses; - Uses.reserve(SA.UsingInstrs.size()); - for (SplitAnalysis::InstrPtrSet::const_iterator I = SA.UsingInstrs.begin(), - E = SA.UsingInstrs.end(); I != E; ++I) - if ((*I)->getParent() == MBB) - Uses.push_back(LIS.getInstructionIndex(*I)); - DEBUG(dbgs() << " splitInsideBlock BB#" << MBB->getNumber() << " for " - << Uses.size() << " instructions.\n"); - assert(Uses.size() >= 3 && "Need at least 3 instructions"); - array_pod_sort(Uses.begin(), Uses.end()); - - // Simple algorithm: Find the largest gap between uses as determined by slot - // indices. Create new intervals for instructions before the gap and after the - // gap. - unsigned bestPos = 0; - int bestGap = 0; - DEBUG(dbgs() << " dist (" << Uses[0]); - for (unsigned i = 1, e = Uses.size(); i != e; ++i) { - int g = Uses[i-1].distance(Uses[i]); - DEBUG(dbgs() << ") -" << g << "- (" << Uses[i]); - if (g > bestGap) - bestPos = i, bestGap = g; - } - DEBUG(dbgs() << "), best: -" << bestGap << "-\n"); - - // bestPos points to the first use after the best gap. - assert(bestPos > 0 && "Invalid gap"); - - // FIXME: Don't create intervals for low densities. - - // First interval before the gap. Don't create single-instr intervals. - if (bestPos > 1) { - openIntv(); - useIntv(enterIntvBefore(Uses.front()), leaveIntvAfter(Uses[bestPos-1])); - closeIntv(); - } - - // Second interval after the gap. - if (bestPos < Uses.size()-1) { - openIntv(); - useIntv(enterIntvBefore(Uses[bestPos]), leaveIntvAfter(Uses.back())); - closeIntv(); - } - - finish(); -} Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=126799&r1=126798&r2=126799&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Tue Mar 1 17:14:50 2011 @@ -141,12 +141,6 @@ /// having CurLI split to a new live interval. Return true if Blocks can be /// passed to SplitEditor::splitSingleBlocks. bool getMultiUseBlocks(BlockPtrSet &Blocks); - - /// getBlockForInsideSplit - If CurLI is contained inside a single basic - /// block, and it would pay to subdivide the interval inside that block, - /// return it. Otherwise return NULL. The returned block can be passed to - /// SplitEditor::splitInsideBlock. - const MachineBasicBlock *getBlockForInsideSplit(); }; @@ -385,9 +379,6 @@ /// splitSingleBlocks - Split CurLI into a separate live interval inside each /// basic block in Blocks. void splitSingleBlocks(const SplitAnalysis::BlockPtrSet &Blocks); - - /// splitInsideBlock - Split CurLI into multiple intervals inside MBB. - void splitInsideBlock(const MachineBasicBlock *); }; } From stoklund at 2pi.dk Tue Mar 1 17:14:53 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 01 Mar 2011 23:14:53 -0000 Subject: [llvm-commits] [llvm] r126800 - in /llvm/trunk/lib/CodeGen: SplitKit.cpp SplitKit.h Message-ID: <20110301231453.CAC9F2A6C12E@llvm.org> Author: stoklund Date: Tue Mar 1 17:14:53 2011 New Revision: 126800 URL: http://llvm.org/viewvc/llvm-project?rev=126800&view=rev Log: Move the value map from LiveIntervalMap to SplitEditor. The value map is currently not used, all values are 'complex mapped' and LiveIntervalMap::mapValue is used to dig them out. This is the first step in a series changes leading to the removal of LiveIntervalMap. Its data structures can be shared among all the live intervals created by a split, so it is wasteful to create a copy for each. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=126800&r1=126799&r2=126800&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Tue Mar 1 17:14:53 2011 @@ -210,41 +210,9 @@ void LiveIntervalMap::reset(LiveInterval *li) { LI = li; - Values.clear(); LiveOutCache.clear(); } -bool LiveIntervalMap::isComplexMapped(const VNInfo *ParentVNI) const { - ValueMap::const_iterator i = Values.find(ParentVNI); - return i != Values.end() && i->second == 0; -} - -// defValue - Introduce a LI def for ParentVNI that could be later than -// ParentVNI->def. -VNInfo *LiveIntervalMap::defValue(const VNInfo *ParentVNI, SlotIndex Idx) { - assert(LI && "call reset first"); - assert(ParentVNI && "Mapping NULL value"); - assert(Idx.isValid() && "Invalid SlotIndex"); - assert(ParentLI.getVNInfoAt(Idx) == ParentVNI && "Bad ParentVNI"); - - // Create a new value. - VNInfo *VNI = LI->getNextValue(Idx, 0, LIS.getVNInfoAllocator()); - - // Preserve the PHIDef bit. - if (ParentVNI->isPHIDef() && Idx == ParentVNI->def) - VNI->setIsPHIDef(true); - - // Use insert for lookup, so we can add missing values with a second lookup. - std::pair InsP = - Values.insert(makeVV(ParentVNI, Idx == ParentVNI->def ? VNI : 0)); - - // This is now a complex def. Mark with a NULL in valueMap. - if (!InsP.second) - InsP.first->second = 0; - - return VNI; -} - // mapValue - Find the mapped value for ParentVNI at Idx. // Potentially create phi-def values. @@ -255,23 +223,6 @@ assert(Idx.isValid() && "Invalid SlotIndex"); assert(ParentLI.getVNInfoAt(Idx) == ParentVNI && "Bad ParentVNI"); - // Use insert for lookup, so we can add missing values with a second lookup. - std::pair InsP = - Values.insert(makeVV(ParentVNI, 0)); - - // This was an unknown value. Create a simple mapping. - if (InsP.second) { - if (simple) *simple = true; - return InsP.first->second = LI->createValueCopy(ParentVNI, - LIS.getVNInfoAllocator()); - } - - // This was a simple mapped value. - if (InsP.first->second) { - if (simple) *simple = true; - return InsP.first->second; - } - // This is a complex mapped value. There may be multiple defs, and we may need // to create phi-defs. if (simple) *simple = false; @@ -589,6 +540,60 @@ dbgs() << '\n'; } +VNInfo *SplitEditor::defValue(unsigned RegIdx, + const VNInfo *ParentVNI, + SlotIndex Idx) { + assert(ParentVNI && "Mapping NULL value"); + assert(Idx.isValid() && "Invalid SlotIndex"); + assert(Edit.getParent().getVNInfoAt(Idx) == ParentVNI && "Bad Parent VNI"); + LiveInterval *LI = Edit.get(RegIdx); + + // Create a new value. + VNInfo *VNI = LI->getNextValue(Idx, 0, LIS.getVNInfoAllocator()); + + // Preserve the PHIDef bit. + if (ParentVNI->isPHIDef() && Idx == ParentVNI->def) + VNI->setIsPHIDef(true); + + // Use insert for lookup, so we can add missing values with a second lookup. + std::pair InsP = + Values.insert(std::make_pair(std::make_pair(RegIdx, ParentVNI->id), VNI)); + + // This was the first time (RegIdx, ParentVNI) was mapped. + // Keep it as a simple def without any liveness. + if (InsP.second) + return VNI; + + // If the previous value was a simple mapping, add liveness for it now. + if (VNInfo *OldVNI = InsP.first->second) { + SlotIndex Def = OldVNI->def; + LI->addRange(LiveRange(Def, Def.getNextSlot(), OldVNI)); + // No longer a simple mapping. + InsP.first->second = 0; + } + + // This is a complex mapping, add liveness for VNI + SlotIndex Def = VNI->def; + LI->addRange(LiveRange(Def, Def.getNextSlot(), VNI)); + + return VNI; +} + +void SplitEditor::markComplexMapped(unsigned RegIdx, const VNInfo *ParentVNI) { + assert(ParentVNI && "Mapping NULL value"); + VNInfo *&VNI = Values[std::make_pair(RegIdx, ParentVNI->id)]; + + // ParentVNI was either unmapped or already complex mapped. Either way. + if (!VNI) + return; + + // This was previously a single mapping. Make sure the old def is represented + // by a trivial live range. + SlotIndex Def = VNI->def; + Edit.get(RegIdx)->addRange(LiveRange(Def, Def.getNextSlot(), VNI)); + VNI = 0; +} + VNInfo *SplitEditor::defFromParent(unsigned RegIdx, VNInfo *ParentVNI, SlotIndex UseIdx, @@ -609,12 +614,12 @@ Def = LIS.InsertMachineInstrInMaps(CopyMI).getDefIndex(); } + // Temporarily mark all values as complex mapped. + markComplexMapped(RegIdx, ParentVNI); + // Define the value in Reg. - VNInfo *VNI = LIMappers[RegIdx].defValue(ParentVNI, Def); + VNInfo *VNI = defValue(RegIdx, ParentVNI, Def); VNI->setCopy(CopyMI); - - // Add minimal liveness for the new value. - Edit.get(RegIdx)->addRange(LiveRange(Def, Def.getNextSlot(), VNI)); return VNI; } @@ -833,13 +838,11 @@ const VNInfo *ParentVNI = *I; if (ParentVNI->isUnused()) continue; - LiveIntervalMap &LIM = LIMappers[RegAssign.lookup(ParentVNI->def)]; - VNInfo *VNI = LIM.defValue(ParentVNI, ParentVNI->def); - LIM.getLI()->addRange(LiveRange(ParentVNI->def, - ParentVNI->def.getNextSlot(), VNI)); + unsigned RegIdx = RegAssign.lookup(ParentVNI->def); // Mark all values as complex to force liveness computation. // This should really only be necessary for remat victims, but we are lazy. - LIM.markComplexMapped(ParentVNI); + markComplexMapped(RegIdx, ParentVNI); + defValue(RegIdx, ParentVNI, ParentVNI->def); } #ifndef NDEBUG Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=126800&r1=126799&r2=126800&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Tue Mar 1 17:14:53 2011 @@ -162,14 +162,6 @@ // The child interval's values are fully contained inside ParentLI values. LiveInterval *LI; - typedef DenseMap ValueMap; - - // Map ParentLI values to simple values in LI that are defined at the same - // SlotIndex, or NULL for ParentLI values that have complex LI defs. - // Note there is a difference between values mapping to NULL (complex), and - // values not present (unknown/unmapped). - ValueMap Values; - typedef std::pair LiveOutPair; typedef DenseMap LiveOutMap; @@ -203,12 +195,6 @@ /// getLI - return the current live interval. LiveInterval *getLI() const { return LI; } - /// defValue - define a value in LI from the ParentLI value VNI and Idx. - /// Idx does not have to be ParentVNI->def, but it must be contained within - /// ParentVNI's live range in ParentLI. - /// Return the new LI value. - VNInfo *defValue(const VNInfo *ParentVNI, SlotIndex Idx); - /// mapValue - map ParentVNI to the corresponding LI value at Idx. It is /// assumed that ParentVNI is live at Idx. /// If ParentVNI has not been defined by defValue, it is assumed that @@ -225,20 +211,6 @@ // Idx. Return the found VNInfo, or NULL. VNInfo *extendTo(const MachineBasicBlock *MBB, SlotIndex Idx); - /// isMapped - Return true is ParentVNI is a known mapped value. It may be a - /// simple 1-1 mapping or a complex mapping to later defs. - bool isMapped(const VNInfo *ParentVNI) const { - return Values.count(ParentVNI); - } - - /// isComplexMapped - Return true if ParentVNI has received new definitions - /// with defValue. - bool isComplexMapped(const VNInfo *ParentVNI) const; - - /// markComplexMapped - Mark ParentVNI as complex mapped regardless of the - /// number of definitions. - void markComplexMapped(const VNInfo *ParentVNI) { Values[ParentVNI] = 0; } - // addSimpleRange - Add a simple range from ParentLI to LI. // ParentVNI must be live in the [Start;End) interval. void addSimpleRange(SlotIndex Start, SlotIndex End, const VNInfo *ParentVNI); @@ -292,6 +264,29 @@ /// LIMappers - One LiveIntervalMap or each interval in Edit. SmallVector LIMappers; + typedef DenseMap, VNInfo*> ValueMap; + + /// Values - keep track of the mapping from parent values to values in the new + /// intervals. Given a pair (RegIdx, ParentVNI->id), Values contains: + /// + /// 1. No entry - the value is not mapped to Edit.get(RegIdx). + /// 2. Null - the value is mapped to multiple values in Edit.get(RegIdx). + /// Each value is represented by a minimal live range at its def. + /// 3. A non-null VNInfo - the value is mapped to a single new value. + /// The new value has no live ranges anywhere. + ValueMap Values; + + /// defValue - define a value in RegIdx from ParentVNI at Idx. + /// Idx does not have to be ParentVNI->def, but it must be contained within + /// ParentVNI's live range in ParentLI. The new value is added to the value + /// map. + /// Return the new LI value. + VNInfo *defValue(unsigned RegIdx, const VNInfo *ParentVNI, SlotIndex Idx); + + /// markComplexMapped - Mark ParentVNI as complex mapped in RegIdx regardless + /// of the number of defs. + void markComplexMapped(unsigned RegIdx, const VNInfo *ParentVNI); + /// defFromParent - Define Reg from ParentVNI at UseIdx using either /// rematerialization or a COPY from parent. Return the new value. VNInfo *defFromParent(unsigned RegIdx, From Erik.Olofsson at hansoft.se Tue Mar 1 17:22:01 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Wed, 2 Mar 2011 00:22:01 +0100 Subject: [llvm-commits] [PATCH] Add support for MSVC style diagnostics in llvm tools Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC4@winserv02.hansoft.local> Adds support for MSVC style diagnostics to llvm tools by providing a cmake option LLVM_ENABLE_MSVC_STYLE_DIAGNOSTICS. This option is by default turned on when configuring for MSVC and off for all other compilers. I also needed to remove location matching from two tests for them to pass with MSVC style diagnostics. This could later be turned into the default for a command line option choosing the diagnostics style in each tool. Please review and commit if good. Regards, Erik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/3a5c1bb2/attachment.html -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: llvm-msvc-style-diagnostics.patch.txt Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/3a5c1bb2/attachment.txt From ofv at wanadoo.es Tue Mar 1 17:26:08 2011 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=) Date: Wed, 02 Mar 2011 00:26:08 +0100 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> Message-ID: <87mxlezalr.fsf@wanadoo.es> Erik Olofsson writes: > Adds a cmake option to compile multiple translation units in parallel > for Microsoft compilers. Option is only added for MSVC and is enabled > by default. > > Please review and commit if good. IMHO, we must have a very good reason for enabling by default a feature that it is disabled by default on the build tool. If the user is expected to add /MP to his project setting in case he wants multiprocessor builds, we shouldn't do more. > Index: cmake/modules/HandleLLVMOptions.cmake > =================================================================== > --- cmake/modules/HandleLLVMOptions.cmake (revision 126745) > +++ cmake/modules/HandleLLVMOptions.cmake (working copy) > @@ -134,6 +134,13 @@ > -w14062 # Promote "enumerator in switch of enum is not handled" to level 1 warning. > ) > > + if (LLVM_ENABLE_MULTIPROCESSORCOMPILATION) > + add_llvm_definitions( /MP ) > + message("Multi processor compilation enabled.") > + else (LLVM_ENABLE_MULTIPROCESSORCOMPILATION) > + message("Multi processor compilation disabled.") There is no need to inform the user about both states. We must print a message when the user changed the default value of the option. > + endif (LLVM_ENABLE_MULTIPROCESSORCOMPILATION) > + > # Enable warnings > if (LLVM_ENABLE_WARNINGS) > add_llvm_definitions( /W4 /Wall ) > Index: CMakeLists.txt > =================================================================== > --- CMakeLists.txt (revision 126745) > +++ CMakeLists.txt (working copy) > @@ -133,6 +133,10 @@ > > include(AddLLVMDefinitions) > > +if( MSVC ) > + option(LLVM_ENABLE_MULTIPROCESSORCOMPILATION "Enable multiprocessor compilation." ON) > +endif() > + MSVC is true for all build tools that work with the MSVC compiler. AFAIK /MP only works with MSBuild or whatever is used nowadays by the IDE. Please use MSVC_IDE instead of MSVC. > option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON) > > include(config-ix) The option needs to be documented on docs/CMake.html. Maybe on the section docs/CMake.html#msvc From stoklund at 2pi.dk Tue Mar 1 17:24:19 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 01 Mar 2011 23:24:19 -0000 Subject: [llvm-commits] [llvm] r126801 - in /llvm/trunk/lib/CodeGen: SplitKit.cpp SplitKit.h Message-ID: <20110301232419.56AFB2A6C12C@llvm.org> Author: stoklund Date: Tue Mar 1 17:24:19 2011 New Revision: 126801 URL: http://llvm.org/viewvc/llvm-project?rev=126801&view=rev Log: Delete dead code. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=126801&r1=126800&r2=126801&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Tue Mar 1 17:24:19 2011 @@ -445,65 +445,6 @@ return I->valno; } -// addSimpleRange - Add a simple range from ParentLI to LI. -// ParentVNI must be live in the [Start;End) interval. -void LiveIntervalMap::addSimpleRange(SlotIndex Start, SlotIndex End, - const VNInfo *ParentVNI) { - assert(LI && "call reset first"); - bool simple; - VNInfo *VNI = mapValue(ParentVNI, Start, &simple); - // A simple mapping is easy. - if (simple) { - LI->addRange(LiveRange(Start, End, VNI)); - return; - } - - // ParentVNI is a complex value. We must map per MBB. - MachineFunction::iterator MBB = LIS.getMBBFromIndex(Start); - MachineFunction::iterator MBBE = LIS.getMBBFromIndex(End.getPrevSlot()); - - if (MBB == MBBE) { - LI->addRange(LiveRange(Start, End, VNI)); - return; - } - - // First block. - LI->addRange(LiveRange(Start, LIS.getMBBEndIdx(MBB), VNI)); - - // Run sequence of full blocks. - for (++MBB; MBB != MBBE; ++MBB) { - Start = LIS.getMBBStartIdx(MBB); - LI->addRange(LiveRange(Start, LIS.getMBBEndIdx(MBB), - mapValue(ParentVNI, Start))); - } - - // Final block. - Start = LIS.getMBBStartIdx(MBB); - if (Start != End) - LI->addRange(LiveRange(Start, End, mapValue(ParentVNI, Start))); -} - -/// addRange - Add live ranges to LI where [Start;End) intersects ParentLI. -/// All needed values whose def is not inside [Start;End) must be defined -/// beforehand so mapValue will work. -void LiveIntervalMap::addRange(SlotIndex Start, SlotIndex End) { - assert(LI && "call reset first"); - LiveInterval::const_iterator B = ParentLI.begin(), E = ParentLI.end(); - LiveInterval::const_iterator I = std::lower_bound(B, E, Start); - - // Check if --I begins before Start and overlaps. - if (I != B) { - --I; - if (I->end > Start) - addSimpleRange(Start, std::min(End, I->end), I->valno); - ++I; - } - - // The remaining ranges begin after Start. - for (;I != E && I->start < End; ++I) - addSimpleRange(I->start, std::min(End, I->end), I->valno); -} - //===----------------------------------------------------------------------===// // Split Editor Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=126801&r1=126800&r2=126801&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Tue Mar 1 17:24:19 2011 @@ -210,15 +210,6 @@ // parentli is assumed to be live at Idx. Extend the live range to include // Idx. Return the found VNInfo, or NULL. VNInfo *extendTo(const MachineBasicBlock *MBB, SlotIndex Idx); - - // addSimpleRange - Add a simple range from ParentLI to LI. - // ParentVNI must be live in the [Start;End) interval. - void addSimpleRange(SlotIndex Start, SlotIndex End, const VNInfo *ParentVNI); - - /// addRange - Add live ranges to LI where [Start;End) intersects ParentLI. - /// All needed values whose def is not inside [Start;End) must be defined - /// beforehand so mapValue will work. - void addRange(SlotIndex Start, SlotIndex End); }; From Erik.Olofsson at hansoft.se Tue Mar 1 17:29:35 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Wed, 2 Mar 2011 00:29:35 +0100 Subject: [llvm-commits] [PATCH] Fix tests with temporary files fails on Windows Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC5@winserv02.hansoft.local> Fixes test failures on Windows where temporary files are used. On Windows a temporary file cannot be opened again while the original file handle is still in use. Please review and commit if good. Regards, Erik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/2bf79fcb/attachment.html -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: llvm-temp-test-file-fail-on-win32.patch.txt Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/2bf79fcb/attachment.txt From ofv at wanadoo.es Tue Mar 1 17:29:29 2011 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=) Date: Wed, 02 Mar 2011 00:29:29 +0100 Subject: [llvm-commits] [PATCH] Add support for MSVC style diagnostics in llvm tools References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC4@winserv02.hansoft.local> Message-ID: <87hbbmzag6.fsf@wanadoo.es> Erik Olofsson writes: > Adds support for MSVC style diagnostics to llvm tools by providing a > cmake option LLVM_ENABLE_MSVC_STYLE_DIAGNOSTICS. This option is by > default turned on when configuring for MSVC and off for all other > compilers. I also needed to remove location matching from two tests > for them to pass with MSVC style diagnostics. > > This could later be turned into the default for a command line option > choosing the diagnostics style in each tool. Please some VS user comment on the value of this feature. From clattner at apple.com Tue Mar 1 17:37:39 2011 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Mar 2011 15:37:39 -0800 Subject: [llvm-commits] [llvm] r126782 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp In-Reply-To: <20110301211354.189E72A6C12C@llvm.org> References: <20110301211354.189E72A6C12C@llvm.org> Message-ID: <26E886B1-7394-43D9-9172-193878248AAD@apple.com> On Mar 1, 2011, at 1:13 PM, Cameron Zwarich wrote: > Author: zwarich > Date: Tue Mar 1 15:13:53 2011 > New Revision: 126782 > > URL: http://llvm.org/viewvc/llvm-project?rev=126782&view=rev > Log: > Stop computing the number of uses twice per value in CodeGenPrepare's sinking of > addressing code. On 403.gcc this almost halves CodeGenPrepare time and reduces > total llc time by 9.5%. Unfortunately, getNumUses() is still the hottest function > in llc. Wow! Can this use hasNUsesOrMore() to avoid walking the entire use list of things with tons of uses? Is this asking things like "i32 1" for the use count? Maybe constants can be filtered earlier? -Chris From clattner at apple.com Tue Mar 1 17:39:49 2011 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Mar 2011 15:39:49 -0800 Subject: [llvm-commits] [llvm] r126787 - /llvm/trunk/include/llvm/Support/SourceMgr.h In-Reply-To: <20110301221152.E34E72A6C12C@llvm.org> References: <20110301221152.E34E72A6C12C@llvm.org> Message-ID: On Mar 1, 2011, at 2:11 PM, Dan Gohman wrote: > Author: djg > Date: Tue Mar 1 16:11:52 2011 > New Revision: 126787 > > URL: http://llvm.org/viewvc/llvm-project?rev=126787&view=rev > Log: > Remove the showline argument from the SMDiagnostic constructor > which constructs a diagnostic with no line to show. Hi Dan, Removing the option sounds fine, but doesn't this patch silently switch it from 'true' to 'false'? -Chris > > Modified: > llvm/trunk/include/llvm/Support/SourceMgr.h > > Modified: llvm/trunk/include/llvm/Support/SourceMgr.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/SourceMgr.h?rev=126787&r1=126786&r2=126787&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Support/SourceMgr.h (original) > +++ llvm/trunk/include/llvm/Support/SourceMgr.h Tue Mar 1 16:11:52 2011 > @@ -156,10 +156,9 @@ > // Null diagnostic. > SMDiagnostic() : SM(0), LineNo(0), ColumnNo(0), ShowLine(0) {} > // Diagnostic with no location (e.g. file not found, command line arg error). > - SMDiagnostic(const std::string &filename, const std::string &Msg, > - bool showline = true) > + SMDiagnostic(const std::string &filename, const std::string &Msg) > : SM(0), Filename(filename), LineNo(-1), ColumnNo(-1), > - Message(Msg), ShowLine(showline) {} > + Message(Msg), ShowLine(false) {} > > // Diagnostic with a location. > SMDiagnostic(const SourceMgr &sm, SMLoc L, const std::string &FN, > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From zwarich at apple.com Tue Mar 1 17:44:51 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Tue, 1 Mar 2011 15:44:51 -0800 Subject: [llvm-commits] [llvm] r126782 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp In-Reply-To: <26E886B1-7394-43D9-9172-193878248AAD@apple.com> References: <20110301211354.189E72A6C12C@llvm.org> <26E886B1-7394-43D9-9172-193878248AAD@apple.com> Message-ID: <5AF8602F-2F29-4883-8732-0079370F1E85@apple.com> On Mar 1, 2011, at 3:37 PM, Chris Lattner wrote: > On Mar 1, 2011, at 1:13 PM, Cameron Zwarich wrote: > >> Author: zwarich >> Date: Tue Mar 1 15:13:53 2011 >> New Revision: 126782 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=126782&view=rev >> Log: >> Stop computing the number of uses twice per value in CodeGenPrepare's sinking of >> addressing code. On 403.gcc this almost halves CodeGenPrepare time and reduces >> total llc time by 9.5%. Unfortunately, getNumUses() is still the hottest function >> in llc. > > Wow! Can this use hasNUsesOrMore() to avoid walking the entire use list of things with tons of uses? Is this asking things like "i32 1" for the use count? Maybe constants can be filtered earlier? I don't think we can use hasNUsesOrMore(), because when it has fewer uses we need to walk them all to prove that, and when it has more uses we need to walk them all anyways because we need to compute the new maximum number of uses. I will experiment with filtering some things earlier though. Cameron From Erik.Olofsson at hansoft.se Tue Mar 1 17:54:53 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Wed, 2 Mar 2011 00:54:53 +0100 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: <87mxlezalr.fsf@wanadoo.es> References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> > -----Original Message----- > From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits- > bounces at cs.uiuc.edu] On Behalf Of ?scar Fuentes > IMHO, we must have a very good reason for enabling by default a feature > that it is disabled by default on the build tool. If the user is expected to add > /MP to his project setting in case he wants multiprocessor builds, we > shouldn't do more. I think Microsoft leaves this off by default because it's incompatible with some other options. Those options are not used by llvm however. I think it would be useful when a developer compiles llvm on Microsoft compilers the compilation should be as fast as possible out of the box. If we leave this off by default most developers will not know about the option and will not benefit from the feature. > MSVC is true for all build tools that work with the MSVC compiler. AFAIK > /MP only works with MSBuild or whatever is used nowadays by the IDE. > Please use MSVC_IDE instead of MSVC. Ok will do. It won't break the build though as it's a compiler option. If the build tool doesn't provide several translation units in one invocation it will simply ignore the parameter. Regards, Erik From rafael.espindola at gmail.com Tue Mar 1 18:04:25 2011 From: rafael.espindola at gmail.com (Rafael Avila de Espindola) Date: Tue, 01 Mar 2011 19:04:25 -0500 Subject: [llvm-commits] Split MCELFStreamer and ELFObjectWriter into .h and .cpp In-Reply-To: <919879.23172.qm@web55601.mail.re4.yahoo.com> References: <919879.23172.qm@web55601.mail.re4.yahoo.com> Message-ID: <4D6D8989.6020109@gmail.com> On 11-03-01 05:28 PM, Jan Sjodin wrote: > This patch splits the MCELFStreamer and ELFObjectWriter into .cpp and .h files > so the classes can be used by other components. I think the patch is OK. How much of the JIT you have implemented? I think that at this point (just before 2.9) the refactorings are OK, but the JIT itself should probably wait for the branch. > - Jan Cheers, Rafael From stoklund at 2pi.dk Tue Mar 1 18:06:16 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 02 Mar 2011 00:06:16 -0000 Subject: [llvm-commits] [llvm] r126803 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/SplitKit.cpp lib/CodeGen/SplitKit.h Message-ID: <20110302000616.1D6992A6C12C@llvm.org> Author: stoklund Date: Tue Mar 1 18:06:15 2011 New Revision: 126803 URL: http://llvm.org/viewvc/llvm-project?rev=126803&view=rev Log: Move LiveIntervalMap::extendTo into LiveInterval itself. This method could probably be used by LiveIntervalAnalysis::shrinkToUses, and now it can use extendIntervalEndTo() which coalesces ranges. Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h llvm/trunk/lib/CodeGen/LiveInterval.cpp llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=126803&r1=126802&r2=126803&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Tue Mar 1 18:06:15 2011 @@ -447,6 +447,11 @@ addRangeFrom(LR, ranges.begin()); } + /// extendInBlock - If this interval is live before UseIdx in the basic + /// block that starts at StartIdx, extend it to be live at UseIdx and return + /// the value. If there is no live range before UseIdx, return NULL. + VNInfo *extendInBlock(SlotIndex StartIdx, SlotIndex UseIdx); + /// join - Join two live intervals (this, and other) together. This applies /// mappings to the value numbers in the LHS/RHS intervals as specified. If /// the intervals are not joinable, this aborts. Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=126803&r1=126802&r2=126803&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Mar 1 18:06:15 2011 @@ -291,6 +291,22 @@ return ranges.insert(it, LR); } +/// extendInBlock - If this interval is live before UseIdx in the basic +/// block that starts at StartIdx, extend it to be live at UseIdx and return +/// the value. If there is no live range before UseIdx, return NULL. +VNInfo *LiveInterval::extendInBlock(SlotIndex StartIdx, SlotIndex UseIdx) { + if (empty()) + return 0; + iterator I = std::upper_bound(begin(), end(), UseIdx); + if (I == begin()) + return 0; + --I; + if (I->end <= StartIdx) + return 0; + if (I->end <= UseIdx) + extendIntervalEndTo(I, UseIdx.getNextSlot()); + return I->valno; +} /// removeRange - Remove the specified range from this interval. Note that /// the range must be in a single LiveRange in its entirety. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=126803&r1=126802&r2=126803&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Tue Mar 1 18:06:15 2011 @@ -230,7 +230,7 @@ assert(IdxMBB && "No MBB at Idx"); // Is there a def in the same MBB we can extend? - if (VNInfo *VNI = extendTo(IdxMBB, Idx)) + if (VNInfo *VNI = LI->extendInBlock(LIS.getMBBStartIdx(IdxMBB), Idx)) return VNI; // Now for the fun part. We know that ParentVNI potentially has multiple defs, @@ -262,8 +262,10 @@ } // Does Pred provide a live-out value? - SlotIndex Last = LIS.getMBBEndIdx(Pred).getPrevSlot(); - if (VNInfo *VNI = extendTo(Pred, Last)) { + SlotIndex Start, Last; + tie(Start, Last) = LIS.getSlotIndexes()->getMBBRange(Pred); + Last = Last.getPrevSlot(); + if (VNInfo *VNI = LI->extendInBlock(Start, Last)) { MachineBasicBlock *DefMBB = LIS.getMBBFromIndex(VNI->def); DEBUG(dbgs() << " found valno #" << VNI->id << " from BB#" << DefMBB->getNumber() @@ -429,22 +431,6 @@ } #endif -// extendTo - Find the last LI value defined in MBB at or before Idx. The -// ParentLI is assumed to be live at Idx. Extend the live range to Idx. -// Return the found VNInfo, or NULL. -VNInfo *LiveIntervalMap::extendTo(const MachineBasicBlock *MBB, SlotIndex Idx) { - assert(LI && "call reset first"); - LiveInterval::iterator I = std::upper_bound(LI->begin(), LI->end(), Idx); - if (I == LI->begin()) - return 0; - --I; - if (I->end <= LIS.getMBBStartIdx(MBB)) - return 0; - if (I->end <= Idx) - I->end = Idx.getNextSlot(); - return I->valno; -} - //===----------------------------------------------------------------------===// // Split Editor Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=126803&r1=126802&r2=126803&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Tue Mar 1 18:06:15 2011 @@ -205,11 +205,6 @@ /// If simple is not NULL, *simple will indicate if ParentVNI is a simply /// mapped value. VNInfo *mapValue(const VNInfo *ParentVNI, SlotIndex Idx, bool *simple = 0); - - // extendTo - Find the last LI value defined in MBB at or before Idx. The - // parentli is assumed to be live at Idx. Extend the live range to include - // Idx. Return the found VNInfo, or NULL. - VNInfo *extendTo(const MachineBasicBlock *MBB, SlotIndex Idx); }; From gohman at apple.com Tue Mar 1 18:11:58 2011 From: gohman at apple.com (Dan Gohman) Date: Tue, 1 Mar 2011 16:11:58 -0800 Subject: [llvm-commits] [llvm] r126787 - /llvm/trunk/include/llvm/Support/SourceMgr.h In-Reply-To: References: <20110301221152.E34E72A6C12C@llvm.org> Message-ID: <9598BAD9-C9E4-4061-AA39-5ED238AAFD0C@apple.com> On Mar 1, 2011, at 3:39 PM, Chris Lattner wrote: > > On Mar 1, 2011, at 2:11 PM, Dan Gohman wrote: > >> Author: djg >> Date: Tue Mar 1 16:11:52 2011 >> New Revision: 126787 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=126787&view=rev >> Log: >> Remove the showline argument from the SMDiagnostic constructor >> which constructs a diagnostic with no line to show. > > Hi Dan, > > Removing the option sounds fine, but doesn't this patch silently switch it from 'true' to 'false'? Yes, but since there's no line to show it doesn't matter. Dan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/77e3405d/attachment.html From ofv at wanadoo.es Tue Mar 1 18:12:50 2011 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=) Date: Wed, 02 Mar 2011 01:12:50 +0100 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> (Erik Olofsson's message of "Wed, 2 Mar 2011 00:54:53 +0100") References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> Message-ID: <87bp1uz8fx.fsf@wanadoo.es> Erik Olofsson writes: >> IMHO, we must have a very good reason for enabling by default a feature >> that it is disabled by default on the build tool. If the user is expected to add >> /MP to his project setting in case he wants multiprocessor builds, we >> shouldn't do more. > > I think Microsoft leaves this off by default because it's incompatible > with some other options. Those options are not used by llvm however. I > think it would be useful when a developer compiles llvm on Microsoft > compilers the compilation should be as fast as possible out of the > box. If we leave this off by default most developers will not know > about the option and will not benefit from the feature. Which are those options? If they are used on the future, having /MP active by default may create some inconveniences. Changing the default value of option(VAR ...) has no effect if VAR already is on CMakeCache.txt. >> MSVC is true for all build tools that work with the MSVC compiler. AFAIK >> /MP only works with MSBuild or whatever is used nowadays by the IDE. >> Please use MSVC_IDE instead of MSVC. > > Ok will do. It won't break the build though as it's a compiler > option. If the build tool doesn't provide several translation units in > one invocation it will simply ignore the parameter. It is a good thing to have a compiler's command line as clean as possible. From gohman at apple.com Tue Mar 1 18:11:28 2011 From: gohman at apple.com (Dan Gohman) Date: Wed, 02 Mar 2011 00:11:28 -0000 Subject: [llvm-commits] [llvm] r126804 - /llvm/trunk/include/llvm/Support/CFG.h Message-ID: <20110302001128.CEE3A2A6C12C@llvm.org> Author: djg Date: Tue Mar 1 18:11:28 2011 New Revision: 126804 URL: http://llvm.org/viewvc/llvm-project?rev=126804&view=rev Log: Make pred_iterator DefaultConstructible, and add an accessor to retrieve the underlying getOperandNo() value. Modified: llvm/trunk/include/llvm/Support/CFG.h Modified: llvm/trunk/include/llvm/Support/CFG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CFG.h?rev=126804&r1=126803&r2=126804&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CFG.h (original) +++ llvm/trunk/include/llvm/Support/CFG.h Tue Mar 1 18:11:28 2011 @@ -41,6 +41,7 @@ public: typedef typename super::pointer pointer; + PredIterator() {} explicit inline PredIterator(Ptr *bb) : It(bb->use_begin()) { advancePastNonTerminators(); } @@ -64,6 +65,12 @@ inline Self operator++(int) { // Postincrement Self tmp = *this; ++*this; return tmp; } + + /// getOperandNo - Return the operand number in the predecessor's + /// terminator of the successor. + unsigned getOperandNo() const { + return It.getOperandNo(); + } }; typedef PredIterator pred_iterator; From Erik.Olofsson at hansoft.se Tue Mar 1 18:24:03 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Wed, 2 Mar 2011 01:24:03 +0100 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: <87bp1uz8fx.fsf@wanadoo.es> References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> <87bp1uz8fx.fsf@wanadoo.es> Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC9@winserv02.hansoft.local> > -----Original Message----- > From: ?scar Fuentes [mailto:ofv at wanadoo.es] > Which are those options? If they are used on the future, having /MP active > by default may create some inconveniences. Changing the default value of > option(VAR ...) has no effect if VAR already is on CMakeCache.txt. Most notably incremental builds and creating a precompiled header. See http://msdn.microsoft.com/en-us/library/bb385193(v=VS.100).aspx Incremental builds are notoriously buggy, so I don't think we would ever want to enable that by default. If we ever want to add support for precompiled headers I do believe that msbuild automatically strips /MP if that option is enabled. Regards, Erik From clattner at apple.com Tue Mar 1 18:33:46 2011 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Mar 2011 16:33:46 -0800 Subject: [llvm-commits] [llvm] r126787 - /llvm/trunk/include/llvm/Support/SourceMgr.h In-Reply-To: <9598BAD9-C9E4-4061-AA39-5ED238AAFD0C@apple.com> References: <20110301221152.E34E72A6C12C@llvm.org> <9598BAD9-C9E4-4061-AA39-5ED238AAFD0C@apple.com> Message-ID: <29CBC7FB-D102-4D78-AE8C-8AF1830C9CF8@apple.com> On Mar 1, 2011, at 4:11 PM, Dan Gohman wrote: >>> Remove the showline argument from the SMDiagnostic constructor >>> which constructs a diagnostic with no line to show. >> >> Hi Dan, >> >> Removing the option sounds fine, but doesn't this patch silently switch it from 'true' to 'false'? > > Yes, but since there's no line to show it doesn't matter. > Hey, how about that. Ok then! :) -Chris From stoklund at 2pi.dk Tue Mar 1 18:33:01 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 02 Mar 2011 00:33:01 -0000 Subject: [llvm-commits] [llvm] r126805 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <20110302003301.3A1662A6C12C@llvm.org> Author: stoklund Date: Tue Mar 1 18:33:01 2011 New Revision: 126805 URL: http://llvm.org/viewvc/llvm-project?rev=126805&view=rev Log: Fix typo. 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=126805&r1=126804&r2=126805&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Mar 1 18:33:01 2011 @@ -847,7 +847,7 @@ assert(LII != NewLI.end() && "Missing live range for PHI"); if (LII->end != VNI->def.getNextSlot()) continue; - if (!VNI->isPHIDef()) { + if (VNI->isPHIDef()) { // This is a dead PHI. Remove it. VNI->setIsUnused(true); NewLI.removeRange(*LII); From stoklund at 2pi.dk Tue Mar 1 18:33:03 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 02 Mar 2011 00:33:03 -0000 Subject: [llvm-commits] [llvm] r126806 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <20110302003303.BC63E2A6C12D@llvm.org> Author: stoklund Date: Tue Mar 1 18:33:03 2011 New Revision: 126806 URL: http://llvm.org/viewvc/llvm-project?rev=126806&view=rev Log: Simplify LiveIntervals::shrinkToUses() a bit by using the new extendInBlock(). 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=126806&r1=126805&r2=126806&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Mar 1 18:33:03 2011 @@ -781,46 +781,34 @@ NewLI.addRange(LiveRange(VNI->def, VNI->def.getNextSlot(), VNI)); } + // Keep track of the PHIs that are in use. + SmallPtrSet UsedPHIs; + // Extend intervals to reach all uses in WorkList. while (!WorkList.empty()) { SlotIndex Idx = WorkList.back().first; VNInfo *VNI = WorkList.back().second; WorkList.pop_back(); - - // Extend the live range for VNI to be live at Idx. - LiveInterval::iterator I = NewLI.find(Idx); - - // Already got it? - if (I != NewLI.end() && I->start <= Idx) { - assert(I->valno == VNI && "Unexpected existing value number"); - continue; - } - - // Is there already a live range in the block containing Idx? const MachineBasicBlock *MBB = getMBBFromIndex(Idx); SlotIndex BlockStart = getMBBStartIdx(MBB); - DEBUG(dbgs() << "Shrink: Use val#" << VNI->id << " at " << Idx - << " in BB#" << MBB->getNumber() << '@' << BlockStart); - if (I != NewLI.begin() && (--I)->end > BlockStart) { - assert(I->valno == VNI && "Wrong reaching def"); - DEBUG(dbgs() << " extend [" << I->start << ';' << I->end << ")\n"); - // Is this the first use of a PHIDef in its defining block? - if (VNI->isPHIDef() && I->end == VNI->def.getNextSlot()) { - // The PHI is live, make sure the predecessors are live-out. - for (MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(), - PE = MBB->pred_end(); PI != PE; ++PI) { - SlotIndex Stop = getMBBEndIdx(*PI).getPrevSlot(); - VNInfo *PVNI = li->getVNInfoAt(Stop); - // A predecessor is not required to have a live-out value for a PHI. - if (PVNI) { - assert(PVNI->hasPHIKill() && "Missing hasPHIKill flag"); - WorkList.push_back(std::make_pair(Stop, PVNI)); - } + + // Extend the live range for VNI to be live at Idx. + if (VNInfo *ExtVNI = NewLI.extendInBlock(BlockStart, Idx)) { + assert(ExtVNI == VNI && "Unexpected existing value number"); + // Is this a PHIDef we haven't seen before? + if (!VNI->isPHIDef() || !UsedPHIs.insert(VNI)) + continue; + // The PHI is live, make sure the predecessors are live-out. + for (MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(), + PE = MBB->pred_end(); PI != PE; ++PI) { + SlotIndex Stop = getMBBEndIdx(*PI).getPrevSlot(); + VNInfo *PVNI = li->getVNInfoAt(Stop); + // A predecessor is not required to have a live-out value for a PHI. + if (PVNI) { + assert(PVNI->hasPHIKill() && "Missing hasPHIKill flag"); + WorkList.push_back(std::make_pair(Stop, PVNI)); } } - - // Extend the live range in the block to include Idx. - NewLI.addRange(LiveRange(I->end, Idx.getNextSlot(), VNI)); continue; } From stoklund at 2pi.dk Tue Mar 1 18:49:28 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 02 Mar 2011 00:49:28 -0000 Subject: [llvm-commits] [llvm] r126809 - in /llvm/trunk/lib/CodeGen: SplitKit.cpp SplitKit.h Message-ID: <20110302004928.B5ADA2A6C12C@llvm.org> Author: stoklund Date: Tue Mar 1 18:49:28 2011 New Revision: 126809 URL: http://llvm.org/viewvc/llvm-project?rev=126809&view=rev Log: Rename mapValue to extendRange because that is its function now. Simplify the signature - The return value and ParentVNI are no longer needed. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=126809&r1=126808&r2=126809&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Tue Mar 1 18:49:28 2011 @@ -214,24 +214,17 @@ } -// mapValue - Find the mapped value for ParentVNI at Idx. +// extendRange - Extend the live range to reach Idx. // Potentially create phi-def values. -VNInfo *LiveIntervalMap::mapValue(const VNInfo *ParentVNI, SlotIndex Idx, - bool *simple) { +void LiveIntervalMap::extendRange(SlotIndex Idx) { assert(LI && "call reset first"); - assert(ParentVNI && "Mapping NULL value"); assert(Idx.isValid() && "Invalid SlotIndex"); - assert(ParentLI.getVNInfoAt(Idx) == ParentVNI && "Bad ParentVNI"); - - // This is a complex mapped value. There may be multiple defs, and we may need - // to create phi-defs. - if (simple) *simple = false; MachineBasicBlock *IdxMBB = LIS.getMBBFromIndex(Idx); assert(IdxMBB && "No MBB at Idx"); // Is there a def in the same MBB we can extend? - if (VNInfo *VNI = LI->extendInBlock(LIS.getMBBStartIdx(IdxMBB), Idx)) - return VNI; + if (LI->extendInBlock(LIS.getMBBStartIdx(IdxMBB), Idx)) + return; // Now for the fun part. We know that ParentVNI potentially has multiple defs, // and we may need to create even more phi-defs to preserve VNInfo SSA form. @@ -395,7 +388,6 @@ // Since we went through the trouble of a full BFS visiting all reaching defs, // the values in LiveIn are now accurate. No more phi-defs are needed // for these blocks, so we can color the live ranges. - // This makes the next mapValue call much faster. for (unsigned i = 0, e = LiveIn.size(); i != e; ++i) { MachineBasicBlock *MBB = LiveIn[i]->getBlock(); SlotIndex Start = LIS.getMBBStartIdx(MBB); @@ -408,8 +400,6 @@ else LI->addRange(LiveRange(Start, LIS.getMBBEndIdx(MBB), VNI)); } - - return IdxVNI; } #ifndef NDEBUG @@ -681,8 +671,8 @@ assert(LIS.getMBBFromIndex(Start) == LIS.getMBBFromIndex(End) && "Range cannot span basic blocks"); - // Treat this as useIntv() for now. The complement interval will be extended - // as needed by mapValue(). + // Treat this as useIntv() for now. + // The complement interval will be extended as needed by extendRange(). DEBUG(dbgs() << " overlapIntv [" << Start << ';' << End << "):"); RegAssign.insert(Start, End, OpenIdx); DEBUG(dump()); @@ -726,8 +716,7 @@ << Idx << ':' << RegIdx << '\t' << *MI); // Extend liveness to Idx. - const VNInfo *ParentVNI = Edit.getParent().getVNInfoAt(Idx); - LIMappers[RegIdx].mapValue(ParentVNI, Idx); + LIMappers[RegIdx].extendRange(Idx); } } @@ -780,7 +769,7 @@ // FIXME: Don't recompute the liveness of all values, infer it from the // overlaps between the parent live interval and RegAssign. - // The mapValue algorithm is only necessary when: + // The extendRange algorithm is only necessary when: // - The parent value maps to multiple defs, and new phis are needed, or // - The value has been rematerialized before some uses, and we want to // minimize the live range so it only reaches the remaining uses. @@ -808,7 +797,7 @@ DEBUG(dbgs() << " has parent valno #" << VNI->id << " live out\n"); assert(RegAssign.lookup(End) == RegIdx && "Different register assignment in phi predecessor"); - LIM.mapValue(VNI, End); + LIM.extendRange(End); } else DEBUG(dbgs() << " is not live-out\n"); Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=126809&r1=126808&r2=126809&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Tue Mar 1 18:49:28 2011 @@ -195,16 +195,9 @@ /// getLI - return the current live interval. LiveInterval *getLI() const { return LI; } - /// mapValue - map ParentVNI to the corresponding LI value at Idx. It is - /// assumed that ParentVNI is live at Idx. - /// If ParentVNI has not been defined by defValue, it is assumed that - /// ParentVNI->def dominates Idx. - /// If ParentVNI has been defined by defValue one or more times, a value that - /// dominates Idx will be returned. This may require creating extra phi-def - /// values and adding live ranges to LI. - /// If simple is not NULL, *simple will indicate if ParentVNI is a simply - /// mapped value. - VNInfo *mapValue(const VNInfo *ParentVNI, SlotIndex Idx, bool *simple = 0); + /// extendRange - Extend the live range of LI so it reaches Idx. + /// Insert PHIDefs as needed to preserve SSA form. + void extendRange(SlotIndex Idx); }; From ofv at wanadoo.es Tue Mar 1 18:59:56 2011 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=) Date: Wed, 02 Mar 2011 01:59:56 +0100 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC9@winserv02.hansoft.local> (Erik Olofsson's message of "Wed, 2 Mar 2011 01:24:03 +0100") References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> <87bp1uz8fx.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC9@winserv02.hansoft.local> Message-ID: <877hciz69f.fsf@wanadoo.es> Erik Olofsson writes: >> Which are those options? If they are used on the future, having /MP active >> by default may create some inconveniences. Changing the default value of >> option(VAR ...) has no effect if VAR already is on CMakeCache.txt. > > Most notably incremental builds and creating a precompiled header. See > http://msdn.microsoft.com/en-us/library/bb385193(v=VS.100).aspx > > Incremental builds are notoriously buggy, so I don't think we would > ever want to enable that by default. If we ever want to add support > for precompiled headers I do believe that msbuild automatically strips > /MP if that option is enabled. Okay, thanks. But IIRC last time I built LLVM with VS 10 it used all 4 cores. If you have checked that /MP is required for parallel builds, no objection here. Don't forget documenting the option in docs/CMake.html. From geek4civic at gmail.com Tue Mar 1 19:10:08 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Wed, 2 Mar 2011 10:10:08 +0900 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: <877hciz69f.fsf@wanadoo.es> References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> <87bp1uz8fx.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC9@winserv02.hansoft.local> <877hciz69f.fsf@wanadoo.es> Message-ID: On Wed, Mar 2, 2011 at 9:59 AM, ?scar Fuentes wrote: > Okay, thanks. But IIRC last time I built LLVM with VS 10 it used all 4 > cores. If you have checked that /MP is required for parallel builds, no > objection here. Don't forget documenting the option in docs/CMake.html. On MSVS10 IDE w/o /MP, building goes parallel by project.vcxproj, IIRC. eg. LLVMSupport was built sequentially. ...Takumi From evan.cheng at apple.com Tue Mar 1 19:08:17 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 02 Mar 2011 01:08:17 -0000 Subject: [llvm-commits] [llvm] r126811 - in /llvm/trunk: lib/CodeGen/TwoAddressInstructionPass.cpp test/CodeGen/X86/iabs.ll test/CodeGen/X86/twoaddr-lea.ll Message-ID: <20110302010817.DCB752A6C12C@llvm.org> Author: evancheng Date: Tue Mar 1 19:08:17 2011 New Revision: 126811 URL: http://llvm.org/viewvc/llvm-project?rev=126811&view=rev Log: Catch more cases where 2-address pass should 3-addressify instructions. rdar://9002648. Modified: llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp llvm/trunk/test/CodeGen/X86/iabs.ll llvm/trunk/test/CodeGen/X86/twoaddr-lea.ll Modified: llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp?rev=126811&r1=126810&r2=126811&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp (original) +++ llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Tue Mar 1 19:08:17 2011 @@ -105,7 +105,7 @@ MachineFunction::iterator &mbbi, unsigned RegB, unsigned RegC, unsigned Dist); - bool isProfitableToConv3Addr(unsigned RegA); + bool isProfitableToConv3Addr(unsigned RegA, unsigned RegB); bool ConvertInstTo3Addr(MachineBasicBlock::iterator &mi, MachineBasicBlock::iterator &nmi, @@ -124,7 +124,11 @@ MachineBasicBlock::iterator &nmi, MachineFunction::iterator &mbbi, unsigned SrcIdx, unsigned DstIdx, - unsigned Dist); + unsigned Dist, + SmallPtrSet &Processed); + + void ScanUses(unsigned DstReg, MachineBasicBlock *MBB, + SmallPtrSet &Processed); void ProcessCopy(MachineInstr *MI, MachineBasicBlock *MBB, SmallPtrSet &Processed); @@ -615,16 +619,18 @@ /// isProfitableToConv3Addr - Return true if it is profitable to convert the /// given 2-address instruction to a 3-address one. bool -TwoAddressInstructionPass::isProfitableToConv3Addr(unsigned RegA) { +TwoAddressInstructionPass::isProfitableToConv3Addr(unsigned RegA,unsigned RegB){ // Look for situations like this: // %reg1024 = MOV r1 // %reg1025 = MOV r0 // %reg1026 = ADD %reg1024, %reg1025 // r2 = MOV %reg1026 // Turn ADD into a 3-address instruction to avoid a copy. - unsigned FromRegA = getMappedReg(RegA, SrcRegMap); + unsigned FromRegB = getMappedReg(RegB, SrcRegMap); + if (!FromRegB) + return false; unsigned ToRegA = getMappedReg(RegA, DstRegMap); - return (FromRegA && ToRegA && !regsAreCompatible(FromRegA, ToRegA, TRI)); + return (ToRegA && !regsAreCompatible(FromRegB, ToRegA, TRI)); } /// ConvertInstTo3Addr - Convert the specified two-address instruction into a @@ -664,6 +670,54 @@ return false; } +/// ScanUses - Scan forward recursively for only uses, update maps if the use +/// is a copy or a two-address instruction. +void +TwoAddressInstructionPass::ScanUses(unsigned DstReg, MachineBasicBlock *MBB, + SmallPtrSet &Processed) { + SmallVector VirtRegPairs; + bool IsDstPhys; + bool IsCopy = false; + unsigned NewReg = 0; + unsigned Reg = DstReg; + while (MachineInstr *UseMI = findOnlyInterestingUse(Reg, MBB, MRI, TII,IsCopy, + NewReg, IsDstPhys)) { + if (IsCopy && !Processed.insert(UseMI)) + break; + + DenseMap::iterator DI = DistanceMap.find(UseMI); + if (DI != DistanceMap.end()) + // Earlier in the same MBB.Reached via a back edge. + break; + + if (IsDstPhys) { + VirtRegPairs.push_back(NewReg); + break; + } + bool isNew = SrcRegMap.insert(std::make_pair(NewReg, Reg)).second; + if (!isNew) + assert(SrcRegMap[NewReg] == Reg && "Can't map to two src registers!"); + VirtRegPairs.push_back(NewReg); + Reg = NewReg; + } + + if (!VirtRegPairs.empty()) { + unsigned ToReg = VirtRegPairs.back(); + VirtRegPairs.pop_back(); + while (!VirtRegPairs.empty()) { + unsigned FromReg = VirtRegPairs.back(); + VirtRegPairs.pop_back(); + bool isNew = DstRegMap.insert(std::make_pair(FromReg, ToReg)).second; + if (!isNew) + assert(DstRegMap[FromReg] == ToReg &&"Can't map to two dst registers!"); + ToReg = FromReg; + } + bool isNew = DstRegMap.insert(std::make_pair(DstReg, ToReg)).second; + if (!isNew) + assert(DstRegMap[DstReg] == ToReg && "Can't map to two dst registers!"); + } +} + /// ProcessCopy - If the specified instruction is not yet processed, process it /// if it's a copy. For a copy instruction, we find the physical registers the /// source and destination registers might be mapped to. These are kept in @@ -695,49 +749,11 @@ assert(SrcRegMap[DstReg] == SrcReg && "Can't map to two src physical registers!"); - SmallVector VirtRegPairs; - bool IsCopy = false; - unsigned NewReg = 0; - while (MachineInstr *UseMI = findOnlyInterestingUse(DstReg, MBB, MRI,TII, - IsCopy, NewReg, IsDstPhys)) { - if (IsCopy) { - if (!Processed.insert(UseMI)) - break; - } - - DenseMap::iterator DI = DistanceMap.find(UseMI); - if (DI != DistanceMap.end()) - // Earlier in the same MBB.Reached via a back edge. - break; - - if (IsDstPhys) { - VirtRegPairs.push_back(NewReg); - break; - } - bool isNew = SrcRegMap.insert(std::make_pair(NewReg, DstReg)).second; - if (!isNew) - assert(SrcRegMap[NewReg] == DstReg && - "Can't map to two src physical registers!"); - VirtRegPairs.push_back(NewReg); - DstReg = NewReg; - } - - if (!VirtRegPairs.empty()) { - unsigned ToReg = VirtRegPairs.back(); - VirtRegPairs.pop_back(); - while (!VirtRegPairs.empty()) { - unsigned FromReg = VirtRegPairs.back(); - VirtRegPairs.pop_back(); - bool isNew = DstRegMap.insert(std::make_pair(FromReg, ToReg)).second; - if (!isNew) - assert(DstRegMap[FromReg] == ToReg && - "Can't map to two dst physical registers!"); - ToReg = FromReg; - } - } + ScanUses(DstReg, MBB, Processed); } Processed.insert(MI); + return; } /// isSafeToDelete - If the specified instruction does not produce any side @@ -836,7 +852,8 @@ TryInstructionTransform(MachineBasicBlock::iterator &mi, MachineBasicBlock::iterator &nmi, MachineFunction::iterator &mbbi, - unsigned SrcIdx, unsigned DstIdx, unsigned Dist) { + unsigned SrcIdx, unsigned DstIdx, unsigned Dist, + SmallPtrSet &Processed) { const TargetInstrDesc &TID = mi->getDesc(); unsigned regA = mi->getOperand(DstIdx).getReg(); unsigned regB = mi->getOperand(SrcIdx).getReg(); @@ -887,10 +904,13 @@ return false; } + if (TargetRegisterInfo::isVirtualRegister(regA)) + ScanUses(regA, &*mbbi, Processed); + if (TID.isConvertibleTo3Addr()) { // This instruction is potentially convertible to a true // three-address instruction. Check if it is profitable. - if (!regBKilled || isProfitableToConv3Addr(regA)) { + if (!regBKilled || isProfitableToConv3Addr(regA, regB)) { // Try to convert it. if (ConvertInstTo3Addr(mi, nmi, mbbi, regA, regB, Dist)) { ++NumConvertedTo3Addr; @@ -951,7 +971,7 @@ MachineBasicBlock::iterator NewMI = NewMIs[1]; bool TransformSuccess = TryInstructionTransform(NewMI, mi, mbbi, - NewSrcIdx, NewDstIdx, Dist); + NewSrcIdx, NewDstIdx, Dist, Processed); if (TransformSuccess || NewMIs[1]->getOperand(NewSrcIdx).isKill()) { // Success, or at least we made an improvement. Keep the unfolded @@ -1100,7 +1120,8 @@ mi->getOperand(DstIdx).getReg()) break; // Done with this instruction. - if (TryInstructionTransform(mi, nmi, mbbi, SrcIdx, DstIdx, Dist)) + if (TryInstructionTransform(mi, nmi, mbbi, SrcIdx, DstIdx, Dist, + Processed)) break; // The tied operands have been eliminated. } Modified: llvm/trunk/test/CodeGen/X86/iabs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/iabs.ll?rev=126811&r1=126810&r2=126811&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/iabs.ll (original) +++ llvm/trunk/test/CodeGen/X86/iabs.ll Tue Mar 1 19:08:17 2011 @@ -1,12 +1,11 @@ ; RUN: llc < %s -march=x86-64 -stats |& \ -; RUN: grep {6 .*Number of machine instrs printed} +; RUN: grep {5 .*Number of machine instrs printed} ;; Integer absolute value, should produce something at least as good as: -;; movl %edi, %eax -;; sarl $31, %eax -;; addl %eax, %edi -;; xorl %eax, %edi -;; movl %edi, %eax +;; movl %edi, %ecx +;; sarl $31, %ecx +;; leal (%rdi,%rcx), %eax +;; xorl %ecx, %eax ;; ret define i32 @test(i32 %a) nounwind { %tmp1neg = sub i32 0, %a Modified: llvm/trunk/test/CodeGen/X86/twoaddr-lea.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/twoaddr-lea.ll?rev=126811&r1=126810&r2=126811&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/twoaddr-lea.ll (original) +++ llvm/trunk/test/CodeGen/X86/twoaddr-lea.ll Tue Mar 1 19:08:17 2011 @@ -34,3 +34,14 @@ %add5 = add i32 %add3, %d ret i32 %add5 } + +; rdar://9002648 +define i64 @test3(i64 %x) nounwind readnone ssp { +entry: +; CHECK: test3: +; CHECK: leaq (%rdi,%rdi), %rax +; CHECK-NOT: addq +; CHECK-NEXT: ret + %0 = shl i64 %x, 1 + ret i64 %0 +} From clattner at apple.com Tue Mar 1 19:15:28 2011 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Mar 2011 17:15:28 -0800 Subject: [llvm-commits] [PATCH] Optimize printf -> iprintf if there are no floating point arguments In-Reply-To: <4D6D2750.6020501@xmos.com> References: <4D6D2750.6020501@xmos.com> Message-ID: On Mar 1, 2011, at 9:05 AM, Richard Osborne wrote: > This patch adds an optimization to SimplifyLibCalls which transforms calls to printf into iprintf calls. iprintf is a restricted version of printf provided by newlib without floating-point formatting (see http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-February/037832.html). > > This patch uses TargetLibraryInfo to determine whether iprintf is available. Currently it is only marked as available on the XCore target. > > I intend to add similar optimizations for sprintf / fprintf once this patch is accepted. Please let me know if this is OK to commit. In addition to Frits' comment about the testcase, the patch would be simpler if you changed this: + // printf(format, ...) -> iprintf(format, ...) if no floating point + // arguments. + if (TLI->has(LibFunc::iprintf) && !CallHasFloatingPointArgument(CI)) { + return EmitIPrintF(CI->op_begin(), CI->op_end(), B, TD); + } Instead of emitting a new IPrintF call, you can just change the callee of the existing call to be iprintf instead of printf. This would make the code look something like this: // printf(format, ...) -> iprintf(format, ...) if no floating point // arguments. if (TLI->has(LibFunc::iprintf) && !CallHasFloatingPointArgument(CI)) { Constant *IPrintFFn = ... CI->setOperand(0, IPrintFFn); return CI; } This allows you to remove the EmitIPrintF implementation and should simplify the fprintf case that's coming next. Thanks for implementing this Richard! -Chris From gohman at apple.com Tue Mar 1 19:34:10 2011 From: gohman at apple.com (Dan Gohman) Date: Wed, 02 Mar 2011 01:34:10 -0000 Subject: [llvm-commits] [llvm] r126812 - in /llvm/trunk: lib/Analysis/ScalarEvolutionExpander.cpp test/CodeGen/X86/lsr-quadratic-expand.ll Message-ID: <20110302013410.547E92A6C12C@llvm.org> Author: djg Date: Tue Mar 1 19:34:10 2011 New Revision: 126812 URL: http://llvm.org/viewvc/llvm-project?rev=126812&view=rev Log: Don't re-use existing addrec expansions if they contain casts. This fixes PR9259. Added: llvm/trunk/test/CodeGen/X86/lsr-quadratic-expand.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=126812&r1=126811&r2=126812&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Tue Mar 1 19:34:10 2011 @@ -858,7 +858,8 @@ // loop already visited by LSR for example, but it wouldn't have // to be. do { - if (IncV->getNumOperands() == 0 || isa(IncV)) { + if (IncV->getNumOperands() == 0 || isa(IncV) || + isa(IncV)) { IncV = 0; break; } Added: llvm/trunk/test/CodeGen/X86/lsr-quadratic-expand.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/lsr-quadratic-expand.ll?rev=126812&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/lsr-quadratic-expand.ll (added) +++ llvm/trunk/test/CodeGen/X86/lsr-quadratic-expand.ll Tue Mar 1 19:34:10 2011 @@ -0,0 +1,22 @@ +; RUN: llc -march=x86-64 < %s + +define void @dw2102_i2c_transfer() nounwind { +entry: + br label %bb + +bb: ; preds = %bb, %entry + %z = phi i64 [ 0, %entry ], [ %z3, %bb ] + %z1 = phi i16 [ undef, %entry ], [ %z6, %bb ] + %z2 = phi i32 [ 0, %entry ], [ %z8, %bb ] + %z3 = add i64 %z, 1 + %z4 = zext i16 %z1 to i32 + %z5 = add nsw i32 %z4, %z2 + %z6 = trunc i32 %z5 to i16 + call fastcc void @dw210x_op_rw(i16 zeroext %z6) + %z7 = getelementptr i8* null, i64 %z + store i8 undef, i8* %z7, align 1 + %z8 = add nsw i32 %z2, 1 + br label %bb +} + +declare fastcc void @dw210x_op_rw(i16 zeroext) nounwind From ofv at wanadoo.es Tue Mar 1 19:40:02 2011 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=) Date: Wed, 02 Mar 2011 02:40:02 +0100 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: (NAKAMURA Takumi's message of "Wed, 2 Mar 2011 10:10:08 +0900") References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> <87bp1uz8fx.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC9@winserv02.hansoft.local> <877hciz69f.fsf@wanadoo.es> Message-ID: <8739n6z4el.fsf@wanadoo.es> NAKAMURA Takumi writes: > On Wed, Mar 2, 2011 at 9:59 AM, ?scar Fuentes wrote: >> Okay, thanks. But IIRC last time I built LLVM with VS 10 it used all 4 >> cores. If you have checked that /MP is required for parallel builds, no >> objection here. Don't forget documenting the option in docs/CMake.html. > > On MSVS10 IDE w/o /MP, building goes parallel by project.vcxproj, IIRC. > eg. LLVMSupport was built sequentially. Thanks Takumi. After reading the documentation for /MP on msdn I think that it would be better to specifiy the number of processors, instead of only offering 1 or all: if( MSVC_IDE ) set(LLVM_COMPILER_JOBS "0" CACHE STRING "Number of parallel compiler jobs. 0 means use all processors. Default is 0.") if( NOT LLVM_COMPILER_JOBS STREQUAL "1" ) if( LLVM_COMPILER_JOBS STREQUAL "0" ) add_llvm_definitions( /MP ) else add_llvm_definitions( /MP${LLVM_COMPILER_JOBS} ) endif() endif() From nicholas at mxc.ca Tue Mar 1 19:43:30 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 02 Mar 2011 01:43:30 -0000 Subject: [llvm-commits] [llvm] r126815 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <20110302014330.DBBF12A6C12D@llvm.org> Author: nicholas Date: Tue Mar 1 19:43:30 2011 New Revision: 126815 URL: http://llvm.org/viewvc/llvm-project?rev=126815&view=rev Log: Quiet a compiler warning about unused variable 'ExtVNI'. 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=126815&r1=126814&r2=126815&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Mar 1 19:43:30 2011 @@ -794,6 +794,7 @@ // Extend the live range for VNI to be live at Idx. if (VNInfo *ExtVNI = NewLI.extendInBlock(BlockStart, Idx)) { + (void)ExtVNI; assert(ExtVNI == VNI && "Unexpected existing value number"); // Is this a PHIDef we haven't seen before? if (!VNI->isPHIDef() || !UsedPHIs.insert(VNI)) From stoklund at 2pi.dk Tue Mar 1 19:59:35 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 02 Mar 2011 01:59:35 -0000 Subject: [llvm-commits] [llvm] r126818 - in /llvm/trunk/lib/CodeGen: SplitKit.cpp SplitKit.h Message-ID: <20110302015935.22D8D2A6C12C@llvm.org> Author: stoklund Date: Tue Mar 1 19:59:34 2011 New Revision: 126818 URL: http://llvm.org/viewvc/llvm-project?rev=126818&view=rev Log: Move extendRange() into SplitEditor and delete the LiveRangeMap class. Extract the updateSSA() method from the too long extendRange(). LiveOutCache can be shared among all the new intervals since there is at most one of the new ranges live out from each basic block. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=126818&r1=126817&r2=126818&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Tue Mar 1 19:59:34 2011 @@ -198,29 +198,101 @@ //===----------------------------------------------------------------------===// -// LiveIntervalMap +// Split Editor //===----------------------------------------------------------------------===// -// Work around the fact that the std::pair constructors are broken for pointer -// pairs in some implementations. makeVV(x, 0) works. -static inline std::pair -makeVV(const VNInfo *a, VNInfo *b) { - return std::make_pair(a, b); +/// Create a new SplitEditor for editing the LiveInterval analyzed by SA. +SplitEditor::SplitEditor(SplitAnalysis &sa, + LiveIntervals &lis, + VirtRegMap &vrm, + MachineDominatorTree &mdt, + LiveRangeEdit &edit) + : SA(sa), LIS(lis), VRM(vrm), + MRI(vrm.getMachineFunction().getRegInfo()), + MDT(mdt), + TII(*vrm.getMachineFunction().getTarget().getInstrInfo()), + TRI(*vrm.getMachineFunction().getTarget().getRegisterInfo()), + Edit(edit), + OpenIdx(0), + RegAssign(Allocator) +{ + // We don't need an AliasAnalysis since we will only be performing + // cheap-as-a-copy remats anyway. + Edit.anyRematerializable(LIS, TII, 0); +} + +void SplitEditor::dump() const { + if (RegAssign.empty()) { + dbgs() << " empty\n"; + return; + } + + for (RegAssignMap::const_iterator I = RegAssign.begin(); I.valid(); ++I) + dbgs() << " [" << I.start() << ';' << I.stop() << "):" << I.value(); + dbgs() << '\n'; } -void LiveIntervalMap::reset(LiveInterval *li) { - LI = li; - LiveOutCache.clear(); +VNInfo *SplitEditor::defValue(unsigned RegIdx, + const VNInfo *ParentVNI, + SlotIndex Idx) { + assert(ParentVNI && "Mapping NULL value"); + assert(Idx.isValid() && "Invalid SlotIndex"); + assert(Edit.getParent().getVNInfoAt(Idx) == ParentVNI && "Bad Parent VNI"); + LiveInterval *LI = Edit.get(RegIdx); + + // Create a new value. + VNInfo *VNI = LI->getNextValue(Idx, 0, LIS.getVNInfoAllocator()); + + // Preserve the PHIDef bit. + if (ParentVNI->isPHIDef() && Idx == ParentVNI->def) + VNI->setIsPHIDef(true); + + // Use insert for lookup, so we can add missing values with a second lookup. + std::pair InsP = + Values.insert(std::make_pair(std::make_pair(RegIdx, ParentVNI->id), VNI)); + + // This was the first time (RegIdx, ParentVNI) was mapped. + // Keep it as a simple def without any liveness. + if (InsP.second) + return VNI; + + // If the previous value was a simple mapping, add liveness for it now. + if (VNInfo *OldVNI = InsP.first->second) { + SlotIndex Def = OldVNI->def; + LI->addRange(LiveRange(Def, Def.getNextSlot(), OldVNI)); + // No longer a simple mapping. + InsP.first->second = 0; + } + + // This is a complex mapping, add liveness for VNI + SlotIndex Def = VNI->def; + LI->addRange(LiveRange(Def, Def.getNextSlot(), VNI)); + + return VNI; } +void SplitEditor::markComplexMapped(unsigned RegIdx, const VNInfo *ParentVNI) { + assert(ParentVNI && "Mapping NULL value"); + VNInfo *&VNI = Values[std::make_pair(RegIdx, ParentVNI->id)]; + + // ParentVNI was either unmapped or already complex mapped. Either way. + if (!VNI) + return; + + // This was previously a single mapping. Make sure the old def is represented + // by a trivial live range. + SlotIndex Def = VNI->def; + Edit.get(RegIdx)->addRange(LiveRange(Def, Def.getNextSlot(), VNI)); + VNI = 0; +} // extendRange - Extend the live range to reach Idx. // Potentially create phi-def values. -void LiveIntervalMap::extendRange(SlotIndex Idx) { - assert(LI && "call reset first"); +void SplitEditor::extendRange(unsigned RegIdx, SlotIndex Idx) { assert(Idx.isValid() && "Invalid SlotIndex"); MachineBasicBlock *IdxMBB = LIS.getMBBFromIndex(Idx); assert(IdxMBB && "No MBB at Idx"); + LiveInterval *LI = Edit.get(RegIdx); // Is there a def in the same MBB we can extend? if (LI->extendInBlock(LIS.getMBBStartIdx(IdxMBB), Idx)) @@ -247,12 +319,8 @@ std::pair LOIP = LiveOutCache.insert(std::make_pair(Pred, LiveOutPair())); // Yes, we have been here before. - if (!LOIP.second) { - DEBUG(if (VNInfo *VNI = LOIP.first->second.first) - dbgs() << " known valno #" << VNI->id - << " at BB#" << Pred->getNumber() << '\n'); + if (!LOIP.second) continue; - } // Does Pred provide a live-out value? SlotIndex Start, Last; @@ -260,9 +328,6 @@ Last = Last.getPrevSlot(); if (VNInfo *VNI = LI->extendInBlock(Start, Last)) { MachineBasicBlock *DefMBB = LIS.getMBBFromIndex(VNI->def); - DEBUG(dbgs() << " found valno #" << VNI->id - << " from BB#" << DefMBB->getNumber() - << " at BB#" << Pred->getNumber() << '\n'); LiveOutPair &LOP = LOIP.first->second; LOP.first = VNI; LOP.second = MDT[DefMBB]; @@ -275,16 +340,56 @@ } // We may need to add phi-def values to preserve the SSA form. + VNInfo *IdxVNI = updateSSA(RegIdx, LiveIn, Idx, IdxMBB); + +#ifndef NDEBUG + // Check the LiveOutCache invariants. + for (LiveOutMap::iterator I = LiveOutCache.begin(), E = LiveOutCache.end(); + I != E; ++I) { + assert(I->first && "Null MBB entry in cache"); + assert(I->second.first && "Null VNInfo in cache"); + assert(I->second.second && "Null DomTreeNode in cache"); + if (I->second.second->getBlock() == I->first) + continue; + for (MachineBasicBlock::pred_iterator PI = I->first->pred_begin(), + PE = I->first->pred_end(); PI != PE; ++PI) + assert(LiveOutCache.lookup(*PI) == I->second && "Bad invariant"); + } +#endif + + // Since we went through the trouble of a full BFS visiting all reaching defs, + // the values in LiveIn are now accurate. No more phi-defs are needed + // for these blocks, so we can color the live ranges. + for (unsigned i = 0, e = LiveIn.size(); i != e; ++i) { + MachineBasicBlock *MBB = LiveIn[i]->getBlock(); + SlotIndex Start = LIS.getMBBStartIdx(MBB); + VNInfo *VNI = LiveOutCache.lookup(MBB).first; + + // Anything in LiveIn other than IdxMBB is live-through. + // In IdxMBB, we should stop at Idx unless the same value is live-out. + if (MBB == IdxMBB && IdxVNI != VNI) + LI->addRange(LiveRange(Start, Idx.getNextSlot(), IdxVNI)); + else + LI->addRange(LiveRange(Start, LIS.getMBBEndIdx(MBB), VNI)); + } +} + +VNInfo *SplitEditor::updateSSA(unsigned RegIdx, + SmallVectorImpl &LiveIn, + SlotIndex Idx, + const MachineBasicBlock *IdxMBB) { // This is essentially the same iterative algorithm that SSAUpdater uses, // except we already have a dominator tree, so we don't have to recompute it. + LiveInterval *LI = Edit.get(RegIdx); VNInfo *IdxVNI = 0; unsigned Changes; do { Changes = 0; DEBUG(dbgs() << " Iterating over " << LiveIn.size() << " blocks.\n"); - // Propagate live-out values down the dominator tree, inserting phi-defs when - // necessary. Since LiveIn was created by a BFS, going backwards makes it more - // likely for us to visit immediate dominators before their children. + // Propagate live-out values down the dominator tree, inserting phi-defs + // when necessary. Since LiveIn was created by a BFS, going backwards makes + // it more likely for us to visit immediate dominators before their + // children. for (unsigned i = LiveIn.size(); i; --i) { MachineDomTreeNode *Node = LiveIn[i-1]; MachineBasicBlock *MBB = Node->getBlock(); @@ -369,146 +474,7 @@ } while (Changes); assert(IdxVNI && "Didn't find value for Idx"); - -#ifndef NDEBUG - // Check the LiveOutCache invariants. - for (LiveOutMap::iterator I = LiveOutCache.begin(), E = LiveOutCache.end(); - I != E; ++I) { - assert(I->first && "Null MBB entry in cache"); - assert(I->second.first && "Null VNInfo in cache"); - assert(I->second.second && "Null DomTreeNode in cache"); - if (I->second.second->getBlock() == I->first) - continue; - for (MachineBasicBlock::pred_iterator PI = I->first->pred_begin(), - PE = I->first->pred_end(); PI != PE; ++PI) - assert(LiveOutCache.lookup(*PI) == I->second && "Bad invariant"); - } -#endif - - // Since we went through the trouble of a full BFS visiting all reaching defs, - // the values in LiveIn are now accurate. No more phi-defs are needed - // for these blocks, so we can color the live ranges. - for (unsigned i = 0, e = LiveIn.size(); i != e; ++i) { - MachineBasicBlock *MBB = LiveIn[i]->getBlock(); - SlotIndex Start = LIS.getMBBStartIdx(MBB); - VNInfo *VNI = LiveOutCache.lookup(MBB).first; - - // Anything in LiveIn other than IdxMBB is live-through. - // In IdxMBB, we should stop at Idx unless the same value is live-out. - if (MBB == IdxMBB && IdxVNI != VNI) - LI->addRange(LiveRange(Start, Idx.getNextSlot(), IdxVNI)); - else - LI->addRange(LiveRange(Start, LIS.getMBBEndIdx(MBB), VNI)); - } -} - -#ifndef NDEBUG -void LiveIntervalMap::dumpCache() { - for (LiveOutMap::iterator I = LiveOutCache.begin(), E = LiveOutCache.end(); - I != E; ++I) { - assert(I->first && "Null MBB entry in cache"); - assert(I->second.first && "Null VNInfo in cache"); - assert(I->second.second && "Null DomTreeNode in cache"); - dbgs() << " cache: BB#" << I->first->getNumber() - << " has valno #" << I->second.first->id << " from BB#" - << I->second.second->getBlock()->getNumber() << ", preds"; - for (MachineBasicBlock::pred_iterator PI = I->first->pred_begin(), - PE = I->first->pred_end(); PI != PE; ++PI) - dbgs() << " BB#" << (*PI)->getNumber(); - dbgs() << '\n'; - } - dbgs() << " cache: " << LiveOutCache.size() << " entries.\n"; -} -#endif - - -//===----------------------------------------------------------------------===// -// Split Editor -//===----------------------------------------------------------------------===// - -/// Create a new SplitEditor for editing the LiveInterval analyzed by SA. -SplitEditor::SplitEditor(SplitAnalysis &sa, - LiveIntervals &lis, - VirtRegMap &vrm, - MachineDominatorTree &mdt, - LiveRangeEdit &edit) - : SA(sa), LIS(lis), VRM(vrm), - MRI(vrm.getMachineFunction().getRegInfo()), - MDT(mdt), - TII(*vrm.getMachineFunction().getTarget().getInstrInfo()), - TRI(*vrm.getMachineFunction().getTarget().getRegisterInfo()), - Edit(edit), - OpenIdx(0), - RegAssign(Allocator) -{ - // We don't need an AliasAnalysis since we will only be performing - // cheap-as-a-copy remats anyway. - Edit.anyRematerializable(LIS, TII, 0); -} - -void SplitEditor::dump() const { - if (RegAssign.empty()) { - dbgs() << " empty\n"; - return; - } - - for (RegAssignMap::const_iterator I = RegAssign.begin(); I.valid(); ++I) - dbgs() << " [" << I.start() << ';' << I.stop() << "):" << I.value(); - dbgs() << '\n'; -} - -VNInfo *SplitEditor::defValue(unsigned RegIdx, - const VNInfo *ParentVNI, - SlotIndex Idx) { - assert(ParentVNI && "Mapping NULL value"); - assert(Idx.isValid() && "Invalid SlotIndex"); - assert(Edit.getParent().getVNInfoAt(Idx) == ParentVNI && "Bad Parent VNI"); - LiveInterval *LI = Edit.get(RegIdx); - - // Create a new value. - VNInfo *VNI = LI->getNextValue(Idx, 0, LIS.getVNInfoAllocator()); - - // Preserve the PHIDef bit. - if (ParentVNI->isPHIDef() && Idx == ParentVNI->def) - VNI->setIsPHIDef(true); - - // Use insert for lookup, so we can add missing values with a second lookup. - std::pair InsP = - Values.insert(std::make_pair(std::make_pair(RegIdx, ParentVNI->id), VNI)); - - // This was the first time (RegIdx, ParentVNI) was mapped. - // Keep it as a simple def without any liveness. - if (InsP.second) - return VNI; - - // If the previous value was a simple mapping, add liveness for it now. - if (VNInfo *OldVNI = InsP.first->second) { - SlotIndex Def = OldVNI->def; - LI->addRange(LiveRange(Def, Def.getNextSlot(), OldVNI)); - // No longer a simple mapping. - InsP.first->second = 0; - } - - // This is a complex mapping, add liveness for VNI - SlotIndex Def = VNI->def; - LI->addRange(LiveRange(Def, Def.getNextSlot(), VNI)); - - return VNI; -} - -void SplitEditor::markComplexMapped(unsigned RegIdx, const VNInfo *ParentVNI) { - assert(ParentVNI && "Mapping NULL value"); - VNInfo *&VNI = Values[std::make_pair(RegIdx, ParentVNI->id)]; - - // ParentVNI was either unmapped or already complex mapped. Either way. - if (!VNI) - return; - - // This was previously a single mapping. Make sure the old def is represented - // by a trivial live range. - SlotIndex Def = VNI->def; - Edit.get(RegIdx)->addRange(LiveRange(Def, Def.getNextSlot(), VNI)); - VNI = 0; + return IdxVNI; } VNInfo *SplitEditor::defFromParent(unsigned RegIdx, @@ -545,17 +511,12 @@ assert(!OpenIdx && "Previous LI not closed before openIntv"); // Create the complement as index 0. - if (Edit.empty()) { + if (Edit.empty()) Edit.create(MRI, LIS, VRM); - LIMappers.push_back(LiveIntervalMap(LIS, MDT, Edit.getParent())); - LIMappers.back().reset(Edit.get(0)); - } // Create the open interval. OpenIdx = Edit.size(); Edit.create(MRI, LIS, VRM); - LIMappers.push_back(LiveIntervalMap(LIS, MDT, Edit.getParent())); - LIMappers[OpenIdx].reset(Edit.get(OpenIdx)); } SlotIndex SplitEditor::enterIntvBefore(SlotIndex Idx) { @@ -716,7 +677,7 @@ << Idx << ':' << RegIdx << '\t' << *MI); // Extend liveness to Idx. - LIMappers[RegIdx].extendRange(Idx); + extendRange(RegIdx, Idx); } } @@ -783,7 +744,6 @@ if (PHIVNI->isUnused() || !PHIVNI->isPHIDef()) continue; unsigned RegIdx = RegAssign.lookup(PHIVNI->def); - LiveIntervalMap &LIM = LIMappers[RegIdx]; MachineBasicBlock *MBB = LIS.getMBBFromIndex(PHIVNI->def); DEBUG(dbgs() << " map phi in BB#" << MBB->getNumber() << '@' << PHIVNI->def << " -> " << RegIdx << '\n'); @@ -793,16 +753,15 @@ DEBUG(dbgs() << " pred BB#" << (*PI)->getNumber() << '@' << End); // The predecessor may not have a live-out value. That is OK, like an // undef PHI operand. - if (VNInfo *VNI = Edit.getParent().getVNInfoAt(End)) { - DEBUG(dbgs() << " has parent valno #" << VNI->id << " live out\n"); + if (Edit.getParent().liveAt(End)) { + DEBUG(dbgs() << " has parent live out\n"); assert(RegAssign.lookup(End) == RegIdx && "Different register assignment in phi predecessor"); - LIM.extendRange(End); - } - else + extendRange(RegIdx, End); + } else DEBUG(dbgs() << " is not live-out\n"); } - DEBUG(dbgs() << " " << *LIM.getLI() << '\n'); + DEBUG(dbgs() << " " << *Edit.get(RegIdx) << '\n'); } // Rewrite instructions. Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=126818&r1=126817&r2=126818&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Tue Mar 1 19:59:34 2011 @@ -144,63 +144,6 @@ }; -/// LiveIntervalMap - Map values from a large LiveInterval into a small -/// interval that is a subset. Insert phi-def values as needed. This class is -/// used by SplitEditor to create new smaller LiveIntervals. -/// -/// ParentLI is the larger interval, LI is the subset interval. Every value -/// in LI corresponds to exactly one value in ParentLI, and the live range -/// of the value is contained within the live range of the ParentLI value. -/// Values in ParentLI may map to any number of OpenLI values, including 0. -class LiveIntervalMap { - LiveIntervals &LIS; - MachineDominatorTree &MDT; - - // The parent interval is never changed. - const LiveInterval &ParentLI; - - // The child interval's values are fully contained inside ParentLI values. - LiveInterval *LI; - - typedef std::pair LiveOutPair; - typedef DenseMap LiveOutMap; - - // LiveOutCache - Map each basic block where LI is live out to the live-out - // value and its defining block. One of these conditions shall be true: - // - // 1. !LiveOutCache.count(MBB) - // 2. LiveOutCache[MBB].second.getNode() == MBB - // 3. forall P in preds(MBB): LiveOutCache[P] == LiveOutCache[MBB] - // - // This is only a cache, the values can be computed as: - // - // VNI = LI->getVNInfoAt(LIS.getMBBEndIdx(MBB)) - // Node = mbt_[LIS.getMBBFromIndex(VNI->def)] - // - // The cache is also used as a visiteed set by mapValue(). - LiveOutMap LiveOutCache; - - // Dump the live-out cache to dbgs(). - void dumpCache(); - -public: - LiveIntervalMap(LiveIntervals &lis, - MachineDominatorTree &mdt, - const LiveInterval &parentli) - : LIS(lis), MDT(mdt), ParentLI(parentli), LI(0) {} - - /// reset - clear all data structures and start a new live interval. - void reset(LiveInterval *); - - /// getLI - return the current live interval. - LiveInterval *getLI() const { return LI; } - - /// extendRange - Extend the live range of LI so it reaches Idx. - /// Insert PHIDefs as needed to preserve SSA form. - void extendRange(SlotIndex Idx); -}; - - /// SplitEditor - Edit machine code and LiveIntervals for live range /// splitting. /// @@ -240,9 +183,6 @@ /// Idx. RegAssignMap RegAssign; - /// LIMappers - One LiveIntervalMap or each interval in Edit. - SmallVector LIMappers; - typedef DenseMap, VNInfo*> ValueMap; /// Values - keep track of the mapping from parent values to values in the new @@ -255,6 +195,26 @@ /// The new value has no live ranges anywhere. ValueMap Values; + typedef std::pair LiveOutPair; + typedef DenseMap LiveOutMap; + + // LiveOutCache - Map each basic block where a new register is live out to the + // live-out value and its defining block. + // One of these conditions shall be true: + // + // 1. !LiveOutCache.count(MBB) + // 2. LiveOutCache[MBB].second.getNode() == MBB + // 3. forall P in preds(MBB): LiveOutCache[P] == LiveOutCache[MBB] + // + // This is only a cache, the values can be computed as: + // + // VNI = Edit.get(RegIdx)->getVNInfoAt(LIS.getMBBEndIdx(MBB)) + // Node = mbt_[LIS.getMBBFromIndex(VNI->def)] + // + // The cache is also used as a visited set by extendRange(). It can be shared + // by all the new registers because at most one is live out of each block. + LiveOutMap LiveOutCache; + /// defValue - define a value in RegIdx from ParentVNI at Idx. /// Idx does not have to be ParentVNI->def, but it must be contained within /// ParentVNI's live range in ParentLI. The new value is added to the value @@ -274,6 +234,18 @@ MachineBasicBlock &MBB, MachineBasicBlock::iterator I); + /// extendRange - Extend the live range of Edit.get(RegIdx) so it reaches Idx. + /// Insert PHIDefs as needed to preserve SSA form. + void extendRange(unsigned RegIdx, SlotIndex Idx); + + /// updateSSA - Insert PHIDefs as necessary and update LiveOutCache such that + /// Edit.get(RegIdx) is live-in to all the blocks in LiveIn. + /// Return the value that is eventually live-in to IdxMBB. + VNInfo *updateSSA(unsigned RegIdx, + SmallVectorImpl &LiveIn, + SlotIndex Idx, + const MachineBasicBlock *IdxMBB); + /// rewriteAssigned - Rewrite all uses of Edit.getReg() to assigned registers. void rewriteAssigned(); From Erik.Olofsson at hansoft.se Tue Mar 1 20:05:20 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Wed, 2 Mar 2011 03:05:20 +0100 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: <8739n6z4el.fsf@wanadoo.es> References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> <87bp1uz8fx.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC9@winserv02.hansoft.local> <877hciz69f.fsf@wanadoo.es> <8739n6z4el.fsf@wanadoo.es> Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACBADF@winserv02.hansoft.local> > -----Original Message----- > From: ?scar Fuentes [mailto:ofv at wanadoo.es] > > if( MSVC_IDE ) > set(LLVM_COMPILER_JOBS "0" CACHE STRING > "Number of parallel compiler jobs. 0 means use all processors. Default is > 0.") > if( NOT LLVM_COMPILER_JOBS STREQUAL "1" ) > if( LLVM_COMPILER_JOBS STREQUAL "0" ) > add_llvm_definitions( /MP ) > else > add_llvm_definitions( /MP${LLVM_COMPILER_JOBS} ) > endif() > endif() Yes, this is even better. Would you like that code in HandleLLVMOptions.cmake or CMakeLists.txt or both with option definition split from logic? I will start working on a patch which is split. Some benchmarks on 8 core machine: Without /MP Full build time: 749 s Change Lexer.h: 122 s With /MP Full build time: 461 s, and here 33% of the time is spent sequentially by tblgen. Change Lexer.h: 51 s Generally it seems that there are a lot of dependencies specified between static libraries that are not needed. This prevents parallel project compilation for a large part of the project. This could be looked into later for almost another halving of compile time if we also fix tblgen. Regards, Erik From isanbard at gmail.com Tue Mar 1 20:17:11 2011 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 02 Mar 2011 02:17:11 -0000 Subject: [llvm-commits] [llvm] r126821 - /llvm/trunk/docs/LangRef.html Message-ID: <20110302021711.938482A6C12C@llvm.org> Author: void Date: Tue Mar 1 20:17:11 2011 New Revision: 126821 URL: http://llvm.org/viewvc/llvm-project?rev=126821&view=rev Log: Small cleanup. Modified: llvm/trunk/docs/LangRef.html Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=126821&r1=126820&r2=126821&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Tue Mar 1 20:17:11 2011 @@ -2690,16 +2690,21 @@

Metadata can be used as function arguments. Here llvm.dbg.value function is using two metadata arguments.

-
-       call void @llvm.dbg.value(metadata !24, i64 0, metadata !25)
-     
+
+
+call void @llvm.dbg.value(metadata !24, i64 0, metadata !25)
+
+

Metadata can be attached with an instruction. Here metadata !21 is attached with add instruction using !dbg identifier.

-
-      %indvar.next = add i64 %indvar, 1, !dbg !21
-    
+
+
+%indvar.next = add i64 %indvar, 1, !dbg !21
+
+
+ From aggarwa4 at illinois.edu Tue Mar 1 20:23:35 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 02 Mar 2011 02:23:35 -0000 Subject: [llvm-commits] [poolalloc] r126822 - /poolalloc/trunk/lib/DSA/DSGraph.cpp Message-ID: <20110302022335.AFC912A6C12C@llvm.org> Author: aggarwa4 Date: Tue Mar 1 20:23:35 2011 New Revision: 126822 URL: http://llvm.org/viewvc/llvm-project?rev=126822&view=rev Log: 1. Filter if a call site passes less arguments than required by a function. 2. When building call graph, look at all call sites, not just the unresolved ones. Modified: poolalloc/trunk/lib/DSA/DSGraph.cpp Modified: poolalloc/trunk/lib/DSA/DSGraph.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DSGraph.cpp?rev=126822&r1=126821&r2=126822&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DSGraph.cpp (original) +++ poolalloc/trunk/lib/DSA/DSGraph.cpp Tue Mar 1 20:23:35 2011 @@ -49,6 +49,10 @@ cl::desc("Don't filter call sites based on calling convention."), cl::Hidden, cl::init(false)); + static cl::opt noDSACallNumArgs("dsa-no-filter-numargs", + cl::desc("Don't filter call sites based on number of arguments."), + cl::Hidden, + cl::init(false)); static cl::opt noDSACallVA("dsa-no-filter-vararg", cl::desc("Don't filter call sites based on vararg presense"), cl::Hidden, @@ -1611,6 +1615,12 @@ ++Pi; } } + + if (!noDSACallNumArgs) { + if(CS.arg_size() < F->arg_size()) { + return false; + } + } // // We've done all the checks we've cared to do. The function F can be called @@ -1638,7 +1648,7 @@ // // Get the list of unresolved call sites. // - const std::list& Calls = getAuxFunctionCalls(); + const std::list& Calls = getFunctionCalls(); for (std::list::const_iterator ii = Calls.begin(), ee = Calls.end(); ii != ee; ++ii) { From aggarwa4 at illinois.edu Tue Mar 1 20:25:09 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 02 Mar 2011 02:25:09 -0000 Subject: [llvm-commits] [poolalloc] r126823 - /poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Message-ID: <20110302022509.6E28D2A6C12C@llvm.org> Author: aggarwa4 Date: Tue Mar 1 20:25:09 2011 New Revision: 126823 URL: http://llvm.org/viewvc/llvm-project?rev=126823&view=rev Log: Build Call graph, only once we have recalculated the I flags Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/BottomUpClosure.cpp?rev=126823&r1=126822&r2=126823&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original) +++ poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Tue Mar 1 20:25:09 2011 @@ -101,12 +101,12 @@ DSGraph *Graph = getOrCreateGraph(F); cloneGlobalsInto(Graph, DSGraph::DontCloneCallNodes | DSGraph::DontCloneAuxCallNodes); - Graph->buildCallGraph(callgraph, GlobalFunctionList, filterCallees); Graph->maskIncompleteMarkers(); Graph->markIncompleteNodes(DSGraph::MarkFormalArgs | DSGraph::IgnoreGlobals); Graph->computeExternalFlags(DSGraph::DontMarkFormalsExternal); Graph->computeIntPtrFlags(); + Graph->buildCallGraph(callgraph, GlobalFunctionList, filterCallees); } } From jan_sjodin at yahoo.com Tue Mar 1 21:07:47 2011 From: jan_sjodin at yahoo.com (Jan Sjodin) Date: Tue, 1 Mar 2011 19:07:47 -0800 (PST) Subject: [llvm-commits] Split MCELFStreamer and ELFObjectWriter into .h and .cpp In-Reply-To: <4D6D8989.6020109@gmail.com> References: <919879.23172.qm@web55601.mail.re4.yahoo.com> <4D6D8989.6020109@gmail.com> Message-ID: <154127.95853.qm@web55605.mail.re4.yahoo.com> Yes, I was only wanting to get some basic refactoring in without disturbing the 2.9 release. There is no good reason to try and squeeze anything in. As far as I know this works in the JIT: 1. Generate code for a module in memory. 2. Inline asm in the code is OK. 3. Debug with gdb, as you would normally do e.g. C-x space for setting a breakpoint. Things that don't work: 1. Lazy compilation. I need to clean up the code, which is being done as I submit patches. If you are curious to see the code I am cleaning up it is located here: http://gitorious.org/llvm-junkjit - Jan ----- Original Message ---- > From: Rafael Avila de Espindola > To: Jan Sjodin > Cc: llvm-commits at cs.uiuc.edu > Sent: Tue, March 1, 2011 7:04:25 PM > Subject: Re: Split MCELFStreamer and ELFObjectWriter into .h and .cpp > > On 11-03-01 05:28 PM, Jan Sjodin wrote: > > This patch splits the MCELFStreamer and ELFObjectWriter into .cpp and .h >files > > so the classes can be used by other components. > > I think the patch is OK. > > How much of the JIT you have implemented? I think that at this point (just >before 2.9) the refactorings are OK, but the JIT itself should probably wait >for the branch. > > > - Jan > > Cheers, > Rafael > From ofv at wanadoo.es Tue Mar 1 21:13:27 2011 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=) Date: Wed, 02 Mar 2011 04:13:27 +0100 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: <97510B8DF78E714D91EB4A27850A17DA0C3EACBADF@winserv02.hansoft.local> (Erik Olofsson's message of "Wed, 2 Mar 2011 03:05:20 +0100") References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> <87bp1uz8fx.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC9@winserv02.hansoft.local> <877hciz69f.fsf@wanadoo.es> <8739n6z4el.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBADF@winserv02.hansoft.local> Message-ID: <87y64yxlig.fsf@wanadoo.es> Erik Olofsson writes: >> -----Original Message----- >> From: ?scar Fuentes [mailto:ofv at wanadoo.es] >> >> if( MSVC_IDE ) >> set(LLVM_COMPILER_JOBS "0" CACHE STRING >> "Number of parallel compiler jobs. 0 means use all processors. Default is >> 0.") >> if( NOT LLVM_COMPILER_JOBS STREQUAL "1" ) >> if( LLVM_COMPILER_JOBS STREQUAL "0" ) >> add_llvm_definitions( /MP ) >> else >> add_llvm_definitions( /MP${LLVM_COMPILER_JOBS} ) >> endif() >> endif() > > Yes, this is even better. Would you like that code in > HandleLLVMOptions.cmake or CMakeLists.txt or both with option > definition split from logic? Put everything in HandleLLVMOptions.cmake, so it can be used when Clang is built using LLVM as an external library. > I will start working on a patch which is split. [snip] Looks quite worthwhile. > Generally it seems that there are a lot of dependencies specified > between static libraries that are not needed. This prevents parallel > project compilation for a large part of the project. This could be > looked into later for almost another halving of compile time if we > also fix tblgen. Certainly, there are superfluous tblgen dependencies, but accurately determining them is tricky. About the dependencies between libraries, there are some among LLVM targets and its subsidiaries (e.g. LLVMX86 and LLVMX86AsmParser) and sometimes a dependency is declared from a library into another when, actually, it should be on its tablegenned products (e.g. LLVMX86 depending on LLVMTarget). In general, those cases can be easily fixed, although I've seen cases of linker errors on Linux due to missing vtables while linking the LLVM tools. If you know more instances of unnecessary inter-library dependencies, please mention them. Parallel builds work fine on Linux with make -jN, there is little room to improve, but it seems that tablegenning on Windows is slow (in release mode, if you are building on debug mode it can take a very long time. I thought about always building tblgen.exe on release mode for avoiding such excruciating build times.) From rafael.espindola at gmail.com Tue Mar 1 21:17:29 2011 From: rafael.espindola at gmail.com (=?ISO-8859-1?Q?Rafael_=C1vila_de_Esp=EDndola?=) Date: Tue, 01 Mar 2011 22:17:29 -0500 Subject: [llvm-commits] Split MCELFStreamer and ELFObjectWriter into .h and .cpp In-Reply-To: <154127.95853.qm@web55605.mail.re4.yahoo.com> References: <919879.23172.qm@web55601.mail.re4.yahoo.com> <4D6D8989.6020109@gmail.com> <154127.95853.qm@web55605.mail.re4.yahoo.com> Message-ID: <4D6DB6C9.3030109@gmail.com> On 2011-03-01 22:07, Jan Sjodin wrote: > Yes, I was only wanting to get some basic refactoring in without disturbing the > 2.9 release. There is no good reason to try and squeeze anything in. As far as I > know this works in the JIT: > 1. Generate code for a module in memory. > 2. Inline asm in the code is OK. > 3. Debug with gdb, as you would normally do e.g. C-x space for setting a > breakpoint. Nice! Item 3 in particular is really interesting. I think the last use of the old ELF writer in Codegen is producing debug info for the old jit. If that can be removed I think a lot of code in Codegen could be cleaned up. > Things that don't work: > 1. Lazy compilation. > > I need to clean up the code, which is being done as I submit patches. If you are > curious to see the code I am cleaning up it is located here: > http://gitorious.org/llvm-junkjit > > - Jan Cheers, Rafael From clchiou at gmail.com Tue Mar 1 21:20:28 2011 From: clchiou at gmail.com (Che-Liang Chiou) Date: Wed, 02 Mar 2011 03:20:28 -0000 Subject: [llvm-commits] [llvm] r126824 - in /llvm/trunk: lib/Target/PTX/ test/CodeGen/PTX/ Message-ID: <20110302032028.B72002A6C12C@llvm.org> Author: clchiou Date: Tue Mar 1 21:20:28 2011 New Revision: 126824 URL: http://llvm.org/viewvc/llvm-project?rev=126824&view=rev Log: Extend initial support for primitive types in PTX backend - Allow i16, i32, i64, float, and double types, using the native .u16, .u32, .u64, .f32, and .f64 PTX types. - Allow loading/storing of all primitive types. - Allow primitive types to be passed as parameters. - Allow selection of PTX Version and Shader Model as sub-target attributes. - Merge integer/floating-point test cases for load/store. - Use .u32 instead of .s32 to conform to output from NVidia nvcc compiler. Patch by Justin Holewinski Removed: llvm/trunk/test/CodeGen/PTX/ld_float.ll llvm/trunk/test/CodeGen/PTX/st_float.ll Modified: llvm/trunk/lib/Target/PTX/PTX.td llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp llvm/trunk/lib/Target/PTX/PTXInstrInfo.td llvm/trunk/lib/Target/PTX/PTXMFInfoExtract.cpp llvm/trunk/lib/Target/PTX/PTXRegisterInfo.td llvm/trunk/lib/Target/PTX/PTXSubtarget.cpp llvm/trunk/lib/Target/PTX/PTXSubtarget.h llvm/trunk/test/CodeGen/PTX/add.ll llvm/trunk/test/CodeGen/PTX/ld.ll llvm/trunk/test/CodeGen/PTX/mov.ll llvm/trunk/test/CodeGen/PTX/mul.ll llvm/trunk/test/CodeGen/PTX/options.ll llvm/trunk/test/CodeGen/PTX/st.ll llvm/trunk/test/CodeGen/PTX/sub.ll Modified: llvm/trunk/lib/Target/PTX/PTX.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTX.td?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTX.td (original) +++ llvm/trunk/lib/Target/PTX/PTX.td Tue Mar 1 21:20:28 2011 @@ -19,8 +19,34 @@ // Subtarget Features. //===----------------------------------------------------------------------===// -def FeatureSM20 : SubtargetFeature<"sm20", "is_sm20", "true", - "Enable sm_20 target architecture">; +//===- Architectural Features ---------------------------------------------===// + +def FeatureDouble : SubtargetFeature<"double", "SupportsDouble", "true", + "Do not demote .f64 to .f32">; + +//===- PTX Version --------------------------------------------------------===// + +def FeaturePTX14 : SubtargetFeature<"ptx14", "PTXVersion", "PTX_VERSION_1_4", + "Use PTX Language Version 1.4">; + +def FeaturePTX20 : SubtargetFeature<"ptx20", "PTXVersion", "PTX_VERSION_2_0", + "Use PTX Language Version 2.0", + [FeaturePTX14]>; + +def FeaturePTX21 : SubtargetFeature<"ptx21", "PTXVersion", "PTX_VERSION_2_1", + "Use PTX Language Version 2.1", + [FeaturePTX20]>; + +//===- PTX Shader Model ---------------------------------------------------===// + +def FeatureSM10 : SubtargetFeature<"sm10", "PTXShaderModel", "PTX_SM_1_0", + "Enable Shader Model 1.0 compliance">; +def FeatureSM13 : SubtargetFeature<"sm13", "PTXShaderModel", "PTX_SM_1_3", + "Enable Shader Model 1.3 compliance", + [FeatureSM10, FeatureDouble]>; +def FeatureSM20 : SubtargetFeature<"sm20", "PTXShaderModel", "PTX_SM_2_0", + "Enable Shader Model 2.0 compliance", + [FeatureSM13]>; //===----------------------------------------------------------------------===// // PTX supported processors. Modified: llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp Tue Mar 1 21:20:28 2011 @@ -24,6 +24,7 @@ #include "llvm/ADT/Twine.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/MachineInstr.h" +#include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" #include "llvm/Target/Mangler.h" @@ -37,13 +38,6 @@ using namespace llvm; -static cl::opt -OptPTXVersion("ptx-version", cl::desc("Set PTX version"), cl::init("1.4")); - -static cl::opt -OptPTXTarget("ptx-target", cl::desc("Set GPU target (comma-separated list)"), - cl::init("sm_10")); - namespace { class PTXAsmPrinter : public AsmPrinter { public: @@ -82,11 +76,14 @@ static const char PARAM_PREFIX[] = "__param_"; static const char *getRegisterTypeName(unsigned RegNo) { -#define TEST_REGCLS(cls, clsstr) \ +#define TEST_REGCLS(cls, clsstr) \ if (PTX::cls ## RegisterClass->contains(RegNo)) return # clsstr; - TEST_REGCLS(RRegf32, f32); - TEST_REGCLS(RRegs32, s32); TEST_REGCLS(Preds, pred); + TEST_REGCLS(RRegu16, u16); + TEST_REGCLS(RRegu32, u32); + TEST_REGCLS(RRegu64, u64); + TEST_REGCLS(RRegf32, f32); + TEST_REGCLS(RRegf64, f64); #undef TEST_REGCLS llvm_unreachable("Not in any register class!"); @@ -121,7 +118,14 @@ switch (type->getTypeID()) { default: llvm_unreachable("Unknown type"); case Type::FloatTyID: return ".f32"; - case Type::IntegerTyID: return ".s32"; // TODO: Handle 64-bit types. + case Type::DoubleTyID: return ".f64"; + case Type::IntegerTyID: + switch (type->getPrimitiveSizeInBits()) { + default: llvm_unreachable("Unknown integer bit-width"); + case 16: return ".u16"; + case 32: return ".u32"; + case 64: return ".u64"; + } case Type::ArrayTyID: case Type::PointerTyID: type = dyn_cast(type)->getElementType(); @@ -162,8 +166,11 @@ void PTXAsmPrinter::EmitStartOfAsmFile(Module &M) { - OutStreamer.EmitRawText(Twine("\t.version " + OptPTXVersion)); - OutStreamer.EmitRawText(Twine("\t.target " + OptPTXTarget)); + const PTXSubtarget& ST = TM.getSubtarget(); + + OutStreamer.EmitRawText(Twine("\t.version " + ST.getPTXVersionString())); + OutStreamer.EmitRawText(Twine("\t.target " + ST.getTargetString() + + (ST.supportsDouble() ? "" : ", map_f64_to_f32"))); OutStreamer.AddBlankLine(); // declare global variables @@ -236,11 +243,24 @@ break; case MachineOperand::MO_FPImmediate: APInt constFP = MO.getFPImm()->getValueAPF().bitcastToAPInt(); + bool isFloat = MO.getFPImm()->getType()->getTypeID() == Type::FloatTyID; + // Emit 0F for 32-bit floats and 0D for 64-bit doubles. + if (isFloat) { + OS << "0F"; + } + else { + OS << "0D"; + } + // Emit the encoded floating-point value. if (constFP.getZExtValue() > 0) { - OS << "0F" << constFP.toString(16, false); + OS << constFP.toString(16, false); } else { - OS << "0F00000000"; + OS << "00000000"; + // If We have a double-precision zero, pad to 8-bytes. + if (!isFloat) { + OS << "00000000"; + } } break; } @@ -338,12 +358,18 @@ if (!MFI->argRegEmpty()) { decl += " ("; if (isKernel) { - for (int i = 0, e = MFI->getNumArg(); i != e; ++i) { - if (i != 0) + unsigned cnt = 0; + //for (int i = 0, e = MFI->getNumArg(); i != e; ++i) { + for(PTXMachineFunctionInfo::reg_iterator + i = MFI->argRegBegin(), e = MFI->argRegEnd(), b = i; i != e; ++i) { + reg = *i; + assert(reg != PTX::NoRegister && "Not a valid register!"); + if (i != b) decl += ", "; - decl += ".param .s32 "; // TODO: add types + decl += ".param .u32"; // TODO: Parse type from register map + decl += " "; decl += PARAM_PREFIX; - decl += utostr(i + 1); + decl += utostr(++cnt); } } else { for (PTXMachineFunctionInfo::reg_iterator Modified: llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp Tue Mar 1 21:20:28 2011 @@ -15,6 +15,7 @@ #include "PTXTargetMachine.h" #include "llvm/CodeGen/SelectionDAGISel.h" #include "llvm/DerivedTypes.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -66,14 +67,34 @@ } SDNode *PTXDAGToDAGISel::SelectREAD_PARAM(SDNode *Node) { - SDValue index = Node->getOperand(1); - DebugLoc dl = Node->getDebugLoc(); + SDValue index = Node->getOperand(1); + DebugLoc dl = Node->getDebugLoc(); + unsigned opcode; if (index.getOpcode() != ISD::TargetConstant) llvm_unreachable("READ_PARAM: index is not ISD::TargetConstant"); + if (Node->getValueType(0) == MVT::i16) { + opcode = PTX::LDpiU16; + } + else if (Node->getValueType(0) == MVT::i32) { + opcode = PTX::LDpiU32; + } + else if (Node->getValueType(0) == MVT::i64) { + opcode = PTX::LDpiU64; + } + else if (Node->getValueType(0) == MVT::f32) { + opcode = PTX::LDpiF32; + } + else if (Node->getValueType(0) == MVT::f64) { + opcode = PTX::LDpiF64; + } + else { + llvm_unreachable("Unknown parameter type for ld.param"); + } + return PTXInstrInfo:: - GetPTXMachineNode(CurDAG, PTX::LDpi, dl, MVT::i32, index); + GetPTXMachineNode(CurDAG, opcode, dl, Node->getValueType(0), index); } // Match memory operand of the form [reg+reg] Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Tue Mar 1 21:20:28 2011 @@ -20,6 +20,7 @@ #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -27,13 +28,17 @@ : TargetLowering(TM, new TargetLoweringObjectFileELF()) { // Set up the register classes. addRegisterClass(MVT::i1, PTX::PredsRegisterClass); - addRegisterClass(MVT::i32, PTX::RRegs32RegisterClass); + addRegisterClass(MVT::i16, PTX::RRegu16RegisterClass); + addRegisterClass(MVT::i32, PTX::RRegu32RegisterClass); + addRegisterClass(MVT::i64, PTX::RRegu64RegisterClass); addRegisterClass(MVT::f32, PTX::RRegf32RegisterClass); - + addRegisterClass(MVT::f64, PTX::RRegf64RegisterClass); + setOperationAction(ISD::EXCEPTIONADDR, MVT::i32, Expand); setOperationAction(ISD::ConstantFP, MVT::f32, Legal); - + setOperationAction(ISD::ConstantFP, MVT::f64, Legal); + // Customize translation of memory addresses setOperationAction(ISD::GlobalAddress, MVT::i32, Custom); @@ -90,10 +95,13 @@ bool operator==(MVT::SimpleValueType _VT) const { return VT == _VT; } } argmap[] = { argmap_entry(MVT::i1, PTX::PredsRegisterClass), - argmap_entry(MVT::i32, PTX::RRegs32RegisterClass), - argmap_entry(MVT::f32, PTX::RRegf32RegisterClass) + argmap_entry(MVT::i16, PTX::RRegu16RegisterClass), + argmap_entry(MVT::i32, PTX::RRegu32RegisterClass), + argmap_entry(MVT::i64, PTX::RRegu64RegisterClass), + argmap_entry(MVT::f32, PTX::RRegf32RegisterClass), + argmap_entry(MVT::f64, PTX::RRegf64RegisterClass) }; -} // end anonymous namespace +} // end anonymous namespace SDValue PTXTargetLowering:: LowerFormalArguments(SDValue Chain, @@ -192,12 +200,21 @@ SDValue Flag; unsigned reg; - if (Outs[0].VT == MVT::i32) { + if (Outs[0].VT == MVT::i16) { + reg = PTX::RH0; + } + else if (Outs[0].VT == MVT::i32) { reg = PTX::R0; } + else if (Outs[0].VT == MVT::i64) { + reg = PTX::RD0; + } else if (Outs[0].VT == MVT::f32) { reg = PTX::F0; } + else if (Outs[0].VT == MVT::f64) { + reg = PTX::FD0; + } else { assert(false && "Can return only basic types"); } Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp Tue Mar 1 21:20:28 2011 @@ -27,9 +27,12 @@ const TargetRegisterClass *cls; const int opcode; } map[] = { - { &PTX::RRegs32RegClass, PTX::MOVrr }, - { &PTX::RRegf32RegClass, PTX::MOVrr }, - { &PTX::PredsRegClass, PTX::MOVpp } + { &PTX::RRegu16RegClass, PTX::MOVU16rr }, + { &PTX::RRegu32RegClass, PTX::MOVU32rr }, + { &PTX::RRegu64RegClass, PTX::MOVU64rr }, + { &PTX::RRegf32RegClass, PTX::MOVF32rr }, + { &PTX::RRegf64RegClass, PTX::MOVF64rr }, + { &PTX::PredsRegClass, PTX::MOVPREDrr } }; void PTXInstrInfo::copyPhysReg(MachineBasicBlock &MBB, @@ -76,8 +79,12 @@ switch (MI.getOpcode()) { default: return false; - case PTX::MOVpp: - case PTX::MOVrr: + case PTX::MOVU16rr: + case PTX::MOVU32rr: + case PTX::MOVU64rr: + case PTX::MOVF32rr: + case PTX::MOVF64rr: + case PTX::MOVPREDrr: assert(MI.getNumOperands() >= 2 && MI.getOperand(0).isReg() && MI.getOperand(1).isReg() && "Invalid register-register move instruction"); Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.td?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.td (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Tue Mar 1 21:20:28 2011 @@ -114,7 +114,7 @@ // Address operands def MEMri : Operand { let PrintMethod = "printMemOperand"; - let MIOperandInfo = (ops RRegs32, i32imm); + let MIOperandInfo = (ops RRegu32, i32imm); } def MEMii : Operand { let PrintMethod = "printMemOperand"; @@ -143,75 +143,115 @@ // Instruction Class Templates //===----------------------------------------------------------------------===// -// Three-operand f32 instruction template +// Three-operand floating-point instruction template multiclass FLOAT3 { - def rr : InstPTX<(outs RRegf32:$d), - (ins RRegf32:$a, RRegf32:$b), - !strconcat(opcstr, ".%type\t$d, $a, $b"), - [(set RRegf32:$d, (opnode RRegf32:$a, RRegf32:$b))]>; - def ri : InstPTX<(outs RRegf32:$d), - (ins RRegf32:$a, f32imm:$b), - !strconcat(opcstr, ".%type\t$d, $a, $b"), - [(set RRegf32:$d, (opnode RRegf32:$a, fpimm:$b))]>; + def rr32 : InstPTX<(outs RRegf32:$d), + (ins RRegf32:$a, RRegf32:$b), + !strconcat(opcstr, ".f32\t$d, $a, $b"), + [(set RRegf32:$d, (opnode RRegf32:$a, RRegf32:$b))]>; + def ri32 : InstPTX<(outs RRegf32:$d), + (ins RRegf32:$a, f32imm:$b), + !strconcat(opcstr, ".f32\t$d, $a, $b"), + [(set RRegf32:$d, (opnode RRegf32:$a, fpimm:$b))]>; + def rr64 : InstPTX<(outs RRegf64:$d), + (ins RRegf64:$a, RRegf64:$b), + !strconcat(opcstr, ".f64\t$d, $a, $b"), + [(set RRegf64:$d, (opnode RRegf64:$a, RRegf64:$b))]>; + def ri64 : InstPTX<(outs RRegf64:$d), + (ins RRegf64:$a, f64imm:$b), + !strconcat(opcstr, ".f64\t$d, $a, $b"), + [(set RRegf64:$d, (opnode RRegf64:$a, fpimm:$b))]>; } multiclass INT3 { - def rr : InstPTX<(outs RRegs32:$d), - (ins RRegs32:$a, RRegs32:$b), - !strconcat(opcstr, ".%type\t$d, $a, $b"), - [(set RRegs32:$d, (opnode RRegs32:$a, RRegs32:$b))]>; - def ri : InstPTX<(outs RRegs32:$d), - (ins RRegs32:$a, i32imm:$b), - !strconcat(opcstr, ".%type\t$d, $a, $b"), - [(set RRegs32:$d, (opnode RRegs32:$a, imm:$b))]>; + def rr16 : InstPTX<(outs RRegu16:$d), + (ins RRegu16:$a, RRegu16:$b), + !strconcat(opcstr, ".u16\t$d, $a, $b"), + [(set RRegu16:$d, (opnode RRegu16:$a, RRegu16:$b))]>; + def ri16 : InstPTX<(outs RRegu16:$d), + (ins RRegu16:$a, i16imm:$b), + !strconcat(opcstr, ".u16\t$d, $a, $b"), + [(set RRegu16:$d, (opnode RRegu16:$a, imm:$b))]>; + def rr32 : InstPTX<(outs RRegu32:$d), + (ins RRegu32:$a, RRegu32:$b), + !strconcat(opcstr, ".u32\t$d, $a, $b"), + [(set RRegu32:$d, (opnode RRegu32:$a, RRegu32:$b))]>; + def ri32 : InstPTX<(outs RRegu32:$d), + (ins RRegu32:$a, i32imm:$b), + !strconcat(opcstr, ".u32\t$d, $a, $b"), + [(set RRegu32:$d, (opnode RRegu32:$a, imm:$b))]>; + def rr64 : InstPTX<(outs RRegu64:$d), + (ins RRegu64:$a, RRegu64:$b), + !strconcat(opcstr, ".u64\t$d, $a, $b"), + [(set RRegu64:$d, (opnode RRegu64:$a, RRegu64:$b))]>; + def ri64 : InstPTX<(outs RRegu64:$d), + (ins RRegu64:$a, i64imm:$b), + !strconcat(opcstr, ".u64\t$d, $a, $b"), + [(set RRegu64:$d, (opnode RRegu64:$a, imm:$b))]>; } // no %type directive, non-communtable multiclass INT3ntnc { - def rr : InstPTX<(outs RRegs32:$d), - (ins RRegs32:$a, RRegs32:$b), + def rr : InstPTX<(outs RRegu32:$d), + (ins RRegu32:$a, RRegu32:$b), !strconcat(opcstr, "\t$d, $a, $b"), - [(set RRegs32:$d, (opnode RRegs32:$a, RRegs32:$b))]>; - def ri : InstPTX<(outs RRegs32:$d), - (ins RRegs32:$a, i32imm:$b), + [(set RRegu32:$d, (opnode RRegu32:$a, RRegu32:$b))]>; + def ri : InstPTX<(outs RRegu32:$d), + (ins RRegu32:$a, i32imm:$b), !strconcat(opcstr, "\t$d, $a, $b"), - [(set RRegs32:$d, (opnode RRegs32:$a, imm:$b))]>; - def ir : InstPTX<(outs RRegs32:$d), - (ins i32imm:$a, RRegs32:$b), + [(set RRegu32:$d, (opnode RRegu32:$a, imm:$b))]>; + def ir : InstPTX<(outs RRegu32:$d), + (ins i32imm:$a, RRegu32:$b), !strconcat(opcstr, "\t$d, $a, $b"), - [(set RRegs32:$d, (opnode imm:$a, RRegs32:$b))]>; + [(set RRegu32:$d, (opnode imm:$a, RRegu32:$b))]>; } -multiclass PTX_LD { +multiclass PTX_LD { def rr : InstPTX<(outs RC:$d), (ins MEMri:$a), - !strconcat(opstr, ".%type\t$d, [$a]"), + !strconcat(opstr, !strconcat(typestr, "\t$d, [$a]")), [(set RC:$d, (pat_load ADDRrr:$a))]>; def ri : InstPTX<(outs RC:$d), (ins MEMri:$a), - !strconcat(opstr, ".%type\t$d, [$a]"), + !strconcat(opstr, !strconcat(typestr, "\t$d, [$a]")), [(set RC:$d, (pat_load ADDRri:$a))]>; def ii : InstPTX<(outs RC:$d), (ins MEMii:$a), - !strconcat(opstr, ".%type\t$d, [$a]"), + !strconcat(opstr, !strconcat(typestr, "\t$d, [$a]")), [(set RC:$d, (pat_load ADDRii:$a))]>; } -multiclass PTX_ST { +multiclass PTX_LD_ALL { + defm u16 : PTX_LD; + defm u32 : PTX_LD; + defm u64 : PTX_LD; + defm f32 : PTX_LD; + defm f64 : PTX_LD; +} + +multiclass PTX_ST { def rr : InstPTX<(outs), (ins RC:$d, MEMri:$a), - !strconcat(opstr, ".%type\t[$a], $d"), + !strconcat(opstr, !strconcat(typestr, "\t[$a], $d")), [(pat_store RC:$d, ADDRrr:$a)]>; def ri : InstPTX<(outs), (ins RC:$d, MEMri:$a), - !strconcat(opstr, ".%type\t[$a], $d"), + !strconcat(opstr, !strconcat(typestr, "\t[$a], $d")), [(pat_store RC:$d, ADDRri:$a)]>; def ii : InstPTX<(outs), (ins RC:$d, MEMii:$a), - !strconcat(opstr, ".%type\t[$a], $d"), + !strconcat(opstr, !strconcat(typestr, "\t[$a], $d")), [(pat_store RC:$d, ADDRii:$a)]>; } +multiclass PTX_ST_ALL { + defm u16 : PTX_ST; + defm u32 : PTX_ST; + defm u64 : PTX_ST; + defm f32 : PTX_ST; + defm f64 : PTX_ST; +} + //===----------------------------------------------------------------------===// // Instructions //===----------------------------------------------------------------------===// @@ -236,60 +276,67 @@ ///===- Data Movement and Conversion Instructions -------------------------===// let neverHasSideEffects = 1 in { - // rely on isMoveInstr to separate MOVpp, MOVrr, etc. - def MOVpp + def MOVPREDrr : InstPTX<(outs Preds:$d), (ins Preds:$a), "mov.pred\t$d, $a", []>; - def MOVrr - : InstPTX<(outs RRegs32:$d), (ins RRegs32:$a), "mov.%type\t$d, $a", []>; - def FMOVrr + def MOVU16rr + : InstPTX<(outs RRegu16:$d), (ins RRegu16:$a), "mov.u16\t$d, $a", []>; + def MOVU32rr + : InstPTX<(outs RRegu32:$d), (ins RRegu32:$a), "mov.u32\t$d, $a", []>; + def MOVU64rr + : InstPTX<(outs RRegu64:$d), (ins RRegu64:$a), "mov.u64\t$d, $a", []>; + def MOVF32rr : InstPTX<(outs RRegf32:$d), (ins RRegf32:$a), "mov.f32\t$d, $a", []>; + def MOVF64rr + : InstPTX<(outs RRegf64:$d), (ins RRegf64:$a), "mov.f64\t$d, $a", []>; } let isReMaterializable = 1, isAsCheapAsAMove = 1 in { - def MOVpi + def MOVPREDri : InstPTX<(outs Preds:$d), (ins i1imm:$a), "mov.pred\t$d, $a", [(set Preds:$d, imm:$a)]>; - def MOVri - : InstPTX<(outs RRegs32:$d), (ins i32imm:$a), "mov.s32\t$d, $a", - [(set RRegs32:$d, imm:$a)]>; - def FMOVri + def MOVU16ri + : InstPTX<(outs RRegu16:$d), (ins i16imm:$a), "mov.u16\t$d, $a", + [(set RRegu16:$d, imm:$a)]>; + def MOVU32ri + : InstPTX<(outs RRegu32:$d), (ins i32imm:$a), "mov.u32\t$d, $a", + [(set RRegu32:$d, imm:$a)]>; + def MOVU164ri + : InstPTX<(outs RRegu64:$d), (ins i64imm:$a), "mov.u64\t$d, $a", + [(set RRegu64:$d, imm:$a)]>; + def MOVF32ri : InstPTX<(outs RRegf32:$d), (ins f32imm:$a), "mov.f32\t$d, $a", [(set RRegf32:$d, fpimm:$a)]>; -} - -// Integer loads -defm LDg : PTX_LD<"ld.global", RRegs32, load_global>; -defm LDc : PTX_LD<"ld.const", RRegs32, load_constant>; -defm LDl : PTX_LD<"ld.local", RRegs32, load_local>; -defm LDp : PTX_LD<"ld.param", RRegs32, load_parameter>; -defm LDs : PTX_LD<"ld.shared", RRegs32, load_shared>; - -def LDpi : InstPTX<(outs RRegs32:$d), (ins MEMpi:$a), - "ld.param.%type\t$d, [$a]", []>; - -// Floating-point loads -defm FLDg : PTX_LD<"ld.global", RRegf32, load_global>; -defm FLDc : PTX_LD<"ld.const", RRegf32, load_constant>; -defm FLDl : PTX_LD<"ld.local", RRegf32, load_local>; -defm FLDp : PTX_LD<"ld.param", RRegf32, load_parameter>; -defm FLDs : PTX_LD<"ld.shared", RRegf32, load_shared>; - -def FLDpi : InstPTX<(outs RRegf32:$d), (ins MEMpi:$a), - "ld.param.%type\t$d, [$a]", []>; - -// Integer stores -defm STg : PTX_ST<"st.global", RRegs32, store_global>; -defm STl : PTX_ST<"st.local", RRegs32, store_local>; -// Store to parameter state space requires PTX 2.0 or higher? -// defm STp : PTX_ST<"st.param", RRegs32, store_parameter>; -defm STs : PTX_ST<"st.shared", RRegs32, store_shared>; - -// Floating-point stores -defm FSTg : PTX_ST<"st.global", RRegf32, store_global>; -defm FSTl : PTX_ST<"st.local", RRegf32, store_local>; -// Store to parameter state space requires PTX 2.0 or higher? -// defm FSTp : PTX_ST<"st.param", RRegf32, store_parameter>; -defm FSTs : PTX_ST<"st.shared", RRegf32, store_shared>; + def MOVF64ri + : InstPTX<(outs RRegf64:$d), (ins f64imm:$a), "mov.f64\t$d, $a", + [(set RRegf64:$d, fpimm:$a)]>; +} + +// Loads +defm LDg : PTX_LD_ALL<"ld.global", load_global>; +defm LDc : PTX_LD_ALL<"ld.const", load_constant>; +defm LDl : PTX_LD_ALL<"ld.local", load_local>; +defm LDs : PTX_LD_ALL<"ld.shared", load_shared>; + +// This is a special instruction that is manually inserted for kernel parameters +def LDpiU16 : InstPTX<(outs RRegu16:$d), (ins MEMpi:$a), + "ld.param.u16\t$d, [$a]", []>; +def LDpiU32 : InstPTX<(outs RRegu32:$d), (ins MEMpi:$a), + "ld.param.u32\t$d, [$a]", []>; +def LDpiU64 : InstPTX<(outs RRegu64:$d), (ins MEMpi:$a), + "ld.param.u64\t$d, [$a]", []>; +def LDpiF32 : InstPTX<(outs RRegf32:$d), (ins MEMpi:$a), + "ld.param.f32\t$d, [$a]", []>; +def LDpiF64 : InstPTX<(outs RRegf64:$d), (ins MEMpi:$a), + "ld.param.f64\t$d, [$a]", []>; + +// Stores +defm STg : PTX_ST_ALL<"st.global", store_global>; +defm STl : PTX_ST_ALL<"st.local", store_local>; +defm STs : PTX_ST_ALL<"st.shared", store_shared>; + +// defm STp : PTX_ST_ALL<"st.param", store_parameter>; +// defm LDp : PTX_LD_ALL<"ld.param", load_parameter>; +// TODO: Do something with st.param if/when it is needed. ///===- Control Flow Instructions -----------------------------------------===// Modified: llvm/trunk/lib/Target/PTX/PTXMFInfoExtract.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXMFInfoExtract.cpp?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXMFInfoExtract.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXMFInfoExtract.cpp Tue Mar 1 21:20:28 2011 @@ -79,12 +79,12 @@ DEBUG(for (PTXMachineFunctionInfo::reg_iterator i = MFI->argRegBegin(), e = MFI->argRegEnd(); - i != e; ++i) + i != e; ++i) dbgs() << "Arg Reg: " << *i << "\n";); DEBUG(for (PTXMachineFunctionInfo::reg_iterator i = MFI->localVarRegBegin(), e = MFI->localVarRegEnd(); - i != e; ++i) + i != e; ++i) dbgs() << "Local Var Reg: " << *i << "\n";); return false; Modified: llvm/trunk/lib/Target/PTX/PTXRegisterInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXRegisterInfo.td?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXRegisterInfo.td (original) +++ llvm/trunk/lib/Target/PTX/PTXRegisterInfo.td Tue Mar 1 21:20:28 2011 @@ -19,6 +19,8 @@ // Registers //===----------------------------------------------------------------------===// +///===- Predicate Registers -----------------------------------------------===// + def P0 : PTXReg<"p0">; def P1 : PTXReg<"p1">; def P2 : PTXReg<"p2">; @@ -52,6 +54,43 @@ def P30 : PTXReg<"p30">; def P31 : PTXReg<"p31">; +///===- 16-bit Integer Registers ------------------------------------------===// + +def RH0 : PTXReg<"rh0">; +def RH1 : PTXReg<"rh1">; +def RH2 : PTXReg<"rh2">; +def RH3 : PTXReg<"rh3">; +def RH4 : PTXReg<"rh4">; +def RH5 : PTXReg<"rh5">; +def RH6 : PTXReg<"rh6">; +def RH7 : PTXReg<"rh7">; +def RH8 : PTXReg<"rh8">; +def RH9 : PTXReg<"rh9">; +def RH10 : PTXReg<"rh10">; +def RH11 : PTXReg<"rh11">; +def RH12 : PTXReg<"rh12">; +def RH13 : PTXReg<"rh13">; +def RH14 : PTXReg<"rh14">; +def RH15 : PTXReg<"rh15">; +def RH16 : PTXReg<"rh16">; +def RH17 : PTXReg<"rh17">; +def RH18 : PTXReg<"rh18">; +def RH19 : PTXReg<"rh19">; +def RH20 : PTXReg<"rh20">; +def RH21 : PTXReg<"rh21">; +def RH22 : PTXReg<"rh22">; +def RH23 : PTXReg<"rh23">; +def RH24 : PTXReg<"rh24">; +def RH25 : PTXReg<"rh25">; +def RH26 : PTXReg<"rh26">; +def RH27 : PTXReg<"rh27">; +def RH28 : PTXReg<"rh28">; +def RH29 : PTXReg<"rh29">; +def RH30 : PTXReg<"rh30">; +def RH31 : PTXReg<"rh31">; + +///===- 32-bit Integer Registers ------------------------------------------===// + def R0 : PTXReg<"r0">; def R1 : PTXReg<"r1">; def R2 : PTXReg<"r2">; @@ -85,6 +124,43 @@ def R30 : PTXReg<"r30">; def R31 : PTXReg<"r31">; +///===- 64-bit Integer Registers ------------------------------------------===// + +def RD0 : PTXReg<"rd0">; +def RD1 : PTXReg<"rd1">; +def RD2 : PTXReg<"rd2">; +def RD3 : PTXReg<"rd3">; +def RD4 : PTXReg<"rd4">; +def RD5 : PTXReg<"rd5">; +def RD6 : PTXReg<"rd6">; +def RD7 : PTXReg<"rd7">; +def RD8 : PTXReg<"rd8">; +def RD9 : PTXReg<"rd9">; +def RD10 : PTXReg<"rd10">; +def RD11 : PTXReg<"rd11">; +def RD12 : PTXReg<"rd12">; +def RD13 : PTXReg<"rd13">; +def RD14 : PTXReg<"rd14">; +def RD15 : PTXReg<"rd15">; +def RD16 : PTXReg<"rd16">; +def RD17 : PTXReg<"rd17">; +def RD18 : PTXReg<"rd18">; +def RD19 : PTXReg<"rd19">; +def RD20 : PTXReg<"rd20">; +def RD21 : PTXReg<"rd21">; +def RD22 : PTXReg<"rd22">; +def RD23 : PTXReg<"rd23">; +def RD24 : PTXReg<"rd24">; +def RD25 : PTXReg<"rd25">; +def RD26 : PTXReg<"rd26">; +def RD27 : PTXReg<"rd27">; +def RD28 : PTXReg<"rd28">; +def RD29 : PTXReg<"rd29">; +def RD30 : PTXReg<"rd30">; +def RD31 : PTXReg<"rd31">; + +///===- 32-bit Floating-Point Registers -----------------------------------===// + def F0 : PTXReg<"f0">; def F1 : PTXReg<"f1">; def F2 : PTXReg<"f2">; @@ -118,6 +194,41 @@ def F30 : PTXReg<"f30">; def F31 : PTXReg<"f31">; +///===- 64-bit Floating-Point Registers -----------------------------------===// + +def FD0 : PTXReg<"fd0">; +def FD1 : PTXReg<"fd1">; +def FD2 : PTXReg<"fd2">; +def FD3 : PTXReg<"fd3">; +def FD4 : PTXReg<"fd4">; +def FD5 : PTXReg<"fd5">; +def FD6 : PTXReg<"fd6">; +def FD7 : PTXReg<"fd7">; +def FD8 : PTXReg<"fd8">; +def FD9 : PTXReg<"fd9">; +def FD10 : PTXReg<"fd10">; +def FD11 : PTXReg<"fd11">; +def FD12 : PTXReg<"fd12">; +def FD13 : PTXReg<"fd13">; +def FD14 : PTXReg<"fd14">; +def FD15 : PTXReg<"fd15">; +def FD16 : PTXReg<"fd16">; +def FD17 : PTXReg<"fd17">; +def FD18 : PTXReg<"fd18">; +def FD19 : PTXReg<"fd19">; +def FD20 : PTXReg<"fd20">; +def FD21 : PTXReg<"fd21">; +def FD22 : PTXReg<"fd22">; +def FD23 : PTXReg<"fd23">; +def FD24 : PTXReg<"fd24">; +def FD25 : PTXReg<"fd25">; +def FD26 : PTXReg<"fd26">; +def FD27 : PTXReg<"fd27">; +def FD28 : PTXReg<"fd28">; +def FD29 : PTXReg<"fd29">; +def FD30 : PTXReg<"fd30">; +def FD31 : PTXReg<"fd31">; + //===----------------------------------------------------------------------===// // Register classes @@ -129,14 +240,32 @@ P16, P17, P18, P19, P20, P21, P22, P23, P24, P25, P26, P27, P28, P29, P30, P31]>; -def RRegs32 : RegisterClass<"PTX", [i32], 32, +def RRegu16 : RegisterClass<"PTX", [i16], 16, + [RH0, RH1, RH2, RH3, RH4, RH5, RH6, RH7, + RH8, RH9, RH10, RH11, RH12, RH13, RH14, RH15, + RH16, RH17, RH18, RH19, RH20, RH21, RH22, RH23, + RH24, RH25, RH26, RH27, RH28, RH29, RH30, RH31]>; + +def RRegu32 : RegisterClass<"PTX", [i32], 32, [R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, R26, R27, R28, R29, R30, R31]>; +def RRegu64 : RegisterClass<"PTX", [i64], 64, + [RD0, RD1, RD2, RD3, RD4, RD5, RD6, RD7, + RD8, RD9, RD10, RD11, RD12, RD13, RD14, RD15, + RD16, RD17, RD18, RD19, RD20, RD21, RD22, RD23, + RD24, RD25, RD26, RD27, RD28, RD29, RD30, RD31]>; + def RRegf32 : RegisterClass<"PTX", [f32], 32, [F0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, F30, F31]>; + +def RRegf64 : RegisterClass<"PTX", [f64], 64, + [FD0, FD1, FD2, FD3, FD4, FD5, FD6, FD7, + FD8, FD9, FD10, FD11, FD12, FD13, FD14, FD15, + FD16, FD17, FD18, FD19, FD20, FD21, FD22, FD23, + FD24, FD25, FD26, FD27, FD28, FD29, FD30, FD31]>; Modified: llvm/trunk/lib/Target/PTX/PTXSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXSubtarget.cpp?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXSubtarget.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXSubtarget.cpp Tue Mar 1 21:20:28 2011 @@ -12,12 +12,33 @@ //===----------------------------------------------------------------------===// #include "PTXSubtarget.h" +#include "llvm/Support/ErrorHandling.h" using namespace llvm; -PTXSubtarget::PTXSubtarget(const std::string &TT, const std::string &FS) { - std::string TARGET = "sm_20"; - // TODO: call ParseSubtargetFeatures(FS, TARGET); +PTXSubtarget::PTXSubtarget(const std::string &TT, const std::string &FS) + : PTXShaderModel(PTX_SM_1_0), + PTXVersion(PTX_VERSION_1_4) { + std::string TARGET = "generic"; + ParseSubtargetFeatures(FS, TARGET); +} + +std::string PTXSubtarget::getTargetString() const { + switch(PTXShaderModel) { + default: llvm_unreachable("Unknown shader model"); + case PTX_SM_1_0: return "sm_10"; + case PTX_SM_1_3: return "sm_13"; + case PTX_SM_2_0: return "sm_20"; + } +} + +std::string PTXSubtarget::getPTXVersionString() const { + switch(PTXVersion) { + default: llvm_unreachable("Unknown PTX version"); + case PTX_VERSION_1_4: return "1.4"; + case PTX_VERSION_2_0: return "2.0"; + case PTX_VERSION_2_1: return "2.1"; + } } #include "PTXGenSubtarget.inc" Modified: llvm/trunk/lib/Target/PTX/PTXSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXSubtarget.h?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXSubtarget.h (original) +++ llvm/trunk/lib/Target/PTX/PTXSubtarget.h Tue Mar 1 21:20:28 2011 @@ -19,11 +19,36 @@ namespace llvm { class PTXSubtarget : public TargetSubtarget { private: - bool is_sm20; + enum PTXShaderModelEnum { + PTX_SM_1_0, + PTX_SM_1_3, + PTX_SM_2_0 + }; + + enum PTXVersionEnum { + PTX_VERSION_1_4, + PTX_VERSION_2_0, + PTX_VERSION_2_1 + }; + + /// Shader Model supported on the target GPU. + PTXShaderModelEnum PTXShaderModel; + + /// PTX Language Version. + PTXVersionEnum PTXVersion; + + // The native .f64 type is supported on the hardware. + bool SupportsDouble; public: PTXSubtarget(const std::string &TT, const std::string &FS); + std::string getTargetString() const; + + std::string getPTXVersionString() const; + + bool supportsDouble() const { return SupportsDouble; } + std::string ParseSubtargetFeatures(const std::string &FS, const std::string &CPU); }; // class PTXSubtarget Modified: llvm/trunk/test/CodeGen/PTX/add.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/add.ll?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PTX/add.ll (original) +++ llvm/trunk/test/CodeGen/PTX/add.ll Tue Mar 1 21:20:28 2011 @@ -1,29 +1,71 @@ ; RUN: llc < %s -march=ptx | FileCheck %s -define ptx_device i32 @t1(i32 %x, i32 %y) { -; CHECK: add.s32 r0, r1, r2; +define ptx_device i16 @t1_u16(i16 %x, i16 %y) { +; CHECK: add.u16 rh0, rh1, rh2; +; CHECK-NEXT: ret; + %z = add i16 %x, %y + ret i16 %z +} + +define ptx_device i32 @t1_u32(i32 %x, i32 %y) { +; CHECK: add.u32 r0, r1, r2; +; CHECK-NEXT: ret; %z = add i32 %x, %y -; CHECK: ret; ret i32 %z } -define ptx_device i32 @t2(i32 %x) { -; CHECK: add.s32 r0, r1, 1; - %z = add i32 %x, 1 -; CHECK: ret; - ret i32 %z +define ptx_device i64 @t1_u64(i64 %x, i64 %y) { +; CHECK: add.u64 rd0, rd1, rd2; +; CHECK-NEXT: ret; + %z = add i64 %x, %y + ret i64 %z } -define ptx_device float @t3(float %x, float %y) { +define ptx_device float @t1_f32(float %x, float %y) { ; CHECK: add.f32 f0, f1, f2 ; CHECK-NEXT: ret; %z = fadd float %x, %y ret float %z } -define ptx_device float @t4(float %x) { +define ptx_device double @t1_f64(double %x, double %y) { +; CHECK: add.f64 fd0, fd1, fd2 +; CHECK-NEXT: ret; + %z = fadd double %x, %y + ret double %z +} + +define ptx_device i16 @t2_u16(i16 %x) { +; CHECK: add.u16 rh0, rh1, 1; +; CHECK-NEXT: ret; + %z = add i16 %x, 1 + ret i16 %z +} + +define ptx_device i32 @t2_u32(i32 %x) { +; CHECK: add.u32 r0, r1, 1; +; CHECK-NEXT: ret; + %z = add i32 %x, 1 + ret i32 %z +} + +define ptx_device i64 @t2_u64(i64 %x) { +; CHECK: add.u64 rd0, rd1, 1; +; CHECK-NEXT: ret; + %z = add i64 %x, 1 + ret i64 %z +} + +define ptx_device float @t2_f32(float %x) { ; CHECK: add.f32 f0, f1, 0F3F800000; ; CHECK-NEXT: ret; %z = fadd float %x, 1.0 ret float %z } + +define ptx_device double @t2_f64(double %x) { +; CHECK: add.f64 fd0, fd1, 0D3FF0000000000000; +; CHECK-NEXT: ret; + %z = fadd double %x, 1.0 + ret double %z +} Modified: llvm/trunk/test/CodeGen/PTX/ld.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/ld.ll?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PTX/ld.ll (original) +++ llvm/trunk/test/CodeGen/PTX/ld.ll Tue Mar 1 21:20:28 2011 @@ -1,78 +1,422 @@ ; RUN: llc < %s -march=ptx | FileCheck %s -;CHECK: .extern .global .s32 array[]; - at array = external global [10 x i32] +;CHECK: .extern .global .u16 array_i16[]; + at array_i16 = external global [10 x i16] -;CHECK: .extern .const .s32 array_constant[]; - at array_constant = external addrspace(1) constant [10 x i32] +;CHECK: .extern .const .u16 array_constant_i16[]; + at array_constant_i16 = external addrspace(1) constant [10 x i16] -;CHECK: .extern .local .s32 array_local[]; - at array_local = external addrspace(2) global [10 x i32] +;CHECK: .extern .local .u16 array_local_i16[]; + at array_local_i16 = external addrspace(2) global [10 x i16] -;CHECK: .extern .shared .s32 array_shared[]; - at array_shared = external addrspace(4) global [10 x i32] +;CHECK: .extern .shared .u16 array_shared_i16[]; + at array_shared_i16 = external addrspace(4) global [10 x i16] -define ptx_device i32 @t1(i32* %p) { +;CHECK: .extern .global .u32 array_i32[]; + at array_i32 = external global [10 x i32] + +;CHECK: .extern .const .u32 array_constant_i32[]; + at array_constant_i32 = external addrspace(1) constant [10 x i32] + +;CHECK: .extern .local .u32 array_local_i32[]; + at array_local_i32 = external addrspace(2) global [10 x i32] + +;CHECK: .extern .shared .u32 array_shared_i32[]; + at array_shared_i32 = external addrspace(4) global [10 x i32] + +;CHECK: .extern .global .u64 array_i64[]; + at array_i64 = external global [10 x i64] + +;CHECK: .extern .const .u64 array_constant_i64[]; + at array_constant_i64 = external addrspace(1) constant [10 x i64] + +;CHECK: .extern .local .u64 array_local_i64[]; + at array_local_i64 = external addrspace(2) global [10 x i64] + +;CHECK: .extern .shared .u64 array_shared_i64[]; + at array_shared_i64 = external addrspace(4) global [10 x i64] + +;CHECK: .extern .global .f32 array_float[]; + at array_float = external global [10 x float] + +;CHECK: .extern .const .f32 array_constant_float[]; + at array_constant_float = external addrspace(1) constant [10 x float] + +;CHECK: .extern .local .f32 array_local_float[]; + at array_local_float = external addrspace(2) global [10 x float] + +;CHECK: .extern .shared .f32 array_shared_float[]; + at array_shared_float = external addrspace(4) global [10 x float] + +;CHECK: .extern .global .f64 array_double[]; + at array_double = external global [10 x double] + +;CHECK: .extern .const .f64 array_constant_double[]; + at array_constant_double = external addrspace(1) constant [10 x double] + +;CHECK: .extern .local .f64 array_local_double[]; + at array_local_double = external addrspace(2) global [10 x double] + +;CHECK: .extern .shared .f64 array_shared_double[]; + at array_shared_double = external addrspace(4) global [10 x double] + + +define ptx_device i16 @t1_u16(i16* %p) { entry: -;CHECK: ld.global.s32 r0, [r1]; +;CHECK: ld.global.u16 rh0, [r1]; +;CHECK-NEXT; ret; + %x = load i16* %p + ret i16 %x +} + +define ptx_device i32 @t1_u32(i32* %p) { +entry: +;CHECK: ld.global.u32 r0, [r1]; +;CHECK-NEXT: ret; %x = load i32* %p ret i32 %x } -define ptx_device i32 @t2(i32* %p) { +define ptx_device i64 @t1_u64(i64* %p) { +entry: +;CHECK: ld.global.u64 rd0, [r1]; +;CHECK-NEXT: ret; + %x = load i64* %p + ret i64 %x +} + +define ptx_device float @t1_f32(float* %p) { +entry: +;CHECK: ld.global.f32 f0, [r1]; +;CHECK-NEXT: ret; + %x = load float* %p + ret float %x +} + +define ptx_device double @t1_f64(double* %p) { +entry: +;CHECK: ld.global.f64 fd0, [r1]; +;CHECK-NEXT: ret; + %x = load double* %p + ret double %x +} + +define ptx_device i16 @t2_u16(i16* %p) { entry: -;CHECK: ld.global.s32 r0, [r1+4]; +;CHECK: ld.global.u16 rh0, [r1+2]; +;CHECK-NEXT: ret; + %i = getelementptr i16* %p, i32 1 + %x = load i16* %i + ret i16 %x +} + +define ptx_device i32 @t2_u32(i32* %p) { +entry: +;CHECK: ld.global.u32 r0, [r1+4]; +;CHECK-NEXT: ret; %i = getelementptr i32* %p, i32 1 %x = load i32* %i ret i32 %x } -define ptx_device i32 @t3(i32* %p, i32 %q) { +define ptx_device i64 @t2_u64(i64* %p) { +entry: +;CHECK: ld.global.u64 rd0, [r1+8]; +;CHECK-NEXT: ret; + %i = getelementptr i64* %p, i32 1 + %x = load i64* %i + ret i64 %x +} + +define ptx_device float @t2_f32(float* %p) { +entry: +;CHECK: ld.global.f32 f0, [r1+4]; +;CHECK-NEXT: ret; + %i = getelementptr float* %p, i32 1 + %x = load float* %i + ret float %x +} + +define ptx_device double @t2_f64(double* %p) { +entry: +;CHECK: ld.global.f64 fd0, [r1+8]; +;CHECK-NEXT: ret; + %i = getelementptr double* %p, i32 1 + %x = load double* %i + ret double %x +} + +define ptx_device i16 @t3_u16(i16* %p, i32 %q) { +entry: +;CHECK: shl.b32 r0, r2, 1; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: ld.global.u16 rh0, [r0]; + %i = getelementptr i16* %p, i32 %q + %x = load i16* %i + ret i16 %x +} + +define ptx_device i32 @t3_u32(i32* %p, i32 %q) { entry: ;CHECK: shl.b32 r0, r2, 2; -;CHECK: add.s32 r0, r1, r0; -;CHECK: ld.global.s32 r0, [r0]; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: ld.global.u32 r0, [r0]; %i = getelementptr i32* %p, i32 %q %x = load i32* %i ret i32 %x } -define ptx_device i32 @t4_global() { +define ptx_device i64 @t3_u64(i64* %p, i32 %q) { +entry: +;CHECK: shl.b32 r0, r2, 3; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: ld.global.u64 rd0, [r0]; + %i = getelementptr i64* %p, i32 %q + %x = load i64* %i + ret i64 %x +} + +define ptx_device float @t3_f32(float* %p, i32 %q) { +entry: +;CHECK: shl.b32 r0, r2, 2; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: ld.global.f32 f0, [r0]; + %i = getelementptr float* %p, i32 %q + %x = load float* %i + ret float %x +} + +define ptx_device double @t3_f64(double* %p, i32 %q) { +entry: +;CHECK: shl.b32 r0, r2, 3; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: ld.global.f64 fd0, [r0]; + %i = getelementptr double* %p, i32 %q + %x = load double* %i + ret double %x +} + +define ptx_device i16 @t4_global_u16() { +entry: +;CHECK: ld.global.u16 rh0, [array_i16]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16]* @array_i16, i32 0, i32 0 + %x = load i16* %i + ret i16 %x +} + +define ptx_device i32 @t4_global_u32() { entry: -;CHECK: ld.global.s32 r0, [array]; - %i = getelementptr [10 x i32]* @array, i32 0, i32 0 +;CHECK: ld.global.u32 r0, [array_i32]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32]* @array_i32, i32 0, i32 0 %x = load i32* %i ret i32 %x } -define ptx_device i32 @t4_const() { +define ptx_device i64 @t4_global_u64() { entry: -;CHECK: ld.const.s32 r0, [array_constant]; - %i = getelementptr [10 x i32] addrspace(1)* @array_constant, i32 0, i32 0 +;CHECK: ld.global.u64 rd0, [array_i64]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64]* @array_i64, i32 0, i32 0 + %x = load i64* %i + ret i64 %x +} + +define ptx_device float @t4_global_f32() { +entry: +;CHECK: ld.global.f32 f0, [array_float]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float]* @array_float, i32 0, i32 0 + %x = load float* %i + ret float %x +} + +define ptx_device double @t4_global_f64() { +entry: +;CHECK: ld.global.f64 fd0, [array_double]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double]* @array_double, i32 0, i32 0 + %x = load double* %i + ret double %x +} + +define ptx_device i16 @t4_const_u16() { +entry: +;CHECK: ld.const.u16 rh0, [array_constant_i16]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16] addrspace(1)* @array_constant_i16, i32 0, i32 0 + %x = load i16 addrspace(1)* %i + ret i16 %x +} + +define ptx_device i32 @t4_const_u32() { +entry: +;CHECK: ld.const.u32 r0, [array_constant_i32]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32] addrspace(1)* @array_constant_i32, i32 0, i32 0 %x = load i32 addrspace(1)* %i ret i32 %x } -define ptx_device i32 @t4_local() { +define ptx_device i64 @t4_const_u64() { +entry: +;CHECK: ld.const.u64 rd0, [array_constant_i64]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64] addrspace(1)* @array_constant_i64, i32 0, i32 0 + %x = load i64 addrspace(1)* %i + ret i64 %x +} + +define ptx_device float @t4_const_f32() { entry: -;CHECK: ld.local.s32 r0, [array_local]; - %i = getelementptr [10 x i32] addrspace(2)* @array_local, i32 0, i32 0 +;CHECK: ld.const.f32 f0, [array_constant_float]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float] addrspace(1)* @array_constant_float, i32 0, i32 0 + %x = load float addrspace(1)* %i + ret float %x +} + +define ptx_device double @t4_const_f64() { +entry: +;CHECK: ld.const.f64 fd0, [array_constant_double]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double] addrspace(1)* @array_constant_double, i32 0, i32 0 + %x = load double addrspace(1)* %i + ret double %x +} + +define ptx_device i16 @t4_local_u16() { +entry: +;CHECK: ld.local.u16 rh0, [array_local_i16]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16] addrspace(2)* @array_local_i16, i32 0, i32 0 + %x = load i16 addrspace(2)* %i + ret i16 %x +} + +define ptx_device i32 @t4_local_u32() { +entry: +;CHECK: ld.local.u32 r0, [array_local_i32]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32] addrspace(2)* @array_local_i32, i32 0, i32 0 %x = load i32 addrspace(2)* %i ret i32 %x } -define ptx_device i32 @t4_shared() { +define ptx_device i64 @t4_local_u64() { entry: -;CHECK: ld.shared.s32 r0, [array_shared]; - %i = getelementptr [10 x i32] addrspace(4)* @array_shared, i32 0, i32 0 +;CHECK: ld.local.u64 rd0, [array_local_i64]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64] addrspace(2)* @array_local_i64, i32 0, i32 0 + %x = load i64 addrspace(2)* %i + ret i64 %x +} + +define ptx_device float @t4_local_f32() { +entry: +;CHECK: ld.local.f32 f0, [array_local_float]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float] addrspace(2)* @array_local_float, i32 0, i32 0 + %x = load float addrspace(2)* %i + ret float %x +} + +define ptx_device double @t4_local_f64() { +entry: +;CHECK: ld.local.f64 fd0, [array_local_double]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double] addrspace(2)* @array_local_double, i32 0, i32 0 + %x = load double addrspace(2)* %i + ret double %x +} + +define ptx_device i16 @t4_shared_u16() { +entry: +;CHECK: ld.shared.u16 rh0, [array_shared_i16]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16] addrspace(4)* @array_shared_i16, i32 0, i32 0 + %x = load i16 addrspace(4)* %i + ret i16 %x +} + +define ptx_device i32 @t4_shared_u32() { +entry: +;CHECK: ld.shared.u32 r0, [array_shared_i32]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32] addrspace(4)* @array_shared_i32, i32 0, i32 0 %x = load i32 addrspace(4)* %i ret i32 %x } -define ptx_device i32 @t5() { +define ptx_device i64 @t4_shared_u64() { +entry: +;CHECK: ld.shared.u64 rd0, [array_shared_i64]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64] addrspace(4)* @array_shared_i64, i32 0, i32 0 + %x = load i64 addrspace(4)* %i + ret i64 %x +} + +define ptx_device float @t4_shared_f32() { +entry: +;CHECK: ld.shared.f32 f0, [array_shared_float]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float] addrspace(4)* @array_shared_float, i32 0, i32 0 + %x = load float addrspace(4)* %i + ret float %x +} + +define ptx_device double @t4_shared_f64() { +entry: +;CHECK: ld.shared.f64 fd0, [array_shared_double]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double] addrspace(4)* @array_shared_double, i32 0, i32 0 + %x = load double addrspace(4)* %i + ret double %x +} + +define ptx_device i16 @t5_u16() { entry: -;CHECK: ld.global.s32 r0, [array+4]; - %i = getelementptr [10 x i32]* @array, i32 0, i32 1 +;CHECK: ld.global.u16 rh0, [array_i16+2]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16]* @array_i16, i32 0, i32 1 + %x = load i16* %i + ret i16 %x +} + +define ptx_device i32 @t5_u32() { +entry: +;CHECK: ld.global.u32 r0, [array_i32+4]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32]* @array_i32, i32 0, i32 1 %x = load i32* %i ret i32 %x } + +define ptx_device i64 @t5_u64() { +entry: +;CHECK: ld.global.u64 rd0, [array_i64+8]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64]* @array_i64, i32 0, i32 1 + %x = load i64* %i + ret i64 %x +} + +define ptx_device float @t5_f32() { +entry: +;CHECK: ld.global.f32 f0, [array_float+4]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float]* @array_float, i32 0, i32 1 + %x = load float* %i + ret float %x +} + +define ptx_device double @t5_f64() { +entry: +;CHECK: ld.global.f64 fd0, [array_double+8]; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double]* @array_double, i32 0, i32 1 + %x = load double* %i + ret double %x +} Removed: llvm/trunk/test/CodeGen/PTX/ld_float.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/ld_float.ll?rev=126823&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PTX/ld_float.ll (original) +++ llvm/trunk/test/CodeGen/PTX/ld_float.ll (removed) @@ -1,86 +0,0 @@ -; RUN: llc < %s -march=ptx | FileCheck %s - -;CHECK: .extern .global .f32 array[]; - at array = external global [10 x float] - -;CHECK: .extern .const .f32 array_constant[]; - at array_constant = external addrspace(1) constant [10 x float] - -;CHECK: .extern .local .f32 array_local[]; - at array_local = external addrspace(2) global [10 x float] - -;CHECK: .extern .shared .f32 array_shared[]; - at array_shared = external addrspace(4) global [10 x float] - -define ptx_device float @t1(float* %p) { -entry: -;CHECK: ld.global.f32 f0, [r1]; -;CHECK-NEXT: ret; - %x = load float* %p - ret float %x -} - -define ptx_device float @t2(float* %p) { -entry: -;CHECK: ld.global.f32 f0, [r1+4]; -;CHECK-NEXT: ret; - %i = getelementptr float* %p, i32 1 - %x = load float* %i - ret float %x -} - -define ptx_device float @t3(float* %p, i32 %q) { -entry: -;CHECK: shl.b32 r0, r2, 2; -;CHECK-NEXT: add.s32 r0, r1, r0; -;CHECK-NEXT: ld.global.f32 f0, [r0]; -;CHECK-NEXT: ret; - %i = getelementptr float* %p, i32 %q - %x = load float* %i - ret float %x -} - -define ptx_device float @t4_global() { -entry: -;CHECK: ld.global.f32 f0, [array]; -;CHECK-NEXT: ret; - %i = getelementptr [10 x float]* @array, i32 0, i32 0 - %x = load float* %i - ret float %x -} - -define ptx_device float @t4_const() { -entry: -;CHECK: ld.const.f32 f0, [array_constant]; -;CHECK-NEXT: ret; - %i = getelementptr [10 x float] addrspace(1)* @array_constant, i32 0, i32 0 - %x = load float addrspace(1)* %i - ret float %x -} - -define ptx_device float @t4_local() { -entry: -;CHECK: ld.local.f32 f0, [array_local]; -;CHECK-NEXT: ret; - %i = getelementptr [10 x float] addrspace(2)* @array_local, i32 0, i32 0 - %x = load float addrspace(2)* %i - ret float %x -} - -define ptx_device float @t4_shared() { -entry: -;CHECK: ld.shared.f32 f0, [array_shared]; -;CHECK-NEXT: ret; - %i = getelementptr [10 x float] addrspace(4)* @array_shared, i32 0, i32 0 - %x = load float addrspace(4)* %i - ret float %x -} - -define ptx_device float @t5() { -entry: -;CHECK: ld.global.f32 f0, [array+4]; -;CHECK-NEXT: ret; - %i = getelementptr [10 x float]* @array, i32 0, i32 1 - %x = load float* %i - ret float %x -} Modified: llvm/trunk/test/CodeGen/PTX/mov.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/mov.ll?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PTX/mov.ll (original) +++ llvm/trunk/test/CodeGen/PTX/mov.ll Tue Mar 1 21:20:28 2011 @@ -1,25 +1,62 @@ ; RUN: llc < %s -march=ptx | FileCheck %s -define ptx_device i32 @t1() { -; CHECK: mov.s32 r0, 0; +define ptx_device i16 @t1_u16() { +; CHECK: mov.u16 rh0, 0; +; CHECK: ret; + ret i16 0 +} + +define ptx_device i32 @t1_u32() { +; CHECK: mov.u32 r0, 0; ; CHECK: ret; ret i32 0 } -define ptx_device i32 @t2(i32 %x) { -; CHECK: mov.s32 r0, r1; +define ptx_device i64 @t1_u64() { +; CHECK: mov.u64 rd0, 0; ; CHECK: ret; - ret i32 %x + ret i64 0 } -define ptx_device float @t3() { +define ptx_device float @t1_f32() { ; CHECK: mov.f32 f0, 0F00000000; -; CHECK-NEXT: ret; +; CHECK: ret; ret float 0.0 } -define ptx_device float @t4(float %x) { +define ptx_device double @t1_f64() { +; CHECK: mov.f64 fd0, 0D0000000000000000; +; CHECK: ret; + ret double 0.0 +} + +define ptx_device i16 @t2_u16(i16 %x) { +; CHECK: mov.u16 rh0, rh1; +; CHECK: ret; + ret i16 %x +} + +define ptx_device i32 @t2_u32(i32 %x) { +; CHECK: mov.u32 r0, r1; +; CHECK: ret; + ret i32 %x +} + +define ptx_device i64 @t2_u64(i64 %x) { +; CHECK: mov.u64 rd0, rd1; +; CHECK: ret; + ret i64 %x +} + +define ptx_device float @t3_f32(float %x) { ; CHECK: mov.f32 f0, f1; ; CHECK-NEXT: ret; ret float %x } + +define ptx_device double @t3_f64(double %x) { +; CHECK: mov.f64 fd0, fd1; +; CHECK-NEXT: ret; + ret double %x +} + Modified: llvm/trunk/test/CodeGen/PTX/mul.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/mul.ll?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PTX/mul.ll (original) +++ llvm/trunk/test/CodeGen/PTX/mul.ll Tue Mar 1 21:20:28 2011 @@ -10,16 +10,30 @@ ; ret i32 %z ;} -define ptx_device float @t3(float %x, float %y) { +define ptx_device float @t1_f32(float %x, float %y) { ; CHECK: mul.f32 f0, f1, f2 ; CHECK-NEXT: ret; %z = fmul float %x, %y ret float %z } -define ptx_device float @t4(float %x) { +define ptx_device double @t1_f64(double %x, double %y) { +; CHECK: mul.f64 fd0, fd1, fd2 +; CHECK-NEXT: ret; + %z = fmul double %x, %y + ret double %z +} + +define ptx_device float @t2_f32(float %x) { ; CHECK: mul.f32 f0, f1, 0F40A00000; ; CHECK-NEXT: ret; %z = fmul float %x, 5.0 ret float %z } + +define ptx_device double @t2_f64(double %x) { +; CHECK: mul.f64 fd0, fd1, 0D4014000000000000; +; CHECK-NEXT: ret; + %z = fmul double %x, 5.0 + ret double %z +} Modified: llvm/trunk/test/CodeGen/PTX/options.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/options.ll?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PTX/options.ll (original) +++ llvm/trunk/test/CodeGen/PTX/options.ll Tue Mar 1 21:20:28 2011 @@ -1,5 +1,8 @@ -; RUN: llc < %s -march=ptx -ptx-version=2.0 | grep ".version 2.0" -; RUN: llc < %s -march=ptx -ptx-target=sm_20 | grep ".target sm_20" +; RUN: llc < %s -march=ptx -mattr=ptx14 | grep ".version 1.4" +; RUN: llc < %s -march=ptx -mattr=ptx20 | grep ".version 2.0" +; RUN: llc < %s -march=ptx -mattr=ptx21 | grep ".version 2.1" +; RUN: llc < %s -march=ptx -mattr=sm20 | grep ".target sm_20" +; RUN: llc < %s -march=ptx -mattr=sm13 | grep ".target sm_13" define ptx_device void @t1() { ret void Modified: llvm/trunk/test/CodeGen/PTX/st.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/st.ll?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PTX/st.ll (original) +++ llvm/trunk/test/CodeGen/PTX/st.ll Tue Mar 1 21:20:28 2011 @@ -1,71 +1,382 @@ ; RUN: llc < %s -march=ptx | FileCheck %s -;CHECK: .extern .global .s32 array[]; - at array = external global [10 x i32] +;CHECK: .extern .global .u16 array_i16[]; + at array_i16 = external global [10 x i16] -;CHECK: .extern .const .s32 array_constant[]; - at array_constant = external addrspace(1) constant [10 x i32] +;CHECK: .extern .const .u16 array_constant_i16[]; + at array_constant_i16 = external addrspace(1) constant [10 x i16] -;CHECK: .extern .local .s32 array_local[]; - at array_local = external addrspace(2) global [10 x i32] +;CHECK: .extern .local .u16 array_local_i16[]; + at array_local_i16 = external addrspace(2) global [10 x i16] -;CHECK: .extern .shared .s32 array_shared[]; - at array_shared = external addrspace(4) global [10 x i32] +;CHECK: .extern .shared .u16 array_shared_i16[]; + at array_shared_i16 = external addrspace(4) global [10 x i16] -define ptx_device void @t1(i32* %p, i32 %x) { +;CHECK: .extern .global .u32 array_i32[]; + at array_i32 = external global [10 x i32] + +;CHECK: .extern .const .u32 array_constant_i32[]; + at array_constant_i32 = external addrspace(1) constant [10 x i32] + +;CHECK: .extern .local .u32 array_local_i32[]; + at array_local_i32 = external addrspace(2) global [10 x i32] + +;CHECK: .extern .shared .u32 array_shared_i32[]; + at array_shared_i32 = external addrspace(4) global [10 x i32] + +;CHECK: .extern .global .u64 array_i64[]; + at array_i64 = external global [10 x i64] + +;CHECK: .extern .const .u64 array_constant_i64[]; + at array_constant_i64 = external addrspace(1) constant [10 x i64] + +;CHECK: .extern .local .u64 array_local_i64[]; + at array_local_i64 = external addrspace(2) global [10 x i64] + +;CHECK: .extern .shared .u64 array_shared_i64[]; + at array_shared_i64 = external addrspace(4) global [10 x i64] + +;CHECK: .extern .global .f32 array_float[]; + at array_float = external global [10 x float] + +;CHECK: .extern .const .f32 array_constant_float[]; + at array_constant_float = external addrspace(1) constant [10 x float] + +;CHECK: .extern .local .f32 array_local_float[]; + at array_local_float = external addrspace(2) global [10 x float] + +;CHECK: .extern .shared .f32 array_shared_float[]; + at array_shared_float = external addrspace(4) global [10 x float] + +;CHECK: .extern .global .f64 array_double[]; + at array_double = external global [10 x double] + +;CHECK: .extern .const .f64 array_constant_double[]; + at array_constant_double = external addrspace(1) constant [10 x double] + +;CHECK: .extern .local .f64 array_local_double[]; + at array_local_double = external addrspace(2) global [10 x double] + +;CHECK: .extern .shared .f64 array_shared_double[]; + at array_shared_double = external addrspace(4) global [10 x double] + + +define ptx_device void @t1_u16(i16* %p, i16 %x) { entry: -;CHECK: st.global.s32 [r1], r2; +;CHECK: st.global.u16 [r1], rh1; +;CHECK-NEXT: ret; + store i16 %x, i16* %p + ret void +} + +define ptx_device void @t1_u32(i32* %p, i32 %x) { +entry: +;CHECK: st.global.u32 [r1], r2; +;CHECK-NEXT: ret; store i32 %x, i32* %p ret void } -define ptx_device void @t2(i32* %p, i32 %x) { +define ptx_device void @t1_u64(i64* %p, i64 %x) { +entry: +;CHECK: st.global.u64 [r1], rd1; +;CHECK-NEXT: ret; + store i64 %x, i64* %p + ret void +} + +define ptx_device void @t1_f32(float* %p, float %x) { +entry: +;CHECK: st.global.f32 [r1], f1; +;CHECK-NEXT: ret; + store float %x, float* %p + ret void +} + +define ptx_device void @t1_f64(double* %p, double %x) { +entry: +;CHECK: st.global.f64 [r1], fd1; +;CHECK-NEXT: ret; + store double %x, double* %p + ret void +} + +define ptx_device void @t2_u16(i16* %p, i16 %x) { entry: -;CHECK: st.global.s32 [r1+4], r2; +;CHECK: st.global.u16 [r1+2], rh1; +;CHECK-NEXT: ret; + %i = getelementptr i16* %p, i32 1 + store i16 %x, i16* %i + ret void +} + +define ptx_device void @t2_u32(i32* %p, i32 %x) { +entry: +;CHECK: st.global.u32 [r1+4], r2; +;CHECK-NEXT: ret; %i = getelementptr i32* %p, i32 1 store i32 %x, i32* %i ret void } -define ptx_device void @t3(i32* %p, i32 %q, i32 %x) { -;CHECK: .reg .s32 r0; +define ptx_device void @t2_u64(i64* %p, i64 %x) { +entry: +;CHECK: st.global.u64 [r1+8], rd1; +;CHECK-NEXT: ret; + %i = getelementptr i64* %p, i32 1 + store i64 %x, i64* %i + ret void +} + +define ptx_device void @t2_f32(float* %p, float %x) { +entry: +;CHECK: st.global.f32 [r1+4], f1; +;CHECK-NEXT: ret; + %i = getelementptr float* %p, i32 1 + store float %x, float* %i + ret void +} + +define ptx_device void @t2_f64(double* %p, double %x) { +entry: +;CHECK: st.global.f64 [r1+8], fd1; +;CHECK-NEXT: ret; + %i = getelementptr double* %p, i32 1 + store double %x, double* %i + ret void +} + +define ptx_device void @t3_u16(i16* %p, i32 %q, i16 %x) { +entry: +;CHECK: shl.b32 r0, r2, 1; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: st.global.u16 [r0], rh1; +;CHECK-NEXT: ret; + %i = getelementptr i16* %p, i32 %q + store i16 %x, i16* %i + ret void +} + +define ptx_device void @t3_u32(i32* %p, i32 %q, i32 %x) { entry: ;CHECK: shl.b32 r0, r2, 2; -;CHECK: add.s32 r0, r1, r0; -;CHECK: st.global.s32 [r0], r3; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: st.global.u32 [r0], r3; +;CHECK-NEXT: ret; %i = getelementptr i32* %p, i32 %q store i32 %x, i32* %i ret void } -define ptx_device void @t4_global(i32 %x) { +define ptx_device void @t3_u64(i64* %p, i32 %q, i64 %x) { +entry: +;CHECK: shl.b32 r0, r2, 3; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: st.global.u64 [r0], rd1; +;CHECK-NEXT: ret; + %i = getelementptr i64* %p, i32 %q + store i64 %x, i64* %i + ret void +} + +define ptx_device void @t3_f32(float* %p, i32 %q, float %x) { +entry: +;CHECK: shl.b32 r0, r2, 2; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: st.global.f32 [r0], f1; +;CHECK-NEXT: ret; + %i = getelementptr float* %p, i32 %q + store float %x, float* %i + ret void +} + +define ptx_device void @t3_f64(double* %p, i32 %q, double %x) { +entry: +;CHECK: shl.b32 r0, r2, 3; +;CHECK-NEXT: add.u32 r0, r1, r0; +;CHECK-NEXT: st.global.f64 [r0], fd1; +;CHECK-NEXT: ret; + %i = getelementptr double* %p, i32 %q + store double %x, double* %i + ret void +} + +define ptx_device void @t4_global_u16(i16 %x) { +entry: +;CHECK: st.global.u16 [array_i16], rh1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16]* @array_i16, i16 0, i16 0 + store i16 %x, i16* %i + ret void +} + +define ptx_device void @t4_global_u32(i32 %x) { entry: -;CHECK: st.global.s32 [array], r1; - %i = getelementptr [10 x i32]* @array, i32 0, i32 0 +;CHECK: st.global.u32 [array_i32], r1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32]* @array_i32, i32 0, i32 0 store i32 %x, i32* %i ret void } -define ptx_device void @t4_local(i32 %x) { +define ptx_device void @t4_global_u64(i64 %x) { +entry: +;CHECK: st.global.u64 [array_i64], rd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64]* @array_i64, i32 0, i32 0 + store i64 %x, i64* %i + ret void +} + +define ptx_device void @t4_global_f32(float %x) { +entry: +;CHECK: st.global.f32 [array_float], f1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float]* @array_float, i32 0, i32 0 + store float %x, float* %i + ret void +} + +define ptx_device void @t4_global_f64(double %x) { +entry: +;CHECK: st.global.f64 [array_double], fd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double]* @array_double, i32 0, i32 0 + store double %x, double* %i + ret void +} + +define ptx_device void @t4_local_u16(i16 %x) { entry: -;CHECK: st.local.s32 [array_local], r1; - %i = getelementptr [10 x i32] addrspace(2)* @array_local, i32 0, i32 0 +;CHECK: st.local.u16 [array_local_i16], rh1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16] addrspace(2)* @array_local_i16, i32 0, i32 0 + store i16 %x, i16 addrspace(2)* %i + ret void +} + +define ptx_device void @t4_local_u32(i32 %x) { +entry: +;CHECK: st.local.u32 [array_local_i32], r1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32] addrspace(2)* @array_local_i32, i32 0, i32 0 store i32 %x, i32 addrspace(2)* %i ret void } -define ptx_device void @t4_shared(i32 %x) { +define ptx_device void @t4_local_u64(i64 %x) { +entry: +;CHECK: st.local.u64 [array_local_i64], rd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64] addrspace(2)* @array_local_i64, i32 0, i32 0 + store i64 %x, i64 addrspace(2)* %i + ret void +} + +define ptx_device void @t4_local_f32(float %x) { +entry: +;CHECK: st.local.f32 [array_local_float], f1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float] addrspace(2)* @array_local_float, i32 0, i32 0 + store float %x, float addrspace(2)* %i + ret void +} + +define ptx_device void @t4_local_f64(double %x) { +entry: +;CHECK: st.local.f64 [array_local_double], fd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double] addrspace(2)* @array_local_double, i32 0, i32 0 + store double %x, double addrspace(2)* %i + ret void +} + +define ptx_device void @t4_shared_u16(i16 %x) { entry: -;CHECK: st.shared.s32 [array_shared], r1; - %i = getelementptr [10 x i32] addrspace(4)* @array_shared, i32 0, i32 0 +;CHECK: st.shared.u16 [array_shared_i16], rh1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16] addrspace(4)* @array_shared_i16, i32 0, i32 0 + store i16 %x, i16 addrspace(4)* %i + ret void +} + +define ptx_device void @t4_shared_u32(i32 %x) { +entry: +;CHECK: st.shared.u32 [array_shared_i32], r1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32] addrspace(4)* @array_shared_i32, i32 0, i32 0 store i32 %x, i32 addrspace(4)* %i ret void } -define ptx_device void @t5(i32 %x) { +define ptx_device void @t4_shared_u64(i64 %x) { +entry: +;CHECK: st.shared.u64 [array_shared_i64], rd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64] addrspace(4)* @array_shared_i64, i32 0, i32 0 + store i64 %x, i64 addrspace(4)* %i + ret void +} + +define ptx_device void @t4_shared_f32(float %x) { +entry: +;CHECK: st.shared.f32 [array_shared_float], f1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float] addrspace(4)* @array_shared_float, i32 0, i32 0 + store float %x, float addrspace(4)* %i + ret void +} + +define ptx_device void @t4_shared_f64(double %x) { +entry: +;CHECK: st.shared.f64 [array_shared_double], fd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double] addrspace(4)* @array_shared_double, i32 0, i32 0 + store double %x, double addrspace(4)* %i + ret void +} + +define ptx_device void @t5_u16(i16 %x) { entry: -;CHECK: st.global.s32 [array+4], r1; - %i = getelementptr [10 x i32]* @array, i32 0, i32 1 +;CHECK: st.global.u16 [array_i16+2], rh1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i16]* @array_i16, i32 0, i32 1 + store i16 %x, i16* %i + ret void +} + +define ptx_device void @t5_u32(i32 %x) { +entry: +;CHECK: st.global.u32 [array_i32+4], r1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i32]* @array_i32, i32 0, i32 1 store i32 %x, i32* %i ret void } + +define ptx_device void @t5_u64(i64 %x) { +entry: +;CHECK: st.global.u64 [array_i64+8], rd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x i64]* @array_i64, i32 0, i32 1 + store i64 %x, i64* %i + ret void +} + +define ptx_device void @t5_f32(float %x) { +entry: +;CHECK: st.global.f32 [array_float+4], f1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x float]* @array_float, i32 0, i32 1 + store float %x, float* %i + ret void +} + +define ptx_device void @t5_f64(double %x) { +entry: +;CHECK: st.global.f64 [array_double+8], fd1; +;CHECK-NEXT: ret; + %i = getelementptr [10 x double]* @array_double, i32 0, i32 1 + store double %x, double* %i + ret void +} Removed: llvm/trunk/test/CodeGen/PTX/st_float.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/st_float.ll?rev=126823&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PTX/st_float.ll (original) +++ llvm/trunk/test/CodeGen/PTX/st_float.ll (removed) @@ -1,78 +0,0 @@ -; RUN: llc < %s -march=ptx | FileCheck %s - -;CHECK: .extern .global .f32 array[]; - at array = external global [10 x float] - -;CHECK: .extern .const .f32 array_constant[]; - at array_constant = external addrspace(1) constant [10 x float] - -;CHECK: .extern .local .f32 array_local[]; - at array_local = external addrspace(2) global [10 x float] - -;CHECK: .extern .shared .f32 array_shared[]; - at array_shared = external addrspace(4) global [10 x float] - -define ptx_device void @t1(float* %p, float %x) { -entry: -;CHECK: st.global.f32 [r1], f1; -;CHECK-NEXT: ret; - store float %x, float* %p - ret void -} - -define ptx_device void @t2(float* %p, float %x) { -entry: -;CHECK: st.global.f32 [r1+4], f1; -;CHECK-NEXT: ret; - %i = getelementptr float* %p, i32 1 - store float %x, float* %i - ret void -} - -define ptx_device void @t3(float* %p, i32 %q, float %x) { -;CHECK: .reg .s32 r0; -entry: -;CHECK: shl.b32 r0, r2, 2; -;CHECK-NEXT: add.s32 r0, r1, r0; -;CHECK-NEXT: st.global.f32 [r0], f1; -;CHECK-NEXT: ret; - %i = getelementptr float* %p, i32 %q - store float %x, float* %i - ret void -} - -define ptx_device void @t4_global(float %x) { -entry: -;CHECK: st.global.f32 [array], f1; -;CHECK-NEXT: ret; - %i = getelementptr [10 x float]* @array, i32 0, i32 0 - store float %x, float* %i - ret void -} - -define ptx_device void @t4_local(float %x) { -entry: -;CHECK: st.local.f32 [array_local], f1; -;CHECK-NEXT: ret; - %i = getelementptr [10 x float] addrspace(2)* @array_local, i32 0, i32 0 - store float %x, float addrspace(2)* %i - ret void -} - -define ptx_device void @t4_shared(float %x) { -entry: -;CHECK: st.shared.f32 [array_shared], f1; -;CHECK-NEXT: ret; - %i = getelementptr [10 x float] addrspace(4)* @array_shared, i32 0, i32 0 - store float %x, float addrspace(4)* %i - ret void -} - -define ptx_device void @t5(float %x) { -entry: -;CHECK: st.global.f32 [array+4], f1; -;CHECK-NEXT: ret; - %i = getelementptr [10 x float]* @array, i32 0, i32 1 - store float %x, float* %i - ret void -} Modified: llvm/trunk/test/CodeGen/PTX/sub.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/sub.ll?rev=126824&r1=126823&r2=126824&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PTX/sub.ll (original) +++ llvm/trunk/test/CodeGen/PTX/sub.ll Tue Mar 1 21:20:28 2011 @@ -1,29 +1,71 @@ ; RUN: llc < %s -march=ptx | FileCheck %s -define ptx_device i32 @t1(i32 %x, i32 %y) { -;CHECK: sub.s32 r0, r1, r2; +define ptx_device i16 @t1_u16(i16 %x, i16 %y) { +; CHECK: sub.u16 rh0, rh1, rh2; +; CHECK-NEXT: ret; + %z = sub i16 %x, %y + ret i16 %z +} + +define ptx_device i32 @t1_u32(i32 %x, i32 %y) { +; CHECK: sub.u32 r0, r1, r2; +; CHECK-NEXT: ret; %z = sub i32 %x, %y -;CHECK: ret; ret i32 %z } -define ptx_device i32 @t2(i32 %x) { -;CHECK: add.s32 r0, r1, -1; - %z = sub i32 %x, 1 -;CHECK: ret; - ret i32 %z +define ptx_device i64 @t1_u64(i64 %x, i64 %y) { +; CHECK: sub.u64 rd0, rd1, rd2; +; CHECK-NEXT: ret; + %z = sub i64 %x, %y + ret i64 %z } -define ptx_device float @t3(float %x, float %y) { +define ptx_device float @t1_f32(float %x, float %y) { ; CHECK: sub.f32 f0, f1, f2 ; CHECK-NEXT: ret; %z = fsub float %x, %y ret float %z } -define ptx_device float @t4(float %x) { +define ptx_device double @t1_f64(double %x, double %y) { +; CHECK: sub.f64 fd0, fd1, fd2 +; CHECK-NEXT: ret; + %z = fsub double %x, %y + ret double %z +} + +define ptx_device i16 @t2_u16(i16 %x) { +; CHECK: add.u16 rh0, rh1, -1; +; CHECK-NEXT: ret; + %z = sub i16 %x, 1 + ret i16 %z +} + +define ptx_device i32 @t2_u32(i32 %x) { +; CHECK: add.u32 r0, r1, -1; +; CHECK-NEXT: ret; + %z = sub i32 %x, 1 + ret i32 %z +} + +define ptx_device i64 @t2_u64(i64 %x) { +; CHECK: add.u64 rd0, rd1, -1; +; CHECK-NEXT: ret; + %z = sub i64 %x, 1 + ret i64 %z +} + +define ptx_device float @t2_f32(float %x) { ; CHECK: add.f32 f0, f1, 0FBF800000; ; CHECK-NEXT: ret; %z = fsub float %x, 1.0 ret float %z } + +define ptx_device double @t2_f64(double %x) { +; CHECK: add.f64 fd0, fd1, 0DBFF0000000000000; +; CHECK-NEXT: ret; + %z = fsub double %x, 1.0 + ret double %z +} From rafael.espindola at gmail.com Tue Mar 1 21:25:18 2011 From: rafael.espindola at gmail.com (=?ISO-8859-1?Q?Rafael_=C1vila_de_Esp=EDndola?=) Date: Tue, 01 Mar 2011 22:25:18 -0500 Subject: [llvm-commits] [patch][lto] Use MC to scan for symbol definitions and uses In-Reply-To: <4D6BEF5F.7030903@gmail.com> References: <4D692112.5030707@gmail.com> <4D6BEF5F.7030903@gmail.com> Message-ID: <4D6DB89E.9050705@gmail.com> On 2011-02-28 13:54, Rafael Avila de Espindola wrote: > I have updated the patch to also create llvm.compiler.used with the uses > it finds in inline assembly. This lets me build Firefox without moving > the assembly to a .s file *or* adding __attribute__((used)) :-) I incremented the patch a bit more. It now *) Creates llvm.compiler.used, so that it is not necessary for the user to add __attribute__((used)). *) Handles IL uses that map to local asm definitions *) Correctly mask symbols as defined (sets the section) An unexpected but really nice benefit of this is that I can link firefox with LTO on Darwin :-) I am now confident that this is a strict superset of the previous heuristic. Is it OK for 2.9? Cheers, Rafael -------------- next part -------------- A non-text attachment was scrubbed... Name: asm-use.patch Type: text/x-patch Size: 23289 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110301/8a3aecb3/attachment-0001.bin From clchiou at gmail.com Tue Mar 1 21:27:15 2011 From: clchiou at gmail.com (Che-Liang Chiou) Date: Wed, 2 Mar 2011 11:27:15 +0800 Subject: [llvm-commits] [PATCH] Extend initial support for primitive types in PTX backend In-Reply-To: References: Message-ID: Hi Justin, I fixed lint warnings and committed your patch in revision 126824. Thanks for the patch. Regards, Che-Liang On Tue, Mar 1, 2011 at 4:52 AM, Justin Holewinski wrote: > The following patch provides support for i16, i64, and double types within > the PTX backend, in addition to the already-supported i32 and float data > types. ?No new instructions are supported; ?instead, this patch provides > much of the infrastructure needed to support basic operations on all > primitive types, not just the basic i32 and float types. > Note: ?the kernel parameter PTX generator still assumes 32-bit addresses for > pointer types. ?This will be fixed in a following patch. > > -- > > Thanks, > Justin Holewinski > From Erik.Olofsson at hansoft.se Tue Mar 1 21:11:40 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Wed, 2 Mar 2011 04:11:40 +0100 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: <97510B8DF78E714D91EB4A27850A17DA0C3EACBADF@winserv02.hansoft.local> References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> <87bp1uz8fx.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC9@winserv02.hansoft.local> <877hciz69f.fsf@wanadoo.es> <8739n6z4el.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBADF@winserv02.hansoft.local> Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAE0@winserv02.hansoft.local> > > -----Original Message----- > > From: ?scar Fuentes [mailto:ofv at wanadoo.es] > > > > if( MSVC_IDE ) > > set(LLVM_COMPILER_JOBS "0" CACHE STRING > > "Number of parallel compiler jobs. 0 means use all processors. Default is > > 0.") > > if( NOT LLVM_COMPILER_JOBS STREQUAL "1" ) > > if( LLVM_COMPILER_JOBS STREQUAL "0" ) > > add_llvm_definitions( /MP ) > > else > > add_llvm_definitions( /MP${LLVM_COMPILER_JOBS} ) > > endif() > > endif() > > Yes, this is even better. Turns out that due to a bug in CMake you can't actually specify /MPx. When generating for Visual Studio 2010 /MP2 will just set the msbuild MultiProcessorCompilation property to true. It does work correctly for Visual Studio 2008 though, so I just report an error if you try to set anything but 0 or 1 for VS2010. New patch attached including documentation. Regards, Erik -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: llvm-msvc-multi-processor-compilation.patch.txt Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/97958141/attachment.txt From zwarich at apple.com Tue Mar 1 21:31:46 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Wed, 02 Mar 2011 03:31:46 -0000 Subject: [llvm-commits] [llvm] r126825 - in /llvm/trunk: lib/Transforms/Scalar/CodeGenPrepare.cpp test/CodeGen/ARM/code-placement.ll test/CodeGen/X86/2010-09-30-CMOV-JumpTable-PHI.ll Message-ID: <20110302033146.4A3232A6C12C@llvm.org> Author: zwarich Date: Tue Mar 1 21:31:46 2011 New Revision: 126825 URL: http://llvm.org/viewvc/llvm-project?rev=126825&view=rev Log: Eliminate the unused CodeGenPrepare option to split critical edges. Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp llvm/trunk/test/CodeGen/ARM/code-placement.ll llvm/trunk/test/CodeGen/X86/2010-09-30-CMOV-JumpTable-PHI.ll Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=126825&r1=126824&r2=126825&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Tue Mar 1 21:31:46 2011 @@ -58,11 +58,6 @@ STATISTIC(NumExtsMoved, "Number of [s|z]ext instructions combined with loads"); STATISTIC(NumExtUses, "Number of uses of [s|z]ext instructions optimized"); -static cl::opt -CriticalEdgeSplit("cgp-critical-edge-splitting", - cl::desc("Split critical edges during codegen prepare"), - cl::init(false), cl::Hidden); - namespace { class CodeGenPrepare : public FunctionPass { /// TLI - Keep a pointer of a TargetLowering to consult for determining @@ -144,11 +139,6 @@ // unconditional branch. EverMadeChange |= EliminateMostlyEmptyBlocks(F); - // Now find loop back edges, but only if they are being used to decide which - // critical edges to split. - if (CriticalEdgeSplit) - findLoopBackEdges(F); - bool MadeChange = true; while (MadeChange) { MadeChange = false; @@ -350,110 +340,6 @@ DEBUG(dbgs() << "AFTER:\n" << *DestBB << "\n\n\n"); } -/// FindReusablePredBB - Check all of the predecessors of the block DestPHI -/// lives in to see if there is a block that we can reuse as a critical edge -/// from TIBB. -static BasicBlock *FindReusablePredBB(PHINode *DestPHI, BasicBlock *TIBB) { - BasicBlock *Dest = DestPHI->getParent(); - - /// TIPHIValues - This array is lazily computed to determine the values of - /// PHIs in Dest that TI would provide. - SmallVector TIPHIValues; - - /// TIBBEntryNo - This is a cache to speed up pred queries for TIBB. - unsigned TIBBEntryNo = 0; - - // Check to see if Dest has any blocks that can be used as a split edge for - // this terminator. - for (unsigned pi = 0, e = DestPHI->getNumIncomingValues(); pi != e; ++pi) { - BasicBlock *Pred = DestPHI->getIncomingBlock(pi); - // To be usable, the pred has to end with an uncond branch to the dest. - BranchInst *PredBr = dyn_cast(Pred->getTerminator()); - if (!PredBr || !PredBr->isUnconditional()) - continue; - // Must be empty other than the branch and debug info. - BasicBlock::iterator I = Pred->begin(); - while (isa(I)) - I++; - if (&*I != PredBr) - continue; - // Cannot be the entry block; its label does not get emitted. - if (Pred == &Dest->getParent()->getEntryBlock()) - continue; - - // Finally, since we know that Dest has phi nodes in it, we have to make - // sure that jumping to Pred will have the same effect as going to Dest in - // terms of PHI values. - PHINode *PN; - unsigned PHINo = 0; - unsigned PredEntryNo = pi; - - bool FoundMatch = true; - for (BasicBlock::iterator I = Dest->begin(); - (PN = dyn_cast(I)); ++I, ++PHINo) { - if (PHINo == TIPHIValues.size()) { - if (PN->getIncomingBlock(TIBBEntryNo) != TIBB) - TIBBEntryNo = PN->getBasicBlockIndex(TIBB); - TIPHIValues.push_back(PN->getIncomingValue(TIBBEntryNo)); - } - - // If the PHI entry doesn't work, we can't use this pred. - if (PN->getIncomingBlock(PredEntryNo) != Pred) - PredEntryNo = PN->getBasicBlockIndex(Pred); - - if (TIPHIValues[PHINo] != PN->getIncomingValue(PredEntryNo)) { - FoundMatch = false; - break; - } - } - - // If we found a workable predecessor, change TI to branch to Succ. - if (FoundMatch) - return Pred; - } - return 0; -} - - -/// SplitEdgeNicely - Split the critical edge from TI to its specified -/// successor if it will improve codegen. We only do this if the successor has -/// phi nodes (otherwise critical edges are ok). If there is already another -/// predecessor of the succ that is empty (and thus has no phi nodes), use it -/// instead of introducing a new block. -static void SplitEdgeNicely(TerminatorInst *TI, unsigned SuccNum, - SmallSet, 8> &BackEdges, - Pass *P) { - BasicBlock *TIBB = TI->getParent(); - BasicBlock *Dest = TI->getSuccessor(SuccNum); - assert(isa(Dest->begin()) && - "This should only be called if Dest has a PHI!"); - PHINode *DestPHI = cast(Dest->begin()); - - // Do not split edges to EH landing pads. - if (InvokeInst *Invoke = dyn_cast(TI)) - if (Invoke->getSuccessor(1) == Dest) - return; - - // As a hack, never split backedges of loops. Even though the copy for any - // PHIs inserted on the backedge would be dead for exits from the loop, we - // assume that the cost of *splitting* the backedge would be too high. - if (BackEdges.count(std::make_pair(TIBB, Dest))) - return; - - if (BasicBlock *ReuseBB = FindReusablePredBB(DestPHI, TIBB)) { - ProfileInfo *PFI = P->getAnalysisIfAvailable(); - if (PFI) - PFI->splitEdge(TIBB, Dest, ReuseBB); - Dest->removePredecessor(TIBB); - TI->setSuccessor(SuccNum, ReuseBB); - return; - } - - SplitCriticalEdge(TI, SuccNum, P, true); -} - - /// OptimizeNoopCopyExpression - If the specified cast instruction is a noop /// copy (e.g. it's casting from one pointer type to another, i32->i8 on PPC), /// sink it into user blocks to reduce the number of virtual @@ -1081,21 +967,8 @@ // across basic blocks and rewrite them to improve basic-block-at-a-time // selection. bool CodeGenPrepare::OptimizeBlock(BasicBlock &BB) { - bool MadeChange = false; - - // Split all critical edges where the dest block has a PHI. - if (CriticalEdgeSplit) { - TerminatorInst *BBTI = BB.getTerminator(); - if (BBTI->getNumSuccessors() > 1 && !isa(BBTI)) { - for (unsigned i = 0, e = BBTI->getNumSuccessors(); i != e; ++i) { - BasicBlock *SuccBB = BBTI->getSuccessor(i); - if (isa(SuccBB->begin()) && isCriticalEdge(BBTI, i, true)) - SplitEdgeNicely(BBTI, i, BackEdges, this); - } - } - } - SunkAddrs.clear(); + bool MadeChange = false; CurInstIterator = BB.begin(); for (BasicBlock::iterator E = BB.end(); CurInstIterator != E; ) Modified: llvm/trunk/test/CodeGen/ARM/code-placement.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/code-placement.ll?rev=126825&r1=126824&r2=126825&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/code-placement.ll (original) +++ llvm/trunk/test/CodeGen/ARM/code-placement.ll Tue Mar 1 21:31:46 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=armv7-apple-darwin -cgp-critical-edge-splitting=0 | FileCheck %s +; RUN: llc < %s -mtriple=armv7-apple-darwin | FileCheck %s ; PHI elimination shouldn't break backedge. ; rdar://8263994 Modified: llvm/trunk/test/CodeGen/X86/2010-09-30-CMOV-JumpTable-PHI.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-09-30-CMOV-JumpTable-PHI.ll?rev=126825&r1=126824&r2=126825&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-09-30-CMOV-JumpTable-PHI.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-09-30-CMOV-JumpTable-PHI.ll Tue Mar 1 21:31:46 2011 @@ -1,4 +1,4 @@ -; RUN: llc -verify-machineinstrs -cgp-critical-edge-splitting=0 -mcpu=i386 < %s +; RUN: llc -verify-machineinstrs -mcpu=i386 < %s target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32" target triple = "i386-pc-linux-gnu" From Erik.Olofsson at hansoft.se Tue Mar 1 21:36:42 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Wed, 2 Mar 2011 04:36:42 +0100 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: <87y64yxlig.fsf@wanadoo.es> References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> <87bp1uz8fx.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC9@winserv02.hansoft.local> <877hciz69f.fsf@wanadoo.es> <8739n6z4el.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBADF@winserv02.hansoft.local> <87y64yxlig.fsf@wanadoo.es> Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAE1@winserv02.hansoft.local> > -----Original Message----- > From: ?scar Fuentes [mailto:ofv at wanadoo.es] > > > Yes, this is even better. Would you like that code in > > HandleLLVMOptions.cmake or CMakeLists.txt or both with option > > definition split from logic? > > Put everything in HandleLLVMOptions.cmake, so it can be used when Clang > is built using LLVM as an external library. Sorry, I just sent a patch that was split before I saw your message, please ignore it. A patch for only HandleLLVMOptions.cmake attached. > Certainly, there are superfluous tblgen dependencies, but accurately > determining them is tricky. About the dependencies between libraries, > there are some among LLVM targets and its subsidiaries (e.g. LLVMX86 and > LLVMX86AsmParser) and sometimes a dependency is declared from a library > into another when, actually, it should be on its tablegenned products (e.g. > LLVMX86 depending on LLVMTarget). In general, those cases can be easily > fixed, although I've seen cases of linker errors on Linux due to missing > vtables while linking the LLVM tools. If you know more instances of > unnecessary inter-library dependencies, please mention them. Actually LLVM looks pretty good, it's clang that has more dependencies. For example clangParse has a dependecy on clangLex. > Parallel builds work fine on Linux with make -jN, there is little room to > improve, but it seems that tablegenning on Windows is slow (in release > mode, if you are building on debug mode it can take a very long time. I > thought about always building tblgen.exe on release mode for avoiding > such excruciating build times.) I was building in Debug mode so tblgen in Release mode would probably help a lot, but one tblgen project includes to several tblgen, this gives room for improvement on msbuild where they are all run sequentially in each project. Regards, Erik -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: llvm-msvc-multi-processor-compilation.patch.txt Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/ec81a6a3/attachment.txt From zwarich at apple.com Tue Mar 1 21:48:30 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Wed, 02 Mar 2011 03:48:30 -0000 Subject: [llvm-commits] [llvm] r126826 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Message-ID: <20110302034830.1FEB32A6C12C@llvm.org> Author: zwarich Date: Tue Mar 1 21:48:29 2011 New Revision: 126826 URL: http://llvm.org/viewvc/llvm-project?rev=126826&view=rev Log: Remove some more unused code that I missed. Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=126826&r1=126825&r2=126826&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Tue Mar 1 21:48:29 2011 @@ -71,10 +71,6 @@ /// update it. BasicBlock::iterator CurInstIterator; - /// BackEdges - Keep a set of all the loop back edges. - /// - SmallSet, 8> BackEdges; - // Keeps track of non-local addresses that have been sunk into a block. This // allows us to avoid inserting duplicate code for blocks with multiple // load/stores of the same address. @@ -93,10 +89,6 @@ AU.addPreserved(); } - virtual void releaseMemory() { - BackEdges.clear(); - } - private: bool EliminateMostlyEmptyBlocks(Function &F); bool CanMergeBlocks(const BasicBlock *BB, const BasicBlock *DestBB) const; @@ -108,7 +100,6 @@ bool OptimizeCallInst(CallInst *CI); bool MoveExtToFormExtLoad(Instruction *I); bool OptimizeExtUses(Instruction *I); - void findLoopBackEdges(const Function &F); }; } @@ -120,16 +111,6 @@ return new CodeGenPrepare(TLI); } -/// findLoopBackEdges - Do a DFS walk to find loop back edges. -/// -void CodeGenPrepare::findLoopBackEdges(const Function &F) { - SmallVector, 32> Edges; - FindFunctionBackedges(F, Edges); - - BackEdges.insert(Edges.begin(), Edges.end()); -} - - bool CodeGenPrepare::runOnFunction(Function &F) { bool EverMadeChange = false; From rjmccall at apple.com Tue Mar 1 22:00:52 2011 From: rjmccall at apple.com (John McCall) Date: Wed, 02 Mar 2011 04:00:52 -0000 Subject: [llvm-commits] [llvm] r126827 - /llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp Message-ID: <20110302040053.0159B2A6C12C@llvm.org> Author: rjmccall Date: Tue Mar 1 22:00:52 2011 New Revision: 126827 URL: http://llvm.org/viewvc/llvm-project?rev=126827&view=rev Log: Teach the clang attribute emitter about InheritableParamAttr. Intended to be atomic with clang r126828. Modified: llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp Modified: llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=126827&r1=126826&r2=126827&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp Tue Mar 1 22:00:52 2011 @@ -589,23 +589,37 @@ OS << "#define LAST_INHERITABLE_ATTR(NAME) INHERITABLE_ATTR(NAME)\n"; OS << "#endif\n\n"; + OS << "#ifndef INHERITABLE_PARAM_ATTR\n"; + OS << "#define INHERITABLE_PARAM_ATTR(NAME) ATTR(NAME)\n"; + OS << "#endif\n\n"; + + OS << "#ifndef LAST_INHERITABLE_PARAM_ATTR\n"; + OS << "#define LAST_INHERITABLE_PARAM_ATTR(NAME)" + " INHERITABLE_PARAM_ATTR(NAME)\n"; + OS << "#endif\n\n"; + Record *InhClass = Records.getClass("InheritableAttr"); + Record *InhParamClass = Records.getClass("InheritableParamAttr"); std::vector Attrs = Records.getAllDerivedDefinitions("Attr"), - NonInhAttrs, InhAttrs; + NonInhAttrs, InhAttrs, InhParamAttrs; for (std::vector::iterator i = Attrs.begin(), e = Attrs.end(); i != e; ++i) { - if ((*i)->isSubClassOf(InhClass)) + if ((*i)->isSubClassOf(InhParamClass)) + InhParamAttrs.push_back(*i); + else if ((*i)->isSubClassOf(InhClass)) InhAttrs.push_back(*i); else NonInhAttrs.push_back(*i); } + EmitAttrList(OS, "INHERITABLE_PARAM_ATTR", InhParamAttrs); EmitAttrList(OS, "INHERITABLE_ATTR", InhAttrs); EmitAttrList(OS, "ATTR", NonInhAttrs); OS << "#undef LAST_ATTR\n"; OS << "#undef INHERITABLE_ATTR\n"; OS << "#undef LAST_INHERITABLE_ATTR\n"; + OS << "#undef LAST_INHERITABLE_PARAM_ATTR\n"; OS << "#undef ATTR\n"; } From Erik.Olofsson at hansoft.se Tue Mar 1 22:05:40 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Wed, 2 Mar 2011 05:05:40 +0100 Subject: [llvm-commits] [PATCH] Add support for OutputDebugString to raw_ostream and add support for virtualized out/err streams Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAE2@winserv02.hansoft.local> Adds support for OutputDebugString to raw_ostream as well as one object to access a virtualized errs and outs. This is needed for subsequent patches in clang so you can redirect errs and outs to OutputDebugString. The rationale for needing this is that debugging from Visual Studio will not allow you to capture stdout and stderr into its Output window but OutputDebugString is captured there. This change (in clang...) will also be useful if you want to redirect compiler output you can just create your own raw_output_streams and pass to the compiler functions. Together with MSVC style diagnostics this really helps in clang development where you can get from diagnostics directly to the code in question when debugging. Please review and submit if good. Regards, Erik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/34fbf90c/attachment.html -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: llvm-outputdebugstring-support.patch.txt Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/34fbf90c/attachment.txt From zwarich at apple.com Tue Mar 1 22:03:46 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Wed, 02 Mar 2011 04:03:46 -0000 Subject: [llvm-commits] [llvm] r126829 - /llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Message-ID: <20110302040346.F2E9C2A6C12C@llvm.org> Author: zwarich Date: Tue Mar 1 22:03:46 2011 New Revision: 126829 URL: http://llvm.org/viewvc/llvm-project?rev=126829&view=rev Log: Fix some typos. Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp?rev=126829&r1=126828&r2=126829&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp (original) +++ llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Tue Mar 1 22:03:46 2011 @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// This file implements the pass that optimize code placement and align loop -// headers to target specific alignment boundary. +// This file implements the pass that optimizes code placement and aligns loop +// headers to target-specific alignment boundaries. // //===----------------------------------------------------------------------===// @@ -40,7 +40,7 @@ virtual bool runOnMachineFunction(MachineFunction &MF); virtual const char *getPassName() const { - return "Code Placement Optimizater"; + return "Code Placement Optimizer"; } virtual void getAnalysisUsage(AnalysisUsage &AU) const { From rafael.espindola at gmail.com Tue Mar 1 22:14:42 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Wed, 02 Mar 2011 04:14:42 -0000 Subject: [llvm-commits] [llvm] r126830 - in /llvm/trunk: include/llvm/Module.h lib/AsmParser/LLParser.cpp lib/VMCore/AsmWriter.cpp tools/lto/LTOCodeGenerator.cpp tools/lto/LTOCodeGenerator.h tools/lto/LTOModule.cpp tools/lto/LTOModule.h Message-ID: <20110302041442.9E0712A6C12C@llvm.org> Author: rafael Date: Tue Mar 1 22:14:42 2011 New Revision: 126830 URL: http://llvm.org/viewvc/llvm-project?rev=126830&view=rev Log: Add a special streamer to libLTO that just records symbols definitions and uses. The result produced by the streamer is used to give the linker more accurate information and to add to llvm.compiler.used. The second improvement removes the need for the user to add __attribute__((used)) to functions only used in inline asm. The first one lets us build firefox with LTO on Darwin :-) Modified: llvm/trunk/include/llvm/Module.h llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/VMCore/AsmWriter.cpp llvm/trunk/tools/lto/LTOCodeGenerator.cpp llvm/trunk/tools/lto/LTOCodeGenerator.h llvm/trunk/tools/lto/LTOModule.cpp llvm/trunk/tools/lto/LTOModule.h Modified: llvm/trunk/include/llvm/Module.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Module.h?rev=126830&r1=126829&r2=126830&view=diff ============================================================================== --- llvm/trunk/include/llvm/Module.h (original) +++ llvm/trunk/include/llvm/Module.h Tue Mar 1 22:14:42 2011 @@ -211,15 +211,20 @@ void setTargetTriple(StringRef T) { TargetTriple = T; } /// Set the module-scope inline assembly blocks. - void setModuleInlineAsm(StringRef Asm) { GlobalScopeAsm = Asm; } + void setModuleInlineAsm(StringRef Asm) { + GlobalScopeAsm = Asm; + if (!GlobalScopeAsm.empty() && + GlobalScopeAsm[GlobalScopeAsm.size()-1] != '\n') + GlobalScopeAsm += '\n'; + } /// Append to the module-scope inline assembly blocks, automatically inserting /// a separating newline if necessary. void appendModuleInlineAsm(StringRef Asm) { + GlobalScopeAsm += Asm; if (!GlobalScopeAsm.empty() && GlobalScopeAsm[GlobalScopeAsm.size()-1] != '\n') GlobalScopeAsm += '\n'; - GlobalScopeAsm += Asm; } /// @} Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=126830&r1=126829&r2=126830&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Mar 1 22:14:42 2011 @@ -249,11 +249,7 @@ if (ParseToken(lltok::kw_asm, "expected 'module asm'") || ParseStringConstant(AsmStr)) return true; - const std::string &AsmSoFar = M->getModuleInlineAsm(); - if (AsmSoFar.empty()) - M->setModuleInlineAsm(AsmStr); - else - M->setModuleInlineAsm(AsmSoFar+"\n"+AsmStr); + M->appendModuleInlineAsm(AsmStr); return false; } Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=126830&r1=126829&r2=126830&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Tue Mar 1 22:14:42 2011 @@ -1338,9 +1338,12 @@ CurPos = NewLine+1; NewLine = Asm.find_first_of('\n', CurPos); } - Out << "module asm \""; - PrintEscapedString(std::string(Asm.begin()+CurPos, Asm.end()), Out); - Out << "\"\n"; + std::string rest(Asm.begin()+CurPos, Asm.end()); + if (!rest.empty()) { + Out << "module asm \""; + PrintEscapedString(rest, Out); + Out << "\"\n"; + } } // Loop over the dependent libraries and emit them. Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=126830&r1=126829&r2=126830&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Tue Mar 1 22:14:42 2011 @@ -75,7 +75,6 @@ { InitializeAllTargets(); InitializeAllAsmPrinters(); - InitializeAllAsmParsers(); } LTOCodeGenerator::~LTOCodeGenerator() @@ -88,7 +87,13 @@ bool LTOCodeGenerator::addModule(LTOModule* mod, std::string& errMsg) { - return _linker.LinkInModule(mod->getLLVVMModule(), &errMsg); + bool ret = _linker.LinkInModule(mod->getLLVVMModule(), &errMsg); + + const std::vector &undefs = mod->getAsmUndefinedRefs(); + for (int i = 0, e = undefs.size(); i != e; ++i) + _asmUndefinedRefs[undefs[i]] = 1; + + return ret; } @@ -249,6 +254,34 @@ return false; } +void LTOCodeGenerator::applyRestriction(GlobalValue &GV, + std::vector &mustPreserveList, + SmallPtrSet &asmUsed, + Mangler &mangler) { + SmallString<64> Buffer; + mangler.getNameWithPrefix(Buffer, &GV, false); + + if (GV.isDeclaration()) + return; + if (_mustPreserveSymbols.count(Buffer)) + mustPreserveList.push_back(GV.getName().data()); + if (_asmUndefinedRefs.count(Buffer)) + asmUsed.insert(&GV); +} + +static void findUsedValues(GlobalVariable *LLVMUsed, + SmallPtrSet &UsedValues) { + if (LLVMUsed == 0) return; + + ConstantArray *Inits = dyn_cast(LLVMUsed->getInitializer()); + if (Inits == 0) return; + + for (unsigned i = 0, e = Inits->getNumOperands(); i != e; ++i) + if (GlobalValue *GV = + dyn_cast(Inits->getOperand(i)->stripPointerCasts())) + UsedValues.insert(GV); +} + void LTOCodeGenerator::applyScopeRestrictions() { if (_scopeRestrictionsDone) return; Module *mergedModule = _linker.getModule(); @@ -258,38 +291,47 @@ passes.add(createVerifierPass()); // mark which symbols can not be internalized - if (!_mustPreserveSymbols.empty()) { - MCContext Context(*_target->getMCAsmInfo(), NULL); - Mangler mangler(Context, *_target->getTargetData()); - std::vector mustPreserveList; - SmallString<64> Buffer; - for (Module::iterator f = mergedModule->begin(), - e = mergedModule->end(); f != e; ++f) { - Buffer.clear(); - mangler.getNameWithPrefix(Buffer, f, false); - if (!f->isDeclaration() && - _mustPreserveSymbols.count(Buffer)) - mustPreserveList.push_back(f->getName().data()); - } - for (Module::global_iterator v = mergedModule->global_begin(), - e = mergedModule->global_end(); v != e; ++v) { - Buffer.clear(); - mangler.getNameWithPrefix(Buffer, v, false); - if (!v->isDeclaration() && - _mustPreserveSymbols.count(Buffer)) - mustPreserveList.push_back(v->getName().data()); - } - for (Module::alias_iterator a = mergedModule->alias_begin(), - e = mergedModule->alias_end(); a != e; ++a) { - Buffer.clear(); - mangler.getNameWithPrefix(Buffer, a, false); - if (!a->isDeclaration() && - _mustPreserveSymbols.count(Buffer)) - mustPreserveList.push_back(a->getName().data()); - } - passes.add(createInternalizePass(mustPreserveList)); + MCContext Context(*_target->getMCAsmInfo(), NULL); + Mangler mangler(Context, *_target->getTargetData()); + std::vector mustPreserveList; + SmallPtrSet asmUsed; + + for (Module::iterator f = mergedModule->begin(), + e = mergedModule->end(); f != e; ++f) + applyRestriction(*f, mustPreserveList, asmUsed, mangler); + for (Module::global_iterator v = mergedModule->global_begin(), + e = mergedModule->global_end(); v != e; ++v) + applyRestriction(*v, mustPreserveList, asmUsed, mangler); + for (Module::alias_iterator a = mergedModule->alias_begin(), + e = mergedModule->alias_end(); a != e; ++a) + applyRestriction(*a, mustPreserveList, asmUsed, mangler); + + GlobalVariable *LLVMCompilerUsed = + mergedModule->getGlobalVariable("llvm.compiler.used"); + findUsedValues(LLVMCompilerUsed, asmUsed); + if (LLVMCompilerUsed) + LLVMCompilerUsed->eraseFromParent(); + + const llvm::Type *i8PTy = llvm::Type::getInt8PtrTy(_context); + std::vector asmUsed2; + for (SmallPtrSet::const_iterator i = asmUsed.begin(), + e = asmUsed.end(); i !=e; ++i) { + GlobalValue *GV = *i; + Constant *c = ConstantExpr::getBitCast(GV, i8PTy); + asmUsed2.push_back(c); } - + + llvm::ArrayType *ATy = llvm::ArrayType::get(i8PTy, asmUsed2.size()); + LLVMCompilerUsed = + new llvm::GlobalVariable(*mergedModule, ATy, false, + llvm::GlobalValue::AppendingLinkage, + llvm::ConstantArray::get(ATy, asmUsed2), + "llvm.compiler.used"); + + LLVMCompilerUsed->setSection("llvm.metadata"); + + passes.add(createInternalizePass(mustPreserveList)); + // apply scope restrictions passes.run(*mergedModule); Modified: llvm/trunk/tools/lto/LTOCodeGenerator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.h?rev=126830&r1=126829&r2=126830&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.h (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.h Tue Mar 1 22:14:42 2011 @@ -19,6 +19,7 @@ #include "llvm/LLVMContext.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/SmallPtrSet.h" #include @@ -46,6 +47,10 @@ bool generateObjectFile(llvm::raw_ostream& out, std::string& errMsg); void applyScopeRestrictions(); + void applyRestriction(llvm::GlobalValue &GV, + std::vector &mustPreserveList, + llvm::SmallPtrSet &asmUsed, + llvm::Mangler &mangler); bool determineTarget(std::string& errMsg); typedef llvm::StringMap StringSet; @@ -57,6 +62,7 @@ bool _scopeRestrictionsDone; lto_codegen_model _codeModel; StringSet _mustPreserveSymbols; + StringSet _asmUndefinedRefs; llvm::MemoryBuffer* _nativeObjectFile; std::vector _codegenOptions; std::string _mCpu; Modified: llvm/trunk/tools/lto/LTOModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=126830&r1=126829&r2=126830&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOModule.cpp (original) +++ llvm/trunk/tools/lto/LTOModule.cpp Tue Mar 1 22:14:42 2011 @@ -26,11 +26,18 @@ #include "llvm/Support/Host.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" +#include "llvm/Support/SourceMgr.h" #include "llvm/Support/system_error.h" #include "llvm/Target/Mangler.h" #include "llvm/Target/SubtargetFeature.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" +#include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCInst.h" +#include "llvm/MC/MCParser/MCAsmParser.h" +#include "llvm/MC/MCStreamer.h" +#include "llvm/MC/MCSymbol.h" +#include "llvm/Target/TargetAsmParser.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetSelect.h" @@ -73,7 +80,7 @@ LTOModule::LTOModule(Module *m, TargetMachine *t) - : _module(m), _target(t), _symbolsParsed(false) + : _module(m), _target(t) { } @@ -123,7 +130,12 @@ LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer, std::string &errMsg) { - InitializeAllTargets(); + static bool Initialized = false; + if (!Initialized) { + InitializeAllTargets(); + InitializeAllAsmParsers(); + Initialized = true; + } // parse bitcode buffer OwningPtr m(ParseBitcodeFile(buffer, getGlobalContext(), &errMsg)); @@ -144,7 +156,13 @@ Features.getDefaultSubtargetFeatures("" /* cpu */, llvm::Triple(Triple)); std::string FeatureStr = Features.getString(); TargetMachine *target = march->createTargetMachine(Triple, FeatureStr); - return new LTOModule(m.take(), target); + LTOModule *Ret = new LTOModule(m.take(), target); + bool Err = Ret->ParseSymbols(); + if (Err) { + delete Ret; + return NULL; + } + return Ret; } @@ -383,7 +401,8 @@ _symbols.push_back(info); } -void LTOModule::addAsmGlobalSymbol(const char *name) { +void LTOModule::addAsmGlobalSymbol(const char *name, + lto_symbol_attributes scope) { StringSet::value_type &entry = _defines.GetOrCreateValue(name); // only add new define if not already defined @@ -393,13 +412,32 @@ entry.setValue(1); const char *symbolName = entry.getKey().data(); uint32_t attr = LTO_SYMBOL_DEFINITION_REGULAR; - attr |= LTO_SYMBOL_SCOPE_DEFAULT; + attr |= scope; NameAndAttributes info; info.name = symbolName; info.attributes = (lto_symbol_attributes)attr; _symbols.push_back(info); } +void LTOModule::addAsmGlobalSymbolUndef(const char *name) { + StringMap::value_type &entry = + _undefines.GetOrCreateValue(name); + + _asm_undefines.push_back(entry.getKey().data()); + + // we already have the symbol + if (entry.getValue().name) + return; + + uint32_t attr = LTO_SYMBOL_DEFINITION_UNDEFINED;; + attr |= LTO_SYMBOL_SCOPE_DEFAULT; + NameAndAttributes info; + info.name = entry.getKey().data(); + info.attributes = (lto_symbol_attributes)attr; + + entry.setValue(info); +} + void LTOModule::addPotentialUndefinedSymbol(GlobalValue *decl, Mangler &mangler) { // ignore all llvm.* symbols @@ -454,12 +492,194 @@ } } -void LTOModule::lazyParseSymbols() { - if (_symbolsParsed) - return; +namespace { + class RecordStreamer : public MCStreamer { + public: + enum State { NeverSeen, Global, Defined, DefinedGlobal, Used}; + + private: + StringMap Symbols; + + void markDefined(const MCSymbol &Symbol) { + State &S = Symbols[Symbol.getName()]; + switch (S) { + case DefinedGlobal: + case Global: + S = DefinedGlobal; + break; + case NeverSeen: + case Defined: + case Used: + S = Defined; + break; + } + } + void markGlobal(const MCSymbol &Symbol) { + State &S = Symbols[Symbol.getName()]; + switch (S) { + case DefinedGlobal: + case Defined: + S = DefinedGlobal; + break; + + case NeverSeen: + case Global: + case Used: + S = Global; + break; + } + } + void markUsed(const MCSymbol &Symbol) { + State &S = Symbols[Symbol.getName()]; + switch (S) { + case DefinedGlobal: + case Defined: + case Global: + break; + + case NeverSeen: + case Used: + S = Used; + break; + } + } - _symbolsParsed = true; + // FIXME: mostly copied for the obj streamer. + void AddValueSymbols(const MCExpr *Value) { + switch (Value->getKind()) { + case MCExpr::Target: + // FIXME: What should we do in here? + break; + + case MCExpr::Constant: + break; + + case MCExpr::Binary: { + const MCBinaryExpr *BE = cast(Value); + AddValueSymbols(BE->getLHS()); + AddValueSymbols(BE->getRHS()); + break; + } + case MCExpr::SymbolRef: + markUsed(cast(Value)->getSymbol()); + break; + + case MCExpr::Unary: + AddValueSymbols(cast(Value)->getSubExpr()); + break; + } + } + + public: + typedef StringMap::const_iterator const_iterator; + + const_iterator begin() { + return Symbols.begin(); + } + + const_iterator end() { + return Symbols.end(); + } + + RecordStreamer(MCContext &Context) : MCStreamer(Context) {} + + virtual void ChangeSection(const MCSection *Section) {} + virtual void InitSections() {} + virtual void EmitLabel(MCSymbol *Symbol) { + Symbol->setSection(*getCurrentSection()); + markDefined(*Symbol); + } + virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) {} + virtual void EmitThumbFunc(MCSymbol *Func) {} + virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) { + // FIXME: should we handle aliases? + markDefined(*Symbol); + } + virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) { + if (Attribute == MCSA_Global) + markGlobal(*Symbol); + } + virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {} + virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {} + virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) {} + virtual void EmitCOFFSymbolStorageClass(int StorageClass) {} + virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol, + unsigned Size , unsigned ByteAlignment) { + markDefined(*Symbol); + } + virtual void EmitCOFFSymbolType(int Type) {} + virtual void EndCOFFSymbolDef() {} + virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, + unsigned ByteAlignment) { + markDefined(*Symbol); + } + virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {} + virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) {} + virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, + uint64_t Size, unsigned ByteAlignment) {} + virtual void EmitBytes(StringRef Data, unsigned AddrSpace) {} + virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, + bool isPCRel, unsigned AddrSpace) {} + virtual void EmitULEB128Value(const MCExpr *Value, + unsigned AddrSpace = 0) {} + virtual void EmitSLEB128Value(const MCExpr *Value, + unsigned AddrSpace = 0) {} + virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value, + unsigned ValueSize, + unsigned MaxBytesToEmit) {} + virtual void EmitCodeAlignment(unsigned ByteAlignment, + unsigned MaxBytesToEmit) {} + virtual void EmitValueToOffset(const MCExpr *Offset, + unsigned char Value ) {} + virtual void EmitFileDirective(StringRef Filename) {} + virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta, + const MCSymbol *LastLabel, + const MCSymbol *Label) {} + + virtual void EmitInstruction(const MCInst &Inst) { + // Scan for values. + for (unsigned i = Inst.getNumOperands(); i--; ) + if (Inst.getOperand(i).isExpr()) + AddValueSymbols(Inst.getOperand(i).getExpr()); + } + virtual void Finish() {} + }; +} + +bool LTOModule::addAsmGlobalSymbols(MCContext &Context) { + const std::string &inlineAsm = _module->getModuleInlineAsm(); + + OwningPtr Streamer(new RecordStreamer(Context)); + MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(inlineAsm); + SourceMgr SrcMgr; + SrcMgr.AddNewSourceBuffer(Buffer, SMLoc()); + OwningPtr Parser(createMCAsmParser(_target->getTarget(), SrcMgr, + Context, *Streamer, + *_target->getMCAsmInfo())); + OwningPtr + TAP(_target->getTarget().createAsmParser(*Parser.get(), *_target.get())); + Parser->setTargetParser(*TAP); + int Res = Parser->Run(false); + if (Res) + return true; + + for (RecordStreamer::const_iterator i = Streamer->begin(), + e = Streamer->end(); i != e; ++i) { + StringRef Key = i->first(); + RecordStreamer::State Value = i->second; + if (Value == RecordStreamer::DefinedGlobal) + addAsmGlobalSymbol(Key.data(), LTO_SYMBOL_SCOPE_DEFAULT); + else if (Value == RecordStreamer::Defined) + addAsmGlobalSymbol(Key.data(), LTO_SYMBOL_SCOPE_INTERNAL); + else if (Value == RecordStreamer::Global || + Value == RecordStreamer::Used) + addAsmGlobalSymbolUndef(Key.data()); + } + return false; +} + +bool LTOModule::ParseSymbols() { // Use mangler to add GlobalPrefix to names to match linker names. MCContext Context(*_target->getMCAsmInfo(), NULL); Mangler mangler(Context, *_target->getTargetData()); @@ -482,30 +702,8 @@ } // add asm globals - const std::string &inlineAsm = _module->getModuleInlineAsm(); - const std::string glbl = ".globl"; - std::string asmSymbolName; - std::string::size_type pos = inlineAsm.find(glbl, 0); - while (pos != std::string::npos) { - // eat .globl - pos = pos + 6; - - // skip white space between .globl and symbol name - std::string::size_type pbegin = inlineAsm.find_first_not_of(' ', pos); - if (pbegin == std::string::npos) - break; - - // find end-of-line - std::string::size_type pend = inlineAsm.find_first_of('\n', pbegin); - if (pend == std::string::npos) - break; - - asmSymbolName.assign(inlineAsm, pbegin, pend - pbegin); - addAsmGlobalSymbol(asmSymbolName.c_str()); - - // search next .globl - pos = inlineAsm.find(glbl, pend); - } + if (addAsmGlobalSymbols(Context)) + return true; // add aliases for (Module::alias_iterator i = _module->alias_begin(), @@ -526,17 +724,16 @@ _symbols.push_back(info); } } + return false; } uint32_t LTOModule::getSymbolCount() { - lazyParseSymbols(); return _symbols.size(); } lto_symbol_attributes LTOModule::getSymbolAttributes(uint32_t index) { - lazyParseSymbols(); if (index < _symbols.size()) return _symbols[index].attributes; else @@ -544,7 +741,6 @@ } const char *LTOModule::getSymbolName(uint32_t index) { - lazyParseSymbols(); if (index < _symbols.size()) return _symbols[index].name; else Modified: llvm/trunk/tools/lto/LTOModule.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.h?rev=126830&r1=126829&r2=126830&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOModule.h (original) +++ llvm/trunk/tools/lto/LTOModule.h Tue Mar 1 22:14:42 2011 @@ -64,11 +64,14 @@ const char* getSymbolName(uint32_t index); llvm::Module * getLLVVMModule() { return _module.get(); } + const std::vector &getAsmUndefinedRefs() { + return _asm_undefines; + } private: LTOModule(llvm::Module* m, llvm::TargetMachine* t); - void lazyParseSymbols(); + bool ParseSymbols(); void addDefinedSymbol(llvm::GlobalValue* def, llvm::Mangler& mangler, bool isFunction); @@ -80,7 +83,10 @@ llvm::Mangler &mangler); void addDefinedDataSymbol(llvm::GlobalValue* v, llvm::Mangler &mangler); - void addAsmGlobalSymbol(const char *); + bool addAsmGlobalSymbols(llvm::MCContext &Context); + void addAsmGlobalSymbol(const char *, + lto_symbol_attributes scope); + void addAsmGlobalSymbolUndef(const char *); void addObjCClass(llvm::GlobalVariable* clgv); void addObjCCategory(llvm::GlobalVariable* clgv); void addObjCClassRef(llvm::GlobalVariable* clgv); @@ -103,11 +109,11 @@ llvm::OwningPtr _module; llvm::OwningPtr _target; - bool _symbolsParsed; std::vector _symbols; // _defines and _undefines only needed to disambiguate tentative definitions StringSet _defines; llvm::StringMap _undefines; + std::vector _asm_undefines; }; #endif // LTO_MODULE_H From pichet2000 at gmail.com Tue Mar 1 22:41:08 2011 From: pichet2000 at gmail.com (Francois Pichet) Date: Tue, 1 Mar 2011 23:41:08 -0500 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAE1@winserv02.hansoft.local> References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> <87bp1uz8fx.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC9@winserv02.hansoft.local> <877hciz69f.fsf@wanadoo.es> <8739n6z4el.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBADF@winserv02.hansoft.local> <87y64yxlig.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAE1@winserv02.hansoft.local> Message-ID: On Tue, Mar 1, 2011 at 10:36 PM, Erik Olofsson wrote: >> -----Original Message----- >> From: ?scar Fuentes [mailto:ofv at wanadoo.es] >> >> > Yes, this is even better. Would you like that code in >> > HandleLLVMOptions.cmake or CMakeLists.txt or both with option >> > definition split from logic? >> >> Put everything in HandleLLVMOptions.cmake, so it can be used when Clang >> is built using LLVM as an external library. > > Sorry, I just sent a patch that was split before I saw your message, please ignore it. A patch for only HandleLLVMOptions.cmake attached. > >> Certainly, there are superfluous tblgen dependencies, but accurately >> determining them is tricky. About the dependencies between libraries, >> there are some among LLVM targets and its subsidiaries (e.g. LLVMX86 and >> LLVMX86AsmParser) and sometimes a dependency is declared from a library >> into another when, actually, it should be on its tablegenned products (e.g. >> LLVMX86 depending on LLVMTarget). In general, those cases can be easily >> fixed, although I've seen cases of linker errors on Linux due to missing >> vtables while linking the LLVM tools. If you know more instances of >> unnecessary inter-library dependencies, please mention them. > > Actually LLVM looks pretty good, it's clang that has more dependencies. For example clangParse has a dependecy on clangLex. > >> Parallel builds work fine on Linux with make -jN, there is little room to >> improve, but it seems that tablegenning on Windows is slow (in release >> mode, if you are building on debug mode it can take a very long time. I >> thought about always building tblgen.exe on release mode for avoiding >> such excruciating build times.) > > I was building in Debug mode so tblgen in Release mode would probably help a lot, but one tblgen project includes to several tblgen, this gives room for improvement on msbuild where they are all run sequentially in each project. > > Regards, > Erik hi Using MSVC 2010 and quadcore. Complete build (release) trunk: 14 mins 45 secs Complete build (release) trunk + patch: 14mins 40 secs It is within the margin of error here. so to me this patch doesn't speed things up. Builds are already multi-processor on a per project basis. From aggarwa4 at illinois.edu Wed Mar 2 00:04:54 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 02 Mar 2011 06:04:54 -0000 Subject: [llvm-commits] [poolalloc] r126831 - /poolalloc/trunk/lib/DSA/StdLibPass.cpp Message-ID: <20110302060454.197722A6C12C@llvm.org> Author: aggarwa4 Date: Wed Mar 2 00:04:53 2011 New Revision: 126831 URL: http://llvm.org/viewvc/llvm-project?rev=126831&view=rev Log: Added support for a few C++ operators. Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/StdLibPass.cpp?rev=126831&r1=126830&r2=126831&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original) +++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Wed Mar 2 00:04:53 2011 @@ -267,10 +267,22 @@ {"_Znwm", {NRET_NARGS, YRET_NARGS, YRET_NARGS, NRET_NARGS, false}}, // operator new[](unsigned long) {"_Znam", {NRET_NARGS, YRET_NARGS, YRET_NARGS, NRET_NARGS, false}}, + // operator new(unsigned int) + {"_Znwj", {NRET_NARGS, YRET_NARGS, YRET_NARGS, NRET_NARGS, false}}, + // operator new[](unsigned int) + {"_Znaj", {NRET_NARGS, YRET_NARGS, YRET_NARGS, NRET_NARGS, false}}, // operator delete(void*) {"_ZdlPv", {NRET_NARGS, NRET_NARGS, NRET_YNARGS,NRET_NARGS, false}}, // operator delete[](void*) {"_ZdaPv", {NRET_NARGS, NRET_NARGS, NRET_YNARGS, NRET_NARGS, false}}, + // flush + {"_ZNSo5flushEv", {NRET_NARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + // << operator + {"_ZNSolsEd", {NRET_YARGS, NRET_YNARGS, NRET_NARGS, NRET_NARGS, false}}, + // << operator + {"_ZNSolsEPFRSoS_E", {NRET_YARGS, NRET_YNARGS, NRET_NARGS, NRET_NARGS, false}}, + //endl + {"_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_", {NRET_NARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, // Terminate the list of special functions recognized by this pass {0, {NRET_NARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, }; From aggarwa4 at illinois.edu Wed Mar 2 00:24:12 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 02 Mar 2011 06:24:12 -0000 Subject: [llvm-commits] [poolalloc] r126832 - in /poolalloc/trunk/test/dsa/callgraph: scc.ll scc1.ll Message-ID: <20110302062413.05FC72A6C12C@llvm.org> Author: aggarwa4 Date: Wed Mar 2 00:24:12 2011 New Revision: 126832 URL: http://llvm.org/viewvc/llvm-project?rev=126832&view=rev Log: Fix signature of B. Modified: poolalloc/trunk/test/dsa/callgraph/scc.ll poolalloc/trunk/test/dsa/callgraph/scc1.ll Modified: poolalloc/trunk/test/dsa/callgraph/scc.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/callgraph/scc.ll?rev=126832&r1=126831&r2=126832&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/callgraph/scc.ll (original) +++ poolalloc/trunk/test/dsa/callgraph/scc.ll Wed Mar 2 00:24:12 2011 @@ -6,7 +6,7 @@ define void @A() nounwind { entry: - call void (...)* bitcast (void ()* @B to void (...)*)() nounwind + call void @B () nounwind br label %return return: ; preds = %entry @@ -22,20 +22,3 @@ ret void } -define void @D() nounwind { -entry: - call void (...)* bitcast (void ()* @C to void (...)*)() nounwind - br label %return - -return: ; preds = %entry - ret void -} - -define void @C() nounwind { -entry: - call void @D() nounwind - br label %return - -return: ; preds = %entry - ret void -} Modified: poolalloc/trunk/test/dsa/callgraph/scc1.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/callgraph/scc1.ll?rev=126832&r1=126831&r2=126832&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/callgraph/scc1.ll (original) +++ poolalloc/trunk/test/dsa/callgraph/scc1.ll Wed Mar 2 00:24:12 2011 @@ -6,7 +6,7 @@ define internal void @A() nounwind { entry: - call void (...)* bitcast (void ()* @B to void (...)*)() nounwind + call void @B() nounwind br label %return return: ; preds = %entry From aggarwa4 at illinois.edu Wed Mar 2 00:38:09 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 02 Mar 2011 06:38:09 -0000 Subject: [llvm-commits] [poolalloc] r126833 - /poolalloc/trunk/lib/DSA/AddressTakenAnalysis.cpp Message-ID: <20110302063809.D07F62A6C12C@llvm.org> Author: aggarwa4 Date: Wed Mar 2 00:38:09 2011 New Revision: 126833 URL: http://llvm.org/viewvc/llvm-project?rev=126833&view=rev Log: Call Inst, may have no uses. But we still want to consider the case where a funtion is passed as argument. Modified: poolalloc/trunk/lib/DSA/AddressTakenAnalysis.cpp Modified: poolalloc/trunk/lib/DSA/AddressTakenAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/AddressTakenAnalysis.cpp?rev=126833&r1=126832&r2=126833&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/AddressTakenAnalysis.cpp (original) +++ poolalloc/trunk/lib/DSA/AddressTakenAnalysis.cpp Wed Mar 2 00:38:09 2011 @@ -41,8 +41,6 @@ User *U = *I; if(isa(U)) return true; - if(U->use_empty()) - continue; if (!isa(U) && !isa(U)) { if(isa(U)) { if(isAddressTaken(U)) @@ -51,7 +49,7 @@ if (Constant *C = dyn_cast(U)) { if (ConstantExpr *CE = dyn_cast(C)) { if (CE->getOpcode() == Instruction::BitCast) { - return isAddressTaken(CE); + return isAddressTaken(CE); } } } From clchiou at gmail.com Wed Mar 2 01:36:48 2011 From: clchiou at gmail.com (Che-Liang Chiou) Date: Wed, 02 Mar 2011 07:36:48 -0000 Subject: [llvm-commits] [llvm] r126837 - in /llvm/trunk/lib/Target/PTX: PTX.td PTXAsmPrinter.cpp PTXISelDAGToDAG.cpp PTXInstrInfo.td PTXMachineFunctionInfo.h PTXSubtarget.cpp PTXSubtarget.h PTXTargetMachine.cpp PTXTargetMachine.h Message-ID: <20110302073648.ED6C02A6C12C@llvm.org> Author: clchiou Date: Wed Mar 2 01:36:48 2011 New Revision: 126837 URL: http://llvm.org/viewvc/llvm-project?rev=126837&view=rev Log: Add 64-bit addressing to PTX backend - Add '64bit' sub-target option. - Select 32-bit/64-bit loads/stores based on '64bit' option. - Fix function parameter order. Patch by Justin Holewinski Modified: llvm/trunk/lib/Target/PTX/PTX.td llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp llvm/trunk/lib/Target/PTX/PTXInstrInfo.td llvm/trunk/lib/Target/PTX/PTXMachineFunctionInfo.h llvm/trunk/lib/Target/PTX/PTXSubtarget.cpp llvm/trunk/lib/Target/PTX/PTXSubtarget.h llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp llvm/trunk/lib/Target/PTX/PTXTargetMachine.h Modified: llvm/trunk/lib/Target/PTX/PTX.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTX.td?rev=126837&r1=126836&r2=126837&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTX.td (original) +++ llvm/trunk/lib/Target/PTX/PTX.td Wed Mar 2 01:36:48 2011 @@ -24,6 +24,9 @@ def FeatureDouble : SubtargetFeature<"double", "SupportsDouble", "true", "Do not demote .f64 to .f32">; +def Feature64Bit : SubtargetFeature<"64bit", "Use64BitAddresses", "true", + "Use 64-bit integer types for addresses.">; + //===- PTX Version --------------------------------------------------------===// def FeaturePTX14 : SubtargetFeature<"ptx14", "PTXVersion", "PTX_VERSION_1_4", Modified: llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp?rev=126837&r1=126836&r2=126837&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp Wed Mar 2 01:36:48 2011 @@ -360,20 +360,21 @@ if (isKernel) { unsigned cnt = 0; //for (int i = 0, e = MFI->getNumArg(); i != e; ++i) { - for(PTXMachineFunctionInfo::reg_iterator - i = MFI->argRegBegin(), e = MFI->argRegEnd(), b = i; i != e; ++i) { + for(PTXMachineFunctionInfo::reg_reverse_iterator + i = MFI->argRegReverseBegin(), e = MFI->argRegReverseEnd(), b = i; i != e; ++i) { reg = *i; assert(reg != PTX::NoRegister && "Not a valid register!"); if (i != b) decl += ", "; - decl += ".param .u32"; // TODO: Parse type from register map + decl += ".param ."; + decl += getRegisterTypeName(reg); decl += " "; decl += PARAM_PREFIX; decl += utostr(++cnt); } } else { - for (PTXMachineFunctionInfo::reg_iterator - i = MFI->argRegBegin(), e = MFI->argRegEnd(), b = i; i != e; ++i) { + for (PTXMachineFunctionInfo::reg_reverse_iterator + i = MFI->argRegReverseBegin(), e = MFI->argRegReverseEnd(), b = i; i != e; ++i) { reg = *i; assert(reg != PTX::NoRegister && "Not a valid register!"); if (i != b) Modified: llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp?rev=126837&r1=126836&r2=126837&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp Wed Mar 2 01:36:48 2011 @@ -45,6 +45,8 @@ bool isImm(const SDValue &operand); bool SelectImm(const SDValue &operand, SDValue &imm); + + const PTXSubtarget& getSubtarget() const; }; // class PTXDAGToDAGISel } // namespace @@ -170,3 +172,9 @@ imm = CurDAG->getTargetConstant(*CN->getConstantIntValue(), MVT::i32); return true; } + +const PTXSubtarget& PTXDAGToDAGISel::getSubtarget() const +{ + return TM.getSubtarget(); +} + Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.td?rev=126837&r1=126836&r2=126837&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.td (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Wed Mar 2 01:36:48 2011 @@ -18,6 +18,13 @@ include "PTXInstrFormats.td" //===----------------------------------------------------------------------===// +// Code Generation Predicates +//===----------------------------------------------------------------------===// + +def Use32BitAddresses : Predicate<"!getSubtarget().use64BitAddresses()">; +def Use64BitAddresses : Predicate<"getSubtarget().use64BitAddresses()">; + +//===----------------------------------------------------------------------===// // Instruction Pattern Stuff //===----------------------------------------------------------------------===// @@ -107,24 +114,39 @@ }]>; // Addressing modes. -def ADDRrr : ComplexPattern; -def ADDRri : ComplexPattern; -def ADDRii : ComplexPattern; +def ADDRrr32 : ComplexPattern; +def ADDRrr64 : ComplexPattern; +def ADDRri32 : ComplexPattern; +def ADDRri64 : ComplexPattern; +def ADDRii32 : ComplexPattern; +def ADDRii64 : ComplexPattern; + // Address operands -def MEMri : Operand { +def MEMri32 : Operand { let PrintMethod = "printMemOperand"; let MIOperandInfo = (ops RRegu32, i32imm); } -def MEMii : Operand { +def MEMri64 : Operand { + let PrintMethod = "printMemOperand"; + let MIOperandInfo = (ops RRegu64, i64imm); +} +def MEMii32 : Operand { let PrintMethod = "printMemOperand"; let MIOperandInfo = (ops i32imm, i32imm); } +def MEMii64 : Operand { + let PrintMethod = "printMemOperand"; + let MIOperandInfo = (ops i64imm, i64imm); +} +// The operand here does not correspond to an actual address, so we +// can use i32 in 64-bit address modes. def MEMpi : Operand { let PrintMethod = "printParamOperand"; let MIOperandInfo = (ops i32imm); } + //===----------------------------------------------------------------------===// // PTX Specific Node Definitions //===----------------------------------------------------------------------===// @@ -207,18 +229,30 @@ } multiclass PTX_LD { - def rr : InstPTX<(outs RC:$d), - (ins MEMri:$a), - !strconcat(opstr, !strconcat(typestr, "\t$d, [$a]")), - [(set RC:$d, (pat_load ADDRrr:$a))]>; - def ri : InstPTX<(outs RC:$d), - (ins MEMri:$a), - !strconcat(opstr, !strconcat(typestr, "\t$d, [$a]")), - [(set RC:$d, (pat_load ADDRri:$a))]>; - def ii : InstPTX<(outs RC:$d), - (ins MEMii:$a), - !strconcat(opstr, !strconcat(typestr, "\t$d, [$a]")), - [(set RC:$d, (pat_load ADDRii:$a))]>; + def rr32 : InstPTX<(outs RC:$d), + (ins MEMri32:$a), + !strconcat(opstr, !strconcat(typestr, "\t$d, [$a]")), + [(set RC:$d, (pat_load ADDRrr32:$a))]>, Requires<[Use32BitAddresses]>; + def rr64 : InstPTX<(outs RC:$d), + (ins MEMri64:$a), + !strconcat(opstr, !strconcat(typestr, "\t$d, [$a]")), + [(set RC:$d, (pat_load ADDRrr64:$a))]>, Requires<[Use64BitAddresses]>; + def ri32 : InstPTX<(outs RC:$d), + (ins MEMri32:$a), + !strconcat(opstr, !strconcat(typestr, "\t$d, [$a]")), + [(set RC:$d, (pat_load ADDRri32:$a))]>, Requires<[Use32BitAddresses]>; + def ri64 : InstPTX<(outs RC:$d), + (ins MEMri64:$a), + !strconcat(opstr, !strconcat(typestr, "\t$d, [$a]")), + [(set RC:$d, (pat_load ADDRri64:$a))]>, Requires<[Use64BitAddresses]>; + def ii32 : InstPTX<(outs RC:$d), + (ins MEMii32:$a), + !strconcat(opstr, !strconcat(typestr, "\t$d, [$a]")), + [(set RC:$d, (pat_load ADDRii32:$a))]>, Requires<[Use32BitAddresses]>; + def ii64 : InstPTX<(outs RC:$d), + (ins MEMii64:$a), + !strconcat(opstr, !strconcat(typestr, "\t$d, [$a]")), + [(set RC:$d, (pat_load ADDRii64:$a))]>, Requires<[Use64BitAddresses]>; } multiclass PTX_LD_ALL { @@ -230,18 +264,30 @@ } multiclass PTX_ST { - def rr : InstPTX<(outs), - (ins RC:$d, MEMri:$a), + def rr32 : InstPTX<(outs), + (ins RC:$d, MEMri32:$a), + !strconcat(opstr, !strconcat(typestr, "\t[$a], $d")), + [(pat_store RC:$d, ADDRrr32:$a)]>, Requires<[Use32BitAddresses]>; + def rr64 : InstPTX<(outs), + (ins RC:$d, MEMri64:$a), + !strconcat(opstr, !strconcat(typestr, "\t[$a], $d")), + [(pat_store RC:$d, ADDRrr64:$a)]>, Requires<[Use64BitAddresses]>; + def ri32 : InstPTX<(outs), + (ins RC:$d, MEMri32:$a), + !strconcat(opstr, !strconcat(typestr, "\t[$a], $d")), + [(pat_store RC:$d, ADDRri32:$a)]>, Requires<[Use32BitAddresses]>; + def ri64 : InstPTX<(outs), + (ins RC:$d, MEMri64:$a), !strconcat(opstr, !strconcat(typestr, "\t[$a], $d")), - [(pat_store RC:$d, ADDRrr:$a)]>; - def ri : InstPTX<(outs), - (ins RC:$d, MEMri:$a), + [(pat_store RC:$d, ADDRri64:$a)]>, Requires<[Use64BitAddresses]>; + def ii32 : InstPTX<(outs), + (ins RC:$d, MEMii32:$a), !strconcat(opstr, !strconcat(typestr, "\t[$a], $d")), - [(pat_store RC:$d, ADDRri:$a)]>; - def ii : InstPTX<(outs), - (ins RC:$d, MEMii:$a), + [(pat_store RC:$d, ADDRii32:$a)]>, Requires<[Use32BitAddresses]>; + def ii64 : InstPTX<(outs), + (ins RC:$d, MEMii64:$a), !strconcat(opstr, !strconcat(typestr, "\t[$a], $d")), - [(pat_store RC:$d, ADDRii:$a)]>; + [(pat_store RC:$d, ADDRii64:$a)]>, Requires<[Use64BitAddresses]>; } multiclass PTX_ST_ALL { Modified: llvm/trunk/lib/Target/PTX/PTXMachineFunctionInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXMachineFunctionInfo.h?rev=126837&r1=126836&r2=126837&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXMachineFunctionInfo.h (original) +++ llvm/trunk/lib/Target/PTX/PTXMachineFunctionInfo.h Wed Mar 2 01:36:48 2011 @@ -53,14 +53,17 @@ bool isKernel() const { return is_kernel; } - typedef std::vector::const_iterator reg_iterator; + typedef std::vector::const_iterator reg_iterator; + typedef std::vector::const_reverse_iterator reg_reverse_iterator; - bool argRegEmpty() const { return reg_arg.empty(); } - int getNumArg() const { return reg_arg.size(); } + bool argRegEmpty() const { return reg_arg.empty(); } + int getNumArg() const { return reg_arg.size(); } reg_iterator argRegBegin() const { return reg_arg.begin(); } reg_iterator argRegEnd() const { return reg_arg.end(); } + reg_reverse_iterator argRegReverseBegin() const { return reg_arg.rbegin(); } + reg_reverse_iterator argRegReverseEnd() const { return reg_arg.rend(); } - bool localVarRegEmpty() const { return reg_local_var.empty(); } + bool localVarRegEmpty() const { return reg_local_var.empty(); } reg_iterator localVarRegBegin() const { return reg_local_var.begin(); } reg_iterator localVarRegEnd() const { return reg_local_var.end(); } Modified: llvm/trunk/lib/Target/PTX/PTXSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXSubtarget.cpp?rev=126837&r1=126836&r2=126837&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXSubtarget.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXSubtarget.cpp Wed Mar 2 01:36:48 2011 @@ -18,7 +18,9 @@ PTXSubtarget::PTXSubtarget(const std::string &TT, const std::string &FS) : PTXShaderModel(PTX_SM_1_0), - PTXVersion(PTX_VERSION_1_4) { + PTXVersion(PTX_VERSION_1_4), + SupportsDouble(false), + Use64BitAddresses(false) { std::string TARGET = "generic"; ParseSubtargetFeatures(FS, TARGET); } Modified: llvm/trunk/lib/Target/PTX/PTXSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXSubtarget.h?rev=126837&r1=126836&r2=126837&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXSubtarget.h (original) +++ llvm/trunk/lib/Target/PTX/PTXSubtarget.h Wed Mar 2 01:36:48 2011 @@ -40,6 +40,9 @@ // The native .f64 type is supported on the hardware. bool SupportsDouble; + // Use .u64 instead of .u32 for addresses. + bool Use64BitAddresses; + public: PTXSubtarget(const std::string &TT, const std::string &FS); @@ -49,6 +52,8 @@ bool supportsDouble() const { return SupportsDouble; } + bool use64BitAddresses() const { return Use64BitAddresses; } + std::string ParseSubtargetFeatures(const std::string &FS, const std::string &CPU); }; // class PTXSubtarget Modified: llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp?rev=126837&r1=126836&r2=126837&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp Wed Mar 2 01:36:48 2011 @@ -16,6 +16,7 @@ #include "PTXTargetMachine.h" #include "llvm/PassManager.h" #include "llvm/Target/TargetRegistry.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -34,16 +35,24 @@ TargetRegistry::RegisterAsmStreamer(ThePTXTarget, createPTXAsmStreamer); } +namespace { + const char* DataLayout32 = "e-p:32:32-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64"; + const char* DataLayout64 = "e-p:64:64-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64"; +} + // DataLayout and FrameLowering are filled with dummy data PTXTargetMachine::PTXTargetMachine(const Target &T, const std::string &TT, const std::string &FS) - : LLVMTargetMachine(T, TT), - DataLayout("e-p:32:32-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64"), + : Subtarget(TT, FS), + // FIXME: This feels like a dirty hack, but Subtarget does not appear to be + // initialized at this point, and we need to finish initialization of + // DataLayout. + DataLayout((FS.find("64bit") != FS.npos) ? DataLayout64 : DataLayout32), + LLVMTargetMachine(T, TT), FrameLowering(Subtarget), - InstrInfo(*this), TLInfo(*this), - Subtarget(TT, FS) { + InstrInfo(*this) { } bool PTXTargetMachine::addInstSelector(PassManagerBase &PM, Modified: llvm/trunk/lib/Target/PTX/PTXTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXTargetMachine.h?rev=126837&r1=126836&r2=126837&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXTargetMachine.h (original) +++ llvm/trunk/lib/Target/PTX/PTXTargetMachine.h Wed Mar 2 01:36:48 2011 @@ -25,11 +25,11 @@ namespace llvm { class PTXTargetMachine : public LLVMTargetMachine { private: - const TargetData DataLayout; - PTXFrameLowering FrameLowering; - PTXInstrInfo InstrInfo; + const TargetData DataLayout; + PTXFrameLowering FrameLowering; + PTXInstrInfo InstrInfo; PTXTargetLowering TLInfo; - PTXSubtarget Subtarget; + PTXSubtarget Subtarget; public: PTXTargetMachine(const Target &T, const std::string &TT, From clchiou at gmail.com Wed Mar 2 01:41:45 2011 From: clchiou at gmail.com (Che-Liang Chiou) Date: Wed, 2 Mar 2011 15:41:45 +0800 Subject: [llvm-commits] [PATCH] Add 64-bit addressing to PTX backend In-Reply-To: References: Message-ID: Hi Justin, Committed in revision 126837. Thanks for the patch. Regards, Che-Liang On Tue, Mar 1, 2011 at 10:53 PM, Justin Holewinski wrote: > This patch adds a new sub-target option to the PTX backend: ?64bit. > When this option is enabled, the generated PTX code will use a 64-bit > pointer size, instead of the default 32-bit pointer size. > This patch also fixes an issue with the function parameter ordering in PTX > code. > (NOTE: ?This patch requires the previous PTX backend patch I submitted > yesterday to be applied.) > > -- > > Thanks, > Justin Holewinski > From clchiou at gmail.com Wed Mar 2 01:58:46 2011 From: clchiou at gmail.com (Che-Liang Chiou) Date: Wed, 02 Mar 2011 07:58:46 -0000 Subject: [llvm-commits] [llvm] r126838 - in /llvm/trunk/lib/Target/PTX: PTXAsmPrinter.cpp PTXTargetMachine.cpp PTXTargetMachine.h Message-ID: <20110302075846.902562A6C12C@llvm.org> Author: clchiou Date: Wed Mar 2 01:58:46 2011 New Revision: 126838 URL: http://llvm.org/viewvc/llvm-project?rev=126838&view=rev Log: ptx: fix lint and compiler warnings Modified: llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp llvm/trunk/lib/Target/PTX/PTXTargetMachine.h Modified: llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp?rev=126838&r1=126837&r2=126838&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp Wed Mar 2 01:58:46 2011 @@ -361,7 +361,8 @@ unsigned cnt = 0; //for (int i = 0, e = MFI->getNumArg(); i != e; ++i) { for(PTXMachineFunctionInfo::reg_reverse_iterator - i = MFI->argRegReverseBegin(), e = MFI->argRegReverseEnd(), b = i; i != e; ++i) { + i = MFI->argRegReverseBegin(), e = MFI->argRegReverseEnd(), b = i; + i != e; ++i) { reg = *i; assert(reg != PTX::NoRegister && "Not a valid register!"); if (i != b) @@ -374,7 +375,8 @@ } } else { for (PTXMachineFunctionInfo::reg_reverse_iterator - i = MFI->argRegReverseBegin(), e = MFI->argRegReverseEnd(), b = i; i != e; ++i) { + i = MFI->argRegReverseBegin(), e = MFI->argRegReverseEnd(), b = i; + i != e; ++i) { reg = *i; assert(reg != PTX::NoRegister && "Not a valid register!"); if (i != b) Modified: llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp?rev=126838&r1=126837&r2=126838&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp Wed Mar 2 01:58:46 2011 @@ -36,23 +36,25 @@ } namespace { - const char* DataLayout32 = "e-p:32:32-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64"; - const char* DataLayout64 = "e-p:64:64-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64"; + const char* DataLayout32 = + "e-p:32:32-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64"; + const char* DataLayout64 = + "e-p:64:64-i64:32:32-f64:32:32-v128:32:128-v64:32:64-n32:64"; } // DataLayout and FrameLowering are filled with dummy data PTXTargetMachine::PTXTargetMachine(const Target &T, const std::string &TT, const std::string &FS) - : Subtarget(TT, FS), + : LLVMTargetMachine(T, TT), // FIXME: This feels like a dirty hack, but Subtarget does not appear to be // initialized at this point, and we need to finish initialization of // DataLayout. DataLayout((FS.find("64bit") != FS.npos) ? DataLayout64 : DataLayout32), - LLVMTargetMachine(T, TT), + Subtarget(TT, FS), FrameLowering(Subtarget), - TLInfo(*this), - InstrInfo(*this) { + InstrInfo(*this), + TLInfo(*this) { } bool PTXTargetMachine::addInstSelector(PassManagerBase &PM, Modified: llvm/trunk/lib/Target/PTX/PTXTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXTargetMachine.h?rev=126838&r1=126837&r2=126838&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXTargetMachine.h (original) +++ llvm/trunk/lib/Target/PTX/PTXTargetMachine.h Wed Mar 2 01:58:46 2011 @@ -26,10 +26,10 @@ class PTXTargetMachine : public LLVMTargetMachine { private: const TargetData DataLayout; + PTXSubtarget Subtarget; // has to be initialized before FrameLowering PTXFrameLowering FrameLowering; PTXInstrInfo InstrInfo; PTXTargetLowering TLInfo; - PTXSubtarget Subtarget; public: PTXTargetMachine(const Target &T, const std::string &TT, From Erik.Olofsson at hansoft.se Wed Mar 2 06:48:08 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Wed, 2 Mar 2011 13:48:08 +0100 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> <87bp1uz8fx.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC9@winserv02.hansoft.local> <877hciz69f.fsf@wanadoo.es> <8739n6z4el.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBADF@winserv02.hansoft.local> <87y64yxlig.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAE1@winserv02.hansoft.local> Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACBB43@winserv02.hansoft.local> > -----Original Message----- > From: Francois Pichet [mailto:pichet2000 at gmail.com] > On Tue, Mar 1, 2011 at 10:36 PM, Erik Olofsson > wrote: > > > > I was building in Debug mode so tblgen in Release mode would probably > help a lot, but one tblgen project includes to several tblgen, this gives room > for improvement on msbuild where they are all run sequentially in each > project. > > > > Regards, > > Erik > > hi > > Using MSVC 2010 and quadcore. > > Complete build (release) trunk: 14 mins 45 secs Complete build (release) > trunk + patch: 14mins 40 secs > > It is within the margin of error here. > > so to me this patch doesn't speed things up. Builds are already multi- > processor on a per project basis. That is curious, as for large part of the compilation only one or two cores are utilized without /MP. It is expected to some degree as it's much easier to saturate 4 cores than 8 hyper threaded cores (16 threads). Depending on if your CPU is hyper threaded or not I would suspect you may be IO bound. cmake -DLLVM_TARGETS_TO_BUILD="all" -DLLVM_COMPILER_JOBS=1 ../llvm Complete build (Release) trunk: 09 mins 59 seconds Change Lexer.h: 02 minutes 14 seconds CPU utilization graph: http://www.olofsson.info/clang/Release-CPU-utilization.gif cmake -DLLVM_TARGETS_TO_BUILD="all" -DLLVM_COMPILER_JOBS=0 ../llvm Complete build (Release) trunk: 03 mins 29 seconds Change Lexer.h: 41 seconds CPU utilization graph: http://www.olofsson.info/clang/Release-MP-CPU-utilization.gif cmake -DLLVM_TARGETS_TO_BUILD="all" -DLLVM_COMPILER_JOBS=1 ../llvm Complete build (Debug) trunk: 12 mins 29 seconds Change Lexer.h: 2 mins 2 seconds CPU utilization graph: http://www.olofsson.info/clang/Debug-CPU-utilization.gif cmake -DLLVM_TARGETS_TO_BUILD="all" -DLLVM_COMPILER_JOBS=0 ../llvm Complete build (Debug) trunk: 7 mins 41 seconds Change Lexer.h: 51 seconds CPU utilization graph: http://www.olofsson.info/clang/Debug-MP-CPU-utilization.gif If you look at http://www.olofsson.info/clang/Release-CPU-utilization.gif you can see the areas where only one or two cores are utilized. It would be interesting to see such graphs for your builds. Regards, Erik From pichet2000 at gmail.com Wed Mar 2 09:26:30 2011 From: pichet2000 at gmail.com (Francois Pichet) Date: Wed, 2 Mar 2011 10:26:30 -0500 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: <97510B8DF78E714D91EB4A27850A17DA0C3EACBB43@winserv02.hansoft.local> References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> <87bp1uz8fx.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC9@winserv02.hansoft.local> <877hciz69f.fsf@wanadoo.es> <8739n6z4el.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBADF@winserv02.hansoft.local> <87y64yxlig.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAE1@winserv02.hansoft.local> <97510B8DF78E714D91EB4A27850A17DA0C3EACBB43@winserv02.hansoft.local> Message-ID: On Wed, Mar 2, 2011 at 7:48 AM, Erik Olofsson wrote: >> -----Original Message----- >> From: Francois Pichet [mailto:pichet2000 at gmail.com] >> On Tue, Mar 1, 2011 at 10:36 PM, Erik Olofsson >> wrote: >> > >> > I was building in Debug mode so tblgen in Release mode would probably >> help a lot, but one tblgen project includes to several tblgen, this gives room >> for improvement on msbuild where they are all run sequentially in each >> project. >> > >> > Regards, >> > Erik >> >> hi >> >> Using MSVC 2010 and quadcore. >> >> Complete build (release) trunk: 14 mins 45 secs Complete build (release) >> trunk + patch: 14mins 40 secs >> >> It is within the margin of error here. >> >> so to me this patch doesn't speed things up. Builds are already multi- >> processor on a per project basis. > > That is curious, as for large part of the compilation only one or two cores are utilized without /MP. It is expected to some degree as it's much easier to saturate 4 cores than 8 hyper threaded cores (16 threads). Depending on if your CPU is hyper threaded or not I would suspect you may be IO bound. > > cmake -DLLVM_TARGETS_TO_BUILD="all" -DLLVM_COMPILER_JOBS=1 ../llvm > Complete build (Release) trunk: 09 mins 59 seconds > Change Lexer.h: 02 minutes 14 seconds > CPU utilization graph: http://www.olofsson.info/clang/Release-CPU-utilization.gif > > cmake -DLLVM_TARGETS_TO_BUILD="all" -DLLVM_COMPILER_JOBS=0 ../llvm > Complete build (Release) trunk: 03 mins 29 seconds > Change Lexer.h: 41 seconds > CPU utilization graph: http://www.olofsson.info/clang/Release-MP-CPU-utilization.gif > > cmake -DLLVM_TARGETS_TO_BUILD="all" -DLLVM_COMPILER_JOBS=1 ../llvm > Complete build (Debug) trunk: 12 mins 29 seconds > Change Lexer.h: 2 mins 2 seconds > CPU utilization graph: http://www.olofsson.info/clang/Debug-CPU-utilization.gif > > cmake -DLLVM_TARGETS_TO_BUILD="all" -DLLVM_COMPILER_JOBS=0 ../llvm > Complete build (Debug) trunk: 7 mins 41 seconds > Change Lexer.h: 51 seconds > CPU utilization graph: http://www.olofsson.info/clang/Debug-MP-CPU-utilization.gif > > If you look at http://www.olofsson.info/clang/Release-CPU-utilization.gif you can see the areas where only one or two cores are utilized. It would be interesting to see such graphs for your builds. > Hi, I have a Intel Q6600 which is quadcore without hyper threading. When I do a build my CPU utilization is maxed at 100% (on the 4 core) almost all the time. What value do you have for "maximum number of parallel project build" in your visual studio options? (here: http://tinyurl.com/5wrqczs) I suspect your value is not equal to the maximum you could put. That would explain the difference you get. Put 16 there and redo your tests with and without your patch. I think that for LLVM it is better to configure multiprocessor msvc build using that option instead of the /MP switch. From Erik.Olofsson at hansoft.se Wed Mar 2 10:00:09 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Wed, 2 Mar 2011 17:00:09 +0100 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> <87bp1uz8fx.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC9@winserv02.hansoft.local> <877hciz69f.fsf@wanadoo.es> <8739n6z4el.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBADF@winserv02.hansoft.local> <87y64yxlig.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAE1@winserv02.hansoft.local> <97510B8DF78E714D91EB4A27850A17DA0C3EACBB43@winserv02.hansoft.local> Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACBB89@winserv02.hansoft.local> > -----Original Message----- > From: Francois Pichet [mailto:pichet2000 at gmail.com] > > If you look at http://www.olofsson.info/clang/Release-CPU-utilization.gif > you can see the areas where only one or two cores are utilized. It would be > interesting to see such graphs for your builds. > > > > Hi, > > I have a Intel Q6600 which is quadcore without hyper threading. > When I do a build my CPU utilization is maxed at 100% (on the 4 core) almost > all the time. > > What value do you have for "maximum number of parallel project build" > in your visual studio options? (here: http://tinyurl.com/5wrqczs) 16, and as you can see from the graph, during some parts of the build the CPU utilization is close to 100% > I suspect your value is not equal to the maximum you could put. That would > explain the difference you get. Put 16 there and redo your tests with and > without your patch. > > I think that for LLVM it is better to configure multiprocessor msvc build using > that option instead of the /MP switch. That may be true for your processor, but as it doesn't hurt performance and the tendency is for the number of cores to increase going forward I think it's worthwhile. >From your statements it sounds like you actually have /MP enabled without the patch. Otherwise in the beginning of the project it would only use one core when it compiles LLVMSupport project which everything else is dependent on. Could you check (Properties->Configuration Properties->C/C++->Multi-Processor Compilation) on project generated without the patch to see what it is set to? Which version of CMake are you using, it might have another default? You could have configured /MP in your Microsoft.Cpp.Win32.user.props file? Regards, Erik From david_dean at apple.com Wed Mar 2 10:08:14 2011 From: david_dean at apple.com (David Dean) Date: Wed, 02 Mar 2011 16:08:14 -0000 Subject: [llvm-commits] [zorg] r126843 - /zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py Message-ID: <20110302160814.B0D6F2A6C12C@llvm.org> Author: ddean Date: Wed Mar 2 10:08:14 2011 New Revision: 126843 URL: http://llvm.org/viewvc/llvm-project?rev=126843&view=rev Log: Property builder used as default in addPackageStep() should have been buildername. Modified: zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py Modified: zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py?rev=126843&r1=126842&r2=126843&view=diff ============================================================================== --- zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py (original) +++ zorg/trunk/zorg/buildbot/builders/LLVMGCCBuilder.py Wed Mar 2 10:08:14 2011 @@ -267,7 +267,7 @@ import os def addPackageStep(f, package_dst, obj_path, - project = '%(builder)s', + project = '%(buildername)s', info_string='r%(got_revision)s'): # Package and upload. From lstask at gmail.com Wed Mar 2 09:54:16 2011 From: lstask at gmail.com (Liam Staskawicz) Date: Wed, 2 Mar 2011 07:54:16 -0800 Subject: [llvm-commits] Fw: sys::fs::can_read() and sys::fs::can_write() for Unix In-Reply-To: <103727D28EE14102ABAB90CE3ED8DE80@gmail.com> References: <103727D28EE14102ABAB90CE3ED8DE80@gmail.com> Message-ID: <49CDBB532D70435F9C467613852704EE@gmail.com> ping. Is anybody available to review and commit if OK? Thanks! Liam Forwarded message: > From: Liam Staskawicz > To: llvm-commits at cs.uiuc.edu > Date: Monday, February 28, 2011 10:39:43 AM > Subject: [PATCH] sys::fs::can_read() and sys::fs::can_write() for Unix > > Hi - the attached patch provides implementations and tests for sys::fs::can_read() and sys::fs::can_write() for Unix. These were adapted from the previous implementations in lib/Support/Unix/Path.inc. can_execute() could be implemented quite similarly, but I wasn't sure where the best place to add a test for it would be, so left it out for now. > > Thanks, > Liam > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/c6f02395/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: pathsupport.diff Type: application/octet-stream Size: 1687 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/c6f02395/attachment.obj From greened at obbligato.org Wed Mar 2 11:23:44 2011 From: greened at obbligato.org (David Greene) Date: Wed, 02 Mar 2011 17:23:44 -0000 Subject: [llvm-commits] [llvm] r126845 - in /llvm/trunk: lib/Target/X86/Utils/X86ShuffleDecode.cpp lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86InstrFragmentsSIMD.td lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/SIMD/ test/CodeGen/X86/SIMD/dg.exp test/CodeGen/X86/SIMD/notvunpcklpd.ll test/CodeGen/X86/SIMD/notvunpcklps.ll test/CodeGen/X86/SIMD/vunpcklpd.ll test/CodeGen/X86/SIMD/vunpcklps.ll Message-ID: <20110302172344.3EECD2A6C12C@llvm.org> Author: greened Date: Wed Mar 2 11:23:43 2011 New Revision: 126845 URL: http://llvm.org/viewvc/llvm-project?rev=126845&view=rev Log: [AVX] Fix mask predicates for 256-bit UNPCKLPS/D and implement missing patterns for them. Add a SIMD test subdirectory to hold tests for SIMD instruction selection correctness and quality. ' Added: llvm/trunk/test/CodeGen/X86/SIMD/ llvm/trunk/test/CodeGen/X86/SIMD/dg.exp llvm/trunk/test/CodeGen/X86/SIMD/notvunpcklpd.ll llvm/trunk/test/CodeGen/X86/SIMD/notvunpcklps.ll llvm/trunk/test/CodeGen/X86/SIMD/vunpcklpd.ll llvm/trunk/test/CodeGen/X86/SIMD/vunpcklps.ll Modified: llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp?rev=126845&r1=126844&r2=126845&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp (original) +++ llvm/trunk/lib/Target/X86/Utils/X86ShuffleDecode.cpp Wed Mar 2 11:23:43 2011 @@ -165,12 +165,25 @@ /// datatypes and vector widths. void DecodeUNPCKLPMask(EVT VT, SmallVectorImpl &ShuffleMask) { + unsigned NumElts = VT.getVectorNumElements(); - unsigned NElts = VT.getVectorNumElements(); + // Handle vector lengths > 128 bits. Define a "section" as a set of + // 128 bits. AVX defines UNPCK* to operate independently on 128-bit + // sections. + unsigned NumSections = VT.getSizeInBits() / 128; + if (NumSections == 0 ) NumSections = 1; // Handle MMX + unsigned NumSectionElts = NumElts / NumSections; - for (unsigned i = 0; i != NElts/2; ++i) { - ShuffleMask.push_back(i); // Reads from dest - ShuffleMask.push_back(i+NElts); // Reads from src + unsigned Start = 0; + unsigned End = NumSectionElts / 2; + for (unsigned s = 0; s < NumSections; ++s) { + for (unsigned i = Start; i != End; ++i) { + ShuffleMask.push_back(i); // Reads from dest/src1 + ShuffleMask.push_back(i+NumSectionElts); // Reads from src/src2 + } + // Process the next 128 bits. + Start += NumSectionElts; + End += NumSectionElts; } } Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=126845&r1=126844&r2=126845&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Mar 2 11:23:43 2011 @@ -3173,7 +3173,8 @@ bool X86::isMOVLHPSMask(ShuffleVectorSDNode *N) { unsigned NumElems = N->getValueType(0).getVectorNumElements(); - if (NumElems != 2 && NumElems != 4) + if ((NumElems != 2 && NumElems != 4) + || N->getValueType(0).getSizeInBits() > 128) return false; for (unsigned i = 0; i < NumElems/2; ++i) @@ -3195,19 +3196,36 @@ if (NumElts != 2 && NumElts != 4 && NumElts != 8 && NumElts != 16) return false; - for (int i = 0, j = 0; i != NumElts; i += 2, ++j) { - int BitI = Mask[i]; - int BitI1 = Mask[i+1]; - if (!isUndefOrEqual(BitI, j)) - return false; - if (V2IsSplat) { - if (!isUndefOrEqual(BitI1, NumElts)) - return false; - } else { - if (!isUndefOrEqual(BitI1, j + NumElts)) + // Handle vector lengths > 128 bits. Define a "section" as a set of + // 128 bits. AVX defines UNPCK* to operate independently on 128-bit + // sections. + unsigned NumSections = VT.getSizeInBits() / 128; + if (NumSections == 0 ) NumSections = 1; // Handle MMX + unsigned NumSectionElts = NumElts / NumSections; + + unsigned Start = 0; + unsigned End = NumSectionElts; + for (unsigned s = 0; s < NumSections; ++s) { + for (unsigned i = Start, j = s * NumSectionElts; + i != End; + i += 2, ++j) { + int BitI = Mask[i]; + int BitI1 = Mask[i+1]; + if (!isUndefOrEqual(BitI, j)) return false; + if (V2IsSplat) { + if (!isUndefOrEqual(BitI1, NumElts)) + return false; + } else { + if (!isUndefOrEqual(BitI1, j + NumElts)) + return false; + } } + // Process the next 128 bits. + Start += NumSectionElts; + End += NumSectionElts; } + return true; } @@ -3255,14 +3273,27 @@ if (NumElems != 2 && NumElems != 4 && NumElems != 8 && NumElems != 16) return false; - for (int i = 0, j = 0; i != NumElems; i += 2, ++j) { - int BitI = Mask[i]; - int BitI1 = Mask[i+1]; - if (!isUndefOrEqual(BitI, j)) - return false; - if (!isUndefOrEqual(BitI1, j)) - return false; + // Handle vector lengths > 128 bits. Define a "section" as a set of + // 128 bits. AVX defines UNPCK* to operate independently on 128-bit + // sections. + unsigned NumSections = VT.getSizeInBits() / 128; + if (NumSections == 0 ) NumSections = 1; // Handle MMX + unsigned NumSectionElts = NumElems / NumSections; + + for (unsigned s = 0; s < NumSections; ++s) { + for (unsigned i = s * NumSectionElts, j = s * NumSectionElts; + i != NumSectionElts * (s + 1); + i += 2, ++j) { + int BitI = Mask[i]; + int BitI1 = Mask[i+1]; + + if (!isUndefOrEqual(BitI, j)) + return false; + if (!isUndefOrEqual(BitI1, j)) + return false; + } } + return true; } Modified: llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td?rev=126845&r1=126844&r2=126845&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td Wed Mar 2 11:23:43 2011 @@ -132,6 +132,8 @@ def X86Unpcklps : SDNode<"X86ISD::UNPCKLPS", SDTShuff2Op>; def X86Unpcklpd : SDNode<"X86ISD::UNPCKLPD", SDTShuff2Op>; +def X86Unpcklpsy : SDNode<"X86ISD::VUNPCKLPSY", SDTShuff2Op>; +def X86Unpcklpdy : SDNode<"X86ISD::VUNPCKLPDY", SDTShuff2Op>; def X86Unpckhps : SDNode<"X86ISD::UNPCKHPS", SDTShuff2Op>; def X86Unpckhpd : SDNode<"X86ISD::UNPCKHPD", SDTShuff2Op>; Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=126845&r1=126844&r2=126845&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Wed Mar 2 11:23:43 2011 @@ -5622,11 +5622,15 @@ // Shuffle with UNPCKLPS def : Pat<(v4f32 (X86Unpcklps VR128:$src1, (memopv4f32 addr:$src2))), (VUNPCKLPSrm VR128:$src1, addr:$src2)>, Requires<[HasAVX]>; +def : Pat<(v8f32 (X86Unpcklpsy VR256:$src1, (memopv8f32 addr:$src2))), + (VUNPCKLPSYrm VR256:$src1, addr:$src2)>, Requires<[HasAVX]>; def : Pat<(v4f32 (X86Unpcklps VR128:$src1, (memopv4f32 addr:$src2))), (UNPCKLPSrm VR128:$src1, addr:$src2)>; def : Pat<(v4f32 (X86Unpcklps VR128:$src1, VR128:$src2)), (VUNPCKLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasAVX]>; +def : Pat<(v8f32 (X86Unpcklpsy VR256:$src1, VR256:$src2)), + (VUNPCKLPSYrr VR256:$src1, VR256:$src2)>, Requires<[HasAVX]>; def : Pat<(v4f32 (X86Unpcklps VR128:$src1, VR128:$src2)), (UNPCKLPSrr VR128:$src1, VR128:$src2)>; @@ -5644,11 +5648,15 @@ // Shuffle with UNPCKLPD def : Pat<(v2f64 (X86Unpcklpd VR128:$src1, (memopv2f64 addr:$src2))), (VUNPCKLPDrm VR128:$src1, addr:$src2)>, Requires<[HasAVX]>; +def : Pat<(v4f64 (X86Unpcklpdy VR256:$src1, (memopv4f64 addr:$src2))), + (VUNPCKLPDYrm VR256:$src1, addr:$src2)>, Requires<[HasAVX]>; def : Pat<(v2f64 (X86Unpcklpd VR128:$src1, (memopv2f64 addr:$src2))), (UNPCKLPDrm VR128:$src1, addr:$src2)>; def : Pat<(v2f64 (X86Unpcklpd VR128:$src1, VR128:$src2)), (VUNPCKLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasAVX]>; +def : Pat<(v4f64 (X86Unpcklpdy VR256:$src1, VR256:$src2)), + (VUNPCKLPDYrr VR256:$src1, VR256:$src2)>, Requires<[HasAVX]>; def : Pat<(v2f64 (X86Unpcklpd VR128:$src1, VR128:$src2)), (UNPCKLPDrr VR128:$src1, VR128:$src2)>; Added: llvm/trunk/test/CodeGen/X86/SIMD/dg.exp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/SIMD/dg.exp?rev=126845&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/SIMD/dg.exp (added) +++ llvm/trunk/test/CodeGen/X86/SIMD/dg.exp Wed Mar 2 11:23:43 2011 @@ -0,0 +1,5 @@ +load_lib llvm.exp + +if { [llvm_supports_target X86] } { + RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] +} Added: llvm/trunk/test/CodeGen/X86/SIMD/notvunpcklpd.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/SIMD/notvunpcklpd.ll?rev=126845&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/SIMD/notvunpcklpd.ll (added) +++ llvm/trunk/test/CodeGen/X86/SIMD/notvunpcklpd.ll Wed Mar 2 11:23:43 2011 @@ -0,0 +1,20 @@ +; RUN: llc < %s -mattr=+avx | FileCheck %s + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-unknown-linux-gnu" + +define void @try_([2 x <4 x double>]* noalias %incarray, [2 x <4 x double>]* noalias %incarrayb ) { +entry: + %incarray1 = alloca [2 x <4 x double>]*, align 8 + %incarrayb1 = alloca [2 x <4 x double>]*, align 8 + %carray = alloca [2 x <4 x double>], align 16 + %r = getelementptr [2 x <4 x double>]* %incarray, i32 0, i32 0 + %rb = getelementptr [2 x <4 x double>]* %incarrayb, i32 0, i32 0 + %r3 = load <4 x double>* %r, align 8 + %r4 = load <4 x double>* %rb, align 8 + %r11 = shufflevector <4 x double> %r3, <4 x double> %r4, <4 x i32> < i32 0, i32 4, i32 1, i32 5 > ; <<4 x double>> [#uses=1] +; CHECK-NOT: vunpcklpd + %r12 = getelementptr [2 x <4 x double>]* %carray, i32 0, i32 1 + store <4 x double> %r11, <4 x double>* %r12, align 4 + ret void +} Added: llvm/trunk/test/CodeGen/X86/SIMD/notvunpcklps.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/SIMD/notvunpcklps.ll?rev=126845&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/SIMD/notvunpcklps.ll (added) +++ llvm/trunk/test/CodeGen/X86/SIMD/notvunpcklps.ll Wed Mar 2 11:23:43 2011 @@ -0,0 +1,20 @@ +; RUN: llc < %s -mattr=+avx | FileCheck %s + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-unknown-linux-gnu" + +define void @try_([2 x <8 x float>]* noalias %incarray, [2 x <8 x float>]* noalias %incarrayb ) { +enmtry: + %incarray1 = alloca [2 x <8 x float>]*, align 8 + %incarrayb1 = alloca [2 x <8 x float>]*, align 8 + %carray = alloca [2 x <8 x float>], align 16 + %r = getelementptr [2 x <8 x float>]* %incarray, i32 0, i32 0 + %rb = getelementptr [2 x <8 x float>]* %incarrayb, i32 0, i32 0 + %r3 = load <8 x float>* %r, align 8 + %r4 = load <8 x float>* %rb, align 8 + %r8 = shufflevector <8 x float> %r3, <8 x float> %r4, <8 x i32> < i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11 > ; <<8 x float>> [#uses=1] +; CHECK-NOT: vunpcklps + %r9 = getelementptr [2 x <8 x float>]* %carray, i32 0, i32 0 + store <8 x float> %r8, <8 x float>* %r9, align 4 + ret void +} Added: llvm/trunk/test/CodeGen/X86/SIMD/vunpcklpd.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/SIMD/vunpcklpd.ll?rev=126845&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/SIMD/vunpcklpd.ll (added) +++ llvm/trunk/test/CodeGen/X86/SIMD/vunpcklpd.ll Wed Mar 2 11:23:43 2011 @@ -0,0 +1,20 @@ +; RUN: llc < %s -mattr=+avx | FileCheck %s + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-unknown-linux-gnu" + +define void @try_([2 x <4 x double>]* noalias %incarray, [2 x <4 x double>]* noalias %incarrayb ) { +entry: + %incarray1 = alloca [2 x <4 x double>]*, align 8 + %incarrayb1 = alloca [2 x <4 x double>]*, align 8 + %carray = alloca [2 x <4 x double>], align 16 + %r = getelementptr [2 x <4 x double>]* %incarray, i32 0, i32 0 + %rb = getelementptr [2 x <4 x double>]* %incarrayb, i32 0, i32 0 + %r3 = load <4 x double>* %r, align 8 + %r4 = load <4 x double>* %rb, align 8 + %r11 = shufflevector <4 x double> %r3, <4 x double> %r4, <4 x i32> < i32 0, i32 4, i32 2, i32 6 > ; <<4 x double>> [#uses=1] +; CHECK: vunpcklpd + %r12 = getelementptr [2 x <4 x double>]* %carray, i32 0, i32 1 + store <4 x double> %r11, <4 x double>* %r12, align 4 + ret void +} Added: llvm/trunk/test/CodeGen/X86/SIMD/vunpcklps.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/SIMD/vunpcklps.ll?rev=126845&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/SIMD/vunpcklps.ll (added) +++ llvm/trunk/test/CodeGen/X86/SIMD/vunpcklps.ll Wed Mar 2 11:23:43 2011 @@ -0,0 +1,20 @@ +; RUN: llc < %s -mattr=+avx | FileCheck %s + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-unknown-linux-gnu" + +define void @try_([2 x <8 x float>]* noalias %incarray, [2 x <8 x float>]* noalias %incarrayb ) { +entry: + %incarray1 = alloca [2 x <8 x float>]*, align 8 + %incarrayb1 = alloca [2 x <8 x float>]*, align 8 + %carray = alloca [2 x <8 x float>], align 16 + %r = getelementptr [2 x <8 x float>]* %incarray, i32 0, i32 0 + %rb = getelementptr [2 x <8 x float>]* %incarrayb, i32 0, i32 0 + %r3 = load <8 x float>* %r, align 8 + %r4 = load <8 x float>* %rb, align 8 + %r11 = shufflevector <8 x float> %r3, <8 x float> %r4, <8 x i32> < i32 0, i32 8, i32 1, i32 9, i32 4, i32 12, i32 5, i32 13 > ; <<8 x float>> [#uses=1] +; CHECK: vunpcklps + %r12 = getelementptr [2 x <8 x float>]* %carray, i32 0, i32 1 + store <8 x float> %r11, <8 x float>* %r12, align 4 + ret void +} From ofv at wanadoo.es Wed Mar 2 11:41:39 2011 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=) Date: Wed, 02 Mar 2011 18:41:39 +0100 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: <97510B8DF78E714D91EB4A27850A17DA0C3EACBB89@winserv02.hansoft.local> (Erik Olofsson's message of "Wed, 2 Mar 2011 17:00:09 +0100") References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> <87bp1uz8fx.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC9@winserv02.hansoft.local> <877hciz69f.fsf@wanadoo.es> <8739n6z4el.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBADF@winserv02.hansoft.local> <87y64yxlig.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAE1@winserv02.hansoft.local> <97510B8DF78E714D91EB4A27850A17DA0C3EACBB43@winserv02.hansoft.local> <97510B8DF78E714D91EB4A27850A17DA0C3EACBB89@winserv02.hansoft.local> Message-ID: <87pqq9xvvw.fsf@wanadoo.es> Erik Olofsson writes: > From: Francois Pichet [mailto:pichet2000 at gmail.com] >> I have a Intel Q6600 which is quadcore without hyper threading. >> When I do a build my CPU utilization is maxed at 100% (on the 4 core) almost >> all the time. >> >> What value do you have for "maximum number of parallel project build" >> in your visual studio options? (here: http://tinyurl.com/5wrqczs) > > 16, and as you can see from the graph, during some parts of the build > the CPU utilization is close to 100% > >> I suspect your value is not equal to the maximum you could put. That would >> explain the difference you get. Put 16 there and redo your tests with and >> without your patch. >> >> I think that for LLVM it is better to configure multiprocessor msvc build using >> that option instead of the /MP switch. > > That may be true for your processor, but as it doesn't hurt > performance and the tendency is for the number of cores to increase > going forward I think it's worthwhile. I have the same CPU as Francois and see it pretty busy while building with the IDE without /MP. However, building top-level targets doesn't work so well for Erik because he has 16 virtual processors and there are no enough independent libraries/tools to keep them all busy. So I can understand that /MP makes a difference for him. Erik is also right pointing out that increasing the number of cores is the trend on the CPU industry. For those reasons I think that it is a good idea to add /MP to the MSVC_IDE build and turn it on by default. [snip] From ofv at wanadoo.es Wed Mar 2 11:47:37 2011 From: ofv at wanadoo.es (Oscar Fuentes) Date: Wed, 02 Mar 2011 17:47:37 -0000 Subject: [llvm-commits] [llvm] r126847 - in /llvm/trunk: cmake/modules/HandleLLVMOptions.cmake docs/CMake.html Message-ID: <20110302174737.8D0042A6C12C@llvm.org> Author: ofv Date: Wed Mar 2 11:47:37 2011 New Revision: 126847 URL: http://llvm.org/viewvc/llvm-project?rev=126847&view=rev Log: Support for parallel compilation (/MP) when using the VS IDE. Patch by Erik Olofsson! Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake llvm/trunk/docs/CMake.html Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=126847&r1=126846&r2=126847&view=diff ============================================================================== --- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original) +++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Wed Mar 2 11:47:37 2011 @@ -102,6 +102,31 @@ endif( LLVM_BUILD_32_BITS ) endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 ) +message(STATUS "uno" +"dos") +if( MSVC_IDE AND ( MSVC90 OR MSVC10 ) ) + # Only Visual Studio 2008 and 2010 officially supports /MP. + # Visual Studio 2005 do support it but it's experimental there. + set(LLVM_COMPILER_JOBS "0" CACHE STRING + "Number of parallel compiler jobs. 0 means use all processors. Default is 0.") + if( NOT LLVM_COMPILER_JOBS STREQUAL "1" ) + if( LLVM_COMPILER_JOBS STREQUAL "0" ) + add_llvm_definitions( /MP ) + else() + if (MSVC10) + message(FATAL_ERROR + "Due to a bug in CMake only 0 and 1 is supported for " + "LLVM_COMPILER_JOBS when generating for Visual Studio 2010") + else() + message(STATUS "Number of parallel compiler jobs set to " ${LLVM_COMPILER_JOBS}) + add_llvm_definitions( /MP${LLVM_COMPILER_JOBS} ) + endif() + endif() + else() + message(STATUS "Parallel compilation disabled") + endif() +endif() + if( MSVC ) include(ChooseMSVCCRT) Modified: llvm/trunk/docs/CMake.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CMake.html?rev=126847&r1=126846&r2=126847&view=diff ============================================================================== --- llvm/trunk/docs/CMake.html (original) +++ llvm/trunk/docs/CMake.html Wed Mar 2 11:47:37 2011 @@ -452,6 +452,22 @@ + + +
+ +
+
LLVM_COMPILER_JOBS:STRING
+
Specifies the maximum number of parallell compiler jobs to use + per project when building with msbuild or Visual Studio. Only supported for + Visual Studio 2008 and Visual Studio 2010 CMake generators. 0 means use all + processors. Default is 0.
+
+ +
+
From ofv at wanadoo.es Wed Mar 2 11:59:02 2011 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=) Date: Wed, 02 Mar 2011 18:59:02 +0100 Subject: [llvm-commits] [PATCH] Add MSVC multi processor compilation to build system In-Reply-To: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAE1@winserv02.hansoft.local> (Erik Olofsson's message of "Wed, 2 Mar 2011 04:36:42 +0100") References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC3@winserv02.hansoft.local> <87mxlezalr.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC6@winserv02.hansoft.local> <87bp1uz8fx.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAC9@winserv02.hansoft.local> <877hciz69f.fsf@wanadoo.es> <8739n6z4el.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBADF@winserv02.hansoft.local> <87y64yxlig.fsf@wanadoo.es> <97510B8DF78E714D91EB4A27850A17DA0C3EACBAE1@winserv02.hansoft.local> Message-ID: <87lj0xxv2x.fsf@wanadoo.es> Erik Olofsson writes: >> Put everything in HandleLLVMOptions.cmake, so it can be used when Clang >> is built using LLVM as an external library. > > Sorry, I just sent a patch that was split before I saw your message, > please ignore it. A patch for only HandleLLVMOptions.cmake attached. Committed as r126847. Thanks! >> Certainly, there are superfluous tblgen dependencies, but accurately >> determining them is tricky. About the dependencies between libraries, >> there are some among LLVM targets and its subsidiaries (e.g. LLVMX86 and >> LLVMX86AsmParser) and sometimes a dependency is declared from a library >> into another when, actually, it should be on its tablegenned products (e.g. >> LLVMX86 depending on LLVMTarget). In general, those cases can be easily >> fixed, although I've seen cases of linker errors on Linux due to missing >> vtables while linking the LLVM tools. If you know more instances of >> unnecessary inter-library dependencies, please mention them. > > Actually LLVM looks pretty good, it's clang that has more > dependencies. For example clangParse has a dependecy on clangLex. Clang depedencies are manually maintained, which tends to produce unnecesary references (as is the case for #include's on C++ sources.) I hope to extend the LLVM automatic library dependency tool to Clang someday. >> Parallel builds work fine on Linux with make -jN, there is little room to >> improve, but it seems that tablegenning on Windows is slow (in release >> mode, if you are building on debug mode it can take a very long time. I >> thought about always building tblgen.exe on release mode for avoiding >> such excruciating build times.) > > I was building in Debug mode so tblgen in Release mode would probably > help a lot, I'm surprised to see how fast your debug builds are. Here, tblgen on debug mode typically takes several minutes each time it is invoked. > but one tblgen project includes to several tblgen, this > gives room for improvement on msbuild where they are all run > sequentially in each project. This can be easily fixed by creating a custom_target for each tblgen invocation. From Renato.Golin at arm.com Wed Mar 2 12:05:35 2011 From: Renato.Golin at arm.com (Renato Golin) Date: Wed, 2 Mar 2011 18:05:35 +0000 Subject: [llvm-commits] ARM .fpu printing - small fix Message-ID: <4D6E86EF.7060105@arm.com> Fixing a bug when printing fpu text to object file. Patch by Mans Rullgard. All tests pass, tested locally with ASM/ELF writer. Can I commit? --renato -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. -------------- next part -------------- A non-text attachment was scrubbed... Name: fpu-printing-fix.patch Type: text/x-patch Size: 582 bytes Desc: fpu-printing-fix.patch Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/755f368f/attachment.bin From jasonwkim at google.com Wed Mar 2 12:46:06 2011 From: jasonwkim at google.com (Jason Kim) Date: Wed, 2 Mar 2011 10:46:06 -0800 Subject: [llvm-commits] ARM .fpu printing - small fix In-Reply-To: <4D6E86EF.7060105@arm.com> References: <4D6E86EF.7060105@arm.com> Message-ID: Looks good! Please go ahead. On Wed, Mar 2, 2011 at 10:05 AM, Renato Golin wrote: > Fixing a bug when printing fpu text to object file. Patch by Mans Rullgard. > > All tests pass, tested locally with ASM/ELF writer. > > Can I commit? > > --renato > > > -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. ?Thank you. > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From aggarwa4 at illinois.edu Wed Mar 2 13:13:55 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 02 Mar 2011 19:13:55 -0000 Subject: [llvm-commits] [poolalloc] r126859 - in /poolalloc/trunk/lib/DSA: BottomUpClosure.cpp CompleteBottomUp.cpp Message-ID: <20110302191355.B364B2A6C12C@llvm.org> Author: aggarwa4 Date: Wed Mar 2 13:13:55 2011 New Revision: 126859 URL: http://llvm.org/viewvc/llvm-project?rev=126859&view=rev Log: Build call graph, when we start inlining. This ensures that we get the same entries as we inline. Build SCCs at the end of BU. Might be needed by TD, and not every client may use EQTD. Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/BottomUpClosure.cpp?rev=126859&r1=126858&r2=126859&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original) +++ poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Wed Mar 2 13:13:55 2011 @@ -31,7 +31,8 @@ STATISTIC (NumCallEdges, "Number of 'actual' call edges"); STATISTIC (NumIndResolved, "Number of resolved IndCalls"); STATISTIC (NumIndUnresolved, "Number of unresolved IndCalls"); - STATISTIC (NumEmptyCalls, "Number of calls we know nothing about"); + // NumEmptyCalls = NumIndUnresolved + Number of calls to external functions + STATISTIC (NumEmptyCalls, "Number of calls we know nothing about"); RegisterPass X("dsa-bu", "Bottom-up Data Structure Analysis"); @@ -101,12 +102,12 @@ DSGraph *Graph = getOrCreateGraph(F); cloneGlobalsInto(Graph, DSGraph::DontCloneCallNodes | DSGraph::DontCloneAuxCallNodes); + Graph->buildCallGraph(callgraph, GlobalFunctionList, filterCallees); Graph->maskIncompleteMarkers(); Graph->markIncompleteNodes(DSGraph::MarkFormalArgs | DSGraph::IgnoreGlobals); Graph->computeExternalFlags(DSGraph::DontMarkFormalsExternal); Graph->computeIntPtrFlags(); - Graph->buildCallGraph(callgraph, GlobalFunctionList, filterCallees); } } @@ -121,6 +122,10 @@ NumCallEdges += callgraph.size(); + // Put the call graph in canonical form + callgraph.buildSCCs(); + callgraph.buildRoots(); + return false; } @@ -525,6 +530,7 @@ // void BUDataStructures::calculateGraph(DSGraph* Graph) { DEBUG(Graph->AssertGraphOK(); Graph->getGlobalsGraph()->AssertGraphOK()); + Graph->buildCallGraph(callgraph, GlobalFunctionList, filterCallees); // Move our call site list into TempFCs so that inline call sites go into the // new call site list and doesn't invalidate our iterators! @@ -552,7 +558,7 @@ if (CalledFuncs.empty()) { ++NumEmptyCalls; - if (CS.isIndirectCall()) + if (CS.isIndirectCall()) ++NumIndUnresolved; // Remember that we could not resolve this yet! AuxCallsList.splice(AuxCallsList.end(), TempFCs, TempFCs.begin()); Modified: poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp?rev=126859&r1=126858&r2=126859&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp (original) +++ poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp Wed Mar 2 13:13:55 2011 @@ -55,8 +55,6 @@ getOrCreateGraph(F); } } - callgraph.buildSCCs(); - callgraph.buildRoots(); buildIndirectFunctionSets(); formGlobalECs(); From aggarwa4 at illinois.edu Wed Mar 2 13:14:41 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 02 Mar 2011 19:14:41 -0000 Subject: [llvm-commits] [poolalloc] r126860 - /poolalloc/trunk/lib/DSA/DSGraph.cpp Message-ID: <20110302191441.86FA82A6C12C@llvm.org> Author: aggarwa4 Date: Wed Mar 2 13:14:41 2011 New Revision: 126860 URL: http://llvm.org/viewvc/llvm-project?rev=126860&view=rev Log: Unnecessary statistic. Modified: poolalloc/trunk/lib/DSA/DSGraph.cpp Modified: poolalloc/trunk/lib/DSA/DSGraph.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DSGraph.cpp?rev=126860&r1=126859&r2=126860&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DSGraph.cpp (original) +++ poolalloc/trunk/lib/DSA/DSGraph.cpp Wed Mar 2 13:14:41 2011 @@ -44,7 +44,7 @@ STATISTIC (NumTrivialDNE , "Number of nodes trivially removed"); STATISTIC (NumTrivialGlobalDNE , "Number of globals trivially removed"); STATISTIC (NumFiltered , "Number of calls filtered"); - STATISTIC (NumIndirectIncompleteCallSites , "Number of calls that could not be resolved"); + static cl::opt noDSACallConv("dsa-no-filter-callcc", cl::desc("Don't filter call sites based on calling convention."), cl::Hidden, @@ -1714,7 +1714,6 @@ MaybeTargets.assign(GlobalFunctionList.begin(), GlobalFunctionList.end()); DCG.insert(CS, 0); - NumIndirectIncompleteCallSites++; // // Add to the call graph only function targets that have well-defined // behavior using LLVM semantics. From tilmann.scheller at googlemail.com Wed Mar 2 13:29:22 2011 From: tilmann.scheller at googlemail.com (Tilmann Scheller) Date: Wed, 02 Mar 2011 19:29:22 -0000 Subject: [llvm-commits] [llvm] r126862 - in /llvm/trunk: include/llvm/CallingConv.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Target/X86/X86CallingConv.td lib/VMCore/AsmWriter.cpp Message-ID: <20110302192922.716EF2A6C12C@llvm.org> Author: tilmann Date: Wed Mar 2 13:29:22 2011 New Revision: 126862 URL: http://llvm.org/viewvc/llvm-project?rev=126862&view=rev Log: Add Win64 thiscall calling convention. Modified: llvm/trunk/include/llvm/CallingConv.h llvm/trunk/lib/AsmParser/LLLexer.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLToken.h llvm/trunk/lib/Target/X86/X86CallingConv.td llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/include/llvm/CallingConv.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CallingConv.h?rev=126862&r1=126861&r2=126862&view=diff ============================================================================== --- llvm/trunk/include/llvm/CallingConv.h (original) +++ llvm/trunk/include/llvm/CallingConv.h Wed Mar 2 13:29:22 2011 @@ -94,7 +94,10 @@ /// MBLAZE_INTR - Calling convention used for MBlaze interrupt support /// routines (i.e. GCC's save_volatiles attribute). - MBLAZE_SVOL = 74 + MBLAZE_SVOL = 74, + + /// Win64_ThisCall - Calling convention used for method calls on Win64. + Win64_ThisCall = 75 }; } // End CallingConv namespace Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=126862&r1=126861&r2=126862&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLLexer.cpp (original) +++ llvm/trunk/lib/AsmParser/LLLexer.cpp Wed Mar 2 13:29:22 2011 @@ -549,6 +549,7 @@ KEYWORD(msp430_intrcc); KEYWORD(ptx_kernel); KEYWORD(ptx_device); + KEYWORD(win64_thiscallcc); KEYWORD(cc); KEYWORD(c); Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=126862&r1=126861&r2=126862&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Mar 2 13:29:22 2011 @@ -1087,6 +1087,7 @@ /// ::= 'msp430_intrcc' /// ::= 'ptx_kernel' /// ::= 'ptx_device' +/// ::= 'win64_thiscallcc' /// ::= 'cc' UINT /// bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) { @@ -1104,6 +1105,7 @@ case lltok::kw_msp430_intrcc: CC = CallingConv::MSP430_INTR; break; case lltok::kw_ptx_kernel: CC = CallingConv::PTX_Kernel; break; case lltok::kw_ptx_device: CC = CallingConv::PTX_Device; break; + case lltok::kw_win64_thiscallcc:CC = CallingConv::Win64_ThisCall; break; case lltok::kw_cc: { unsigned ArbitraryCC; Lex.Lex(); Modified: llvm/trunk/lib/AsmParser/LLToken.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=126862&r1=126861&r2=126862&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLToken.h (original) +++ llvm/trunk/lib/AsmParser/LLToken.h Wed Mar 2 13:29:22 2011 @@ -74,6 +74,7 @@ kw_arm_apcscc, kw_arm_aapcscc, kw_arm_aapcs_vfpcc, kw_msp430_intrcc, kw_ptx_kernel, kw_ptx_device, + kw_win64_thiscallcc, kw_signext, kw_zeroext, Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CallingConv.td?rev=126862&r1=126861&r2=126862&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CallingConv.td (original) +++ llvm/trunk/lib/Target/X86/X86CallingConv.td Wed Mar 2 13:29:22 2011 @@ -215,6 +215,13 @@ // The first 4 integer arguments are passed in integer registers. CCIfType<[i32], CCAssignToRegWithShadow<[ECX , EDX , R8D , R9D ], [XMM0, XMM1, XMM2, XMM3]>>, + + // Do not pass the sret argument in RCX, the Win64 thiscall calling + // convention requires "this" to be passed in RCX. + CCIfCC<"CallingConv::Win64_ThisCall", + CCIfSRet>>>, + CCIfType<[i64], CCAssignToRegWithShadow<[RCX , RDX , R8 , R9 ], [XMM0, XMM1, XMM2, XMM3]>>, Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=126862&r1=126861&r2=126862&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Wed Mar 2 13:29:22 2011 @@ -1586,6 +1586,7 @@ case CallingConv::MSP430_INTR: Out << "msp430_intrcc "; break; case CallingConv::PTX_Kernel: Out << "ptx_kernel"; break; case CallingConv::PTX_Device: Out << "ptx_device"; break; + case CallingConv::Win64_ThisCall:Out << "win64_thiscallcc "; break; default: Out << "cc" << F->getCallingConv() << " "; break; } @@ -1858,6 +1859,7 @@ case CallingConv::MSP430_INTR: Out << " msp430_intrcc "; break; case CallingConv::PTX_Kernel: Out << " ptx_kernel"; break; case CallingConv::PTX_Device: Out << " ptx_device"; break; + case CallingConv::Win64_ThisCall:Out << " win64_thiscallcc "; break; default: Out << " cc" << CI->getCallingConv(); break; } @@ -1914,6 +1916,7 @@ case CallingConv::MSP430_INTR: Out << " msp430_intrcc "; break; case CallingConv::PTX_Kernel: Out << " ptx_kernel"; break; case CallingConv::PTX_Device: Out << " ptx_device"; break; + case CallingConv::Win64_ThisCall:Out << " win64_thiscallcc "; break; default: Out << " cc" << II->getCallingConv(); break; } From stuart at apple.com Wed Mar 2 13:36:30 2011 From: stuart at apple.com (Stuart Hastings) Date: Wed, 02 Mar 2011 19:36:30 -0000 Subject: [llvm-commits] [llvm] r126864 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Message-ID: <20110302193630.9066E2A6C12D@llvm.org> Author: stuart Date: Wed Mar 2 13:36:30 2011 New Revision: 126864 URL: http://llvm.org/viewvc/llvm-project?rev=126864&view=rev Log: Can't introduce floating-point immediate constants after legalization. Radar 9056407. 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=126864&r1=126863&r2=126864&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed Mar 2 13:36:30 2011 @@ -5142,7 +5142,9 @@ EVT OpVT = N0.getValueType(); // fold (sint_to_fp c1) -> c1fp - if (N0C && OpVT != MVT::ppcf128) + if (N0C && OpVT != MVT::ppcf128 && + // ...but only if the target supports immediate floating-point values + (Level == llvm::Unrestricted || TLI.isOperationLegalOrCustom(llvm::ISD::ConstantFP, VT))) return DAG.getNode(ISD::SINT_TO_FP, N->getDebugLoc(), VT, N0); // If the input is a legal type, and SINT_TO_FP is not legal on this target, @@ -5164,7 +5166,9 @@ EVT OpVT = N0.getValueType(); // fold (uint_to_fp c1) -> c1fp - if (N0C && OpVT != MVT::ppcf128) + if (N0C && OpVT != MVT::ppcf128 && + // ...but only if the target supports immediate floating-point values + (Level == llvm::Unrestricted || TLI.isOperationLegalOrCustom(llvm::ISD::ConstantFP, VT))) return DAG.getNode(ISD::UINT_TO_FP, N->getDebugLoc(), VT, N0); // If the input is a legal type, and UINT_TO_FP is not legal on this target, From gkistanova at gmail.com Wed Mar 2 13:41:08 2011 From: gkistanova at gmail.com (Galina Kistanova) Date: Wed, 2 Mar 2011 11:41:08 -0800 Subject: [llvm-commits] Failed build llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi Message-ID: Just a short notice, the last successful build for 3-srage-builder llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi was yesterday for revision 126801, the fist failed build is for revision 126817: http://google1.osuosl.org:8011/builders/llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi/builds/294 Thanks Galina From baldrick at free.fr Wed Mar 2 13:52:19 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 02 Mar 2011 20:52:19 +0100 Subject: [llvm-commits] [llvm] r126864 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp In-Reply-To: <20110302193630.9066E2A6C12D@llvm.org> References: <20110302193630.9066E2A6C12D@llvm.org> Message-ID: <4D6E9FF3.9000106@free.fr> > Can't introduce floating-point immediate constants after legalization. > Radar 9056407. Sorry to sound like a worn out record, but... testcase? Ciao, Duncan. From gohman at apple.com Wed Mar 2 13:55:13 2011 From: gohman at apple.com (Dan Gohman) Date: Wed, 2 Mar 2011 11:55:13 -0800 Subject: [llvm-commits] [PATCH] Add support for OutputDebugString to raw_ostream and add support for virtualized out/err streams In-Reply-To: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAE2@winserv02.hansoft.local> References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAE2@winserv02.hansoft.local> Message-ID: On Mar 1, 2011, at 8:05 PM, Erik Olofsson wrote: > Adds support for OutputDebugString to raw_ostream as well as one object to access a virtualized errs and outs. This is needed for subsequent patches in clang so you can redirect errs and outs to OutputDebugString. The rationale for needing this is that debugging from Visual Studio will not allow you to capture stdout and stderr into its Output window but OutputDebugString is captured there. Hmm. It's not even possible to view the output of a classic "hello world"? > This change (in clang...) will also be useful if you want to redirect compiler output you can just create your own raw_output_streams and pass to the compiler functions. > > > > Together with MSVC style diagnostics this really helps in clang development where you can get from diagnostics directly to the code in question when debugging. Would it be possible to achieve what you want by extending dbgs()? If not, how should code decide between using dbgs() and debugouts()? What's the purpose of the raw_output_streams class? Are you expecting to migrate code that uses errs() and outs() to using it? If so, that's quite invasive. If not, what's the purpose? Dan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/1ffc46fc/attachment.html From stoklund at 2pi.dk Wed Mar 2 13:58:51 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 2 Mar 2011 11:58:51 -0800 Subject: [llvm-commits] Failed build llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi In-Reply-To: References: Message-ID: On Mar 2, 2011, at 11:41 AM, Galina Kistanova wrote: > Just a short notice, > the last successful build for 3-srage-builder > llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi was yesterday for > revision 126801, the fist failed build is for revision 126817: > > http://google1.osuosl.org:8011/builders/llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi/builds/294 The assertion failure is likely caused by one of my patches: Assertion failed: (PVNI->hasPHIKill() && "Missing hasPHIKill flag"), function shrinkToUses, file /Users/buildslave/zorg/buildbot/smooshlab/slave/llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi/llvm.src/lib/CodeGen/LiveIntervalAnalysis.cpp, line 809. I don't think I can reproduce what this bot is doing, is there any way you can get me a bitcode file? Thanks, /jakob From vmle at ucdavis.edu Wed Mar 2 14:08:33 2011 From: vmle at ucdavis.edu (Vu Le) Date: Wed, 2 Mar 2011 12:08:33 -0800 Subject: [llvm-commits] Patch for simplifying regions In-Reply-To: References: <4D4882FC.8060102@fim.uni-passau.de> <4D6BCEBA.9080609@fim.uni-passau.de> <4D6CF971.5050300@fim.uni-passau.de> Message-ID: Add more test cases. Vu On Tue, Mar 1, 2011 at 12:15 PM, Vu Le wrote: > > > On Tue, Mar 1, 2011 at 12:12 PM, Vu Le wrote: > >> Hi Tobias, >> Thanks for the feedback. >> >> On Tue, Mar 1, 2011 at 5:49 AM, Tobias Grosser > > wrote: >> >>> On 02/28/2011 02:52 PM, Vu Le wrote: >>> >>>> Hi Tobias, >>>> >>>> I did make some changes to use splitBlockPredecessors in splitting >>>> entry nodes. >>>> >>> >>> Thanks for your fast reaction. The patch looks very nice. Though I have >>> some comments that we need to fix before committing it. >>> >>> Thank you. >> >>> >>> I tested it with coreutils and MySQL together with region-extractor >>>> pass. >>>> >>> Nice. >>> >>> >>> If you're still interested in region-extractor pass, I'll make a patch. >>>> >>> Yes. I am extremely interested. >>> >>> diff --git a/include/llvm/InitializePasses.h >>>> b/include/llvm/InitializePasses.h >>>> index 02dbfbd..0591845 100644 >>>> --- a/include/llvm/InitializePasses.h >>>> +++ b/include/llvm/InitializePasses.h >>>> @@ -192,6 +192,7 @@ void initializeRegionInfoPass(PassRegistry&); >>>> void initializeRegionOnlyPrinterPass(PassRegistry&); >>>> void initializeRegionOnlyViewerPass(PassRegistry&); >>>> void initializeRegionPrinterPass(PassRegistry&); >>>> +void initializeRegionSimplifyPass(PassRegistry&); >>>> void initializeRegionViewerPass(PassRegistry&); >>>> void initializeRegisterCoalescerAnalysisGroup(PassRegistry&); >>>> void initializeRenderMachineFunctionPass(PassRegistry&); >>>> diff --git a/include/llvm/LinkAllPasses.h b/include/llvm/LinkAllPasses.h >>>> index 69e1bd9..ea1faec 100644 >>>> --- a/include/llvm/LinkAllPasses.h >>>> +++ b/include/llvm/LinkAllPasses.h >>>> @@ -114,7 +114,8 @@ namespace { >>>> (void) llvm::createRegionInfoPass(); >>>> (void) llvm::createRegionOnlyPrinterPass(); >>>> (void) llvm::createRegionOnlyViewerPass(); >>>> - (void) llvm::createRegionPrinterPass(); >>>> + (void) llvm::createRegionPrinterPass(); >>>> >>> This change does not seem to be needed. Please remove it. >>> >>> OK >> >>> + (void) llvm::createRegionSimplifyPass(); >>>> (void) llvm::createRegionViewerPass(); >>>> (void) llvm::createSCCPPass(); >>>> (void) llvm::createScalarReplAggregatesPass(); >>>> diff --git a/include/llvm/Transforms/Scalar.h >>>> b/include/llvm/Transforms/Scalar.h >>>> index 6f2a38e..e3ca06a 100644 >>>> --- a/include/llvm/Transforms/Scalar.h >>>> +++ b/include/llvm/Transforms/Scalar.h >>>> @@ -349,6 +349,12 @@ Pass *createCorrelatedValuePropagationPass(); >>>> FunctionPass *createInstructionSimplifierPass(); >>>> extern char&InstructionSimplifierID; >>>> >>>> >>>> +//===----------------------------------------------------------------------===// >>>> +// >>>> +// RegionSimplify - Simplify refined regions, if possible. >>>> >>> Are there cases when it is not possible? Would be interesting to mention >>> those. >>> >>> It is when a region has function entry as its entry and a single edge >> exit. >> But then it is a simple region, I suppose. >> I'll remove the "if possible" part. >> >> +Pass *createRegionSimplifyPass(); >>>> + >>>> } // End llvm namespace >>>> >>>> #endif >>>> diff --git a/lib/Transforms/Scalar/CMakeLists.txt >>>> b/lib/Transforms/Scalar/CMakeLists.txt >>>> index 106fb8f..53fcf69 100644 >>>> --- a/lib/Transforms/Scalar/CMakeLists.txt >>>> +++ b/lib/Transforms/Scalar/CMakeLists.txt >>>> @@ -23,6 +23,7 @@ add_llvm_library(LLVMScalarOpts >>>> MemCpyOptimizer.cpp >>>> Reassociate.cpp >>>> Reg2Mem.cpp >>>> + RegionSimplify.cpp >>>> SCCP.cpp >>>> Scalar.cpp >>>> ScalarReplAggregates.cpp >>>> diff --git a/lib/Transforms/Scalar/RegionSimplify.cpp >>>> b/lib/Transforms/Scalar/RegionSimplify.cpp >>>> new file mode 100644 >>>> index 0000000..65e4d5c >>>> --- /dev/null >>>> +++ b/lib/Transforms/Scalar/RegionSimplify.cpp >>>> @@ -0,0 +1,185 @@ >>>> +//===- SeSeRegionInfo.cpp >>>> -------------------------------------------------===// >>>> +// >>>> +// The LLVM Compiler Infrastructure >>>> +// >>>> +// This file is distributed under the University of Illinois Open >>>> Source >>>> +// License. See LICENSE.TXT for details. >>>> +// >>>> >>>> +//===----------------------------------------------------------------------===// >>>> +// >>>> +// This file converts refined regions detected by the RegionInfo >>>> analysis >>>> +// into simple regions. >>>> +// >>>> >>>> +//===----------------------------------------------------------------------===// >>>> + >>>> +#include "llvm/Instructions.h" >>>> +#include "llvm/ADT/Statistic.h" >>>> +#include "llvm/Analysis/Dominators.h" >>>> +#include "llvm/Analysis/RegionPass.h" >>>> +#include "llvm/Analysis/RegionInfo.h" >>>> +#include "llvm/Transforms/Utils/BasicBlockUtils.h" >>>> + >>>> +#define DEBUG_TYPE "regionsimplify" >>>> >>> Can we call the pass "region-simplify"? Like "loop-simplify" (The name >>> was recently changed) >>> >>> Sure >> >>> +using namespace llvm; >>>> + >>>> +STATISTIC(NumEntries, "The # of created entry edges"); >>>> +STATISTIC(NumExits, "The # of created exit edges"); >>>> + >>>> +namespace { >>>> +class RegionSimplify: public RegionPass { >>>> + bool modified; >>>> + Region *CR; >>>> + void createSingleEntryEdge(Region *R); >>>> + void createSingleExitEdge(Region *R); >>>> +public: >>>> + static char ID; >>>> + explicit RegionSimplify() : >>>> + RegionPass(ID) { >>>> + initializeRegionSimplifyPass(*PassRegistry::getPassRegistry()); >>>> + } >>>> + >>>> + virtual void print(raw_ostream&O, const Module *M) const; >>>> + >>>> + virtual bool runOnRegion(Region *R, RGPassManager&RGM); >>>> + virtual void getAnalysisUsage(AnalysisUsage&AU) const; >>>> +}; >>>> +} >>>> + >>>> +INITIALIZE_PASS(RegionSimplify, "regionsimplify", >>>> >>> "regionsimplify" -> "region-simplify" >>> >> OK >> >>> >>> + "Transform refined regions into simple regions", false, false) >>>> + >>>> +char RegionSimplify::ID = 0; >>>> +namespace llvm { >>>> +Pass *createRegionSimplifyPass() { >>>> + return new RegionSimplify(); >>>> +} >>>> +} >>>> + >>>> +void RegionSimplify::print(raw_ostream&O, const Module *M) const { >>>> >>>> + if (!modified) >>>> + return; >>>> + >>>> + BasicBlock *enteringBlock = CR->getEnteringBlock(); >>>> + BasicBlock *exitingBlock = CR->getExitingBlock(); >>>> + >>>> + O<< "\nRegion: ["<< CR->getNameStr()<< "] Edges:\n"; >>>> + if (enteringBlock) >>>> + O<< " Entry: ]"<< enteringBlock->getNameStr()<< " => " >>>> +<< enteringBlock->getNameStr()<< "]\n"; >>>> + if (exitingBlock) >>>> + O<< " Exit: ["<< exitingBlock->getNameStr()<< " => " >>>> +<< exitingBlock->getNameStr()<< "[\n"; >>>> + >>>> + O<< "\n"; >>>> +} >>>> + >>>> +void RegionSimplify::getAnalysisUsage(AnalysisUsage&AU) const { >>>> + AU.addPreserved (); >>>> + AU.addPreserved (); >>>> + AU.addRequired (); >>>> +} >>>> + >>>> +// createSingleEntryEdge - Split the entry basic block of the given >>>> >>>> +// region after the last PHINode to form a single entry edge. >>>> +void RegionSimplify::createSingleEntryEdge(Region *R) { >>>> + BasicBlock *oldEntry = R->getEntry(); >>>> + SmallVector Preds; >>>> >>>> + for (pred_iterator PI = pred_begin(oldEntry), PE = >>>> pred_end(oldEntry); >>>> + PI != PE; ++PI) >>>> + if (!R->contains(*PI)) >>>> + Preds.push_back(*PI); >>>> + >>>> + if (Preds.size()==0) >>>> + return; >>>> >>> Can we change this to an assert? >>> >>> assert(Preds.size() && "This region has already a single entry edge"); >>> >> >> Then we have to make sure that R's entry is not the function entry. >> In runOnRegion >> if (!(R->getEnteringBlock()) >> && (pred_begin(R->getEntry()) != pred_end(R->getEntry()))) { >> createSingleEntryEdge(R); >> ... >> >> >> >>> + >>>> + BasicBlock *newEntry = SplitBlockPredecessors(oldEntry, >>>> + Preds.data(), >>>> Preds.size(), >>>> + ".single_entry", this); >>>> + >>>> + RegionInfo *RI =&getAnalysis (); >>>> + // We do not update entry node for children of this region. >>>> + // This make it easier to extract children regions because they do >>>> not share >>>> + // the entry node with their parents. >>>> + // all parent regions whose entry is oldEntry are updated with >>>> newEntry >>>> + Region *r = R->getParent(); >>>> + while (r->getEntry() == oldEntry&& !r->isTopLevelRegion()) { >>>> + r->replaceEntry(newEntry); >>>> + r = r->getParent(); >>>> + } >>>> + >>>> + // We do not update exit node for children of this region for the >>>> same reason >>>> + // of not updating entry node. >>>> + // All other regions whose exit is oldEntry are updated with new exit >>>> node >>>> + r = RI->getTopLevelRegion(); >>>> >>> r = r->getParent() should be enough? >>> >> >> I don't think so. We want to find ALL other regions, not just the regions >> starting from >> parent of R. We must start from the top. >> >>> >>> + std::deque RQ; >>>> >>> std::vector is probably simpler >>> >>> + RQ.push_back(r); >>>> + while (!RQ.empty()){ >>>> + r = RQ.front(); >>>> + for (Region::const_iterator RI = r->begin(), RE = r->end(); RI!=RE; >>>> ++RI) >>>> + RQ.push_back(*RI); >>>> + if (r->getExit() == oldEntry&& !R->contains(r)) >>>> + r->replaceExit(newEntry); >>>> + RQ.pop_front(); >>>> + } >>>> >>> I need to think about this part (Will send feedback later). >>> >> This is not clean. Here is a cleaner version >> r = RI->getTopLevelRegion(); >> std::vector RQ; >> >> RQ.push_back(r); >> >> while (!RQ.empty()){ >> r = RQ.back(); >> RQ.pop_back(); >> >> if (r->getExit() != oldEntry || R->contains(r)) >> continue; >> >> r->replaceExit(newEntry); >> >> >> for (Region::const_iterator RI = r->begin(), RE = r->end(); RI!=RE; >> ++RI) >> RQ.push_back(*RI); >> } >> > Please ignore this code fragment. It should be like this: > > r = RI->getTopLevelRegion(); > std::vector RQ; > RQ.push_back(r); > > while (!RQ.empty()){ > r = RQ.back(); > RQ.pop_back(); > > for (Region::const_iterator RI = r->begin(), RE = r->end(); RI!=RE; > ++RI) > RQ.push_back(*RI); > > if (r->getExit() == oldEntry && !R->contains(r)) > r->replaceExit(newEntry); > } > > > >> We cannot make sure that those regions whose exit is OldEntry belong to >> any >> >> particular subregions. That's why we have to iterate over all the regions >> in the >> tree. >> >>> >>> + >>>> + modified |= true; >>>> >>> I do not believe this is part of creating the edges. 'modified' is part >>> of the status tracking of the pass and should probably be put into >>> runOnRegion(). >>> >>> + ++NumEntries; >>>> >>> Dito. Please put in runOnRegion(). >>> >> Sure. >> >>> >>> +} >>>> + >>>> +// createSingleExitEdge - Split the exit basic of the given region >>>> >>>> +// to form a single exit edge. >>>> +void RegionSimplify::createSingleExitEdge(Region *R) { >>>> + BasicBlock *oldExit = R->getExit(); >>>> + >>>> + SmallVector Preds; >>>> + for (pred_iterator PI = pred_begin(oldExit), PE = pred_end(oldExit); >>>> >>>> + PI != PE; ++PI) >>>> + if (R->contains(*PI)) >>>> + Preds.push_back(*PI); >>>> + >>>> + BasicBlock *newExit = SplitBlockPredecessors(oldExit, >>>> + Preds.data(), >>>> Preds.size(), >>>> + ".single_exit", this); >>>> + RegionInfo *RI =&getAnalysis (); >>>> + >>>> + // We do not need to update entry nodes because this split happens >>>> inside >>>> + // this region and it affects only this region and all of its >>>> children. >>>> + // The new split node belongs to this region >>>> >>> >>> + RI->setRegionFor(newExit,R); >>>> + >>>> + // all children of this region whose exit is oldExit is changed to >>>> newExit >>>> + std::deque RQ; >>>> + for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; >>>> ++RI) >>>> + RQ.push_back(*RI); >>>> + while (!RQ.empty()){ >>>> + R = RQ.front(); >>>> + for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; >>>> ++RI) >>>> + RQ.push_back(*RI); >>>> + >>>> + if (R->getExit() == oldExit) >>>> + R->replaceExit(newExit); >>>> + RQ.pop_front(); >>>> + } >>>> >>> >>> A vector is probably simpler. We also do not need to add child regions >>> for regions that do not have an exit matching oldExit. What about this code? >>> >> I'm not sure about this. >> A child might not share the exit with its parent. >> I think we still need to check. >> >>> >>> std::vector RQ; >>> >>> while (!RQ.empty()){ >>> R = RQ.back(); >>> RQ.pop_back(); >>> >>> if (R->getExit() != oldExit) >>> continue; >>> >>> R->replaceExit(newExit); >>> >>> for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; >>> ++RI) >>> RQ.push_back(*RI); >>> >>> } >>> >>> std::vector RQ; >> >> for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; >> ++RI) >> RQ.push_back(*RI); >> >> while (!RQ.empty()){ >> R = RQ.back(); >> RQ.pop_back(); >> >> >> for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; >> ++RI) >> RQ.push_back(*RI); >> >> if (R->getExit() == oldExit) >> R->replaceExit(newExit); >> } >> >> >>> >>> + >>>> + modified |= true; >>>> >>> This function always modifies the CFG. So no need to put additional logic >>> here. >>> >>> + ++NumExits; >>>> >>> Dito. >>> >>> +} >>>> >>>> + >>>> +bool RegionSimplify::runOnRegion(Region *R, RGPassManager&RGM) { >>>> + modified = false; >>>> + >>>> + CR = R; >>>> + if (!R->isTopLevelRegion()) { >>>> + >>>> + if (!(R->getEnteringBlock())) { >>>> + createSingleEntryEdge(R); >>>> + } >>>> >>> >>> if (!(R->getEnteringBlock())) { >>> createSingleEntryEdge(R); >>> ++NumEntries; >>> modified = true. >>> } >>> >> We need to add additional check for the special case where R does not have >> any predecessor. >> >> if (!(R->getEnteringBlock()) >> && (pred_begin(R->getEntry()) != pred_end(R->getEntry()))) { >> createSingleEntryEdge(R); >> modified = true; >> ++NumEntries; >> } >> >>> >>> + >>>> + if (!(R->getExitingBlock())) { >>>> + modified |= createSingleExitEdge(R); >>>> >>> >>> if (!(R->getExitingBlock())) { >>> createSingleExitEdge(R); >>> ++NumExits; >>> modified = true; >>> } >>> >>> + } >>>> + } >>>> + >>>> + return modified; >>>> +} >>>> diff --git a/lib/Transforms/Scalar/Scalar.cpp >>>> b/lib/Transforms/Scalar/Scalar.cpp >>>> index bf9ca6d..5d18f22 100644 >>>> --- a/lib/Transforms/Scalar/Scalar.cpp >>>> +++ b/lib/Transforms/Scalar/Scalar.cpp >>>> @@ -51,6 +51,7 @@ void llvm::initializeScalarOpts(PassRegistry&Registry) >>>> { >>>> initializeMemCpyOptPass(Registry); >>>> initializeReassociatePass(Registry); >>>> initializeRegToMemPass(Registry); >>>> + initializeRegionSimplifyPass(Registry); >>>> initializeSCCPPass(Registry); >>>> initializeIPSCCPPass(Registry); >>>> initializeSROA_DTPass(Registry); >>>> diff --git a/test/Transforms/RegionSimplify/dg.exp >>>> b/test/Transforms/RegionSimplify/dg.exp >>>> new file mode 100644 >>>> index 0000000..f200589 >>>> --- /dev/null >>>> +++ b/test/Transforms/RegionSimplify/dg.exp >>>> @@ -0,0 +1,3 @@ >>>> +load_lib llvm.exp >>>> + >>>> +RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] >>>> diff --git a/test/Transforms/RegionSimplify/multi_exits.ll >>>> b/test/Transforms/RegionSimplify/multi_exits.ll >>>> new file mode 100644 >>>> index 0000000..024971c >>>> --- /dev/null >>>> +++ b/test/Transforms/RegionSimplify/multi_exits.ll >>>> @@ -0,0 +1,15 @@ >>>> +; RUN: opt -regionsimplify >>>> >>> >>> Did you test this test case. I believe you should use a line like: >>> >>> ; RUN: opt -regionsimplify %s >>> >>> Furthermore, we should also check the generated output. >>> >>> ; RUN: opt -regionsimplify %s | FileCheck %s >>> >>> +define void @f() nounwind { >>>> >>> ; CHECK: @f() >>> ; CHECK: br label %"1" >>> ... >>> >>> Add after the CHECK lines the output you expect. >>> >>> The same comments apply to the other test files. I would also be >>> interested to have some test files that include PHI-Nodes. >>> >>> Can you send out an updated patch? >>> >>> I'll look at FileCheck and create additional tests. >> Thank you again for your help ;). >> >> >>> Thanks a lot >>> Tobi >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/b2568b44/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: regionsimplify3.patch Type: text/x-patch Size: 14878 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/b2568b44/attachment-0001.bin From gohman at apple.com Wed Mar 2 14:14:41 2011 From: gohman at apple.com (Dan Gohman) Date: Wed, 2 Mar 2011 12:14:41 -0800 Subject: [llvm-commits] sys::fs::can_read() and sys::fs::can_write() for Unix In-Reply-To: <49CDBB532D70435F9C467613852704EE@gmail.com> References: <103727D28EE14102ABAB90CE3ED8DE80@gmail.com> <49CDBB532D70435F9C467613852704EE@gmail.com> Message-ID: On Mar 2, 2011, at 7:54 AM, Liam Staskawicz wrote: > ping. > > Is anybody available to review and commit if OK? Thanks! > > Liam > Forwarded message: > >> From: Liam Staskawicz >> To: llvm-commits at cs.uiuc.edu >> Date: Monday, February 28, 2011 10:39:43 AM >> Subject: [PATCH] sys::fs::can_read() and sys::fs::can_write() for Unix >> >> Hi - the attached patch provides implementations and tests for sys::fs::can_read() and sys::fs::can_write() for Unix. These were adapted from the previous implementations in lib/Support/Unix/Path.inc. can_execute() could be implemented quite similarly, but I wasn't sure where the best place to add a test for it would be, so left it out for now. I'm surprised that anything in LLVM and clang is actually using canWrite(). It appears that there is one use, in clang, and that one looks pretty suspicious. Perhaps it can be removed altogether instead of ported to PathV2? Dan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/28eaaf97/attachment.html From baldrick at free.fr Wed Mar 2 14:30:37 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 02 Mar 2011 20:30:37 -0000 Subject: [llvm-commits] [llvm] r126871 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp Message-ID: <20110302203037.5F6412A6C12C@llvm.org> Author: baldrick Date: Wed Mar 2 14:30:37 2011 New Revision: 126871 URL: http://llvm.org/viewvc/llvm-project?rev=126871&view=rev Log: Remove DIFactory. Patch by Devang. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=126871&r1=126870&r2=126871&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Wed Mar 2 14:30:37 2011 @@ -666,214 +666,6 @@ bool Verify() const; }; - /// DIFactory - This object assists with the construction of the various - /// descriptors. - class DIFactory { - Module &M; - LLVMContext& VMContext; - - Function *DeclareFn; // llvm.dbg.declare - Function *ValueFn; // llvm.dbg.value - - DIFactory(const DIFactory &); // DO NOT IMPLEMENT - void operator=(const DIFactory&); // DO NOT IMPLEMENT - public: - enum ComplexAddrKind { OpPlus=1, OpDeref }; - - explicit DIFactory(Module &m); - - /// GetOrCreateArray - Create an descriptor for an array of descriptors. - /// This implicitly uniques the arrays created. - DIArray GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys); - - /// GetOrCreateSubrange - Create a descriptor for a value range. This - /// implicitly uniques the values returned. - DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi); - - /// CreateUnspecifiedParameter - Create unspeicified type descriptor - /// for a subroutine type. - DIDescriptor CreateUnspecifiedParameter(); - - /// CreateCompileUnit - Create a new descriptor for the specified compile - /// unit. - DICompileUnit CreateCompileUnit(unsigned LangID, - StringRef Filename, - StringRef Directory, - StringRef Producer, - bool isMain = false, - bool isOptimized = false, - StringRef Flags = "", - unsigned RunTimeVer = 0); - - /// CreateFile - Create a new descriptor for the specified file. - DIFile CreateFile(StringRef Filename, StringRef Directory, - DICompileUnit CU); - - /// CreateEnumerator - Create a single enumerator value. - DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val); - - /// CreateBasicType - Create a basic type like int, float, etc. - DIBasicType CreateBasicType(DIDescriptor Context, StringRef Name, - DIFile F, unsigned LineNumber, - uint64_t SizeInBits, uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, - unsigned Encoding); - - /// CreateBasicType - Create a basic type like int, float, etc. - DIBasicType CreateBasicTypeEx(DIDescriptor Context, StringRef Name, - DIFile F, unsigned LineNumber, - Constant *SizeInBits, Constant *AlignInBits, - Constant *OffsetInBits, unsigned Flags, - unsigned Encoding); - - /// CreateDerivedType - Create a derived type like const qualified type, - /// pointer, typedef, etc. - DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context, - StringRef Name, - DIFile F, - unsigned LineNumber, - uint64_t SizeInBits, uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, - DIType DerivedFrom); - - /// CreateDerivedType - Create a derived type like const qualified type, - /// pointer, typedef, etc. - DIDerivedType CreateDerivedTypeEx(unsigned Tag, DIDescriptor Context, - StringRef Name, - DIFile F, - unsigned LineNumber, - Constant *SizeInBits, - Constant *AlignInBits, - Constant *OffsetInBits, unsigned Flags, - DIType DerivedFrom); - - /// CreateCompositeType - Create a composite type like array, struct, etc. - DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context, - StringRef Name, - DIFile F, - unsigned LineNumber, - uint64_t SizeInBits, - uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, - DIType DerivedFrom, - DIArray Elements, - unsigned RunTimeLang = 0, - MDNode *ContainingType = 0); - - /// CreateTemporaryType - Create a temporary forward-declared type. - DIType CreateTemporaryType(); - DIType CreateTemporaryType(DIFile F); - - /// CreateArtificialType - Create a new DIType with "artificial" flag set. - DIType CreateArtificialType(DIType Ty); - - /// CreateCompositeType - Create a composite type like array, struct, etc. - DICompositeType CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context, - StringRef Name, - DIFile F, - unsigned LineNumber, - Constant *SizeInBits, - Constant *AlignInBits, - Constant *OffsetInBits, - unsigned Flags, - DIType DerivedFrom, - DIArray Elements, - unsigned RunTimeLang = 0, - MDNode *ContainingType = 0); - - /// CreateSubprogram - Create a new descriptor for the specified subprogram. - /// See comments in DISubprogram for descriptions of these fields. - DISubprogram CreateSubprogram(DIDescriptor Context, StringRef Name, - StringRef DisplayName, - StringRef LinkageName, - DIFile F, unsigned LineNo, - DIType Ty, bool isLocalToUnit, - bool isDefinition, - unsigned VK = 0, - unsigned VIndex = 0, - DIType ContainingType = DIType(), - unsigned Flags = 0, - bool isOptimized = false, - Function *Fn = 0); - - /// CreateSubprogramDefinition - Create new subprogram descriptor for the - /// given declaration. - DISubprogram CreateSubprogramDefinition(DISubprogram &SPDeclaration); - - /// CreateGlobalVariable - Create a new descriptor for the specified global. - DIGlobalVariable - CreateGlobalVariable(DIDescriptor Context, StringRef Name, - StringRef DisplayName, - StringRef LinkageName, - DIFile F, - unsigned LineNo, DIType Ty, bool isLocalToUnit, - bool isDefinition, llvm::GlobalVariable *GV); - - /// CreateGlobalVariable - Create a new descriptor for the specified constant. - DIGlobalVariable - CreateGlobalVariable(DIDescriptor Context, StringRef Name, - StringRef DisplayName, - StringRef LinkageName, - DIFile F, - unsigned LineNo, DIType Ty, bool isLocalToUnit, - bool isDefinition, llvm::Constant *C); - - /// CreateVariable - Create a new descriptor for the specified variable. - DIVariable CreateVariable(unsigned Tag, DIDescriptor Context, - StringRef Name, - DIFile F, unsigned LineNo, - DIType Ty, bool AlwaysPreserve = false, - unsigned Flags = 0); - - /// CreateComplexVariable - Create a new descriptor for the specified - /// variable which has a complex address expression for its address. - DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Context, - StringRef Name, DIFile F, unsigned LineNo, - DIType Ty, Value *const *Addr, - unsigned NumAddr); - - /// CreateLexicalBlock - This creates a descriptor for a lexical block - /// with the specified parent context. - DILexicalBlock CreateLexicalBlock(DIDescriptor Context, DIFile F, - unsigned Line = 0, unsigned Col = 0); - - /// CreateNameSpace - This creates new descriptor for a namespace - /// with the specified parent context. - DINameSpace CreateNameSpace(DIDescriptor Context, StringRef Name, - DIFile F, unsigned LineNo); - - /// CreateLocation - Creates a debug info location. - DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo, - DIScope S, DILocation OrigLoc); - - /// CreateLocation - Creates a debug info location. - DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo, - DIScope S, MDNode *OrigLoc = 0); - - /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. - Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D, - BasicBlock *InsertAtEnd); - - /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. - Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D, - Instruction *InsertBefore); - - /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. - Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset, - DIVariable D, BasicBlock *InsertAtEnd); - - /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. - Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset, - DIVariable D, Instruction *InsertBefore); - - // RecordType - Record DIType in a module such that it is not lost even if - // it is not referenced through debug info anchors. - void RecordType(DIType T); - - private: - Constant *GetTagConstant(unsigned TAG); - }; - /// getDISubprogram - Find subprogram that is enclosing this scope. DISubprogram getDISubprogram(const MDNode *Scope); Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=126871&r1=126870&r2=126871&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Wed Mar 2 14:30:37 2011 @@ -725,484 +725,6 @@ print(dbgs()); dbgs() << '\n'; } -//===----------------------------------------------------------------------===// -// DIFactory: Basic Helpers -//===----------------------------------------------------------------------===// - -DIFactory::DIFactory(Module &m) - : M(m), VMContext(M.getContext()), DeclareFn(0), ValueFn(0) {} - -Constant *DIFactory::GetTagConstant(unsigned TAG) { - assert((TAG & LLVMDebugVersionMask) == 0 && - "Tag too large for debug encoding!"); - return ConstantInt::get(Type::getInt32Ty(VMContext), TAG | LLVMDebugVersion); -} - -//===----------------------------------------------------------------------===// -// DIFactory: Primary Constructors -//===----------------------------------------------------------------------===// - -/// GetOrCreateArray - Create an descriptor for an array of descriptors. -/// This implicitly uniques the arrays created. -DIArray DIFactory::GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys) { - if (NumTys == 0) { - Value *Null = llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)); - return DIArray(MDNode::get(VMContext, &Null, 1)); - } - - SmallVector Elts(Tys, Tys+NumTys); - return DIArray(MDNode::get(VMContext, Elts.data(), Elts.size())); -} - -/// GetOrCreateSubrange - Create a descriptor for a value range. This -/// implicitly uniques the values returned. -DISubrange DIFactory::GetOrCreateSubrange(int64_t Lo, int64_t Hi) { - Value *Elts[] = { - GetTagConstant(dwarf::DW_TAG_subrange_type), - ConstantInt::get(Type::getInt64Ty(VMContext), Lo), - ConstantInt::get(Type::getInt64Ty(VMContext), Hi) - }; - - return DISubrange(MDNode::get(VMContext, &Elts[0], 3)); -} - -/// CreateUnspecifiedParameter - Create unspeicified type descriptor -/// for the subroutine type. -DIDescriptor DIFactory::CreateUnspecifiedParameter() { - Value *Elts[] = { - GetTagConstant(dwarf::DW_TAG_unspecified_parameters) - }; - return DIDescriptor(MDNode::get(VMContext, &Elts[0], 1)); -} - -/// CreateCompileUnit - Create a new descriptor for the specified compile -/// unit. Note that this does not unique compile units within the module. -DICompileUnit DIFactory::CreateCompileUnit(unsigned LangID, - StringRef Filename, - StringRef Directory, - StringRef Producer, - bool isMain, - bool isOptimized, - StringRef Flags, - unsigned RunTimeVer) { - Value *Elts[] = { - GetTagConstant(dwarf::DW_TAG_compile_unit), - llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), - ConstantInt::get(Type::getInt32Ty(VMContext), LangID), - MDString::get(VMContext, Filename), - MDString::get(VMContext, Directory), - MDString::get(VMContext, Producer), - ConstantInt::get(Type::getInt1Ty(VMContext), isMain), - ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized), - MDString::get(VMContext, Flags), - ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeVer) - }; - - return DICompileUnit(MDNode::get(VMContext, &Elts[0], 10)); -} - -/// CreateFile - Create a new descriptor for the specified file. -DIFile DIFactory::CreateFile(StringRef Filename, - StringRef Directory, - DICompileUnit CU) { - Value *Elts[] = { - GetTagConstant(dwarf::DW_TAG_file_type), - MDString::get(VMContext, Filename), - MDString::get(VMContext, Directory), - CU - }; - - return DIFile(MDNode::get(VMContext, &Elts[0], 4)); -} - -/// CreateEnumerator - Create a single enumerator value. -DIEnumerator DIFactory::CreateEnumerator(StringRef Name, uint64_t Val){ - Value *Elts[] = { - GetTagConstant(dwarf::DW_TAG_enumerator), - MDString::get(VMContext, Name), - ConstantInt::get(Type::getInt64Ty(VMContext), Val) - }; - return DIEnumerator(MDNode::get(VMContext, &Elts[0], 3)); -} - - -/// CreateBasicType - Create a basic type like int, float, etc. -DIBasicType DIFactory::CreateBasicType(DIDescriptor Context, - StringRef Name, - DIFile F, - unsigned LineNumber, - uint64_t SizeInBits, - uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, - unsigned Encoding) { - Value *Elts[] = { - GetTagConstant(dwarf::DW_TAG_base_type), - Context, - MDString::get(VMContext, Name), - F, - ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), - ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), - ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), - ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits), - ConstantInt::get(Type::getInt32Ty(VMContext), Flags), - ConstantInt::get(Type::getInt32Ty(VMContext), Encoding) - }; - return DIBasicType(MDNode::get(VMContext, &Elts[0], 10)); -} - - -/// CreateBasicType - Create a basic type like int, float, etc. -DIBasicType DIFactory::CreateBasicTypeEx(DIDescriptor Context, - StringRef Name, - DIFile F, - unsigned LineNumber, - Constant *SizeInBits, - Constant *AlignInBits, - Constant *OffsetInBits, unsigned Flags, - unsigned Encoding) { - Value *Elts[] = { - GetTagConstant(dwarf::DW_TAG_base_type), - Context, - MDString::get(VMContext, Name), - F, - ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), - SizeInBits, - AlignInBits, - OffsetInBits, - ConstantInt::get(Type::getInt32Ty(VMContext), Flags), - ConstantInt::get(Type::getInt32Ty(VMContext), Encoding) - }; - return DIBasicType(MDNode::get(VMContext, &Elts[0], 10)); -} - -/// CreateArtificialType - Create a new DIType with "artificial" flag set. -DIType DIFactory::CreateArtificialType(DIType Ty) { - if (Ty.isArtificial()) - return Ty; - - SmallVector Elts; - MDNode *N = Ty; - assert (N && "Unexpected input DIType!"); - for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { - if (Value *V = N->getOperand(i)) - Elts.push_back(V); - else - Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext))); - } - - unsigned CurFlags = Ty.getFlags(); - CurFlags = CurFlags | DIType::FlagArtificial; - - // Flags are stored at this slot. - Elts[8] = ConstantInt::get(Type::getInt32Ty(VMContext), CurFlags); - - return DIType(MDNode::get(VMContext, Elts.data(), Elts.size())); -} - -/// CreateDerivedType - Create a derived type like const qualified type, -/// pointer, typedef, etc. -DIDerivedType DIFactory::CreateDerivedType(unsigned Tag, - DIDescriptor Context, - StringRef Name, - DIFile F, - unsigned LineNumber, - uint64_t SizeInBits, - uint64_t AlignInBits, - uint64_t OffsetInBits, - unsigned Flags, - DIType DerivedFrom) { - Value *Elts[] = { - GetTagConstant(Tag), - Context, - MDString::get(VMContext, Name), - F, - ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), - ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), - ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), - ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits), - ConstantInt::get(Type::getInt32Ty(VMContext), Flags), - DerivedFrom, - }; - return DIDerivedType(MDNode::get(VMContext, &Elts[0], 10)); -} - - -/// CreateDerivedType - Create a derived type like const qualified type, -/// pointer, typedef, etc. -DIDerivedType DIFactory::CreateDerivedTypeEx(unsigned Tag, - DIDescriptor Context, - StringRef Name, - DIFile F, - unsigned LineNumber, - Constant *SizeInBits, - Constant *AlignInBits, - Constant *OffsetInBits, - unsigned Flags, - DIType DerivedFrom) { - Value *Elts[] = { - GetTagConstant(Tag), - Context, - MDString::get(VMContext, Name), - F, - ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), - SizeInBits, - AlignInBits, - OffsetInBits, - ConstantInt::get(Type::getInt32Ty(VMContext), Flags), - DerivedFrom, - }; - return DIDerivedType(MDNode::get(VMContext, &Elts[0], 10)); -} - - -/// CreateCompositeType - Create a composite type like array, struct, etc. -DICompositeType DIFactory::CreateCompositeType(unsigned Tag, - DIDescriptor Context, - StringRef Name, - DIFile F, - unsigned LineNumber, - uint64_t SizeInBits, - uint64_t AlignInBits, - uint64_t OffsetInBits, - unsigned Flags, - DIType DerivedFrom, - DIArray Elements, - unsigned RuntimeLang, - MDNode *ContainingType) { - - Value *Elts[] = { - GetTagConstant(Tag), - Context, - MDString::get(VMContext, Name), - F, - ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), - ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), - ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), - ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits), - ConstantInt::get(Type::getInt32Ty(VMContext), Flags), - DerivedFrom, - Elements, - ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang), - ContainingType - }; - - MDNode *Node = MDNode::get(VMContext, &Elts[0], 13); - // Create a named metadata so that we do not lose this enum info. - if (Tag == dwarf::DW_TAG_enumeration_type) { - NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.enum"); - NMD->addOperand(Node); - } - return DICompositeType(Node); -} - -/// CreateTemporaryType - Create a temporary forward-declared type. -DIType DIFactory::CreateTemporaryType() { - // Give the temporary MDNode a tag. It doesn't matter what tag we - // use here as long as DIType accepts it. - Value *Elts[] = { - GetTagConstant(DW_TAG_base_type) - }; - MDNode *Node = MDNode::getTemporary(VMContext, Elts, array_lengthof(Elts)); - return DIType(Node); -} - -/// CreateTemporaryType - Create a temporary forward-declared type. -DIType DIFactory::CreateTemporaryType(DIFile F) { - // Give the temporary MDNode a tag. It doesn't matter what tag we - // use here as long as DIType accepts it. - Value *Elts[] = { - GetTagConstant(DW_TAG_base_type), - F.getCompileUnit(), - NULL, - F - }; - MDNode *Node = MDNode::getTemporary(VMContext, Elts, array_lengthof(Elts)); - return DIType(Node); -} - -/// CreateCompositeType - Create a composite type like array, struct, etc. -DICompositeType DIFactory::CreateCompositeTypeEx(unsigned Tag, - DIDescriptor Context, - StringRef Name, - DIFile F, - unsigned LineNumber, - Constant *SizeInBits, - Constant *AlignInBits, - Constant *OffsetInBits, - unsigned Flags, - DIType DerivedFrom, - DIArray Elements, - unsigned RuntimeLang, - MDNode *ContainingType) { - Value *Elts[] = { - GetTagConstant(Tag), - Context, - MDString::get(VMContext, Name), - F, - ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), - SizeInBits, - AlignInBits, - OffsetInBits, - ConstantInt::get(Type::getInt32Ty(VMContext), Flags), - DerivedFrom, - Elements, - ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang), - ContainingType - }; - MDNode *Node = MDNode::get(VMContext, &Elts[0], 13); - // Create a named metadata so that we do not lose this enum info. - if (Tag == dwarf::DW_TAG_enumeration_type) { - NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.enum"); - NMD->addOperand(Node); - } - return DICompositeType(Node); -} - - -/// CreateSubprogram - Create a new descriptor for the specified subprogram. -/// See comments in DISubprogram for descriptions of these fields. This -/// method does not unique the generated descriptors. -DISubprogram DIFactory::CreateSubprogram(DIDescriptor Context, - StringRef Name, - StringRef DisplayName, - StringRef LinkageName, - DIFile F, - unsigned LineNo, DIType Ty, - bool isLocalToUnit, - bool isDefinition, - unsigned VK, unsigned VIndex, - DIType ContainingType, - unsigned Flags, - bool isOptimized, - Function *Fn) { - - Value *Elts[] = { - GetTagConstant(dwarf::DW_TAG_subprogram), - llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), - Context, - MDString::get(VMContext, Name), - MDString::get(VMContext, DisplayName), - MDString::get(VMContext, LinkageName), - F, - ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), - Ty, - ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit), - ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition), - ConstantInt::get(Type::getInt32Ty(VMContext), (unsigned)VK), - ConstantInt::get(Type::getInt32Ty(VMContext), VIndex), - ContainingType, - ConstantInt::get(Type::getInt32Ty(VMContext), Flags), - ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized), - Fn - }; - MDNode *Node = MDNode::get(VMContext, &Elts[0], 17); - - // Create a named metadata so that we do not lose this mdnode. - NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.sp"); - NMD->addOperand(Node); - return DISubprogram(Node); -} - -/// CreateSubprogramDefinition - Create new subprogram descriptor for the -/// given declaration. -DISubprogram DIFactory::CreateSubprogramDefinition(DISubprogram &SPDeclaration){ - if (SPDeclaration.isDefinition()) - return DISubprogram(SPDeclaration); - - MDNode *DeclNode = SPDeclaration; - Value *Elts[] = { - GetTagConstant(dwarf::DW_TAG_subprogram), - llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), - DeclNode->getOperand(2), // Context - DeclNode->getOperand(3), // Name - DeclNode->getOperand(4), // DisplayName - DeclNode->getOperand(5), // LinkageName - DeclNode->getOperand(6), // CompileUnit - DeclNode->getOperand(7), // LineNo - DeclNode->getOperand(8), // Type - DeclNode->getOperand(9), // isLocalToUnit - ConstantInt::get(Type::getInt1Ty(VMContext), true), - DeclNode->getOperand(11), // Virtuality - DeclNode->getOperand(12), // VIndex - DeclNode->getOperand(13), // Containting Type - DeclNode->getOperand(14), // Flags - DeclNode->getOperand(15), // isOptimized - SPDeclaration.getFunction() - }; - MDNode *Node =MDNode::get(VMContext, &Elts[0], 16); - - // Create a named metadata so that we do not lose this mdnode. - NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.sp"); - NMD->addOperand(Node); - return DISubprogram(Node); -} - -/// CreateGlobalVariable - Create a new descriptor for the specified global. -DIGlobalVariable -DIFactory::CreateGlobalVariable(DIDescriptor Context, StringRef Name, - StringRef DisplayName, - StringRef LinkageName, - DIFile F, - unsigned LineNo, DIType Ty,bool isLocalToUnit, - bool isDefinition, llvm::GlobalVariable *Val) { - Value *Elts[] = { - GetTagConstant(dwarf::DW_TAG_variable), - llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), - Context, - MDString::get(VMContext, Name), - MDString::get(VMContext, DisplayName), - MDString::get(VMContext, LinkageName), - F, - ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), - Ty, - ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit), - ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition), - Val - }; - - Value *const *Vs = &Elts[0]; - MDNode *Node = MDNode::get(VMContext,Vs, 12); - - // Create a named metadata so that we do not lose this mdnode. - NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv"); - NMD->addOperand(Node); - - return DIGlobalVariable(Node); -} - -/// CreateGlobalVariable - Create a new descriptor for the specified constant. -DIGlobalVariable -DIFactory::CreateGlobalVariable(DIDescriptor Context, StringRef Name, - StringRef DisplayName, - StringRef LinkageName, - DIFile F, - unsigned LineNo, DIType Ty,bool isLocalToUnit, - bool isDefinition, llvm::Constant *Val) { - Value *Elts[] = { - GetTagConstant(dwarf::DW_TAG_variable), - llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), - Context, - MDString::get(VMContext, Name), - MDString::get(VMContext, DisplayName), - MDString::get(VMContext, LinkageName), - F, - ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), - Ty, - ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit), - ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition), - Val - }; - - Value *const *Vs = &Elts[0]; - MDNode *Node = MDNode::get(VMContext,Vs, 12); - - // Create a named metadata so that we do not lose this mdnode. - NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv"); - NMD->addOperand(Node); - - return DIGlobalVariable(Node); -} - /// fixupObjcLikeName - Replace contains special characters used /// in a typical Objective-C names with '.' in a given string. static void fixupObjcLikeName(std::string &Str) { @@ -1214,19 +736,6 @@ } } -/// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable -/// to hold function specific information. -NamedMDNode *llvm::getOrInsertFnSpecificMDNode(Module &M, StringRef FuncName) { - SmallString<32> Out; - if (FuncName.find('[') == StringRef::npos) - return M.getOrInsertNamedMetadata(Twine("llvm.dbg.lv.", FuncName) - .toStringRef(Out)); - std::string Name = FuncName; - fixupObjcLikeName(Name); - return M.getOrInsertNamedMetadata(Twine("llvm.dbg.lv.", Name) - .toStringRef(Out)); -} - /// getFnSpecificMDNode - Return a NameMDNode, if available, that is /// suitable to hold function specific information. NamedMDNode *llvm::getFnSpecificMDNode(const Module &M, StringRef FuncName) { @@ -1237,178 +746,18 @@ return M.getNamedMetadata(Twine("llvm.dbg.lv.", Name)); } -/// CreateVariable - Create a new descriptor for the specified variable. -DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context, - StringRef Name, - DIFile F, - unsigned LineNo, - DIType Ty, bool AlwaysPreserve, - unsigned Flags) { - Value *Elts[] = { - GetTagConstant(Tag), - Context, - MDString::get(VMContext, Name), - F, - ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), - Ty, - ConstantInt::get(Type::getInt32Ty(VMContext), Flags) - }; - MDNode *Node = MDNode::get(VMContext, &Elts[0], 7); - if (AlwaysPreserve) { - // The optimizer may remove local variable. If there is an interest - // to preserve variable info in such situation then stash it in a - // named mdnode. - DISubprogram Fn(getDISubprogram(Context)); - StringRef FName = "fn"; - if (Fn.getFunction()) - FName = Fn.getFunction()->getName(); - char One = '\1'; - if (FName.startswith(StringRef(&One, 1))) - FName = FName.substr(1); - - - NamedMDNode *FnLocals = getOrInsertFnSpecificMDNode(M, FName); - FnLocals->addOperand(Node); - } - return DIVariable(Node); -} - - -/// CreateComplexVariable - Create a new descriptor for the specified variable -/// which has a complex address expression for its address. -DIVariable DIFactory::CreateComplexVariable(unsigned Tag, DIDescriptor Context, - StringRef Name, DIFile F, - unsigned LineNo, - DIType Ty, Value *const *Addr, - unsigned NumAddr) { - SmallVector Elts; - Elts.push_back(GetTagConstant(Tag)); - Elts.push_back(Context); - Elts.push_back(MDString::get(VMContext, Name)); - Elts.push_back(F); - Elts.push_back(ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)); - Elts.push_back(Ty); - Elts.append(Addr, Addr+NumAddr); - - return DIVariable(MDNode::get(VMContext, Elts.data(), Elts.size())); -} - - -/// CreateBlock - This creates a descriptor for a lexical block with the -/// specified parent VMContext. -DILexicalBlock DIFactory::CreateLexicalBlock(DIDescriptor Context, - DIFile F, unsigned LineNo, - unsigned Col) { - // Defeat MDNode uniqing for lexical blocks. - static unsigned int unique_id = 0; - Value *Elts[] = { - GetTagConstant(dwarf::DW_TAG_lexical_block), - Context, - ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), - ConstantInt::get(Type::getInt32Ty(VMContext), Col), - F, - ConstantInt::get(Type::getInt32Ty(VMContext), unique_id++) - }; - return DILexicalBlock(MDNode::get(VMContext, &Elts[0], 6)); -} - -/// CreateNameSpace - This creates new descriptor for a namespace -/// with the specified parent context. -DINameSpace DIFactory::CreateNameSpace(DIDescriptor Context, StringRef Name, - DIFile F, - unsigned LineNo) { - Value *Elts[] = { - GetTagConstant(dwarf::DW_TAG_namespace), - Context, - MDString::get(VMContext, Name), - F, - ConstantInt::get(Type::getInt32Ty(VMContext), LineNo) - }; - return DINameSpace(MDNode::get(VMContext, &Elts[0], 5)); -} - -/// CreateLocation - Creates a debug info location. -DILocation DIFactory::CreateLocation(unsigned LineNo, unsigned ColumnNo, - DIScope S, DILocation OrigLoc) { - Value *Elts[] = { - ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), - ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo), - S, - OrigLoc, - }; - return DILocation(MDNode::get(VMContext, &Elts[0], 4)); -} - -//===----------------------------------------------------------------------===// -// DIFactory: Routines for inserting code into a function -//===----------------------------------------------------------------------===// - -/// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. -Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, - Instruction *InsertBefore) { - assert(Storage && "no storage passed to dbg.declare"); - assert(D.Verify() && "empty DIVariable passed to dbg.declare"); - if (!DeclareFn) - DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); - - Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1), - D }; - return CallInst::Create(DeclareFn, Args, Args+2, "", InsertBefore); -} - -/// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. -Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, - BasicBlock *InsertAtEnd) { - assert(Storage && "no storage passed to dbg.declare"); - assert(D.Verify() && "invalid DIVariable passed to dbg.declare"); - if (!DeclareFn) - DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); - - Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1), - D }; - - // If this block already has a terminator then insert this intrinsic - // before the terminator. - if (TerminatorInst *T = InsertAtEnd->getTerminator()) - return CallInst::Create(DeclareFn, Args, Args+2, "", T); - else - return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd);} - -/// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. -Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, uint64_t Offset, - DIVariable D, - Instruction *InsertBefore) { - assert(V && "no value passed to dbg.value"); - assert(D.Verify() && "invalid DIVariable passed to dbg.value"); - if (!ValueFn) - ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value); - - Value *Args[] = { MDNode::get(V->getContext(), &V, 1), - ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset), - D }; - return CallInst::Create(ValueFn, Args, Args+3, "", InsertBefore); -} - -/// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. -Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, uint64_t Offset, - DIVariable D, - BasicBlock *InsertAtEnd) { - assert(V && "no value passed to dbg.value"); - assert(D.Verify() && "invalid DIVariable passed to dbg.value"); - if (!ValueFn) - ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value); - - Value *Args[] = { MDNode::get(V->getContext(), &V, 1), - ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset), - D }; - return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd); -} - -// RecordType - Record DIType in a module such that it is not lost even if -// it is not referenced through debug info anchors. -void DIFactory::RecordType(DIType T) { - NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.ty"); - NMD->addOperand(T); +/// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable +/// to hold function specific information. +NamedMDNode *llvm::getOrInsertFnSpecificMDNode(Module &M, StringRef FuncName) { + SmallString<32> Out; + if (FuncName.find('[') == StringRef::npos) + return M.getOrInsertNamedMetadata(Twine("llvm.dbg.lv.", FuncName) + .toStringRef(Out)); + + std::string Name = FuncName; + fixupObjcLikeName(Name); + return M.getOrInsertNamedMetadata(Twine("llvm.dbg.lv.", Name) + .toStringRef(Out)); } From baldrick at free.fr Wed Mar 2 14:30:39 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 02 Mar 2011 20:30:39 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r126872 - in /llvm-gcc-4.2/trunk/gcc: llvm-debug.cpp llvm-debug.h llvm-linker-hack.cpp Message-ID: <20110302203039.A4C3F2A6C12D@llvm.org> Author: baldrick Date: Wed Mar 2 14:30:39 2011 New Revision: 126872 URL: http://llvm.org/viewvc/llvm-project?rev=126872&view=rev Log: DIFactory has been removed from the LLVM core. Put a copy of it here so that llvm-gcc continues to work. Patch by Devang. Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp llvm-gcc-4.2/trunk/gcc/llvm-debug.h llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=126872&r1=126871&r2=126872&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Wed Mar 2 14:30:39 2011 @@ -36,6 +36,7 @@ #include "llvm/Support/Dwarf.h" #include "llvm/Target/TargetMachine.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" extern "C" { @@ -1457,4 +1458,656 @@ return DebugFactory.CreateFile(FileName, Directory, TheCU); } +//===----------------------------------------------------------------------===// +// DIFactory: Basic Helpers +//===----------------------------------------------------------------------===// + +DIFactory::DIFactory(Module &m) + : M(m), VMContext(M.getContext()), DeclareFn(0), ValueFn(0) {} + +Constant *DIFactory::GetTagConstant(unsigned TAG) { + assert((TAG & LLVMDebugVersionMask) == 0 && + "Tag too large for debug encoding!"); + return ConstantInt::get(Type::getInt32Ty(VMContext), TAG | LLVMDebugVersion); +} + +//===----------------------------------------------------------------------===// +// DIFactory: Primary Constructors +//===----------------------------------------------------------------------===// + +/// GetOrCreateArray - Create an descriptor for an array of descriptors. +/// This implicitly uniques the arrays created. +DIArray DIFactory::GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys) { + if (NumTys == 0) { + Value *Null = llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)); + return DIArray(MDNode::get(VMContext, &Null, 1)); + } + + SmallVector Elts(Tys, Tys+NumTys); + return DIArray(MDNode::get(VMContext, Elts.data(), Elts.size())); +} + +/// GetOrCreateSubrange - Create a descriptor for a value range. This +/// implicitly uniques the values returned. +DISubrange DIFactory::GetOrCreateSubrange(int64_t Lo, int64_t Hi) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_subrange_type), + ConstantInt::get(Type::getInt64Ty(VMContext), Lo), + ConstantInt::get(Type::getInt64Ty(VMContext), Hi) + }; + + return DISubrange(MDNode::get(VMContext, &Elts[0], 3)); +} + +/// CreateUnspecifiedParameter - Create unspeicified type descriptor +/// for the subroutine type. +DIDescriptor DIFactory::CreateUnspecifiedParameter() { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_unspecified_parameters) + }; + return DIDescriptor(MDNode::get(VMContext, &Elts[0], 1)); +} + +/// CreateCompileUnit - Create a new descriptor for the specified compile +/// unit. Note that this does not unique compile units within the module. +DICompileUnit DIFactory::CreateCompileUnit(unsigned LangID, + StringRef Filename, + StringRef Directory, + StringRef Producer, + bool isMain, + bool isOptimized, + StringRef Flags, + unsigned RunTimeVer) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_compile_unit), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + ConstantInt::get(Type::getInt32Ty(VMContext), LangID), + MDString::get(VMContext, Filename), + MDString::get(VMContext, Directory), + MDString::get(VMContext, Producer), + ConstantInt::get(Type::getInt1Ty(VMContext), isMain), + ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized), + MDString::get(VMContext, Flags), + ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeVer) + }; + + return DICompileUnit(MDNode::get(VMContext, &Elts[0], 10)); +} + +/// CreateFile - Create a new descriptor for the specified file. +DIFile DIFactory::CreateFile(StringRef Filename, + StringRef Directory, + DICompileUnit CU) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_file_type), + MDString::get(VMContext, Filename), + MDString::get(VMContext, Directory), + CU + }; + + return DIFile(MDNode::get(VMContext, &Elts[0], 4)); +} + +/// CreateEnumerator - Create a single enumerator value. +DIEnumerator DIFactory::CreateEnumerator(StringRef Name, uint64_t Val){ + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_enumerator), + MDString::get(VMContext, Name), + ConstantInt::get(Type::getInt64Ty(VMContext), Val) + }; + return DIEnumerator(MDNode::get(VMContext, &Elts[0], 3)); +} + + +/// CreateBasicType - Create a basic type like int, float, etc. +DIBasicType DIFactory::CreateBasicType(DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + uint64_t SizeInBits, + uint64_t AlignInBits, + uint64_t OffsetInBits, unsigned Flags, + unsigned Encoding) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_base_type), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits), + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + ConstantInt::get(Type::getInt32Ty(VMContext), Encoding) + }; + return DIBasicType(MDNode::get(VMContext, &Elts[0], 10)); +} + + +/// CreateBasicType - Create a basic type like int, float, etc. +DIBasicType DIFactory::CreateBasicTypeEx(DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + Constant *SizeInBits, + Constant *AlignInBits, + Constant *OffsetInBits, unsigned Flags, + unsigned Encoding) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_base_type), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + SizeInBits, + AlignInBits, + OffsetInBits, + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + ConstantInt::get(Type::getInt32Ty(VMContext), Encoding) + }; + return DIBasicType(MDNode::get(VMContext, &Elts[0], 10)); +} + +/// CreateArtificialType - Create a new DIType with "artificial" flag set. +DIType DIFactory::CreateArtificialType(DIType Ty) { + if (Ty.isArtificial()) + return Ty; + + SmallVector Elts; + MDNode *N = Ty; + assert (N && "Unexpected input DIType!"); + for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { + if (Value *V = N->getOperand(i)) + Elts.push_back(V); + else + Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext))); + } + + unsigned CurFlags = Ty.getFlags(); + CurFlags = CurFlags | DIType::FlagArtificial; + + // Flags are stored at this slot. + Elts[8] = ConstantInt::get(Type::getInt32Ty(VMContext), CurFlags); + + return DIType(MDNode::get(VMContext, Elts.data(), Elts.size())); +} + +/// CreateDerivedType - Create a derived type like const qualified type, +/// pointer, typedef, etc. +DIDerivedType DIFactory::CreateDerivedType(unsigned Tag, + DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + uint64_t SizeInBits, + uint64_t AlignInBits, + uint64_t OffsetInBits, + unsigned Flags, + DIType DerivedFrom) { + Value *Elts[] = { + GetTagConstant(Tag), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits), + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + DerivedFrom, + }; + return DIDerivedType(MDNode::get(VMContext, &Elts[0], 10)); +} + + +/// CreateDerivedType - Create a derived type like const qualified type, +/// pointer, typedef, etc. +DIDerivedType DIFactory::CreateDerivedTypeEx(unsigned Tag, + DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + Constant *SizeInBits, + Constant *AlignInBits, + Constant *OffsetInBits, + unsigned Flags, + DIType DerivedFrom) { + Value *Elts[] = { + GetTagConstant(Tag), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + SizeInBits, + AlignInBits, + OffsetInBits, + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + DerivedFrom, + }; + return DIDerivedType(MDNode::get(VMContext, &Elts[0], 10)); +} + + +/// CreateCompositeType - Create a composite type like array, struct, etc. +DICompositeType DIFactory::CreateCompositeType(unsigned Tag, + DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + uint64_t SizeInBits, + uint64_t AlignInBits, + uint64_t OffsetInBits, + unsigned Flags, + DIType DerivedFrom, + DIArray Elements, + unsigned RuntimeLang, + MDNode *ContainingType) { + + Value *Elts[] = { + GetTagConstant(Tag), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits), + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + DerivedFrom, + Elements, + ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang), + ContainingType + }; + + MDNode *Node = MDNode::get(VMContext, &Elts[0], 13); + // Create a named metadata so that we do not lose this enum info. + if (Tag == dwarf::DW_TAG_enumeration_type) { + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.enum"); + NMD->addOperand(Node); + } + return DICompositeType(Node); +} + +/// CreateTemporaryType - Create a temporary forward-declared type. +DIType DIFactory::CreateTemporaryType() { + // Give the temporary MDNode a tag. It doesn't matter what tag we + // use here as long as DIType accepts it. + Value *Elts[] = { + GetTagConstant(DW_TAG_base_type) + }; + MDNode *Node = MDNode::getTemporary(VMContext, Elts, array_lengthof(Elts)); + return DIType(Node); +} + +/// CreateTemporaryType - Create a temporary forward-declared type. +DIType DIFactory::CreateTemporaryType(DIFile F) { + // Give the temporary MDNode a tag. It doesn't matter what tag we + // use here as long as DIType accepts it. + Value *Elts[] = { + GetTagConstant(DW_TAG_base_type), + F.getCompileUnit(), + NULL, + F + }; + MDNode *Node = MDNode::getTemporary(VMContext, Elts, array_lengthof(Elts)); + return DIType(Node); +} + +/// CreateCompositeType - Create a composite type like array, struct, etc. +DICompositeType DIFactory::CreateCompositeTypeEx(unsigned Tag, + DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + Constant *SizeInBits, + Constant *AlignInBits, + Constant *OffsetInBits, + unsigned Flags, + DIType DerivedFrom, + DIArray Elements, + unsigned RuntimeLang, + MDNode *ContainingType) { + Value *Elts[] = { + GetTagConstant(Tag), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + SizeInBits, + AlignInBits, + OffsetInBits, + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + DerivedFrom, + Elements, + ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang), + ContainingType + }; + MDNode *Node = MDNode::get(VMContext, &Elts[0], 13); + // Create a named metadata so that we do not lose this enum info. + if (Tag == dwarf::DW_TAG_enumeration_type) { + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.enum"); + NMD->addOperand(Node); + } + return DICompositeType(Node); +} + + +/// CreateSubprogram - Create a new descriptor for the specified subprogram. +/// See comments in DISubprogram for descriptions of these fields. This +/// method does not unique the generated descriptors. +DISubprogram DIFactory::CreateSubprogram(DIDescriptor Context, + StringRef Name, + StringRef DisplayName, + StringRef LinkageName, + DIFile F, + unsigned LineNo, DIType Ty, + bool isLocalToUnit, + bool isDefinition, + unsigned VK, unsigned VIndex, + DIType ContainingType, + unsigned Flags, + bool isOptimized, + Function *Fn) { + + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_subprogram), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + Context, + MDString::get(VMContext, Name), + MDString::get(VMContext, DisplayName), + MDString::get(VMContext, LinkageName), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + Ty, + ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit), + ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition), + ConstantInt::get(Type::getInt32Ty(VMContext), (unsigned)VK), + ConstantInt::get(Type::getInt32Ty(VMContext), VIndex), + ContainingType, + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized), + Fn + }; + MDNode *Node = MDNode::get(VMContext, &Elts[0], 17); + + // Create a named metadata so that we do not lose this mdnode. + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.sp"); + NMD->addOperand(Node); + return DISubprogram(Node); +} + +/// CreateSubprogramDefinition - Create new subprogram descriptor for the +/// given declaration. +DISubprogram DIFactory::CreateSubprogramDefinition(DISubprogram &SPDeclaration){ + if (SPDeclaration.isDefinition()) + return DISubprogram(SPDeclaration); + + MDNode *DeclNode = SPDeclaration; + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_subprogram), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + DeclNode->getOperand(2), // Context + DeclNode->getOperand(3), // Name + DeclNode->getOperand(4), // DisplayName + DeclNode->getOperand(5), // LinkageName + DeclNode->getOperand(6), // CompileUnit + DeclNode->getOperand(7), // LineNo + DeclNode->getOperand(8), // Type + DeclNode->getOperand(9), // isLocalToUnit + ConstantInt::get(Type::getInt1Ty(VMContext), true), + DeclNode->getOperand(11), // Virtuality + DeclNode->getOperand(12), // VIndex + DeclNode->getOperand(13), // Containting Type + DeclNode->getOperand(14), // Flags + DeclNode->getOperand(15), // isOptimized + SPDeclaration.getFunction() + }; + MDNode *Node =MDNode::get(VMContext, &Elts[0], 16); + + // Create a named metadata so that we do not lose this mdnode. + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.sp"); + NMD->addOperand(Node); + return DISubprogram(Node); +} + +/// CreateGlobalVariable - Create a new descriptor for the specified global. +DIGlobalVariable +DIFactory::CreateGlobalVariable(DIDescriptor Context, StringRef Name, + StringRef DisplayName, + StringRef LinkageName, + DIFile F, + unsigned LineNo, DIType Ty,bool isLocalToUnit, + bool isDefinition, llvm::GlobalVariable *Val) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_variable), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + Context, + MDString::get(VMContext, Name), + MDString::get(VMContext, DisplayName), + MDString::get(VMContext, LinkageName), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + Ty, + ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit), + ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition), + Val + }; + + Value *const *Vs = &Elts[0]; + MDNode *Node = MDNode::get(VMContext,Vs, 12); + + // Create a named metadata so that we do not lose this mdnode. + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv"); + NMD->addOperand(Node); + + return DIGlobalVariable(Node); +} + +/// CreateGlobalVariable - Create a new descriptor for the specified constant. +DIGlobalVariable +DIFactory::CreateGlobalVariable(DIDescriptor Context, StringRef Name, + StringRef DisplayName, + StringRef LinkageName, + DIFile F, + unsigned LineNo, DIType Ty,bool isLocalToUnit, + bool isDefinition, llvm::Constant *Val) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_variable), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + Context, + MDString::get(VMContext, Name), + MDString::get(VMContext, DisplayName), + MDString::get(VMContext, LinkageName), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + Ty, + ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit), + ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition), + Val + }; + + Value *const *Vs = &Elts[0]; + MDNode *Node = MDNode::get(VMContext,Vs, 12); + + // Create a named metadata so that we do not lose this mdnode. + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv"); + NMD->addOperand(Node); + + return DIGlobalVariable(Node); +} + +/// CreateVariable - Create a new descriptor for the specified variable. +DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNo, + DIType Ty, bool AlwaysPreserve, + unsigned Flags) { + Value *Elts[] = { + GetTagConstant(Tag), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + Ty, + ConstantInt::get(Type::getInt32Ty(VMContext), Flags) + }; + MDNode *Node = MDNode::get(VMContext, &Elts[0], 7); + if (AlwaysPreserve) { + // The optimizer may remove local variable. If there is an interest + // to preserve variable info in such situation then stash it in a + // named mdnode. + DISubprogram Fn(getDISubprogram(Context)); + StringRef FName = "fn"; + if (Fn.getFunction()) + FName = Fn.getFunction()->getName(); + char One = '\1'; + if (FName.startswith(StringRef(&One, 1))) + FName = FName.substr(1); + + + NamedMDNode *FnLocals = getOrInsertFnSpecificMDNode(M, FName); + FnLocals->addOperand(Node); + } + return DIVariable(Node); +} + + +/// CreateComplexVariable - Create a new descriptor for the specified variable +/// which has a complex address expression for its address. +DIVariable DIFactory::CreateComplexVariable(unsigned Tag, DIDescriptor Context, + StringRef Name, DIFile F, + unsigned LineNo, + DIType Ty, Value *const *Addr, + unsigned NumAddr) { + SmallVector Elts; + Elts.push_back(GetTagConstant(Tag)); + Elts.push_back(Context); + Elts.push_back(MDString::get(VMContext, Name)); + Elts.push_back(F); + Elts.push_back(ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)); + Elts.push_back(Ty); + Elts.append(Addr, Addr+NumAddr); + + return DIVariable(MDNode::get(VMContext, Elts.data(), Elts.size())); +} + + +/// CreateBlock - This creates a descriptor for a lexical block with the +/// specified parent VMContext. +DILexicalBlock DIFactory::CreateLexicalBlock(DIDescriptor Context, + DIFile F, unsigned LineNo, + unsigned Col) { + // Defeat MDNode uniqing for lexical blocks. + static unsigned int unique_id = 0; + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_lexical_block), + Context, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + ConstantInt::get(Type::getInt32Ty(VMContext), Col), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), unique_id++) + }; + return DILexicalBlock(MDNode::get(VMContext, &Elts[0], 6)); +} + +/// CreateNameSpace - This creates new descriptor for a namespace +/// with the specified parent context. +DINameSpace DIFactory::CreateNameSpace(DIDescriptor Context, StringRef Name, + DIFile F, + unsigned LineNo) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_namespace), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo) + }; + return DINameSpace(MDNode::get(VMContext, &Elts[0], 5)); +} + +/// CreateLocation - Creates a debug info location. +DILocation DIFactory::CreateLocation(unsigned LineNo, unsigned ColumnNo, + DIScope S, DILocation OrigLoc) { + Value *Elts[] = { + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo), + S, + OrigLoc, + }; + return DILocation(MDNode::get(VMContext, &Elts[0], 4)); +} + +//===----------------------------------------------------------------------===// +// DIFactory: Routines for inserting code into a function +//===----------------------------------------------------------------------===// + +/// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. +Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, + Instruction *InsertBefore) { + assert(Storage && "no storage passed to dbg.declare"); + assert(D.Verify() && "empty DIVariable passed to dbg.declare"); + if (!DeclareFn) + DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); + + Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1), + D }; + return CallInst::Create(DeclareFn, Args, Args+2, "", InsertBefore); +} + +/// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. +Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, + BasicBlock *InsertAtEnd) { + assert(Storage && "no storage passed to dbg.declare"); + assert(D.Verify() && "invalid DIVariable passed to dbg.declare"); + if (!DeclareFn) + DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); + + Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1), + D }; + + // If this block already has a terminator then insert this intrinsic + // before the terminator. + if (TerminatorInst *T = InsertAtEnd->getTerminator()) + return CallInst::Create(DeclareFn, Args, Args+2, "", T); + else + return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd);} + +/// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. +Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, uint64_t Offset, + DIVariable D, + Instruction *InsertBefore) { + assert(V && "no value passed to dbg.value"); + assert(D.Verify() && "invalid DIVariable passed to dbg.value"); + if (!ValueFn) + ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value); + + Value *Args[] = { MDNode::get(V->getContext(), &V, 1), + ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset), + D }; + return CallInst::Create(ValueFn, Args, Args+3, "", InsertBefore); +} + +/// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. +Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, uint64_t Offset, + DIVariable D, + BasicBlock *InsertAtEnd) { + assert(V && "no value passed to dbg.value"); + assert(D.Verify() && "invalid DIVariable passed to dbg.value"); + if (!ValueFn) + ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value); + + Value *Args[] = { MDNode::get(V->getContext(), &V, 1), + ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset), + D }; + return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd); +} + +// RecordType - Record DIType in a module such that it is not lost even if +// it is not referenced through debug info anchors. +void DIFactory::RecordType(DIType T) { + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.ty"); + NMD->addOperand(T); +} + /* LLVM LOCAL end (ENTIRE FILE!) */ Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.h?rev=126872&r1=126871&r2=126872&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Wed Mar 2 14:30:39 2011 @@ -51,6 +51,214 @@ class Function; class Module; +/// DIFactory - This object assists with the construction of the various +/// descriptors. +class DIFactory { + Module &M; + LLVMContext& VMContext; + + Function *DeclareFn; // llvm.dbg.declare + Function *ValueFn; // llvm.dbg.value + + DIFactory(const DIFactory &); // DO NOT IMPLEMENT + void operator=(const DIFactory&); // DO NOT IMPLEMENT + public: + enum ComplexAddrKind { OpPlus=1, OpDeref }; + + explicit DIFactory(Module &m); + + /// GetOrCreateArray - Create an descriptor for an array of descriptors. + /// This implicitly uniques the arrays created. + DIArray GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys); + + /// GetOrCreateSubrange - Create a descriptor for a value range. This + /// implicitly uniques the values returned. + DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi); + + /// CreateUnspecifiedParameter - Create unspeicified type descriptor + /// for a subroutine type. + DIDescriptor CreateUnspecifiedParameter(); + + /// CreateCompileUnit - Create a new descriptor for the specified compile + /// unit. + DICompileUnit CreateCompileUnit(unsigned LangID, + StringRef Filename, + StringRef Directory, + StringRef Producer, + bool isMain = false, + bool isOptimized = false, + StringRef Flags = "", + unsigned RunTimeVer = 0); + + /// CreateFile - Create a new descriptor for the specified file. + DIFile CreateFile(StringRef Filename, StringRef Directory, + DICompileUnit CU); + + /// CreateEnumerator - Create a single enumerator value. + DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val); + + /// CreateBasicType - Create a basic type like int, float, etc. + DIBasicType CreateBasicType(DIDescriptor Context, StringRef Name, + DIFile F, unsigned LineNumber, + uint64_t SizeInBits, uint64_t AlignInBits, + uint64_t OffsetInBits, unsigned Flags, + unsigned Encoding); + + /// CreateBasicType - Create a basic type like int, float, etc. + DIBasicType CreateBasicTypeEx(DIDescriptor Context, StringRef Name, + DIFile F, unsigned LineNumber, + Constant *SizeInBits, Constant *AlignInBits, + Constant *OffsetInBits, unsigned Flags, + unsigned Encoding); + + /// CreateDerivedType - Create a derived type like const qualified type, + /// pointer, typedef, etc. + DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + uint64_t SizeInBits, uint64_t AlignInBits, + uint64_t OffsetInBits, unsigned Flags, + DIType DerivedFrom); + + /// CreateDerivedType - Create a derived type like const qualified type, + /// pointer, typedef, etc. + DIDerivedType CreateDerivedTypeEx(unsigned Tag, DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + Constant *SizeInBits, + Constant *AlignInBits, + Constant *OffsetInBits, unsigned Flags, + DIType DerivedFrom); + + /// CreateCompositeType - Create a composite type like array, struct, etc. + DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + uint64_t SizeInBits, + uint64_t AlignInBits, + uint64_t OffsetInBits, unsigned Flags, + DIType DerivedFrom, + DIArray Elements, + unsigned RunTimeLang = 0, + MDNode *ContainingType = 0); + + /// CreateTemporaryType - Create a temporary forward-declared type. + DIType CreateTemporaryType(); + DIType CreateTemporaryType(DIFile F); + + /// CreateArtificialType - Create a new DIType with "artificial" flag set. + DIType CreateArtificialType(DIType Ty); + + /// CreateCompositeType - Create a composite type like array, struct, etc. + DICompositeType CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + Constant *SizeInBits, + Constant *AlignInBits, + Constant *OffsetInBits, + unsigned Flags, + DIType DerivedFrom, + DIArray Elements, + unsigned RunTimeLang = 0, + MDNode *ContainingType = 0); + + /// CreateSubprogram - Create a new descriptor for the specified subprogram. + /// See comments in DISubprogram for descriptions of these fields. + DISubprogram CreateSubprogram(DIDescriptor Context, StringRef Name, + StringRef DisplayName, + StringRef LinkageName, + DIFile F, unsigned LineNo, + DIType Ty, bool isLocalToUnit, + bool isDefinition, + unsigned VK = 0, + unsigned VIndex = 0, + DIType ContainingType = DIType(), + unsigned Flags = 0, + bool isOptimized = false, + Function *Fn = 0); + + /// CreateSubprogramDefinition - Create new subprogram descriptor for the + /// given declaration. + DISubprogram CreateSubprogramDefinition(DISubprogram &SPDeclaration); + + /// CreateGlobalVariable - Create a new descriptor for the specified global. + DIGlobalVariable + CreateGlobalVariable(DIDescriptor Context, StringRef Name, + StringRef DisplayName, + StringRef LinkageName, + DIFile F, + unsigned LineNo, DIType Ty, bool isLocalToUnit, + bool isDefinition, llvm::GlobalVariable *GV); + + /// CreateGlobalVariable - Create a new descriptor for the specified constant. + DIGlobalVariable + CreateGlobalVariable(DIDescriptor Context, StringRef Name, + StringRef DisplayName, + StringRef LinkageName, + DIFile F, + unsigned LineNo, DIType Ty, bool isLocalToUnit, + bool isDefinition, llvm::Constant *C); + + /// CreateVariable - Create a new descriptor for the specified variable. + DIVariable CreateVariable(unsigned Tag, DIDescriptor Context, + StringRef Name, + DIFile F, unsigned LineNo, + DIType Ty, bool AlwaysPreserve = false, + unsigned Flags = 0); + + /// CreateComplexVariable - Create a new descriptor for the specified + /// variable which has a complex address expression for its address. + DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Context, + StringRef Name, DIFile F, unsigned LineNo, + DIType Ty, Value *const *Addr, + unsigned NumAddr); + + /// CreateLexicalBlock - This creates a descriptor for a lexical block + /// with the specified parent context. + DILexicalBlock CreateLexicalBlock(DIDescriptor Context, DIFile F, + unsigned Line = 0, unsigned Col = 0); + + /// CreateNameSpace - This creates new descriptor for a namespace + /// with the specified parent context. + DINameSpace CreateNameSpace(DIDescriptor Context, StringRef Name, + DIFile F, unsigned LineNo); + + /// CreateLocation - Creates a debug info location. + DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo, + DIScope S, DILocation OrigLoc); + + /// CreateLocation - Creates a debug info location. + DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo, + DIScope S, MDNode *OrigLoc = 0); + + /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. + Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D, + BasicBlock *InsertAtEnd); + + /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. + Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D, + Instruction *InsertBefore); + + /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. + Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset, + DIVariable D, BasicBlock *InsertAtEnd); + + /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. + Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset, + DIVariable D, Instruction *InsertBefore); + + // RecordType - Record DIType in a module such that it is not lost even if + // it is not referenced through debug info anchors. + void RecordType(DIType T); + + private: + Constant *GetTagConstant(unsigned TAG); +}; + /// DebugInfo - This class gathers all debug information during compilation and /// is responsible for emitting to llvm globals or pass directly to the backend. class DebugInfo { Modified: llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp?rev=126872&r1=126871&r2=126872&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Wed Mar 2 14:30:39 2011 @@ -96,7 +96,6 @@ llvm::Type::getInt8Ty(llvm::getGlobalContext()); llvm::PrettyStackTraceProgram(0, 0); - llvm::DIFactory(*static_cast(0)); std::string Err; llvm::TargetRegistry::lookupTarget("", Err); From baldrick at free.fr Wed Mar 2 14:30:41 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 02 Mar 2011 20:30:41 -0000 Subject: [llvm-commits] [dragonegg] r126873 - in /dragonegg/trunk: llvm-debug.cpp llvm-debug.h Message-ID: <20110302203041.472602A6C12E@llvm.org> Author: baldrick Date: Wed Mar 2 14:30:41 2011 New Revision: 126873 URL: http://llvm.org/viewvc/llvm-project?rev=126873&view=rev Log: DIFactory has been removed from the LLVM core. Put a copy of it here so that llvm-gcc continues to work. Based on Devang's patch. Modified: dragonegg/trunk/llvm-debug.cpp dragonegg/trunk/llvm-debug.h Modified: dragonegg/trunk/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=126873&r1=126872&r2=126873&view=diff ============================================================================== --- dragonegg/trunk/llvm-debug.cpp (original) +++ dragonegg/trunk/llvm-debug.cpp Wed Mar 2 14:30:41 2011 @@ -26,6 +26,7 @@ // LLVM headers #include "llvm/Module.h" +#include "llvm/ADT/STLExtras.h" // System headers #include @@ -1156,3 +1157,655 @@ DirectoryAndFile(FullPath, Directory, FileName); return DebugFactory.CreateFile(FileName, Directory, TheCU); } + +//===----------------------------------------------------------------------===// +// DIFactory: Basic Helpers +//===----------------------------------------------------------------------===// + +DIFactory::DIFactory(Module &m) + : M(m), VMContext(M.getContext()), DeclareFn(0), ValueFn(0) {} + +Constant *DIFactory::GetTagConstant(unsigned TAG) { + assert((TAG & LLVMDebugVersionMask) == 0 && + "Tag too large for debug encoding!"); + return ConstantInt::get(Type::getInt32Ty(VMContext), TAG | LLVMDebugVersion); +} + +//===----------------------------------------------------------------------===// +// DIFactory: Primary Constructors +//===----------------------------------------------------------------------===// + +/// GetOrCreateArray - Create an descriptor for an array of descriptors. +/// This implicitly uniques the arrays created. +DIArray DIFactory::GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys) { + if (NumTys == 0) { + Value *Null = llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)); + return DIArray(MDNode::get(VMContext, &Null, 1)); + } + + SmallVector Elts(Tys, Tys+NumTys); + return DIArray(MDNode::get(VMContext, Elts.data(), Elts.size())); +} + +/// GetOrCreateSubrange - Create a descriptor for a value range. This +/// implicitly uniques the values returned. +DISubrange DIFactory::GetOrCreateSubrange(int64_t Lo, int64_t Hi) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_subrange_type), + ConstantInt::get(Type::getInt64Ty(VMContext), Lo), + ConstantInt::get(Type::getInt64Ty(VMContext), Hi) + }; + + return DISubrange(MDNode::get(VMContext, &Elts[0], 3)); +} + +/// CreateUnspecifiedParameter - Create unspeicified type descriptor +/// for the subroutine type. +DIDescriptor DIFactory::CreateUnspecifiedParameter() { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_unspecified_parameters) + }; + return DIDescriptor(MDNode::get(VMContext, &Elts[0], 1)); +} + +/// CreateCompileUnit - Create a new descriptor for the specified compile +/// unit. Note that this does not unique compile units within the module. +DICompileUnit DIFactory::CreateCompileUnit(unsigned LangID, + StringRef Filename, + StringRef Directory, + StringRef Producer, + bool isMain, + bool isOptimized, + StringRef Flags, + unsigned RunTimeVer) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_compile_unit), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + ConstantInt::get(Type::getInt32Ty(VMContext), LangID), + MDString::get(VMContext, Filename), + MDString::get(VMContext, Directory), + MDString::get(VMContext, Producer), + ConstantInt::get(Type::getInt1Ty(VMContext), isMain), + ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized), + MDString::get(VMContext, Flags), + ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeVer) + }; + + return DICompileUnit(MDNode::get(VMContext, &Elts[0], 10)); +} + +/// CreateFile - Create a new descriptor for the specified file. +DIFile DIFactory::CreateFile(StringRef Filename, + StringRef Directory, + DICompileUnit CU) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_file_type), + MDString::get(VMContext, Filename), + MDString::get(VMContext, Directory), + CU + }; + + return DIFile(MDNode::get(VMContext, &Elts[0], 4)); +} + +/// CreateEnumerator - Create a single enumerator value. +DIEnumerator DIFactory::CreateEnumerator(StringRef Name, uint64_t Val){ + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_enumerator), + MDString::get(VMContext, Name), + ConstantInt::get(Type::getInt64Ty(VMContext), Val) + }; + return DIEnumerator(MDNode::get(VMContext, &Elts[0], 3)); +} + + +/// CreateBasicType - Create a basic type like int, float, etc. +DIBasicType DIFactory::CreateBasicType(DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + uint64_t SizeInBits, + uint64_t AlignInBits, + uint64_t OffsetInBits, unsigned Flags, + unsigned Encoding) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_base_type), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits), + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + ConstantInt::get(Type::getInt32Ty(VMContext), Encoding) + }; + return DIBasicType(MDNode::get(VMContext, &Elts[0], 10)); +} + + +/// CreateBasicType - Create a basic type like int, float, etc. +DIBasicType DIFactory::CreateBasicTypeEx(DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + Constant *SizeInBits, + Constant *AlignInBits, + Constant *OffsetInBits, unsigned Flags, + unsigned Encoding) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_base_type), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + SizeInBits, + AlignInBits, + OffsetInBits, + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + ConstantInt::get(Type::getInt32Ty(VMContext), Encoding) + }; + return DIBasicType(MDNode::get(VMContext, &Elts[0], 10)); +} + +/// CreateArtificialType - Create a new DIType with "artificial" flag set. +DIType DIFactory::CreateArtificialType(DIType Ty) { + if (Ty.isArtificial()) + return Ty; + + SmallVector Elts; + MDNode *N = Ty; + assert (N && "Unexpected input DIType!"); + for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { + if (Value *V = N->getOperand(i)) + Elts.push_back(V); + else + Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext))); + } + + unsigned CurFlags = Ty.getFlags(); + CurFlags = CurFlags | DIType::FlagArtificial; + + // Flags are stored at this slot. + Elts[8] = ConstantInt::get(Type::getInt32Ty(VMContext), CurFlags); + + return DIType(MDNode::get(VMContext, Elts.data(), Elts.size())); +} + +/// CreateDerivedType - Create a derived type like const qualified type, +/// pointer, typedef, etc. +DIDerivedType DIFactory::CreateDerivedType(unsigned Tag, + DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + uint64_t SizeInBits, + uint64_t AlignInBits, + uint64_t OffsetInBits, + unsigned Flags, + DIType DerivedFrom) { + Value *Elts[] = { + GetTagConstant(Tag), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits), + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + DerivedFrom, + }; + return DIDerivedType(MDNode::get(VMContext, &Elts[0], 10)); +} + + +/// CreateDerivedType - Create a derived type like const qualified type, +/// pointer, typedef, etc. +DIDerivedType DIFactory::CreateDerivedTypeEx(unsigned Tag, + DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + Constant *SizeInBits, + Constant *AlignInBits, + Constant *OffsetInBits, + unsigned Flags, + DIType DerivedFrom) { + Value *Elts[] = { + GetTagConstant(Tag), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + SizeInBits, + AlignInBits, + OffsetInBits, + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + DerivedFrom, + }; + return DIDerivedType(MDNode::get(VMContext, &Elts[0], 10)); +} + + +/// CreateCompositeType - Create a composite type like array, struct, etc. +DICompositeType DIFactory::CreateCompositeType(unsigned Tag, + DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + uint64_t SizeInBits, + uint64_t AlignInBits, + uint64_t OffsetInBits, + unsigned Flags, + DIType DerivedFrom, + DIArray Elements, + unsigned RuntimeLang, + MDNode *ContainingType) { + + Value *Elts[] = { + GetTagConstant(Tag), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits), + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + DerivedFrom, + Elements, + ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang), + ContainingType + }; + + MDNode *Node = MDNode::get(VMContext, &Elts[0], 13); + // Create a named metadata so that we do not lose this enum info. + if (Tag == dwarf::DW_TAG_enumeration_type) { + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.enum"); + NMD->addOperand(Node); + } + return DICompositeType(Node); +} + +/// CreateTemporaryType - Create a temporary forward-declared type. +DIType DIFactory::CreateTemporaryType() { + // Give the temporary MDNode a tag. It doesn't matter what tag we + // use here as long as DIType accepts it. + Value *Elts[] = { + GetTagConstant(DW_TAG_base_type) + }; + MDNode *Node = MDNode::getTemporary(VMContext, Elts, array_lengthof(Elts)); + return DIType(Node); +} + +/// CreateTemporaryType - Create a temporary forward-declared type. +DIType DIFactory::CreateTemporaryType(DIFile F) { + // Give the temporary MDNode a tag. It doesn't matter what tag we + // use here as long as DIType accepts it. + Value *Elts[] = { + GetTagConstant(DW_TAG_base_type), + F.getCompileUnit(), + NULL, + F + }; + MDNode *Node = MDNode::getTemporary(VMContext, Elts, array_lengthof(Elts)); + return DIType(Node); +} + +/// CreateCompositeType - Create a composite type like array, struct, etc. +DICompositeType DIFactory::CreateCompositeTypeEx(unsigned Tag, + DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + Constant *SizeInBits, + Constant *AlignInBits, + Constant *OffsetInBits, + unsigned Flags, + DIType DerivedFrom, + DIArray Elements, + unsigned RuntimeLang, + MDNode *ContainingType) { + Value *Elts[] = { + GetTagConstant(Tag), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + SizeInBits, + AlignInBits, + OffsetInBits, + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + DerivedFrom, + Elements, + ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang), + ContainingType + }; + MDNode *Node = MDNode::get(VMContext, &Elts[0], 13); + // Create a named metadata so that we do not lose this enum info. + if (Tag == dwarf::DW_TAG_enumeration_type) { + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.enum"); + NMD->addOperand(Node); + } + return DICompositeType(Node); +} + + +/// CreateSubprogram - Create a new descriptor for the specified subprogram. +/// See comments in DISubprogram for descriptions of these fields. This +/// method does not unique the generated descriptors. +DISubprogram DIFactory::CreateSubprogram(DIDescriptor Context, + StringRef Name, + StringRef DisplayName, + StringRef LinkageName, + DIFile F, + unsigned LineNo, DIType Ty, + bool isLocalToUnit, + bool isDefinition, + unsigned VK, unsigned VIndex, + DIType ContainingType, + unsigned Flags, + bool isOptimized, + Function *Fn) { + + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_subprogram), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + Context, + MDString::get(VMContext, Name), + MDString::get(VMContext, DisplayName), + MDString::get(VMContext, LinkageName), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + Ty, + ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit), + ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition), + ConstantInt::get(Type::getInt32Ty(VMContext), (unsigned)VK), + ConstantInt::get(Type::getInt32Ty(VMContext), VIndex), + ContainingType, + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized), + Fn + }; + MDNode *Node = MDNode::get(VMContext, &Elts[0], 17); + + // Create a named metadata so that we do not lose this mdnode. + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.sp"); + NMD->addOperand(Node); + return DISubprogram(Node); +} + +/// CreateSubprogramDefinition - Create new subprogram descriptor for the +/// given declaration. +DISubprogram DIFactory::CreateSubprogramDefinition(DISubprogram &SPDeclaration){ + if (SPDeclaration.isDefinition()) + return DISubprogram(SPDeclaration); + + MDNode *DeclNode = SPDeclaration; + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_subprogram), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + DeclNode->getOperand(2), // Context + DeclNode->getOperand(3), // Name + DeclNode->getOperand(4), // DisplayName + DeclNode->getOperand(5), // LinkageName + DeclNode->getOperand(6), // CompileUnit + DeclNode->getOperand(7), // LineNo + DeclNode->getOperand(8), // Type + DeclNode->getOperand(9), // isLocalToUnit + ConstantInt::get(Type::getInt1Ty(VMContext), true), + DeclNode->getOperand(11), // Virtuality + DeclNode->getOperand(12), // VIndex + DeclNode->getOperand(13), // Containting Type + DeclNode->getOperand(14), // Flags + DeclNode->getOperand(15), // isOptimized + SPDeclaration.getFunction() + }; + MDNode *Node =MDNode::get(VMContext, &Elts[0], 16); + + // Create a named metadata so that we do not lose this mdnode. + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.sp"); + NMD->addOperand(Node); + return DISubprogram(Node); +} + +/// CreateGlobalVariable - Create a new descriptor for the specified global. +DIGlobalVariable +DIFactory::CreateGlobalVariable(DIDescriptor Context, StringRef Name, + StringRef DisplayName, + StringRef LinkageName, + DIFile F, + unsigned LineNo, DIType Ty,bool isLocalToUnit, + bool isDefinition, llvm::GlobalVariable *Val) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_variable), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + Context, + MDString::get(VMContext, Name), + MDString::get(VMContext, DisplayName), + MDString::get(VMContext, LinkageName), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + Ty, + ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit), + ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition), + Val + }; + + Value *const *Vs = &Elts[0]; + MDNode *Node = MDNode::get(VMContext,Vs, 12); + + // Create a named metadata so that we do not lose this mdnode. + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv"); + NMD->addOperand(Node); + + return DIGlobalVariable(Node); +} + +/// CreateGlobalVariable - Create a new descriptor for the specified constant. +DIGlobalVariable +DIFactory::CreateGlobalVariable(DIDescriptor Context, StringRef Name, + StringRef DisplayName, + StringRef LinkageName, + DIFile F, + unsigned LineNo, DIType Ty,bool isLocalToUnit, + bool isDefinition, llvm::Constant *Val) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_variable), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + Context, + MDString::get(VMContext, Name), + MDString::get(VMContext, DisplayName), + MDString::get(VMContext, LinkageName), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + Ty, + ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit), + ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition), + Val + }; + + Value *const *Vs = &Elts[0]; + MDNode *Node = MDNode::get(VMContext,Vs, 12); + + // Create a named metadata so that we do not lose this mdnode. + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv"); + NMD->addOperand(Node); + + return DIGlobalVariable(Node); +} + +/// CreateVariable - Create a new descriptor for the specified variable. +DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNo, + DIType Ty, bool AlwaysPreserve, + unsigned Flags) { + Value *Elts[] = { + GetTagConstant(Tag), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + Ty, + ConstantInt::get(Type::getInt32Ty(VMContext), Flags) + }; + MDNode *Node = MDNode::get(VMContext, &Elts[0], 7); + if (AlwaysPreserve) { + // The optimizer may remove local variable. If there is an interest + // to preserve variable info in such situation then stash it in a + // named mdnode. + DISubprogram Fn(getDISubprogram(Context)); + StringRef FName = "fn"; + if (Fn.getFunction()) + FName = Fn.getFunction()->getName(); + char One = '\1'; + if (FName.startswith(StringRef(&One, 1))) + FName = FName.substr(1); + + + NamedMDNode *FnLocals = getOrInsertFnSpecificMDNode(M, FName); + FnLocals->addOperand(Node); + } + return DIVariable(Node); +} + + +/// CreateComplexVariable - Create a new descriptor for the specified variable +/// which has a complex address expression for its address. +DIVariable DIFactory::CreateComplexVariable(unsigned Tag, DIDescriptor Context, + StringRef Name, DIFile F, + unsigned LineNo, + DIType Ty, Value *const *Addr, + unsigned NumAddr) { + SmallVector Elts; + Elts.push_back(GetTagConstant(Tag)); + Elts.push_back(Context); + Elts.push_back(MDString::get(VMContext, Name)); + Elts.push_back(F); + Elts.push_back(ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)); + Elts.push_back(Ty); + Elts.append(Addr, Addr+NumAddr); + + return DIVariable(MDNode::get(VMContext, Elts.data(), Elts.size())); +} + + +/// CreateBlock - This creates a descriptor for a lexical block with the +/// specified parent VMContext. +DILexicalBlock DIFactory::CreateLexicalBlock(DIDescriptor Context, + DIFile F, unsigned LineNo, + unsigned Col) { + // Defeat MDNode uniqing for lexical blocks. + static unsigned int unique_id = 0; + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_lexical_block), + Context, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + ConstantInt::get(Type::getInt32Ty(VMContext), Col), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), unique_id++) + }; + return DILexicalBlock(MDNode::get(VMContext, &Elts[0], 6)); +} + +/// CreateNameSpace - This creates new descriptor for a namespace +/// with the specified parent context. +DINameSpace DIFactory::CreateNameSpace(DIDescriptor Context, StringRef Name, + DIFile F, + unsigned LineNo) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_namespace), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo) + }; + return DINameSpace(MDNode::get(VMContext, &Elts[0], 5)); +} + +/// CreateLocation - Creates a debug info location. +DILocation DIFactory::CreateLocation(unsigned LineNo, unsigned ColumnNo, + DIScope S, DILocation OrigLoc) { + Value *Elts[] = { + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo), + S, + OrigLoc, + }; + return DILocation(MDNode::get(VMContext, &Elts[0], 4)); +} + +//===----------------------------------------------------------------------===// +// DIFactory: Routines for inserting code into a function +//===----------------------------------------------------------------------===// + +/// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. +Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, + Instruction *InsertBefore) { + assert(Storage && "no storage passed to dbg.declare"); + assert(D.Verify() && "empty DIVariable passed to dbg.declare"); + if (!DeclareFn) + DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); + + Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1), + D }; + return CallInst::Create(DeclareFn, Args, Args+2, "", InsertBefore); +} + +/// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. +Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, + BasicBlock *InsertAtEnd) { + assert(Storage && "no storage passed to dbg.declare"); + assert(D.Verify() && "invalid DIVariable passed to dbg.declare"); + if (!DeclareFn) + DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); + + Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1), + D }; + + // If this block already has a terminator then insert this intrinsic + // before the terminator. + if (TerminatorInst *T = InsertAtEnd->getTerminator()) + return CallInst::Create(DeclareFn, Args, Args+2, "", T); + else + return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd);} + +/// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. +Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, uint64_t Offset, + DIVariable D, + Instruction *InsertBefore) { + assert(V && "no value passed to dbg.value"); + assert(D.Verify() && "invalid DIVariable passed to dbg.value"); + if (!ValueFn) + ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value); + + Value *Args[] = { MDNode::get(V->getContext(), &V, 1), + ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset), + D }; + return CallInst::Create(ValueFn, Args, Args+3, "", InsertBefore); +} + +/// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. +Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, uint64_t Offset, + DIVariable D, + BasicBlock *InsertAtEnd) { + assert(V && "no value passed to dbg.value"); + assert(D.Verify() && "invalid DIVariable passed to dbg.value"); + if (!ValueFn) + ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value); + + Value *Args[] = { MDNode::get(V->getContext(), &V, 1), + ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset), + D }; + return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd); +} + +// RecordType - Record DIType in a module such that it is not lost even if +// it is not referenced through debug info anchors. +void DIFactory::RecordType(DIType T) { + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.ty"); + NMD->addOperand(T); +} Modified: dragonegg/trunk/llvm-debug.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.h?rev=126873&r1=126872&r2=126873&view=diff ============================================================================== --- dragonegg/trunk/llvm-debug.h (original) +++ dragonegg/trunk/llvm-debug.h Wed Mar 2 14:30:41 2011 @@ -43,6 +43,214 @@ class Function; class Module; +/// DIFactory - This object assists with the construction of the various +/// descriptors. +class DIFactory { + Module &M; + LLVMContext& VMContext; + + Function *DeclareFn; // llvm.dbg.declare + Function *ValueFn; // llvm.dbg.value + + DIFactory(const DIFactory &); // DO NOT IMPLEMENT + void operator=(const DIFactory&); // DO NOT IMPLEMENT + public: + enum ComplexAddrKind { OpPlus=1, OpDeref }; + + explicit DIFactory(Module &m); + + /// GetOrCreateArray - Create an descriptor for an array of descriptors. + /// This implicitly uniques the arrays created. + DIArray GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys); + + /// GetOrCreateSubrange - Create a descriptor for a value range. This + /// implicitly uniques the values returned. + DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi); + + /// CreateUnspecifiedParameter - Create unspeicified type descriptor + /// for a subroutine type. + DIDescriptor CreateUnspecifiedParameter(); + + /// CreateCompileUnit - Create a new descriptor for the specified compile + /// unit. + DICompileUnit CreateCompileUnit(unsigned LangID, + StringRef Filename, + StringRef Directory, + StringRef Producer, + bool isMain = false, + bool isOptimized = false, + StringRef Flags = "", + unsigned RunTimeVer = 0); + + /// CreateFile - Create a new descriptor for the specified file. + DIFile CreateFile(StringRef Filename, StringRef Directory, + DICompileUnit CU); + + /// CreateEnumerator - Create a single enumerator value. + DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val); + + /// CreateBasicType - Create a basic type like int, float, etc. + DIBasicType CreateBasicType(DIDescriptor Context, StringRef Name, + DIFile F, unsigned LineNumber, + uint64_t SizeInBits, uint64_t AlignInBits, + uint64_t OffsetInBits, unsigned Flags, + unsigned Encoding); + + /// CreateBasicType - Create a basic type like int, float, etc. + DIBasicType CreateBasicTypeEx(DIDescriptor Context, StringRef Name, + DIFile F, unsigned LineNumber, + Constant *SizeInBits, Constant *AlignInBits, + Constant *OffsetInBits, unsigned Flags, + unsigned Encoding); + + /// CreateDerivedType - Create a derived type like const qualified type, + /// pointer, typedef, etc. + DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + uint64_t SizeInBits, uint64_t AlignInBits, + uint64_t OffsetInBits, unsigned Flags, + DIType DerivedFrom); + + /// CreateDerivedType - Create a derived type like const qualified type, + /// pointer, typedef, etc. + DIDerivedType CreateDerivedTypeEx(unsigned Tag, DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + Constant *SizeInBits, + Constant *AlignInBits, + Constant *OffsetInBits, unsigned Flags, + DIType DerivedFrom); + + /// CreateCompositeType - Create a composite type like array, struct, etc. + DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + uint64_t SizeInBits, + uint64_t AlignInBits, + uint64_t OffsetInBits, unsigned Flags, + DIType DerivedFrom, + DIArray Elements, + unsigned RunTimeLang = 0, + MDNode *ContainingType = 0); + + /// CreateTemporaryType - Create a temporary forward-declared type. + DIType CreateTemporaryType(); + DIType CreateTemporaryType(DIFile F); + + /// CreateArtificialType - Create a new DIType with "artificial" flag set. + DIType CreateArtificialType(DIType Ty); + + /// CreateCompositeType - Create a composite type like array, struct, etc. + DICompositeType CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context, + StringRef Name, + DIFile F, + unsigned LineNumber, + Constant *SizeInBits, + Constant *AlignInBits, + Constant *OffsetInBits, + unsigned Flags, + DIType DerivedFrom, + DIArray Elements, + unsigned RunTimeLang = 0, + MDNode *ContainingType = 0); + + /// CreateSubprogram - Create a new descriptor for the specified subprogram. + /// See comments in DISubprogram for descriptions of these fields. + DISubprogram CreateSubprogram(DIDescriptor Context, StringRef Name, + StringRef DisplayName, + StringRef LinkageName, + DIFile F, unsigned LineNo, + DIType Ty, bool isLocalToUnit, + bool isDefinition, + unsigned VK = 0, + unsigned VIndex = 0, + DIType ContainingType = DIType(), + unsigned Flags = 0, + bool isOptimized = false, + Function *Fn = 0); + + /// CreateSubprogramDefinition - Create new subprogram descriptor for the + /// given declaration. + DISubprogram CreateSubprogramDefinition(DISubprogram &SPDeclaration); + + /// CreateGlobalVariable - Create a new descriptor for the specified global. + DIGlobalVariable + CreateGlobalVariable(DIDescriptor Context, StringRef Name, + StringRef DisplayName, + StringRef LinkageName, + DIFile F, + unsigned LineNo, DIType Ty, bool isLocalToUnit, + bool isDefinition, llvm::GlobalVariable *GV); + + /// CreateGlobalVariable - Create a new descriptor for the specified constant. + DIGlobalVariable + CreateGlobalVariable(DIDescriptor Context, StringRef Name, + StringRef DisplayName, + StringRef LinkageName, + DIFile F, + unsigned LineNo, DIType Ty, bool isLocalToUnit, + bool isDefinition, llvm::Constant *C); + + /// CreateVariable - Create a new descriptor for the specified variable. + DIVariable CreateVariable(unsigned Tag, DIDescriptor Context, + StringRef Name, + DIFile F, unsigned LineNo, + DIType Ty, bool AlwaysPreserve = false, + unsigned Flags = 0); + + /// CreateComplexVariable - Create a new descriptor for the specified + /// variable which has a complex address expression for its address. + DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Context, + StringRef Name, DIFile F, unsigned LineNo, + DIType Ty, Value *const *Addr, + unsigned NumAddr); + + /// CreateLexicalBlock - This creates a descriptor for a lexical block + /// with the specified parent context. + DILexicalBlock CreateLexicalBlock(DIDescriptor Context, DIFile F, + unsigned Line = 0, unsigned Col = 0); + + /// CreateNameSpace - This creates new descriptor for a namespace + /// with the specified parent context. + DINameSpace CreateNameSpace(DIDescriptor Context, StringRef Name, + DIFile F, unsigned LineNo); + + /// CreateLocation - Creates a debug info location. + DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo, + DIScope S, DILocation OrigLoc); + + /// CreateLocation - Creates a debug info location. + DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo, + DIScope S, MDNode *OrigLoc = 0); + + /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. + Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D, + BasicBlock *InsertAtEnd); + + /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. + Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D, + Instruction *InsertBefore); + + /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. + Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset, + DIVariable D, BasicBlock *InsertAtEnd); + + /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. + Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset, + DIVariable D, Instruction *InsertBefore); + + // RecordType - Record DIType in a module such that it is not lost even if + // it is not referenced through debug info anchors. + void RecordType(DIType T); + + private: + Constant *GetTagConstant(unsigned TAG); +}; + /// DebugInfo - This class gathers all debug information during compilation and /// is responsible for emitting to llvm globals or pass directly to the backend. class DebugInfo { From Erik.Olofsson at hansoft.se Wed Mar 2 14:37:40 2011 From: Erik.Olofsson at hansoft.se (Erik Olofsson) Date: Wed, 2 Mar 2011 21:37:40 +0100 Subject: [llvm-commits] [PATCH] Add support for OutputDebugString to raw_ostream and add support for virtualized out/err streams In-Reply-To: References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAE2@winserv02.hansoft.local> Message-ID: <97510B8DF78E714D91EB4A27850A17DA0C3EACBBA7@winserv02.hansoft.local> > From: Dan Gohman [mailto:gohman at apple.com] > Hmm. It's not even possible to view the output of a classic > "hello world"? Exactly so. It is inexplicable that they haven't managed to implement this feature and I did some additional searching around the net and everyone is saying to use OutputDebugString. > Would it be possible to achieve what you want by extending dbgs()? > If not, how should code decide between using dbgs() and debugouts()? Maybe, but it seems inappropriate as I want this to be a command line option and in that case I would have to change the behavior of dbgs globally when this command line option is specified. It would however be beneficial to be able to tell dbgs to output to debugouts instead of stderr. Maybe it would be more appropriate to hide debugouts in the cpp file so it's not public and only use debugstreams() from the clang code. I also want this code to work in release builds. > What's the purpose of the raw_output_streams class? Are you expecting > to migrate code that uses errs() and outs() to using it? If so, > that's quite invasive. If not, what's the purpose? Most functions that I needed to override already takes an raw_ostream. Some functions however needs both errs and outs. I first implemented this by letting these functions take both errs and outs as arguments, but that resulted in asserts because there is check in place that prevents the application from calling outs() if you are for example outputting the results to stdout. That is why I need to virtualize calling outs() so you can replace it without actually calling the outs() function until it's actually needed. See the attached patch for how I'm expecting to implement this in clang. FYI I will split this patch into refactoring and implementing the new feature before submitting it again to clang-commits. Regards, Erik -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: clang-visual-studio-debuggability.patch.txt Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/65d6c189/attachment.txt From sabre at nondot.org Wed Mar 2 14:55:51 2011 From: sabre at nondot.org (Chris Lattner) Date: Wed, 02 Mar 2011 20:55:51 -0000 Subject: [llvm-commits] [llvm] r126878 - /llvm/trunk/include/llvm/ADT/ArrayRef.h Message-ID: <20110302205551.B77DF2A6C12C@llvm.org> Author: lattner Date: Wed Mar 2 14:55:51 2011 New Revision: 126878 URL: http://llvm.org/viewvc/llvm-project?rev=126878&view=rev Log: add some slice helper methods. Modified: llvm/trunk/include/llvm/ADT/ArrayRef.h Modified: llvm/trunk/include/llvm/ADT/ArrayRef.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ArrayRef.h?rev=126878&r1=126877&r2=126878&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/ArrayRef.h (original) +++ llvm/trunk/include/llvm/ADT/ArrayRef.h Wed Mar 2 14:55:51 2011 @@ -96,10 +96,22 @@ return Data[Length-1]; } + /// slice(n) - Chop off the first N elements of the array. + ArrayRef slice(unsigned N) { + assert(N <= size() && "Invalid specifier"); + return ArrayRef(data()+N, size()-N); + } + + /// slice(n, m) - Chop off the first N elements of the array, and keep M + /// elements in the array. + ArrayRef slice(unsigned N, unsigned M) { + assert(N+M <= size() && "Invalid specifier"); + return ArrayRef(data()+N, M); + } + /// @} /// @name Operator Overloads /// @{ - const T &operator[](size_t Index) const { assert(Index < Length && "Invalid index!"); return Data[Index]; @@ -108,7 +120,6 @@ /// @} /// @name Expensive Operations /// @{ - std::vector vec() const { return std::vector(Data, Data+Length); } From gohman at apple.com Wed Mar 2 15:13:23 2011 From: gohman at apple.com (Dan Gohman) Date: Wed, 2 Mar 2011 13:13:23 -0800 Subject: [llvm-commits] [PATCH] Add support for OutputDebugString to raw_ostream and add support for virtualized out/err streams In-Reply-To: <97510B8DF78E714D91EB4A27850A17DA0C3EACBBA7@winserv02.hansoft.local> References: <97510B8DF78E714D91EB4A27850A17DA0C3EACBAE2@winserv02.hansoft.local> <97510B8DF78E714D91EB4A27850A17DA0C3EACBBA7@winserv02.hansoft.local> Message-ID: <7992E9ED-B579-4C0D-8673-6C6566607D5B@apple.com> On Mar 2, 2011, at 12:37 PM, Erik Olofsson wrote: >> What's the purpose of the raw_output_streams class? Are you expecting >> to migrate code that uses errs() and outs() to using it? If so, >> that's quite invasive. If not, what's the purpose? > > Most functions that I needed to override already takes an raw_ostream. Some functions however needs both errs and outs. I first implemented this by letting these functions take both errs and outs as arguments, but that resulted in asserts because there is check in place that prevents the application from calling outs() if you are for example outputting the results to stdout. That is why I need to virtualize calling outs() so you can replace it without actually calling the outs() function until it's actually needed. > > See the attached patch for how I'm expecting to implement this in clang. FYI I will split this patch into refactoring and implementing the new feature before submitting it again to clang-commits. Here's an idea for an alternate approach: Add a function llvm::redirect_outs_and_errs_for_debugging() (or with a better name). On non-Windows, it's a no-op. On Windows, it sets a global boolean flag to true. Then add code to outs() and errs() that checks the flag and returns the OutputDebugString streams if it is true, on Windows. Do you think that's feasible? Otherwise, if you're only planning to update clang for all this, then the code should all be in clang-specific headers, rather than in llvm/Support/raw_ostream.h. Dan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/816d4efa/attachment.html From lstask at gmail.com Wed Mar 2 15:16:29 2011 From: lstask at gmail.com (Liam Staskawicz) Date: Wed, 2 Mar 2011 13:16:29 -0800 Subject: [llvm-commits] sys::fs::can_read() and sys::fs::can_write() for Unix In-Reply-To: References: <103727D28EE14102ABAB90CE3ED8DE80@gmail.com> <49CDBB532D70435F9C467613852704EE@gmail.com> Message-ID: On Wed, Mar 2, 2011 at 12:14 PM, Dan Gohman wrote: > > On Mar 2, 2011, at 7:54 AM, Liam Staskawicz wrote: > > ping. > > Is anybody available to review and commit if OK? Thanks! > > Liam > Forwarded message: > > From: Liam Staskawicz > To: llvm-commits at cs.uiuc.edu > Date: Monday, February 28, 2011 10:39:43 AM > Subject: [PATCH] sys::fs::can_read() and sys::fs::can_write() for Unix > > Hi - the attached patch provides implementations and tests for > sys::fs::can_read() and sys::fs::can_write() for Unix. These were adapted > from the previous implementations in lib/Support/Unix/Path.inc. > can_execute() could be implemented quite similarly, but I wasn't sure where > the best place to add a test for it would be, so left it out for now. > > > I'm surprised that anything in LLVM and clang is actually using canWrite(). > It appears that there is one use, in clang, and that one looks pretty > suspicious. Perhaps it can be removed altogether instead of ported to > PathV2? > > Dan > > Removing it altogether would actually be fine from my perspective, though it would be good to know what the plan is, so I can plan accordingly. Thanks. Liam -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/614a3aa5/attachment.html From renato.golin at arm.com Wed Mar 2 15:20:09 2011 From: renato.golin at arm.com (Renato Golin) Date: Wed, 02 Mar 2011 21:20:09 -0000 Subject: [llvm-commits] [llvm] r126882 - /llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Message-ID: <20110302212009.7542C2A6C12C@llvm.org> Author: rengolin Date: Wed Mar 2 15:20:09 2011 New Revision: 126882 URL: http://llvm.org/viewvc/llvm-project?rev=126882&view=rev Log: Fixing a bug when printing fpu text to object file. Patch by Mans Rullgard. Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=126882&r1=126881&r2=126882&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Wed Mar 2 15:20:09 2011 @@ -498,7 +498,7 @@ ARMBuildAttrs::Allowed); } - if (Subtarget->hasNEON()) { + if (Subtarget->hasNEON() && emitFPU) { /* NEON is not exactly a VFP architecture, but GAS emit one of * neon/vfpv3/vfpv2 for .fpu parameters */ AttrEmitter->EmitTextAttribute(ARMBuildAttrs::Advanced_SIMD_arch, "neon"); From grosser at fim.uni-passau.de Wed Mar 2 16:22:06 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Wed, 02 Mar 2011 17:22:06 -0500 Subject: [llvm-commits] Patch for simplifying regions In-Reply-To: References: <4D4882FC.8060102@fim.uni-passau.de> <4D6BCEBA.9080609@fim.uni-passau.de> <4D6CF971.5050300@fim.uni-passau.de> Message-ID: <4D6EC30E.8020305@fim.uni-passau.de> On 03/02/2011 03:08 PM, Vu Le wrote: > Add more test cases. Hi, this looks already very good. Though I still have a bunch of comments (I did not spend enough time reviewing it before. Sorry) Comments inline > Vu > diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h > index 02dbfbd..0591845 100644 > --- a/include/llvm/InitializePasses.h > +++ b/include/llvm/InitializePasses.h > @@ -192,6 +192,7 @@ void initializeRegionInfoPass(PassRegistry&); > void initializeRegionOnlyPrinterPass(PassRegistry&); > void initializeRegionOnlyViewerPass(PassRegistry&); > void initializeRegionPrinterPass(PassRegistry&); > +void initializeRegionSimplifyPass(PassRegistry&); > void initializeRegionViewerPass(PassRegistry&); > void initializeRegisterCoalescerAnalysisGroup(PassRegistry&); > void initializeRenderMachineFunctionPass(PassRegistry&); > diff --git a/include/llvm/LinkAllPasses.h b/include/llvm/LinkAllPasses.h > index 69e1bd9..6764543 100644 > --- a/include/llvm/LinkAllPasses.h > +++ b/include/llvm/LinkAllPasses.h > @@ -115,6 +115,7 @@ namespace { > (void) llvm::createRegionOnlyPrinterPass(); > (void) llvm::createRegionOnlyViewerPass(); > (void) llvm::createRegionPrinterPass(); > + (void) llvm::createRegionSimplifyPass(); > (void) llvm::createRegionViewerPass(); > (void) llvm::createSCCPPass(); > (void) llvm::createScalarReplAggregatesPass(); > diff --git a/include/llvm/Transforms/Scalar.h b/include/llvm/Transforms/Scalar.h > index 6f2a38e..330fa15 100644 > --- a/include/llvm/Transforms/Scalar.h > +++ b/include/llvm/Transforms/Scalar.h > @@ -349,6 +349,12 @@ Pass *createCorrelatedValuePropagationPass(); > FunctionPass *createInstructionSimplifierPass(); > extern char&InstructionSimplifierID; > > +//===----------------------------------------------------------------------===// > +// > +// RegionSimplify - Simplify refined regions. > +// > +Pass *createRegionSimplifyPass(); > + > } // End llvm namespace > > #endif > diff --git a/lib/Transforms/Scalar/CMakeLists.txt b/lib/Transforms/Scalar/CMakeLists.txt > index 106fb8f..53fcf69 100644 > --- a/lib/Transforms/Scalar/CMakeLists.txt > +++ b/lib/Transforms/Scalar/CMakeLists.txt > @@ -23,6 +23,7 @@ add_llvm_library(LLVMScalarOpts > MemCpyOptimizer.cpp > Reassociate.cpp > Reg2Mem.cpp > + RegionSimplify.cpp > SCCP.cpp > Scalar.cpp > ScalarReplAggregates.cpp > diff --git a/lib/Transforms/Scalar/RegionSimplify.cpp b/lib/Transforms/Scalar/RegionSimplify.cpp > new file mode 100644 > index 0000000..9c78269 > --- /dev/null > +++ b/lib/Transforms/Scalar/RegionSimplify.cpp > @@ -0,0 +1,191 @@ > +//===- RegionSimplify.cpp -------------------------------------------------===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > +// > +// This file converts refined regions detected by the RegionInfo analysis > +// into simple regions. > +// > +//===----------------------------------------------------------------------===// > + > +#include "llvm/Instructions.h" > +#include "llvm/ADT/Statistic.h" > +#include "llvm/Analysis/Dominators.h" > +#include "llvm/Analysis/RegionPass.h" > +#include "llvm/Analysis/RegionInfo.h" > +#include "llvm/Transforms/Utils/BasicBlockUtils.h" > + > +#define DEBUG_TYPE "region-simplify" > + > +using namespace llvm; > + > +STATISTIC(NumEntries, "The # of created entry edges"); > +STATISTIC(NumExits, "The # of created exit edges"); > + > +namespace { > +class RegionSimplify: public RegionPass { > + bool modified; > + Region *CR; > + void createSingleEntryEdge(Region *R); > + void createSingleExitEdge(Region *R); > +public: > + static char ID; > + explicit RegionSimplify() : > + RegionPass(ID) { > + initializeRegionSimplifyPass(*PassRegistry::getPassRegistry()); > + } > + > + virtual void print(raw_ostream&O, const Module *M) const; > + > + virtual bool runOnRegion(Region *R, RGPassManager&RGM); > + virtual void getAnalysisUsage(AnalysisUsage&AU) const; > +}; > +} > + > +INITIALIZE_PASS(RegionSimplify, "region-simplify", > + "Transform refined regions into simple regions", false, false) > + > +char RegionSimplify::ID = 0; > +namespace llvm { > +Pass *createRegionSimplifyPass() { > + return new RegionSimplify(); > +} > +} > + > +void RegionSimplify::print(raw_ostream&O, const Module *M) const { > + if (!modified) > + return; > + > + BasicBlock *enteringBlock = CR->getEnteringBlock(); > + BasicBlock *exitingBlock = CR->getExitingBlock(); > + > + O<< "\nRegion: ["<< CR->getNameStr()<< "] Edges:\n"; > + if (enteringBlock) > + O<< " Entry: ]"<< enteringBlock->getNameStr()<< " => " > +<< enteringBlock->getNameStr()<< "]\n"; I believe this should be something like: O<< " Entry: ]"<< enteringBlock->getNameStr()<< " => " << CR->getEntry()->getNameStr()<< "]\n"; No need to update the condition as all regions have a entry node. > + if (exitingBlock) > + O<< " Exit: ["<< exitingBlock->getNameStr()<< " => " > +<< exitingBlock->getNameStr()<< "[\n"; if (exitingBlock && CR->getExit()) O<< " Exit: ["<< exitingBlock->getNameStr()<< " => " << CR->getExit() << "[\n"; Here we need to update the condition as the toplevel region does not have an exit node. Unfortunately I could not test this as '-analyze' leads to a crash: opt -region-simplify phi_entry.ll -analyze Printing analysis 'Transform refined regions into simple regions' for region: 'l4 => exit' in function 'f': Stack dump: 0. Program arguments: opt -load /home/grosser/Projekte/polly/build_clang/lib/LLVMPolly.so -region-simplify phi_entry.ll -analyze 1. Running pass 'Function Pass Manager' on module 'phi_entry.ll'. 2. Running pass 'Region Pass Manager' on function '@f' 3. Running pass 'RegionPass Printer: Transform refined regions into simple regions' on basic block '%l4' Segmentation fault Similar crashes for the other test cases. Can you reproduce this? We should add a call to -analysis to the test suite, after this is fixed. > + > + O<< "\n"; > +} > + > +void RegionSimplify::getAnalysisUsage(AnalysisUsage&AU) const { > + AU.addPreserved (); > + AU.addPreserved (); > + AU.addRequired (); Please remove the space before the '()'. > +} > + > +// createSingleEntryEdge - Split the entry basic block of the given > +// region after the last PHINode to form a single entry edge. > +void RegionSimplify::createSingleEntryEdge(Region *R) { Sorry for bugging you again. I changed my mind. Splitting NewExit->OldExit is incorrect. As we need to update Regions that are not descendants of R. I would like to follow the ideas of the LoopPasses and disallow to change anything outside of the Loop/Region currently worked on. Can you just add the code we had in the original patch? I also added some more comments: +// createSingleEntryEdge - Split the entry BasicBlock of the given +// region after the last PHINode to form a single entry edge. +// This is similar to CodeExtractor::severSplitPHINodes +BasicBlock *RegionSimplify::createSingleEntryEdge(Region *R) { + Function *f = R->getEntry()->getParent(); + if (&f->getEntryBlock() == R->getEntry()) + return NULL; // Entry node is the function's entry blocks This can now be removed + BasicBlock *oldEntry = R->getEntry(); + PHINode *PN = dyn_cast (oldEntry->begin()); + if (!PN) + return NULL; // No PHI nodes. I do not see a reason why we should not create a single entry edge, just because there are no PHI nodes. + + BasicBlock::iterator AfterPHIs = oldEntry->getFirstNonPHI(); + BasicBlock *newEntry = oldEntry->splitBasicBlock(AfterPHIs, + oldEntry->getName() + ".simregentry"); region_exit + // Okay, update dominator sets. + if (DominatorTree *DT = getAnalysisIfAvailable()) { + succ_iterator secondSucc = succ_begin(newEntry) + 1; + if (secondSucc == succ_end(newEntry)) //newEntry has 1 successor + DT->splitBlock(newEntry); + else { // newEntry has more than 1 successor, update DT manually + // oldEntry dominates newEntry. So this should be moved up here. We always want to newEntry to the dominator tree DomTreeNode *NewNode = DT->addNewBlock(newEntry, OldEntry); + // newEntry node dominates all other nodes dominated by oldEntry. + DomTreeNode *OldNode = DT->getNode(oldEntry); + if (OldNode) { // don't bother if oldEntry doesn't dominates any node No need for this extra check. In case oldEntry does not dominate anything the loop will just not be executed. Adding more code, if a relevant performance improvement is not shown, is something I would like to avoid. + std::vector Children; + for (DomTreeNode::iterator I = OldNode->begin(), E = OldNode->end(); I + != E; ++I) + Children.push_back(*I); + + DomTreeNode *NewNode = DT->addNewBlock(newEntry, oldEntry); + for (std::vector::iterator I = Children.begin(), E = + Children.end(); I != E; ++I) + DT->changeImmediateDominator(*I, NewNode); + } + } + } + + // Loop over all of the predecessors of the old entry that are in the region, + // changing them to branch to the new entry instead of the old one A little shorter would be: // Change all predecessors of the old entry, that are part of the // region, to branch to the new entry instead of the old one. + for (pred_iterator PI = pred_begin(oldEntry), PE = pred_end(oldEntry); PI + != PE; ++PI) { + if (R->contains(*PI)) { + TerminatorInst *TI = (*PI)->getTerminator(); + TI->replaceUsesOfWith(oldEntry, newEntry); + } + } + + // Okay, everthing within the region is now branching to the right block, we + // just have to update the PHI nodes now, inserting PHI nodes into NewBB. A shorter comment: // Insert required PHI nodes into NewBB. + for (BasicBlock::iterator PI = oldEntry->begin(); isa (PI); ++PI) { It is probably faster to do: for (BasicBlock::iterator PI = oldEntry->begin(), PE = oldEntry->getFirstNonPHI(); PI != PE; ++PI) + PHINode *PN = cast (PI); + // Create a new PHI node in the new region, which has an incoming value + // from oldEntry of PN. + PHINode *NewPN = PHINode::Create(PN->getType(), PN->getName() + ".ph", + newEntry->begin()); + + NewPN->addIncoming(PN, oldEntry); + + // Loop over all of the incoming value in PN, moving them to NewPN if they + // are from the region. Removing the 'Loop over'. No need to explain the for loop: // Move the incoming values of PN to NewPN, if they are contained // in the region. + for (unsigned i = 0; i != PN->getNumIncomingValues(); ++i) { + BasicBlock *HasValToPN = PN->getIncomingBlock(i); + if (R->contains(HasValToPN)) { + NewPN->addIncoming(PN->getIncomingValue(i), HasValToPN); + PN->removeIncomingValue(i); + --i; + } + } + } + + return newEntry; +} > +} > + > +// createSingleExitEdge - Split the exit basic of the given region ^ block > +// to form a single exit edge. > +void RegionSimplify::createSingleExitEdge(Region *R) { > + BasicBlock *oldExit = R->getExit(); > + > + SmallVector Preds; > + for (pred_iterator PI = pred_begin(oldExit), PE = pred_end(oldExit); > + PI != PE; ++PI) > + if (R->contains(*PI)) > + Preds.push_back(*PI); We can add an assert here to check if we need to split at all: assert(Preds.size() && "This region has already a single exit edge"); > + > + BasicBlock *newExit = SplitBlockPredecessors(oldExit, > + Preds.data(), Preds.size(), > + ".single_exit", this); > + RegionInfo *RI =&getAnalysis (); Please remove the space before the '()'. > + > + // We do not need to update entry nodes because this split happens inside > + // this region and it affects only this region and all of its children. Can you add: // Children of this region cannot have an entry node that matches // the exiting node of this region. > + // The new split node belongs to this region > + RI->setRegionFor(newExit,R); > + > + // all children of this region whose exit is oldExit is changed to newExit // If the exit of a descendant of RI is oldExit, change it to // newExit. Maybe this is a little clearer. > + std::vector RQ; > + for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; ++RI) > + RQ.push_back(*RI); > + > + while (!RQ.empty()){ > + R = RQ.back(); > + RQ.pop_back(); The indentation is here just one space. It should be two. > + > + for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; ++RI) > + RQ.push_back(*RI); > + > + if (R->getExit() == oldExit) > + R->replaceExit(newExit); > + } I believe it is correct to optimize this to: while (!RQ.empty()) { R = RQ.back(); RQ.pop_back(); if (R->getExit() != oldExit) continue; for (Region::const_iterator RI = R->begin(), RE = R->end(); RI!=RE; ++RI) RQ.push_back(*RI); R->replaceExit(newExit); } This passes all test cases. In case this is incorrect, please add a test case that shows it is incorrect. > + > +} > + > +bool RegionSimplify::runOnRegion(Region *R, RGPassManager&RGM) { > + modified = false; > + > + if (!R->isTopLevelRegion()) { Can you change this to: if (R->isTopLevelRegion) return false; And reduce the indentation. > + // split entry node if the region has multiple entry edges // The region has multiple exits. Comments start with a large letter and finish with a '.' or something equivalent. I also propose to remove the part 'Split entry node' as this information is nicely available in the name of the function called afterwords. > + if (!(R->getEnteringBlock()) > +&& (pred_begin(R->getEntry()) != pred_end(R->getEntry()))) { > + createSingleEntryEdge(R); > + modified = true; > + ++NumEntries; > + } > + > + // The region has multiple exit edges. > + if (!(R->getExitingBlock())) { > + createSingleExitEdge(R); > + modified = true; > + ++NumExits; > + } > + } > + > + return modified; > +} > diff --git a/lib/Transforms/Scalar/Scalar.cpp b/lib/Transforms/Scalar/Scalar.cpp > index bf9ca6d..5d18f22 100644 > --- a/lib/Transforms/Scalar/Scalar.cpp > +++ b/lib/Transforms/Scalar/Scalar.cpp > @@ -51,6 +51,7 @@ void llvm::initializeScalarOpts(PassRegistry&Registry) { > initializeMemCpyOptPass(Registry); > initializeReassociatePass(Registry); > initializeRegToMemPass(Registry); > + initializeRegionSimplifyPass(Registry); > initializeSCCPPass(Registry); > initializeIPSCCPPass(Registry); > initializeSROA_DTPass(Registry); > diff --git a/test/Transforms/RegionSimplify/basic_test.ll b/test/Transforms/RegionSimplify/basic_test.ll > new file mode 100644 > index 0000000..e51772f > --- /dev/null > +++ b/test/Transforms/RegionSimplify/basic_test.ll > @@ -0,0 +1,28 @@ > +; RUN: opt< %s -region-simplify -S | FileCheck %s Very nice test cases. Just one thing. Can you add -verify-region-info to the flags of all tests? (I tried it and it works). Tobi From aggarwa4 at illinois.edu Wed Mar 2 16:36:54 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 02 Mar 2011 22:36:54 -0000 Subject: [llvm-commits] [poolalloc] r126889 - /poolalloc/trunk/lib/DSA/DataStructure.cpp Message-ID: <20110302223654.A400A2A6C12C@llvm.org> Author: aggarwa4 Date: Wed Mar 2 16:36:54 2011 New Revision: 126889 URL: http://llvm.org/viewvc/llvm-project?rev=126889&view=rev Log: When merging call sites, either the caller or callee might have extra params. Handle each case appropriately. See comments in code. Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=126889&r1=126888&r2=126889&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DataStructure.cpp (original) +++ poolalloc/trunk/lib/DSA/DataStructure.cpp Wed Mar 2 16:36:54 2011 @@ -983,8 +983,22 @@ for (unsigned a = 0; a != MinArgs; ++a) merge(DestCS.getPtrArg(a), SrcCS.getPtrArg(a)); - for (unsigned a = MinArgs, e = SrcCS.getNumPtrArgs(); a != e; ++a) - DestCS.addPtrArg(getClonedNH(SrcCS.getPtrArg(a))); + for (unsigned a = MinArgs, e = SrcCS.getNumPtrArgs(); a != e; ++a) { + // If a call site passes more params, ignore the extra params. + // If the called function is varargs, merge the extra params, with + // the varargs node. + if(DestCS.getVAVal() != NULL) { + merge(DestCS.getVAVal(), SrcCS.getPtrArg(a)); + } + } + + for (unsigned a = MinArgs, e = DestCS.getNumPtrArgs(); a!=e; ++a) { + // If a call site passes less explicit params, than the function needs + // But passes params through a varargs node, merge those in. + if(SrcCS.getVAVal() != NULL) { + merge(DestCS.getPtrArg(a), SrcCS.getVAVal()); + } + } } DSCallSite ReachabilityCloner::cloneCallSite(const DSCallSite& SrcCS) { From stoklund at 2pi.dk Wed Mar 2 17:05:16 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 02 Mar 2011 23:05:16 -0000 Subject: [llvm-commits] [llvm] r126893 - in /llvm/trunk/lib/CodeGen: SplitKit.cpp SplitKit.h Message-ID: <20110302230516.9BAD72A6C12D@llvm.org> Author: stoklund Date: Wed Mar 2 17:05:16 2011 New Revision: 126893 URL: http://llvm.org/viewvc/llvm-project?rev=126893&view=rev Log: Extract a method. No functional change. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=126893&r1=126892&r2=126893&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Wed Mar 2 17:05:16 2011 @@ -646,6 +646,29 @@ OpenIdx = 0; } +void SplitEditor::extendPHIKillRanges() { + // Extend live ranges to be live-out for successor PHI values. + for (LiveInterval::const_vni_iterator I = Edit.getParent().vni_begin(), + E = Edit.getParent().vni_end(); I != E; ++I) { + const VNInfo *PHIVNI = *I; + if (PHIVNI->isUnused() || !PHIVNI->isPHIDef()) + continue; + unsigned RegIdx = RegAssign.lookup(PHIVNI->def); + MachineBasicBlock *MBB = LIS.getMBBFromIndex(PHIVNI->def); + for (MachineBasicBlock::pred_iterator PI = MBB->pred_begin(), + PE = MBB->pred_end(); PI != PE; ++PI) { + SlotIndex End = LIS.getMBBEndIdx(*PI).getPrevSlot(); + // The predecessor may not have a live-out value. That is OK, like an + // undef PHI operand. + if (Edit.getParent().liveAt(End)) { + assert(RegAssign.lookup(End) == RegIdx && + "Different register assignment in phi predecessor"); + extendRange(RegIdx, End); + } + } + } +} + /// rewriteAssigned - Rewrite all uses of Edit.getReg(). void SplitEditor::rewriteAssigned() { for (MachineRegisterInfo::reg_iterator RI = MRI.reg_begin(Edit.getReg()), @@ -737,34 +760,8 @@ // All other values have simple liveness that can be computed from RegAssign // and the parent live interval. - // Extend live ranges to be live-out for successor PHI values. - for (LiveInterval::const_vni_iterator I = Edit.getParent().vni_begin(), - E = Edit.getParent().vni_end(); I != E; ++I) { - const VNInfo *PHIVNI = *I; - if (PHIVNI->isUnused() || !PHIVNI->isPHIDef()) - continue; - unsigned RegIdx = RegAssign.lookup(PHIVNI->def); - MachineBasicBlock *MBB = LIS.getMBBFromIndex(PHIVNI->def); - DEBUG(dbgs() << " map phi in BB#" << MBB->getNumber() << '@' << PHIVNI->def - << " -> " << RegIdx << '\n'); - for (MachineBasicBlock::pred_iterator PI = MBB->pred_begin(), - PE = MBB->pred_end(); PI != PE; ++PI) { - SlotIndex End = LIS.getMBBEndIdx(*PI).getPrevSlot(); - DEBUG(dbgs() << " pred BB#" << (*PI)->getNumber() << '@' << End); - // The predecessor may not have a live-out value. That is OK, like an - // undef PHI operand. - if (Edit.getParent().liveAt(End)) { - DEBUG(dbgs() << " has parent live out\n"); - assert(RegAssign.lookup(End) == RegIdx && - "Different register assignment in phi predecessor"); - extendRange(RegIdx, End); - } else - DEBUG(dbgs() << " is not live-out\n"); - } - DEBUG(dbgs() << " " << *Edit.get(RegIdx) << '\n'); - } - // Rewrite instructions. + extendPHIKillRanges(); rewriteAssigned(); // FIXME: Delete defs that were rematted everywhere. Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=126893&r1=126892&r2=126893&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Wed Mar 2 17:05:16 2011 @@ -246,6 +246,10 @@ SlotIndex Idx, const MachineBasicBlock *IdxMBB); + /// extendPHIKillRanges - Extend the ranges of all values killed by original + /// parent PHIDefs. + void extendPHIKillRanges(); + /// rewriteAssigned - Rewrite all uses of Edit.getReg() to assigned registers. void rewriteAssigned(); From stoklund at 2pi.dk Wed Mar 2 17:05:19 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 02 Mar 2011 23:05:19 -0000 Subject: [llvm-commits] [llvm] r126894 - in /llvm/trunk/lib/CodeGen: LiveRangeEdit.h SplitKit.cpp SplitKit.h Message-ID: <20110302230519.7F3AE2A6C12F@llvm.org> Author: stoklund Date: Wed Mar 2 17:05:19 2011 New Revision: 126894 URL: http://llvm.org/viewvc/llvm-project?rev=126894&view=rev Log: Transfer simply defined values directly without recomputing liveness and SSA. Values that map to a single new value in a new interval after splitting don't need new PHIDefs, and if the parent value was never rematerialized the live range will be the same. Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.h llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveRangeEdit.h?rev=126894&r1=126893&r2=126894&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveRangeEdit.h (original) +++ llvm/trunk/lib/CodeGen/LiveRangeEdit.h Wed Mar 2 17:05:19 2011 @@ -41,11 +41,11 @@ /// remattable_ - Values defined by remattable instructions as identified by /// tii.isTriviallyReMaterializable(). - SmallPtrSet remattable_; + SmallPtrSet remattable_; /// rematted_ - Values that were actually rematted, and so need to have their /// live range trimmed or entirely removed. - SmallPtrSet rematted_; + SmallPtrSet rematted_; /// scanRemattable - Identify the parent_ values that may rematerialize. void scanRemattable(LiveIntervals &lis, @@ -120,12 +120,12 @@ /// markRematerialized - explicitly mark a value as rematerialized after doing /// it manually. - void markRematerialized(VNInfo *ParentVNI) { + void markRematerialized(const VNInfo *ParentVNI) { rematted_.insert(ParentVNI); } /// didRematerialize - Return true if ParentVNI was rematerialized anywhere. - bool didRematerialize(VNInfo *ParentVNI) const { + bool didRematerialize(const VNInfo *ParentVNI) const { return rematted_.count(ParentVNI); } }; Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=126894&r1=126893&r2=126894&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Wed Mar 2 17:05:19 2011 @@ -16,6 +16,7 @@ #include "SplitKit.h" #include "LiveRangeEdit.h" #include "VirtRegMap.h" +#include "llvm/ADT/Statistic.h" #include "llvm/CodeGen/CalcSpillWeights.h" #include "llvm/CodeGen/LiveIntervalAnalysis.h" #include "llvm/CodeGen/MachineDominators.h" @@ -33,6 +34,9 @@ AllowSplit("spiller-splits-edges", cl::desc("Allow critical edge splitting during spilling")); +STATISTIC(NumFinished, "Number of splits finished"); +STATISTIC(NumSimple, "Number of splits that were simple"); + //===----------------------------------------------------------------------===// // Split Analysis //===----------------------------------------------------------------------===// @@ -497,9 +501,6 @@ Def = LIS.InsertMachineInstrInMaps(CopyMI).getDefIndex(); } - // Temporarily mark all values as complex mapped. - markComplexMapped(RegIdx, ParentVNI); - // Define the value in Reg. VNInfo *VNI = defValue(RegIdx, ParentVNI, Def); VNI->setCopy(CopyMI); @@ -625,15 +626,14 @@ void SplitEditor::overlapIntv(SlotIndex Start, SlotIndex End) { assert(OpenIdx && "openIntv not called before overlapIntv"); - assert(Edit.getParent().getVNInfoAt(Start) == - Edit.getParent().getVNInfoAt(End.getPrevSlot()) && + const VNInfo *ParentVNI = Edit.getParent().getVNInfoAt(Start); + assert(ParentVNI == Edit.getParent().getVNInfoAt(End.getPrevSlot()) && "Parent changes value in extended range"); - assert(Edit.get(0)->getVNInfoAt(Start) && "Start must come from leaveIntv*"); assert(LIS.getMBBFromIndex(Start) == LIS.getMBBFromIndex(End) && "Range cannot span basic blocks"); - // Treat this as useIntv() for now. // The complement interval will be extended as needed by extendRange(). + markComplexMapped(0, ParentVNI); DEBUG(dbgs() << " overlapIntv [" << Start << ';' << End << "):"); RegAssign.insert(Start, End, OpenIdx); DEBUG(dump()); @@ -646,6 +646,47 @@ OpenIdx = 0; } +/// transferSimpleValues - Transfer all simply defined values to the new live +/// ranges. +/// Values that were rematerialized or that have multiple defs are left alone. +bool SplitEditor::transferSimpleValues() { + bool Skipped = false; + RegAssignMap::const_iterator AssignI = RegAssign.begin(); + for (LiveInterval::const_iterator ParentI = Edit.getParent().begin(), + ParentE = Edit.getParent().end(); ParentI != ParentE; ++ParentI) { + DEBUG(dbgs() << " blit " << *ParentI << ':'); + VNInfo *ParentVNI = ParentI->valno; + // RegAssign has holes where RegIdx 0 should be used. + SlotIndex Start = ParentI->start; + AssignI.advanceTo(Start); + do { + unsigned RegIdx; + SlotIndex End = ParentI->end; + if (!AssignI.valid()) { + RegIdx = 0; + } else if (AssignI.start() <= Start) { + RegIdx = AssignI.value(); + if (AssignI.stop() < End) { + End = AssignI.stop(); + ++AssignI; + } + } else { + RegIdx = 0; + End = std::min(End, AssignI.start()); + } + DEBUG(dbgs() << " [" << Start << ';' << End << ")=" << RegIdx); + if (VNInfo *VNI = Values.lookup(std::make_pair(RegIdx, ParentVNI->id))) { + DEBUG(dbgs() << ':' << VNI->id); + Edit.get(RegIdx)->addRange(LiveRange(Start, End, VNI)); + } else + Skipped = true; + Start = End; + } while (Start != ParentI->end); + DEBUG(dbgs() << '\n'); + } + return Skipped; +} + void SplitEditor::extendPHIKillRanges() { // Extend live ranges to be live-out for successor PHI values. for (LiveInterval::const_vni_iterator I = Edit.getParent().vni_begin(), @@ -670,7 +711,7 @@ } /// rewriteAssigned - Rewrite all uses of Edit.getReg(). -void SplitEditor::rewriteAssigned() { +void SplitEditor::rewriteAssigned(bool ExtendRanges) { for (MachineRegisterInfo::reg_iterator RI = MRI.reg_begin(Edit.getReg()), RE = MRI.reg_end(); RI != RE;) { MachineOperand &MO = RI.getOperand(); @@ -700,7 +741,8 @@ << Idx << ':' << RegIdx << '\t' << *MI); // Extend liveness to Idx. - extendRange(RegIdx, Idx); + if (ExtendRanges) + extendRange(RegIdx, Idx); } } @@ -728,6 +770,7 @@ void SplitEditor::finish() { assert(OpenIdx == 0 && "Previous LI not closed before rewrite"); + ++NumFinished; // At this point, the live intervals in Edit contain VNInfos corresponding to // the inserted copies. @@ -739,10 +782,12 @@ if (ParentVNI->isUnused()) continue; unsigned RegIdx = RegAssign.lookup(ParentVNI->def); - // Mark all values as complex to force liveness computation. - // This should really only be necessary for remat victims, but we are lazy. - markComplexMapped(RegIdx, ParentVNI); defValue(RegIdx, ParentVNI, ParentVNI->def); + // Mark rematted values as complex everywhere to force liveness computation. + // The new live ranges may be truncated. + if (Edit.didRematerialize(ParentVNI)) + for (unsigned i = 0, e = Edit.size(); i != e; ++i) + markComplexMapped(i, ParentVNI); } #ifndef NDEBUG @@ -751,18 +796,15 @@ assert((*I)->hasAtLeastOneValue() && "Split interval has no value"); #endif - // FIXME: Don't recompute the liveness of all values, infer it from the - // overlaps between the parent live interval and RegAssign. - // The extendRange algorithm is only necessary when: - // - The parent value maps to multiple defs, and new phis are needed, or - // - The value has been rematerialized before some uses, and we want to - // minimize the live range so it only reaches the remaining uses. - // All other values have simple liveness that can be computed from RegAssign - // and the parent live interval. - - // Rewrite instructions. - extendPHIKillRanges(); - rewriteAssigned(); + // Transfer the simply mapped values, check if any are complex. + bool Complex = transferSimpleValues(); + if (Complex) + extendPHIKillRanges(); + else + ++NumSimple; + + // Rewrite virtual registers, possibly extending ranges. + rewriteAssigned(Complex); // FIXME: Delete defs that were rematted everywhere. Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=126894&r1=126893&r2=126894&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Wed Mar 2 17:05:19 2011 @@ -246,12 +246,16 @@ SlotIndex Idx, const MachineBasicBlock *IdxMBB); + /// transferSimpleValues - Transfer simply defined values to the new ranges. + /// Return true if any complex ranges were skipped. + bool transferSimpleValues(); + /// extendPHIKillRanges - Extend the ranges of all values killed by original /// parent PHIDefs. void extendPHIKillRanges(); /// rewriteAssigned - Rewrite all uses of Edit.getReg() to assigned registers. - void rewriteAssigned(); + void rewriteAssigned(bool ExtendRanges); /// rewriteComponents - Rewrite all uses of Intv[0] according to the eq /// classes in ConEQ. From enderby at apple.com Wed Mar 2 17:08:33 2011 From: enderby at apple.com (Kevin Enderby) Date: Wed, 02 Mar 2011 23:08:33 -0000 Subject: [llvm-commits] [llvm] r126895 - in /llvm/trunk: lib/Target/ARM/ARMInstrInfo.td test/MC/Disassembler/ARM/arm-tests.txt Message-ID: <20110302230833.8B7AC2A6C12C@llvm.org> Author: enderby Date: Wed Mar 2 17:08:33 2011 New Revision: 126895 URL: http://llvm.org/viewvc/llvm-project?rev=126895&view=rev Log: Fixes an assertion failure while disassembling ARM rsbs reg/reg form. Patch by Ted Kremenek! Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=126895&r1=126894&r2=126895&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Mar 2 17:08:33 2011 @@ -2203,6 +2203,19 @@ let Inst{19-16} = Rn; let Inst{11-0} = imm; } +def RSBSrr : AI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, + IIC_iALUr, "rsbs", "\t$Rd, $Rn, $Rm", + [/* For disassembly only; pattern left blank */]> { + bits<4> Rd; + bits<4> Rn; + bits<4> Rm; + let Inst{11-4} = 0b00000000; + let Inst{25} = 0; + let Inst{20} = 1; + let Inst{3-0} = Rm; + let Inst{15-12} = Rd; + let Inst{19-16} = Rn; +} def RSBSrs : AI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), DPSoRegFrm, IIC_iALUsr, "rsbs", "\t$Rd, $Rn, $shift", [(set GPR:$Rd, (subc so_reg:$shift, GPR:$Rn))]> { Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt?rev=126895&r1=126894&r2=126895&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Wed Mar 2 17:08:33 2011 @@ -130,3 +130,6 @@ # CHECK: msr cpsr_fc, r0 0x00 0xf0 0x29 0xe1 + +# CHECK: rsbs r6, r7, r8 +0x08 0x60 0x77 0xe0 From geek4civic at gmail.com Wed Mar 2 17:17:35 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Thu, 3 Mar 2011 08:17:35 +0900 Subject: [llvm-commits] [llvm] r126862 - in /llvm/trunk: include/llvm/CallingConv.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Target/X86/X86CallingConv.td lib/VMCore/AsmWriter.cpp In-Reply-To: <20110302192922.716EF2A6C12C@llvm.org> References: <20110302192922.716EF2A6C12C@llvm.org> Message-ID: Good morning, Tilmann. Naive question. Why didn't you reuse x86_thiscall for x64? ...Takumi From gkistanova at gmail.com Wed Mar 2 17:21:25 2011 From: gkistanova at gmail.com (Galina Kistanova) Date: Wed, 2 Mar 2011 15:21:25 -0800 Subject: [llvm-commits] Failed build llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi In-Reply-To: References: Message-ID: Hi Jacob, Please see .bc file attached. Thanks Galina On Wed, Mar 2, 2011 at 11:58 AM, Jakob Stoklund Olesen wrote: > > On Mar 2, 2011, at 11:41 AM, Galina Kistanova wrote: > >> Just a short notice, >> the last successful build for 3-srage-builder >> llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi was yesterday for >> revision 126801, the fist failed build is for revision 126817: >> >> http://google1.osuosl.org:8011/builders/llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi/builds/294 > > The assertion failure is likely caused by one of my patches: > Assertion failed: (PVNI->hasPHIKill() && "Missing hasPHIKill flag"), function shrinkToUses, file /Users/buildslave/zorg/buildbot/smooshlab/slave/llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi/llvm.src/lib/CodeGen/LiveIntervalAnalysis.cpp, line 809. > > I don't think I can reproduce what this bot is doing, is there any way you can get me a bitcode file? > > Thanks, > /jakob > > -------------- next part -------------- A non-text attachment was scrubbed... Name: tree-stdarg.bc Type: application/octet-stream Size: 133808 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110302/2a9e5485/attachment-0001.obj From stuart at apple.com Wed Mar 2 17:24:44 2011 From: stuart at apple.com (Stuart Hastings) Date: Wed, 02 Mar 2011 23:24:44 -0000 Subject: [llvm-commits] [llvm] r126896 - /llvm/trunk/test/FrontendC/2011-03-02-UnionInitializer.c Message-ID: <20110302232444.59B452A6C12C@llvm.org> Author: stuart Date: Wed Mar 2 17:24:44 2011 New Revision: 126896 URL: http://llvm.org/viewvc/llvm-project?rev=126896&view=rev Log: Test case for r126672. Radar 9055247. Added: llvm/trunk/test/FrontendC/2011-03-02-UnionInitializer.c Added: llvm/trunk/test/FrontendC/2011-03-02-UnionInitializer.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2011-03-02-UnionInitializer.c?rev=126896&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/2011-03-02-UnionInitializer.c (added) +++ llvm/trunk/test/FrontendC/2011-03-02-UnionInitializer.c Wed Mar 2 17:24:44 2011 @@ -0,0 +1,2 @@ +// RUN: %llvmgcc -S %s +union { int :3; double f; } u17_017 = {17.17}; From stuart at apple.com Wed Mar 2 17:32:16 2011 From: stuart at apple.com (Stuart Hastings) Date: Wed, 2 Mar 2011 15:32:16 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r126672 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <4D6CB603.4080600@free.fr> References: <20110228194800.B507F2A6C12C@llvm.org> <4D6CB603.4080600@free.fr> Message-ID: <08F6841B-841C-4841-A83B-172F8CA4C547@apple.com> On Mar 1, 2011, at 1:01 AM, Duncan Sands wrote: > Hi Stuart, > >> Skip anonymous union fields when initializing. Radar 9055247. > > please add a testcase. r126896 >> - // Unions are initialized using the first member field. Find it. >> + // Unions are initialized using the first non-anonymous member field. Find it. > > I'm curious to know what this is based on? This ICEd LLVM-GCC: union { int :3; double f; } u17_017 = {17.17}; > Does the C standard say this? I'm not a language lawyer, but one of my local Language Lawyers said "yes." stuart > Thanks, Duncan. > >> tree Field = TYPE_FIELDS(TREE_TYPE(exp)); >> assert(Field&& "cannot initialize union with no fields"); >> - while (TREE_CODE(Field) != FIELD_DECL) { >> + while (TREE_CODE(Field) != FIELD_DECL || DECL_NAME(Field) == NULL_TREE) { >> Field = TREE_CHAIN(Field); >> assert(Field&& "cannot initialize union with no fields"); >> } >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From stoklund at 2pi.dk Wed Mar 2 17:31:50 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 02 Mar 2011 23:31:50 -0000 Subject: [llvm-commits] [llvm] r126898 - in /llvm/trunk/lib/CodeGen: SplitKit.cpp SplitKit.h Message-ID: <20110302233150.57CBE2A6C12C@llvm.org> Author: stoklund Date: Wed Mar 2 17:31:50 2011 New Revision: 126898 URL: http://llvm.org/viewvc/llvm-project?rev=126898&view=rev Log: Turn the Edit member into a pointer so it can change dynamically. No functional change. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=126898&r1=126897&r2=126898&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Wed Mar 2 17:31:50 2011 @@ -216,13 +216,13 @@ MDT(mdt), TII(*vrm.getMachineFunction().getTarget().getInstrInfo()), TRI(*vrm.getMachineFunction().getTarget().getRegisterInfo()), - Edit(edit), + Edit(&edit), OpenIdx(0), RegAssign(Allocator) { // We don't need an AliasAnalysis since we will only be performing // cheap-as-a-copy remats anyway. - Edit.anyRematerializable(LIS, TII, 0); + Edit->anyRematerializable(LIS, TII, 0); } void SplitEditor::dump() const { @@ -241,8 +241,8 @@ SlotIndex Idx) { assert(ParentVNI && "Mapping NULL value"); assert(Idx.isValid() && "Invalid SlotIndex"); - assert(Edit.getParent().getVNInfoAt(Idx) == ParentVNI && "Bad Parent VNI"); - LiveInterval *LI = Edit.get(RegIdx); + assert(Edit->getParent().getVNInfoAt(Idx) == ParentVNI && "Bad Parent VNI"); + LiveInterval *LI = Edit->get(RegIdx); // Create a new value. VNInfo *VNI = LI->getNextValue(Idx, 0, LIS.getVNInfoAllocator()); @@ -286,7 +286,7 @@ // This was previously a single mapping. Make sure the old def is represented // by a trivial live range. SlotIndex Def = VNI->def; - Edit.get(RegIdx)->addRange(LiveRange(Def, Def.getNextSlot(), VNI)); + Edit->get(RegIdx)->addRange(LiveRange(Def, Def.getNextSlot(), VNI)); VNI = 0; } @@ -296,7 +296,7 @@ assert(Idx.isValid() && "Invalid SlotIndex"); MachineBasicBlock *IdxMBB = LIS.getMBBFromIndex(Idx); assert(IdxMBB && "No MBB at Idx"); - LiveInterval *LI = Edit.get(RegIdx); + LiveInterval *LI = Edit->get(RegIdx); // Is there a def in the same MBB we can extend? if (LI->extendInBlock(LIS.getMBBStartIdx(IdxMBB), Idx)) @@ -384,7 +384,7 @@ const MachineBasicBlock *IdxMBB) { // This is essentially the same iterative algorithm that SSAUpdater uses, // except we already have a dominator tree, so we don't have to recompute it. - LiveInterval *LI = Edit.get(RegIdx); + LiveInterval *LI = Edit->get(RegIdx); VNInfo *IdxVNI = 0; unsigned Changes; do { @@ -488,16 +488,16 @@ MachineBasicBlock::iterator I) { MachineInstr *CopyMI = 0; SlotIndex Def; - LiveInterval *LI = Edit.get(RegIdx); + LiveInterval *LI = Edit->get(RegIdx); // Attempt cheap-as-a-copy rematerialization. LiveRangeEdit::Remat RM(ParentVNI); - if (Edit.canRematerializeAt(RM, UseIdx, true, LIS)) { - Def = Edit.rematerializeAt(MBB, I, LI->reg, RM, LIS, TII, TRI); + if (Edit->canRematerializeAt(RM, UseIdx, true, LIS)) { + Def = Edit->rematerializeAt(MBB, I, LI->reg, RM, LIS, TII, TRI); } else { // Can't remat, just insert a copy from parent. CopyMI = BuildMI(MBB, I, DebugLoc(), TII.get(TargetOpcode::COPY), LI->reg) - .addReg(Edit.getReg()); + .addReg(Edit->getReg()); Def = LIS.InsertMachineInstrInMaps(CopyMI).getDefIndex(); } @@ -512,19 +512,19 @@ assert(!OpenIdx && "Previous LI not closed before openIntv"); // Create the complement as index 0. - if (Edit.empty()) - Edit.create(MRI, LIS, VRM); + if (Edit->empty()) + Edit->create(MRI, LIS, VRM); // Create the open interval. - OpenIdx = Edit.size(); - Edit.create(MRI, LIS, VRM); + OpenIdx = Edit->size(); + Edit->create(MRI, LIS, VRM); } SlotIndex SplitEditor::enterIntvBefore(SlotIndex Idx) { assert(OpenIdx && "openIntv not called before enterIntvBefore"); DEBUG(dbgs() << " enterIntvBefore " << Idx); Idx = Idx.getBaseIndex(); - VNInfo *ParentVNI = Edit.getParent().getVNInfoAt(Idx); + VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx); if (!ParentVNI) { DEBUG(dbgs() << ": not live\n"); return Idx; @@ -542,14 +542,14 @@ SlotIndex End = LIS.getMBBEndIdx(&MBB); SlotIndex Last = End.getPrevSlot(); DEBUG(dbgs() << " enterIntvAtEnd BB#" << MBB.getNumber() << ", " << Last); - VNInfo *ParentVNI = Edit.getParent().getVNInfoAt(Last); + VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Last); if (!ParentVNI) { DEBUG(dbgs() << ": not live\n"); return End; } DEBUG(dbgs() << ": valno " << ParentVNI->id); VNInfo *VNI = defFromParent(OpenIdx, ParentVNI, Last, MBB, - LIS.getLastSplitPoint(Edit.getParent(), &MBB)); + LIS.getLastSplitPoint(Edit->getParent(), &MBB)); RegAssign.insert(VNI->def, End, OpenIdx); DEBUG(dump()); return VNI->def; @@ -573,7 +573,7 @@ // The interval must be live beyond the instruction at Idx. Idx = Idx.getBoundaryIndex(); - VNInfo *ParentVNI = Edit.getParent().getVNInfoAt(Idx); + VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx); if (!ParentVNI) { DEBUG(dbgs() << ": not live\n"); return Idx.getNextSlot(); @@ -593,7 +593,7 @@ // The interval must be live into the instruction at Idx. Idx = Idx.getBoundaryIndex(); - VNInfo *ParentVNI = Edit.getParent().getVNInfoAt(Idx); + VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx); if (!ParentVNI) { DEBUG(dbgs() << ": not live\n"); return Idx.getNextSlot(); @@ -611,7 +611,7 @@ SlotIndex Start = LIS.getMBBStartIdx(&MBB); DEBUG(dbgs() << " leaveIntvAtTop BB#" << MBB.getNumber() << ", " << Start); - VNInfo *ParentVNI = Edit.getParent().getVNInfoAt(Start); + VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Start); if (!ParentVNI) { DEBUG(dbgs() << ": not live\n"); return Start; @@ -626,8 +626,8 @@ void SplitEditor::overlapIntv(SlotIndex Start, SlotIndex End) { assert(OpenIdx && "openIntv not called before overlapIntv"); - const VNInfo *ParentVNI = Edit.getParent().getVNInfoAt(Start); - assert(ParentVNI == Edit.getParent().getVNInfoAt(End.getPrevSlot()) && + const VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Start); + assert(ParentVNI == Edit->getParent().getVNInfoAt(End.getPrevSlot()) && "Parent changes value in extended range"); assert(LIS.getMBBFromIndex(Start) == LIS.getMBBFromIndex(End) && "Range cannot span basic blocks"); @@ -652,8 +652,8 @@ bool SplitEditor::transferSimpleValues() { bool Skipped = false; RegAssignMap::const_iterator AssignI = RegAssign.begin(); - for (LiveInterval::const_iterator ParentI = Edit.getParent().begin(), - ParentE = Edit.getParent().end(); ParentI != ParentE; ++ParentI) { + for (LiveInterval::const_iterator ParentI = Edit->getParent().begin(), + ParentE = Edit->getParent().end(); ParentI != ParentE; ++ParentI) { DEBUG(dbgs() << " blit " << *ParentI << ':'); VNInfo *ParentVNI = ParentI->valno; // RegAssign has holes where RegIdx 0 should be used. @@ -677,7 +677,7 @@ DEBUG(dbgs() << " [" << Start << ';' << End << ")=" << RegIdx); if (VNInfo *VNI = Values.lookup(std::make_pair(RegIdx, ParentVNI->id))) { DEBUG(dbgs() << ':' << VNI->id); - Edit.get(RegIdx)->addRange(LiveRange(Start, End, VNI)); + Edit->get(RegIdx)->addRange(LiveRange(Start, End, VNI)); } else Skipped = true; Start = End; @@ -689,8 +689,8 @@ void SplitEditor::extendPHIKillRanges() { // Extend live ranges to be live-out for successor PHI values. - for (LiveInterval::const_vni_iterator I = Edit.getParent().vni_begin(), - E = Edit.getParent().vni_end(); I != E; ++I) { + for (LiveInterval::const_vni_iterator I = Edit->getParent().vni_begin(), + E = Edit->getParent().vni_end(); I != E; ++I) { const VNInfo *PHIVNI = *I; if (PHIVNI->isUnused() || !PHIVNI->isPHIDef()) continue; @@ -701,7 +701,7 @@ SlotIndex End = LIS.getMBBEndIdx(*PI).getPrevSlot(); // The predecessor may not have a live-out value. That is OK, like an // undef PHI operand. - if (Edit.getParent().liveAt(End)) { + if (Edit->getParent().liveAt(End)) { assert(RegAssign.lookup(End) == RegIdx && "Different register assignment in phi predecessor"); extendRange(RegIdx, End); @@ -710,9 +710,9 @@ } } -/// rewriteAssigned - Rewrite all uses of Edit.getReg(). +/// rewriteAssigned - Rewrite all uses of Edit->getReg(). void SplitEditor::rewriteAssigned(bool ExtendRanges) { - for (MachineRegisterInfo::reg_iterator RI = MRI.reg_begin(Edit.getReg()), + for (MachineRegisterInfo::reg_iterator RI = MRI.reg_begin(Edit->getReg()), RE = MRI.reg_end(); RI != RE;) { MachineOperand &MO = RI.getOperand(); MachineInstr *MI = MO.getParent(); @@ -727,7 +727,7 @@ // operands don't really read the register, so just assign them to // the complement. if (MO.isUse() && MO.isUndef()) { - MO.setReg(Edit.get(0)->reg); + MO.setReg(Edit->get(0)->reg); continue; } @@ -736,7 +736,7 @@ // Rewrite to the mapped register at Idx. unsigned RegIdx = RegAssign.lookup(Idx); - MO.setReg(Edit.get(RegIdx)->reg); + MO.setReg(Edit->get(RegIdx)->reg); DEBUG(dbgs() << " rewr BB#" << MI->getParent()->getNumber() << '\t' << Idx << ':' << RegIdx << '\t' << *MI); @@ -776,8 +776,8 @@ // the inserted copies. // Add the original defs from the parent interval. - for (LiveInterval::const_vni_iterator I = Edit.getParent().vni_begin(), - E = Edit.getParent().vni_end(); I != E; ++I) { + for (LiveInterval::const_vni_iterator I = Edit->getParent().vni_begin(), + E = Edit->getParent().vni_end(); I != E; ++I) { const VNInfo *ParentVNI = *I; if (ParentVNI->isUnused()) continue; @@ -785,14 +785,14 @@ defValue(RegIdx, ParentVNI, ParentVNI->def); // Mark rematted values as complex everywhere to force liveness computation. // The new live ranges may be truncated. - if (Edit.didRematerialize(ParentVNI)) - for (unsigned i = 0, e = Edit.size(); i != e; ++i) + if (Edit->didRematerialize(ParentVNI)) + for (unsigned i = 0, e = Edit->size(); i != e; ++i) markComplexMapped(i, ParentVNI); } #ifndef NDEBUG // Every new interval must have a def by now, otherwise the split is bogus. - for (LiveRangeEdit::iterator I = Edit.begin(), E = Edit.end(); I != E; ++I) + for (LiveRangeEdit::iterator I = Edit->begin(), E = Edit->end(); I != E; ++I) assert((*I)->hasAtLeastOneValue() && "Split interval has no value"); #endif @@ -809,14 +809,14 @@ // FIXME: Delete defs that were rematted everywhere. // Get rid of unused values and set phi-kill flags. - for (LiveRangeEdit::iterator I = Edit.begin(), E = Edit.end(); I != E; ++I) + for (LiveRangeEdit::iterator I = Edit->begin(), E = Edit->end(); I != E; ++I) (*I)->RenumberValues(LIS); // Now check if any registers were separated into multiple components. ConnectedVNInfoEqClasses ConEQ(LIS); - for (unsigned i = 0, e = Edit.size(); i != e; ++i) { + for (unsigned i = 0, e = Edit->size(); i != e; ++i) { // Don't use iterators, they are invalidated by create() below. - LiveInterval *li = Edit.get(i); + LiveInterval *li = Edit->get(i); unsigned NumComp = ConEQ.Classify(li); if (NumComp <= 1) continue; @@ -824,14 +824,14 @@ SmallVector dups; dups.push_back(li); for (unsigned i = 1; i != NumComp; ++i) - dups.push_back(&Edit.create(MRI, LIS, VRM)); + dups.push_back(&Edit->create(MRI, LIS, VRM)); rewriteComponents(dups, ConEQ); ConEQ.Distribute(&dups[0]); } // Calculate spill weight and allocation hints for new intervals. VirtRegAuxInfo vrai(VRM.getMachineFunction(), LIS, SA.Loops); - for (LiveRangeEdit::iterator I = Edit.begin(), E = Edit.end(); I != E; ++I){ + for (LiveRangeEdit::iterator I = Edit->begin(), E = Edit->end(); I != E; ++I){ LiveInterval &li = **I; vrai.CalculateRegClass(li.reg); vrai.CalculateWeightAndHint(li); Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=126898&r1=126897&r2=126898&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Wed Mar 2 17:31:50 2011 @@ -165,7 +165,7 @@ const TargetRegisterInfo &TRI; /// Edit - The current parent register and new intervals created. - LiveRangeEdit &Edit; + LiveRangeEdit *Edit; /// Index into Edit of the currently open interval. /// The index 0 is used for the complement, so the first interval started by From stoklund at 2pi.dk Wed Mar 2 17:40:12 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 2 Mar 2011 15:40:12 -0800 Subject: [llvm-commits] Failed build llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi In-Reply-To: References: Message-ID: On Mar 2, 2011, at 3:21 PM, Galina Kistanova wrote: > Hi Jacob, > > Please see .bc file attached. Thanks! I can reproduce the crash, I'll try to fix it. /jakob From bob.wilson at apple.com Wed Mar 2 17:38:07 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 02 Mar 2011 23:38:07 -0000 Subject: [llvm-commits] [llvm] r126899 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Message-ID: <20110302233807.1235D2A6C12C@llvm.org> Author: bwilson Date: Wed Mar 2 17:38:06 2011 New Revision: 126899 URL: http://llvm.org/viewvc/llvm-project?rev=126899&view=rev Log: Avoid exponential blow-up when printing DAGs. David Greene changed CannotYetSelect() to print the full DAG including multiple copies of operands reached through different paths in the DAG. Unfortunately this blows up exponentially in some cases. The depth limit of 100 is way too high to prevent this -- I'm seeing a message string of 150MB with a depth of only 40 in one particularly bad case, even though the DAG has less than 200 nodes. Part of the problem is that the printing code is following chain operands, so if you fail to select an operation with a chain, the printer will follow all the chained operations back to the entry node. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=126899&r1=126898&r2=126899&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Mar 2 17:38:06 2011 @@ -6226,6 +6226,9 @@ return; for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { + // Don't follow chain operands. + if (N->getOperand(i).getValueType() == MVT::Other) + continue; OS << '\n'; printrWithDepthHelper(OS, N->getOperand(i).getNode(), G, depth-1, indent+2); } @@ -6238,7 +6241,7 @@ void SDNode::printrFull(raw_ostream &OS, const SelectionDAG *G) const { // Don't print impossibly deep things. - printrWithDepth(OS, G, 100); + printrWithDepth(OS, G, 10); } void SDNode::dumprWithDepth(const SelectionDAG *G, unsigned depth) const { @@ -6247,7 +6250,7 @@ void SDNode::dumprFull(const SelectionDAG *G) const { // Don't print impossibly deep things. - dumprWithDepth(G, 100); + dumprWithDepth(G, 10); } static void DumpNodes(const SDNode *N, unsigned indent, const SelectionDAG *G) { From stuart at apple.com Wed Mar 2 17:41:40 2011 From: stuart at apple.com (Stuart Hastings) Date: Wed, 02 Mar 2011 23:41:40 -0000 Subject: [llvm-commits] [llvm] r126900 - /llvm/trunk/test/CodeGen/X86/2011-03-02-DAGCombiner.ll Message-ID: <20110302234140.D53962A6C12C@llvm.org> Author: stuart Date: Wed Mar 2 17:41:40 2011 New Revision: 126900 URL: http://llvm.org/viewvc/llvm-project?rev=126900&view=rev Log: Test case for r126864. Radar 9056407. Added: llvm/trunk/test/CodeGen/X86/2011-03-02-DAGCombiner.ll Added: llvm/trunk/test/CodeGen/X86/2011-03-02-DAGCombiner.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2011-03-02-DAGCombiner.ll?rev=126900&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2011-03-02-DAGCombiner.ll (added) +++ llvm/trunk/test/CodeGen/X86/2011-03-02-DAGCombiner.ll Wed Mar 2 17:41:40 2011 @@ -0,0 +1,51 @@ +; RUN: llc < %s -march=x86-64 + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-apple-darwin11.0.0" + +%0 = type { i8, [3 x i8] } +%struct.anon = type { float, x86_fp80 } + +define i32 @main() nounwind ssp { +entry: + %retval = alloca i32, align 4 + %F = alloca %struct.anon, align 16 + %K = alloca %0, align 4 + store i32 0, i32* %retval + %0 = bitcast %0* %K to i32* + %1 = load i32* %0, align 4 + %2 = and i32 %1, -121 + %3 = or i32 %2, 32 + store i32 %3, i32* %0, align 4 + %4 = bitcast %0* %K to i32* + %5 = load i32* %4, align 4 + %6 = lshr i32 %5, 3 + %bf.clear = and i32 %6, 15 + %conv = sitofp i32 %bf.clear to float + %f = getelementptr inbounds %struct.anon* %F, i32 0, i32 0 + %tmp = load float* %f, align 4 + %sub = fsub float %tmp, %conv + store float %sub, float* %f, align 4 + %ld = getelementptr inbounds %struct.anon* %F, i32 0, i32 1 + %tmp1 = load x86_fp80* %ld, align 16 + %7 = bitcast %0* %K to i32* + %8 = load i32* %7, align 4 + %9 = lshr i32 %8, 7 + %bf.clear2 = and i32 %9, 1 + %conv3 = uitofp i32 %bf.clear2 to x86_fp80 + %sub4 = fsub x86_fp80 %conv3, %tmp1 + %conv5 = fptoui x86_fp80 %sub4 to i32 + %bf.value = and i32 %conv5, 1 + %10 = bitcast %0* %K to i32* + %11 = and i32 %bf.value, 1 + %12 = shl i32 %11, 7 + %13 = load i32* %10, align 4 + %14 = and i32 %13, -129 + %15 = or i32 %14, %12 + store i32 %15, i32* %10, align 4 + %call = call i32 (...)* @iequals(i32 1841, i32 %bf.value, i32 0) + %16 = load i32* %retval + ret i32 %16 +} + +declare i32 @iequals(...) From stuart at apple.com Wed Mar 2 17:45:46 2011 From: stuart at apple.com (Stuart Hastings) Date: Wed, 2 Mar 2011 15:45:46 -0800 Subject: [llvm-commits] [llvm] r126864 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp In-Reply-To: <4D6E9FF3.9000106@free.fr> References: <20110302193630.9066E2A6C12D@llvm.org> <4D6E9FF3.9000106@free.fr> Message-ID: On Mar 2, 2011, at 11:52 AM, Duncan Sands wrote: >> Can't introduce floating-point immediate constants after legalization. >> Radar 9056407. > > Sorry to sound like a worn out record, but... testcase? r126900 stuart > > Ciao, Duncan. > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From stoklund at 2pi.dk Wed Mar 2 18:20:51 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 03 Mar 2011 00:20:51 -0000 Subject: [llvm-commits] [llvm] r126905 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <20110303002051.E88202A6C12C@llvm.org> Author: stoklund Date: Wed Mar 2 18:20:51 2011 New Revision: 126905 URL: http://llvm.org/viewvc/llvm-project?rev=126905&view=rev Log: Fix PHI handling in LiveIntervals::shrinkToUses(). We need to wait until we meet a PHIDef in its defining block before resurrecting PHIKills in the predecessors. This should unbreak the llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi bot. 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=126905&r1=126904&r2=126905&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Mar 2 18:20:51 2011 @@ -797,7 +797,7 @@ (void)ExtVNI; assert(ExtVNI == VNI && "Unexpected existing value number"); // Is this a PHIDef we haven't seen before? - if (!VNI->isPHIDef() || !UsedPHIs.insert(VNI)) + if (!VNI->isPHIDef() || VNI->def != BlockStart || !UsedPHIs.insert(VNI)) continue; // The PHI is live, make sure the predecessors are live-out. for (MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(), From stoklund at 2pi.dk Wed Mar 2 18:25:07 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 2 Mar 2011 16:25:07 -0800 Subject: [llvm-commits] Failed build llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi In-Reply-To: References: Message-ID: <85FABFEA-8179-464C-9102-2E2B9F5344EC@2pi.dk> Should be fixed in r126905. Thanks! On Mar 2, 2011, at 3:21 PM, Galina Kistanova wrote: > Hi Jacob, > > Please see .bc file attached. > > Thanks > > Galina > > On Wed, Mar 2, 2011 at 11:58 AM, Jakob Stoklund Olesen wrote: >> >> On Mar 2, 2011, at 11:41 AM, Galina Kistanova wrote: >> >>> Just a short notice, >>> the last successful build for 3-srage-builder >>> llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi was yesterday for >>> revision 126801, the fist failed build is for revision 126817: >>> >>> http://google1.osuosl.org:8011/builders/llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi/builds/294 >> >> The assertion failure is likely caused by one of my patches: >> Assertion failed: (PVNI->hasPHIKill() && "Missing hasPHIKill flag"), function shrinkToUses, file /Users/buildslave/zorg/buildbot/smooshlab/slave/llvm-gcc-build-x86_64-darwin10-x-mingw32-x-armeabi/llvm.src/lib/CodeGen/LiveIntervalAnalysis.cpp, line 809. >> >> I don't think I can reproduce what this bot is doing, is there any way you can get me a bitcode file? >> >> Thanks, >> /jakob >> >> > From dpatel at apple.com Wed Mar 2 18:39:25 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 03 Mar 2011 00:39:25 -0000 Subject: [llvm-commits] [test-suite] r126906 - /test-suite/trunk/SingleSource/Regression/C/PR491.c Message-ID: <20110303003925.2AA002A6C12C@llvm.org> Author: dpatel Date: Wed Mar 2 18:39:25 2011 New Revision: 126906 URL: http://llvm.org/viewvc/llvm-project?rev=126906&view=rev Log: Check x86_64 also. Modified: test-suite/trunk/SingleSource/Regression/C/PR491.c Modified: test-suite/trunk/SingleSource/Regression/C/PR491.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/PR491.c?rev=126906&r1=126905&r2=126906&view=diff ============================================================================== --- test-suite/trunk/SingleSource/Regression/C/PR491.c (original) +++ test-suite/trunk/SingleSource/Regression/C/PR491.c Wed Mar 2 18:39:25 2011 @@ -8,7 +8,7 @@ #define ASSERT(expr) ((expr) ? 1 : assert_fail(#expr,__LINE__)) int test(int r) { -#if !defined(__i386__) +#if !defined(__i386__) && !defined(__x86_64__) #if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) return r; #else From bob.wilson at apple.com Wed Mar 2 18:53:25 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 2 Mar 2011 16:53:25 -0800 Subject: [llvm-commits] [llvm] r126895 - in /llvm/trunk: lib/Target/ARM/ARMInstrInfo.td test/MC/Disassembler/ARM/arm-tests.txt In-Reply-To: <20110302230833.8B7AC2A6C12C@llvm.org> References: <20110302230833.8B7AC2A6C12C@llvm.org> Message-ID: The patch was actually done by Jyun-Yan You. This fixes pr9366. On Mar 2, 2011, at 3:08 PM, Kevin Enderby wrote: > Author: enderby > Date: Wed Mar 2 17:08:33 2011 > New Revision: 126895 > > URL: http://llvm.org/viewvc/llvm-project?rev=126895&view=rev > Log: > Fixes an assertion failure while disassembling ARM rsbs reg/reg form. > Patch by Ted Kremenek! > > Modified: > llvm/trunk/lib/Target/ARM/ARMInstrInfo.td > llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt > > Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=126895&r1=126894&r2=126895&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Mar 2 17:08:33 2011 > @@ -2203,6 +2203,19 @@ > let Inst{19-16} = Rn; > let Inst{11-0} = imm; > } > +def RSBSrr : AI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, > + IIC_iALUr, "rsbs", "\t$Rd, $Rn, $Rm", > + [/* For disassembly only; pattern left blank */]> { > + bits<4> Rd; > + bits<4> Rn; > + bits<4> Rm; > + let Inst{11-4} = 0b00000000; > + let Inst{25} = 0; > + let Inst{20} = 1; > + let Inst{3-0} = Rm; > + let Inst{15-12} = Rd; > + let Inst{19-16} = Rn; > +} > def RSBSrs : AI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), > DPSoRegFrm, IIC_iALUsr, "rsbs", "\t$Rd, $Rn, $shift", > [(set GPR:$Rd, (subc so_reg:$shift, GPR:$Rn))]> { > > Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt?rev=126895&r1=126894&r2=126895&view=diff > ============================================================================== > --- llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt (original) > +++ llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Wed Mar 2 17:08:33 2011 > @@ -130,3 +130,6 @@ > > # CHECK: msr cpsr_fc, r0 > 0x00 0xf0 0x29 0xe1 > + > +# CHECK: rsbs r6, r7, r8 > +0x08 0x60 0x77 0xe0 > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dpatel at apple.com Wed Mar 2 18:51:08 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 03 Mar 2011 00:51:08 -0000 Subject: [llvm-commits] [test-suite] r126908 - /test-suite/trunk/SingleSource/Regression/C++/EH/Makefile Message-ID: <20110303005108.8B61D2A6C12C@llvm.org> Author: dpatel Date: Wed Mar 2 18:51:08 2011 New Revision: 126908 URL: http://llvm.org/viewvc/llvm-project?rev=126908&view=rev Log: Do not force -std=c99. clang will take it literally and reject c++ constructs. Modified: test-suite/trunk/SingleSource/Regression/C++/EH/Makefile Modified: test-suite/trunk/SingleSource/Regression/C++/EH/Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C%2B%2B/EH/Makefile?rev=126908&r1=126907&r2=126908&view=diff ============================================================================== --- test-suite/trunk/SingleSource/Regression/C++/EH/Makefile (original) +++ test-suite/trunk/SingleSource/Regression/C++/EH/Makefile Wed Mar 2 18:51:08 2011 @@ -9,6 +9,5 @@ endif endif -CFLAGS += -std=c99 LDFLAGS += -lstdc++ include $(LEVEL)/SingleSource/Makefile.singlesrc From stoklund at 2pi.dk Wed Mar 2 19:29:10 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 03 Mar 2011 01:29:10 -0000 Subject: [llvm-commits] [llvm] r126911 - /llvm/trunk/lib/CodeGen/SplitKit.cpp Message-ID: <20110303012910.791FF2A6C12C@llvm.org> Author: stoklund Date: Wed Mar 2 19:29:10 2011 New Revision: 126911 URL: http://llvm.org/viewvc/llvm-project?rev=126911&view=rev Log: Only run the updateSSA loop when we have actually seen multiple values. When only a single value has been seen, new PHIDefs are never needed. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=126911&r1=126910&r2=126911&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Wed Mar 2 19:29:10 2011 @@ -313,6 +313,10 @@ SmallVector LiveIn; LiveIn.push_back(MDT[IdxMBB]); + // Remember if we have seen more than one value. + bool UniqueVNI = true; + VNInfo *IdxVNI = 0; + // Using LiveOutCache as a visited set, perform a BFS for all reaching defs. for (unsigned i = 0; i != LiveIn.size(); ++i) { MachineBasicBlock *MBB = LiveIn[i]->getBlock(); @@ -323,9 +327,14 @@ std::pair LOIP = LiveOutCache.insert(std::make_pair(Pred, LiveOutPair())); // Yes, we have been here before. - if (!LOIP.second) + if (!LOIP.second) { + if (VNInfo *VNI = LOIP.first->second.first) { + if (IdxVNI && IdxVNI != VNI) + UniqueVNI = false; + IdxVNI = VNI; + } continue; - + } // Does Pred provide a live-out value? SlotIndex Start, Last; tie(Start, Last) = LIS.getSlotIndexes()->getMBBRange(Pred); @@ -335,16 +344,27 @@ LiveOutPair &LOP = LOIP.first->second; LOP.first = VNI; LOP.second = MDT[DefMBB]; + if (IdxVNI && IdxVNI != VNI) + UniqueVNI = false; + IdxVNI = VNI; continue; } // No, we need a live-in value for Pred as well if (Pred != IdxMBB) LiveIn.push_back(MDT[Pred]); + else + UniqueVNI = false; // Loopback to IdxMBB, ask updateSSA() for help. } } // We may need to add phi-def values to preserve the SSA form. - VNInfo *IdxVNI = updateSSA(RegIdx, LiveIn, Idx, IdxMBB); + if (UniqueVNI) { + LiveOutPair LOP(IdxVNI, MDT[LIS.getMBBFromIndex(IdxVNI->def)]); + // Update LiveOutCache, but skip IdxMBB at LiveIn[0]. + for (unsigned i = 1, e = LiveIn.size(); i != e; ++i) + LiveOutCache[LiveIn[i]->getBlock()] = LOP; + } else + IdxVNI = updateSSA(RegIdx, LiveIn, Idx, IdxMBB); #ifndef NDEBUG // Check the LiveOutCache invariants. From stoklund at 2pi.dk Wed Mar 2 19:29:13 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 03 Mar 2011 01:29:13 -0000 Subject: [llvm-commits] [llvm] r126912 - in /llvm/trunk/lib/CodeGen: RegAllocGreedy.cpp SplitKit.cpp SplitKit.h Message-ID: <20110303012913.8BCC42A6C13A@llvm.org> Author: stoklund Date: Wed Mar 2 19:29:13 2011 New Revision: 126912 URL: http://llvm.org/viewvc/llvm-project?rev=126912&view=rev Log: Change the SplitEditor interface to a single instance can be shared for multiple splits. Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=126912&r1=126911&r2=126912&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Wed Mar 2 19:29:13 2011 @@ -111,6 +111,7 @@ // splitting state. std::auto_ptr SA; + std::auto_ptr SE; /// All basic blocks where the current register is live. SmallVector SpillConstraints; @@ -699,10 +700,10 @@ SmallVector SpillRegs; LiveRangeEdit LREdit(VirtReg, NewVRegs, SpillRegs); - SplitEditor SE(*SA, *LIS, *VRM, *DomTree, LREdit); + SE->reset(LREdit); // Create the main cross-block interval. - SE.openIntv(); + SE->openIntv(); // First add all defs that are live out of a block. for (unsigned i = 0, e = SA->LiveBlocks.size(); i != e; ++i) { @@ -736,19 +737,19 @@ DEBUG(dbgs() << ", no uses" << (RegIn ? ", live-through.\n" : ", stack in.\n")); if (!RegIn) - SE.enterIntvAtEnd(*BI.MBB); + SE->enterIntvAtEnd(*BI.MBB); continue; } if (!BI.LiveThrough) { DEBUG(dbgs() << ", not live-through.\n"); - SE.useIntv(SE.enterIntvBefore(BI.Def), Stop); + SE->useIntv(SE->enterIntvBefore(BI.Def), Stop); continue; } if (!RegIn) { // Block is live-through, but entry bundle is on the stack. // Reload just before the first use. DEBUG(dbgs() << ", not live-in, enter before first use.\n"); - SE.useIntv(SE.enterIntvBefore(BI.FirstUse), Stop); + SE->useIntv(SE->enterIntvBefore(BI.FirstUse), Stop); continue; } DEBUG(dbgs() << ", live-through.\n"); @@ -761,7 +762,7 @@ if (!BI.LiveThrough && IP.second <= BI.Def) { // The interference doesn't reach the outgoing segment. DEBUG(dbgs() << " doesn't affect def from " << BI.Def << '\n'); - SE.useIntv(BI.Def, Stop); + SE->useIntv(BI.Def, Stop); continue; } @@ -769,7 +770,7 @@ if (!BI.Uses) { // No uses in block, avoid interference by reloading as late as possible. DEBUG(dbgs() << ", no uses.\n"); - SlotIndex SegStart = SE.enterIntvAtEnd(*BI.MBB); + SlotIndex SegStart = SE->enterIntvAtEnd(*BI.MBB); assert(SegStart >= IP.second && "Couldn't avoid interference"); continue; } @@ -786,17 +787,17 @@ // Only attempt a split befroe the last split point. if (Use.getBaseIndex() <= BI.LastSplitPoint) { DEBUG(dbgs() << ", free use at " << Use << ".\n"); - SlotIndex SegStart = SE.enterIntvBefore(Use); + SlotIndex SegStart = SE->enterIntvBefore(Use); assert(SegStart >= IP.second && "Couldn't avoid interference"); assert(SegStart < BI.LastSplitPoint && "Impossible split point"); - SE.useIntv(SegStart, Stop); + SE->useIntv(SegStart, Stop); continue; } } // Interference is after the last use. DEBUG(dbgs() << " after last use.\n"); - SlotIndex SegStart = SE.enterIntvAtEnd(*BI.MBB); + SlotIndex SegStart = SE->enterIntvAtEnd(*BI.MBB); assert(SegStart >= IP.second && "Couldn't avoid interference"); } @@ -827,16 +828,16 @@ // Block is live-through without interference. if (RegOut) { DEBUG(dbgs() << ", no uses, live-through.\n"); - SE.useIntv(Start, Stop); + SE->useIntv(Start, Stop); } else { DEBUG(dbgs() << ", no uses, stack-out.\n"); - SE.leaveIntvAtTop(*BI.MBB); + SE->leaveIntvAtTop(*BI.MBB); } continue; } if (!BI.LiveThrough) { DEBUG(dbgs() << ", killed in block.\n"); - SE.useIntv(Start, SE.leaveIntvAfter(BI.Kill)); + SE->useIntv(Start, SE->leaveIntvAfter(BI.Kill)); continue; } if (!RegOut) { @@ -844,24 +845,24 @@ // Spill immediately after the last use. if (BI.LastUse < BI.LastSplitPoint) { DEBUG(dbgs() << ", uses, stack-out.\n"); - SE.useIntv(Start, SE.leaveIntvAfter(BI.LastUse)); + SE->useIntv(Start, SE->leaveIntvAfter(BI.LastUse)); continue; } // The last use is after the last split point, it is probably an // indirect jump. DEBUG(dbgs() << ", uses at " << BI.LastUse << " after split point " << BI.LastSplitPoint << ", stack-out.\n"); - SlotIndex SegEnd = SE.leaveIntvBefore(BI.LastSplitPoint); - SE.useIntv(Start, SegEnd); + SlotIndex SegEnd = SE->leaveIntvBefore(BI.LastSplitPoint); + SE->useIntv(Start, SegEnd); // Run a double interval from the split to the last use. // This makes it possible to spill the complement without affecting the // indirect branch. - SE.overlapIntv(SegEnd, BI.LastUse); + SE->overlapIntv(SegEnd, BI.LastUse); continue; } // Register is live-through. DEBUG(dbgs() << ", uses, live-through.\n"); - SE.useIntv(Start, Stop); + SE->useIntv(Start, Stop); continue; } @@ -871,14 +872,14 @@ if (!BI.LiveThrough && IP.first >= BI.Kill) { // The interference doesn't reach the outgoing segment. DEBUG(dbgs() << " doesn't affect kill at " << BI.Kill << '\n'); - SE.useIntv(Start, BI.Kill); + SE->useIntv(Start, BI.Kill); continue; } if (!BI.Uses) { // No uses in block, avoid interference by spilling as soon as possible. DEBUG(dbgs() << ", no uses.\n"); - SlotIndex SegEnd = SE.leaveIntvAtTop(*BI.MBB); + SlotIndex SegEnd = SE->leaveIntvAtTop(*BI.MBB); assert(SegEnd <= IP.first && "Couldn't avoid interference"); continue; } @@ -891,24 +892,24 @@ assert(UI != SA->UseSlots.begin() && "Couldn't find first use"); SlotIndex Use = (--UI)->getBoundaryIndex(); DEBUG(dbgs() << ", free use at " << *UI << ".\n"); - SlotIndex SegEnd = SE.leaveIntvAfter(Use); + SlotIndex SegEnd = SE->leaveIntvAfter(Use); assert(SegEnd <= IP.first && "Couldn't avoid interference"); - SE.useIntv(Start, SegEnd); + SE->useIntv(Start, SegEnd); continue; } // Interference is before the first use. DEBUG(dbgs() << " before first use.\n"); - SlotIndex SegEnd = SE.leaveIntvAtTop(*BI.MBB); + SlotIndex SegEnd = SE->leaveIntvAtTop(*BI.MBB); assert(SegEnd <= IP.first && "Couldn't avoid interference"); } - SE.closeIntv(); + SE->closeIntv(); // FIXME: Should we be more aggressive about splitting the stack region into // per-block segments? The current approach allows the stack region to // separate into connected components. Some components may be allocatable. - SE.finish(); + SE->finish(); ++NumGlobalSplits; if (VerifyEnabled) { @@ -1215,14 +1216,14 @@ SmallVector SpillRegs; LiveRangeEdit LREdit(VirtReg, NewVRegs, SpillRegs); - SplitEditor SE(*SA, *LIS, *VRM, *DomTree, LREdit); + SE->reset(LREdit); - SE.openIntv(); - SlotIndex SegStart = SE.enterIntvBefore(Uses[BestBefore]); - SlotIndex SegStop = SE.leaveIntvAfter(Uses[BestAfter]); - SE.useIntv(SegStart, SegStop); - SE.closeIntv(); - SE.finish(); + SE->openIntv(); + SlotIndex SegStart = SE->enterIntvBefore(Uses[BestBefore]); + SlotIndex SegStop = SE->leaveIntvAfter(Uses[BestAfter]); + SE->useIntv(SegStart, SegStop); + SE->closeIntv(); + SE->finish(); setStage(NewVRegs.begin(), NewVRegs.end(), RS_Local); ++NumLocalSplits; @@ -1268,7 +1269,8 @@ if (SA->getMultiUseBlocks(Blocks)) { SmallVector SpillRegs; LiveRangeEdit LREdit(VirtReg, NewVRegs, SpillRegs); - SplitEditor(*SA, *LIS, *VRM, *DomTree, LREdit).splitSingleBlocks(Blocks); + SE->reset(LREdit); + SE->splitSingleBlocks(Blocks); setStage(NewVRegs.begin(), NewVRegs.end(), RS_Block); if (VerifyEnabled) MF->verify(this, "After splitting live range around basic blocks"); @@ -1350,6 +1352,7 @@ SpillPlacer = &getAnalysis(); SA.reset(new SplitAnalysis(*VRM, *LIS, *Loops)); + SE.reset(new SplitEditor(*SA, *LIS, *VRM, *DomTree)); LRStage.clear(); LRStage.resize(MRI->getNumVirtRegs()); Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=126912&r1=126911&r2=126912&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Wed Mar 2 19:29:13 2011 @@ -209,17 +209,24 @@ SplitEditor::SplitEditor(SplitAnalysis &sa, LiveIntervals &lis, VirtRegMap &vrm, - MachineDominatorTree &mdt, - LiveRangeEdit &edit) + MachineDominatorTree &mdt) : SA(sa), LIS(lis), VRM(vrm), MRI(vrm.getMachineFunction().getRegInfo()), MDT(mdt), TII(*vrm.getMachineFunction().getTarget().getInstrInfo()), TRI(*vrm.getMachineFunction().getTarget().getRegisterInfo()), - Edit(&edit), + Edit(0), OpenIdx(0), RegAssign(Allocator) -{ +{} + +void SplitEditor::reset(LiveRangeEdit &lre) { + Edit = &lre; + OpenIdx = 0; + RegAssign.clear(); + Values.clear(); + LiveOutCache.clear(); + // We don't need an AliasAnalysis since we will only be performing // cheap-as-a-copy remats anyway. Edit->anyRematerializable(LIS, TII, 0); Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=126912&r1=126911&r2=126912&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Wed Mar 2 19:29:13 2011 @@ -268,10 +268,10 @@ /// Create a new SplitEditor for editing the LiveInterval analyzed by SA. /// Newly created intervals will be appended to newIntervals. SplitEditor(SplitAnalysis &SA, LiveIntervals&, VirtRegMap&, - MachineDominatorTree&, LiveRangeEdit&); + MachineDominatorTree&); - /// getAnalysis - Get the corresponding analysis. - SplitAnalysis &getAnalysis() { return SA; } + /// reset - Prepare for a new split. + void reset(LiveRangeEdit&); /// Create a new virtual register and live interval. void openIntv(); From isanbard at gmail.com Wed Mar 2 19:32:38 2011 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 03 Mar 2011 01:32:38 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r126913 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <20110303013238.51A5E2A6C12C@llvm.org> Author: void Date: Wed Mar 2 19:32:38 2011 New Revision: 126913 URL: http://llvm.org/viewvc/llvm-project?rev=126913&view=rev Log: Constant CFString literals should be aligned at 1-byte boundaries in the "__TEXT,__cstring,cstring_literal" section. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=126913&r1=126912&r2=126913&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Mar 2 19:32:38 2011 @@ -8757,10 +8757,12 @@ // Support -fwritable-strings. bool StringIsConstant = !flag_writable_strings; + bool IsConstCFString = false; #ifdef CONFIG_DARWIN_H // However, ignores it if exp is a CFString and // -fconstant-cfstring (default) is set. - StringIsConstant |= darwin_constant_cfstring_p(exp); + IsConstCFString = darwin_constant_cfstring_p(exp); + StringIsConstant |= IsConstCFString; #endif // Literal cstrings in data section needs a label the linker can @@ -8784,7 +8786,14 @@ StringIsConstant, Linkage, Init, ".str"); GV->setUnnamedAddr(true); - GV->setAlignment(get_constant_alignment(exp) / 8); + if (!IsConstCFString) { + GV->setAlignment(get_constant_alignment(exp) / 8); + } else { + // CFStrings don't need to be over-aligned. Align them to 1. + // + GV->setAlignment(1); + GV->setSection("__TEXT,__cstring,cstring_literals"); + } if (SlotP) *SlotP = GV; return GV; From isanbard at gmail.com Wed Mar 2 19:32:56 2011 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 03 Mar 2011 01:32:56 -0000 Subject: [llvm-commits] [llvm] r126914 - /llvm/trunk/test/FrontendObjC/2011-03-02-ConstCFStringLiteralAlign.m Message-ID: <20110303013256.56A082A6C12C@llvm.org> Author: void Date: Wed Mar 2 19:32:56 2011 New Revision: 126914 URL: http://llvm.org/viewvc/llvm-project?rev=126914&view=rev Log: Testcase for r126913. Added: llvm/trunk/test/FrontendObjC/2011-03-02-ConstCFStringLiteralAlign.m Added: llvm/trunk/test/FrontendObjC/2011-03-02-ConstCFStringLiteralAlign.m URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendObjC/2011-03-02-ConstCFStringLiteralAlign.m?rev=126914&view=auto ============================================================================== --- llvm/trunk/test/FrontendObjC/2011-03-02-ConstCFStringLiteralAlign.m (added) +++ llvm/trunk/test/FrontendObjC/2011-03-02-ConstCFStringLiteralAlign.m Wed Mar 2 19:32:56 2011 @@ -0,0 +1,10 @@ +// RUN: %llvmgcc -S -w -m64 -mmacosx-version-min=10.5 %s -o - | FileCheck %s +// XFAIL: * +// XTARGET: darwin + + at interface Foo + at end +Foo *FooName = @"FooBar"; + +// CHECK: .section __TEXT,__cstring,cstring_literals +// CHECK-NEXT: L_.str: From bob.wilson at apple.com Wed Mar 2 19:41:01 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 03 Mar 2011 01:41:01 -0000 Subject: [llvm-commits] [llvm] r126915 - in /llvm/trunk: lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp test/MC/Disassembler/ARM/arm-tests.txt utils/TableGen/ARMDecoderEmitter.cpp Message-ID: <20110303014101.D7C702A6C12C@llvm.org> Author: bwilson Date: Wed Mar 2 19:41:01 2011 New Revision: 126915 URL: http://llvm.org/viewvc/llvm-project?rev=126915&view=rev Log: pr9367: Add missing predicated BLX instructions. Patch by Jyun-Yan You, with some minor adjustments and a testcase from me. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=126915&r1=126914&r2=126915&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Mar 2 19:41:01 2011 @@ -1340,7 +1340,16 @@ Requires<[IsARM, HasV5T, IsNotDarwin]> { bits<4> func; let Inst{31-4} = 0b1110000100101111111111110011; - let Inst{3-0} = func; + let Inst{3-0} = func; + } + + def BLX_pred : AI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm, + IIC_Br, "blx", "\t$func", + [(ARMcall_pred GPR:$func)]>, + Requires<[IsARM, HasV5T, IsNotDarwin]> { + bits<4> func; + let Inst{27-4} = 0b000100101111111111110011; + let Inst{3-0} = func; } // ARMv4T @@ -1389,6 +1398,15 @@ let Inst{3-0} = func; } + def BLXr9_pred : AI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm, + IIC_Br, "blx", "\t$func", + [(ARMcall_pred GPR:$func)]>, + Requires<[IsARM, HasV5T, IsDarwin]> { + bits<4> func; + let Inst{27-4} = 0b000100101111111111110011; + let Inst{3-0} = func; + } + // ARMv4T // Note: Restrict $func to the tGPR regclass to prevent it being in LR. def BXr9_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops), Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=126915&r1=126914&r2=126915&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Wed Mar 2 19:41:01 2011 @@ -809,8 +809,10 @@ if (Opcode == ARM::BX_RET || Opcode == ARM::MOVPCLR) return true; - // BLXr9 and BX take one GPR reg. - if (Opcode == ARM::BLXr9 || Opcode == ARM::BX) { + // BLX and BX take one GPR reg. + if (Opcode == ARM::BLXr9 || Opcode == ARM::BLXr9_pred || + Opcode == ARM::BLX || Opcode == ARM::BLX_pred || + Opcode == ARM::BX) { assert(NumOps >= 1 && OpInfo[OpIdx].RegClass == ARM::GPRRegClassID && "Reg operand expected"); MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt?rev=126915&r1=126914&r2=126915&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Wed Mar 2 19:41:01 2011 @@ -133,3 +133,6 @@ # CHECK: rsbs r6, r7, r8 0x08 0x60 0x77 0xe0 + +# CHECK: blxeq r5 +0x35 0xff 0x2f 0x01 Modified: llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp?rev=126915&r1=126914&r2=126915&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Wed Mar 2 19:41:01 2011 @@ -1632,7 +1632,7 @@ // Ignore the non-Darwin BL instructions and the TPsoft (TLS) instruction. if (Name == "BL" || Name == "BL_pred" || Name == "BLX" || Name == "BX" || - Name == "TPsoft") + Name == "BLX_pred" || Name == "TPsoft") return false; // Ignore VDUPf[d|q] instructions known to conflict with VDUP32[d-q] for From isanbard at gmail.com Wed Mar 2 20:02:12 2011 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 03 Mar 2011 02:02:12 -0000 Subject: [llvm-commits] [llvm] r126918 - /llvm/trunk/test/FrontendObjC/2011-03-02-ConstCFStringLiteralAlign.m Message-ID: <20110303020212.539BA2A6C12C@llvm.org> Author: void Date: Wed Mar 2 20:02:12 2011 New Revision: 126918 URL: http://llvm.org/viewvc/llvm-project?rev=126918&view=rev Log: Check the ASM, not LLVM IR. Modified: llvm/trunk/test/FrontendObjC/2011-03-02-ConstCFStringLiteralAlign.m Modified: llvm/trunk/test/FrontendObjC/2011-03-02-ConstCFStringLiteralAlign.m URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendObjC/2011-03-02-ConstCFStringLiteralAlign.m?rev=126918&r1=126917&r2=126918&view=diff ============================================================================== --- llvm/trunk/test/FrontendObjC/2011-03-02-ConstCFStringLiteralAlign.m (original) +++ llvm/trunk/test/FrontendObjC/2011-03-02-ConstCFStringLiteralAlign.m Wed Mar 2 20:02:12 2011 @@ -1,4 +1,5 @@ -// RUN: %llvmgcc -S -w -m64 -mmacosx-version-min=10.5 %s -o - | FileCheck %s +// RUN: %llvmgcc -S -w -m64 -mmacosx-version-min=10.5 %s -o - | \ +// RUN: llc --disable-fp-elim -o - | FileCheck %s // XFAIL: * // XTARGET: darwin From stoklund at 2pi.dk Wed Mar 2 21:41:29 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 03 Mar 2011 03:41:29 -0000 Subject: [llvm-commits] [llvm] r126921 - in /llvm/trunk/lib/CodeGen: RegAllocGreedy.cpp SplitKit.cpp SplitKit.h Message-ID: <20110303034129.B974F2A6C12C@llvm.org> Author: stoklund Date: Wed Mar 2 21:41:29 2011 New Revision: 126921 URL: http://llvm.org/viewvc/llvm-project?rev=126921&view=rev Log: Cache basic block bounds instead of asking SlotIndexes::getMBBRange all the time. This speeds up the greedy register allocator by 15%. DenseMap is not as fast as one might hope. Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=126921&r1=126920&r2=126921&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Wed Mar 2 21:41:29 2011 @@ -473,19 +473,17 @@ for (unsigned i = 0, e = SA->LiveBlocks.size(); i != e; ++i) { SplitAnalysis::BlockInfo &BI = SA->LiveBlocks[i]; SpillPlacement::BlockConstraint &BC = SpillConstraints[i]; - SlotIndex Start, Stop; - tie(Start, Stop) = Indexes->getMBBRange(BI.MBB); // Skip interference-free blocks. - if (IntI.start() >= Stop) + if (IntI.start() >= BI.Stop) continue; // Is the interference live-in? if (BI.LiveIn) { - IntI.advanceTo(Start); + IntI.advanceTo(BI.Start); if (!IntI.valid()) break; - if (IntI.start() <= Start) + if (IntI.start() <= BI.Start) BC.Entry = SpillPlacement::MustSpill; } @@ -495,7 +493,7 @@ IntI.advanceTo(BI.LastSplitPoint.getPrevSlot()); if (!IntI.valid()) break; - if (IntI.start() < Stop) + if (IntI.start() < BI.Stop) BC.Exit = SpillPlacement::MustSpill; } } @@ -505,20 +503,18 @@ for (unsigned i = 0, e = SA->LiveBlocks.size(); i != e; ++i) { SplitAnalysis::BlockInfo &BI = SA->LiveBlocks[i]; SpillPlacement::BlockConstraint &BC = SpillConstraints[i]; - SlotIndex Start, Stop; - tie(Start, Stop) = Indexes->getMBBRange(BI.MBB); // Skip interference-free blocks. - if (IntI.start() >= Stop) + if (IntI.start() >= BI.Stop) continue; // Handle transparent blocks with interference separately. // Transparent blocks never incur any fixed cost. if (BI.LiveThrough && !BI.Uses) { - IntI.advanceTo(Start); + IntI.advanceTo(BI.Start); if (!IntI.valid()) break; - if (IntI.start() >= Stop) + if (IntI.start() >= BI.Stop) continue; if (BC.Entry != SpillPlacement::MustSpill) @@ -534,7 +530,7 @@ // Check interference on entry. if (BI.LiveIn && BC.Entry != SpillPlacement::MustSpill) { - IntI.advanceTo(Start); + IntI.advanceTo(BI.Start); if (!IntI.valid()) break; // Not live in, but before the first use. @@ -575,7 +571,7 @@ IntI.advanceTo(BI.LastUse); if (!IntI.valid()) break; - if (IntI.start() < Stop) { + if (IntI.start() < BI.Stop) { BC.Exit = SpillPlacement::PrefSpill; // Avoid splitting twice in the same block. if (!BI.LiveThrough && !SA->isOriginalEndpoint(BI.Def)) @@ -668,18 +664,17 @@ for (unsigned i = 0, e = SA->LiveBlocks.size(); i != e; ++i) { const SplitAnalysis::BlockInfo &BI = SA->LiveBlocks[i]; IndexPair &IP = InterferenceRanges[i]; - SlotIndex Start, Stop; - tie(Start, Stop) = Indexes->getMBBRange(BI.MBB); + // Skip interference-free blocks. - if (IntI.start() >= Stop) + if (IntI.start() >= BI.Stop) continue; // First interference in block. if (BI.LiveIn) { - IntI.advanceTo(Start); + IntI.advanceTo(BI.Start); if (!IntI.valid()) break; - if (IntI.start() >= Stop) + if (IntI.start() >= BI.Stop) continue; if (!IP.first.isValid() || IntI.start() < IP.first) IP.first = IntI.start(); @@ -687,10 +682,10 @@ // Last interference in block. if (BI.LiveOut) { - IntI.advanceTo(Stop); - if (!IntI.valid() || IntI.start() >= Stop) + IntI.advanceTo(BI.Stop); + if (!IntI.valid() || IntI.start() >= BI.Stop) --IntI; - if (IntI.stop() <= Start) + if (IntI.stop() <= BI.Start) continue; if (!IP.second.isValid() || IntI.stop() > IP.second) IP.second = IntI.stop(); @@ -716,16 +711,14 @@ continue; IndexPair &IP = InterferenceRanges[i]; - SlotIndex Start, Stop; - tie(Start, Stop) = Indexes->getMBBRange(BI.MBB); - DEBUG(dbgs() << "BB#" << BI.MBB->getNumber() << " -> EB#" << Bundles->getBundle(BI.MBB->getNumber(), 1) << " intf [" << IP.first << ';' << IP.second << ')'); // The interference interval should either be invalid or overlap MBB. - assert((!IP.first.isValid() || IP.first < Stop) && "Bad interference"); - assert((!IP.second.isValid() || IP.second > Start) && "Bad interference"); + assert((!IP.first.isValid() || IP.first < BI.Stop) && "Bad interference"); + assert((!IP.second.isValid() || IP.second > BI.Start) + && "Bad interference"); // Check interference leaving the block. if (!IP.second.isValid()) { @@ -742,14 +735,14 @@ } if (!BI.LiveThrough) { DEBUG(dbgs() << ", not live-through.\n"); - SE->useIntv(SE->enterIntvBefore(BI.Def), Stop); + SE->useIntv(SE->enterIntvBefore(BI.Def), BI.Stop); continue; } if (!RegIn) { // Block is live-through, but entry bundle is on the stack. // Reload just before the first use. DEBUG(dbgs() << ", not live-in, enter before first use.\n"); - SE->useIntv(SE->enterIntvBefore(BI.FirstUse), Stop); + SE->useIntv(SE->enterIntvBefore(BI.FirstUse), BI.Stop); continue; } DEBUG(dbgs() << ", live-through.\n"); @@ -762,7 +755,7 @@ if (!BI.LiveThrough && IP.second <= BI.Def) { // The interference doesn't reach the outgoing segment. DEBUG(dbgs() << " doesn't affect def from " << BI.Def << '\n'); - SE->useIntv(BI.Def, Stop); + SE->useIntv(BI.Def, BI.Stop); continue; } @@ -790,7 +783,7 @@ SlotIndex SegStart = SE->enterIntvBefore(Use); assert(SegStart >= IP.second && "Couldn't avoid interference"); assert(SegStart < BI.LastSplitPoint && "Impossible split point"); - SE->useIntv(SegStart, Stop); + SE->useIntv(SegStart, BI.Stop); continue; } } @@ -813,8 +806,6 @@ // We have an incoming register. Check for interference. IndexPair &IP = InterferenceRanges[i]; - SlotIndex Start, Stop; - tie(Start, Stop) = Indexes->getMBBRange(BI.MBB); DEBUG(dbgs() << "EB#" << Bundles->getBundle(BI.MBB->getNumber(), 0) << " -> BB#" << BI.MBB->getNumber()); @@ -828,7 +819,7 @@ // Block is live-through without interference. if (RegOut) { DEBUG(dbgs() << ", no uses, live-through.\n"); - SE->useIntv(Start, Stop); + SE->useIntv(BI.Start, BI.Stop); } else { DEBUG(dbgs() << ", no uses, stack-out.\n"); SE->leaveIntvAtTop(*BI.MBB); @@ -837,7 +828,7 @@ } if (!BI.LiveThrough) { DEBUG(dbgs() << ", killed in block.\n"); - SE->useIntv(Start, SE->leaveIntvAfter(BI.Kill)); + SE->useIntv(BI.Start, SE->leaveIntvAfter(BI.Kill)); continue; } if (!RegOut) { @@ -845,7 +836,7 @@ // Spill immediately after the last use. if (BI.LastUse < BI.LastSplitPoint) { DEBUG(dbgs() << ", uses, stack-out.\n"); - SE->useIntv(Start, SE->leaveIntvAfter(BI.LastUse)); + SE->useIntv(BI.Start, SE->leaveIntvAfter(BI.LastUse)); continue; } // The last use is after the last split point, it is probably an @@ -853,7 +844,7 @@ DEBUG(dbgs() << ", uses at " << BI.LastUse << " after split point " << BI.LastSplitPoint << ", stack-out.\n"); SlotIndex SegEnd = SE->leaveIntvBefore(BI.LastSplitPoint); - SE->useIntv(Start, SegEnd); + SE->useIntv(BI.Start, SegEnd); // Run a double interval from the split to the last use. // This makes it possible to spill the complement without affecting the // indirect branch. @@ -862,7 +853,7 @@ } // Register is live-through. DEBUG(dbgs() << ", uses, live-through.\n"); - SE->useIntv(Start, Stop); + SE->useIntv(BI.Start, BI.Stop); continue; } @@ -872,7 +863,7 @@ if (!BI.LiveThrough && IP.first >= BI.Kill) { // The interference doesn't reach the outgoing segment. DEBUG(dbgs() << " doesn't affect kill at " << BI.Kill << '\n'); - SE->useIntv(Start, BI.Kill); + SE->useIntv(BI.Start, BI.Kill); continue; } @@ -894,7 +885,7 @@ DEBUG(dbgs() << ", free use at " << *UI << ".\n"); SlotIndex SegEnd = SE->leaveIntvAfter(Use); assert(SegEnd <= IP.first && "Couldn't avoid interference"); - SE->useIntv(Start, SegEnd); + SE->useIntv(BI.Start, SegEnd); continue; } Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=126921&r1=126920&r2=126921&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Wed Mar 2 21:41:29 2011 @@ -105,8 +105,7 @@ for (;;) { BlockInfo BI; BI.MBB = MFI; - SlotIndex Start, Stop; - tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB); + tie(BI.Start, BI.Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB); // The last split point is the latest possible insertion point that dominates // all successor blocks. If interference reaches LastSplitPoint, it is not @@ -114,12 +113,12 @@ // outgoing bundle. MachineBasicBlock::iterator LSP = LIS.getLastSplitPoint(*CurLI, BI.MBB); if (LSP == BI.MBB->end()) - BI.LastSplitPoint = Stop; + BI.LastSplitPoint = BI.Stop; else BI.LastSplitPoint = LIS.getInstructionIndex(LSP); // LVI is the first live segment overlapping MBB. - BI.LiveIn = LVI->start <= Start; + BI.LiveIn = LVI->start <= BI.Start; if (!BI.LiveIn) BI.Def = LVI->start; @@ -127,19 +126,19 @@ BI.Uses = hasUses(MFI); if (BI.Uses && UseI != UseE) { BI.FirstUse = *UseI; - assert(BI.FirstUse >= Start); + assert(BI.FirstUse >= BI.Start); do ++UseI; - while (UseI != UseE && *UseI < Stop); + while (UseI != UseE && *UseI < BI.Stop); BI.LastUse = UseI[-1]; - assert(BI.LastUse < Stop); + assert(BI.LastUse < BI.Stop); } // Look for gaps in the live range. bool hasGap = false; BI.LiveOut = true; - while (LVI->end < Stop) { + while (LVI->end < BI.Stop) { SlotIndex LastStop = LVI->end; - if (++LVI == LVE || LVI->start >= Stop) { + if (++LVI == LVE || LVI->start >= BI.Stop) { BI.Kill = LastStop; BI.LiveOut = false; break; @@ -160,11 +159,11 @@ break; // Live segment ends exactly at Stop. Move to the next segment. - if (LVI->end == Stop && ++LVI == LVE) + if (LVI->end == BI.Stop && ++LVI == LVE) break; // Pick the next basic block. - if (LVI->start < Stop) + if (LVI->start < BI.Stop) ++MFI; else MFI = LIS.getMBBFromIndex(LVI->start); Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=126921&r1=126920&r2=126921&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Wed Mar 2 21:41:29 2011 @@ -71,6 +71,8 @@ /// struct BlockInfo { MachineBasicBlock *MBB; + SlotIndex Start; ///< Beginining of block. + SlotIndex Stop; ///< End of block. SlotIndex FirstUse; ///< First instr using current reg. SlotIndex LastUse; ///< Last instr using current reg. SlotIndex Kill; ///< Interval end point inside block. From stoklund at 2pi.dk Wed Mar 2 22:23:52 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 03 Mar 2011 04:23:52 -0000 Subject: [llvm-commits] [llvm] r126922 - /llvm/trunk/lib/CodeGen/LiveInterval.cpp Message-ID: <20110303042352.AC6202A6C12C@llvm.org> Author: stoklund Date: Wed Mar 2 22:23:52 2011 New Revision: 126922 URL: http://llvm.org/viewvc/llvm-project?rev=126922&view=rev Log: Avoid comparing invalid slot indexes. Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=126922&r1=126921&r2=126922&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Wed Mar 2 22:23:52 2011 @@ -33,16 +33,18 @@ // CompEnd - Compare LiveRange ends. namespace { struct CompEnd { - bool operator()(const LiveRange &A, const LiveRange &B) const { - return A.end < B.end; + bool operator()(SlotIndex A, const LiveRange &B) const { + return A < B.end; + } + bool operator()(const LiveRange &A, SlotIndex B) const { + return A.end < B; } }; } LiveInterval::iterator LiveInterval::find(SlotIndex Pos) { assert(Pos.isValid() && "Cannot search for an invalid index"); - return std::upper_bound(begin(), end(), LiveRange(SlotIndex(), Pos, 0), - CompEnd()); + return std::upper_bound(begin(), end(), Pos, CompEnd()); } /// killedInRange - Return true if the interval has kills in [Start,End). From bigcheesegs at gmail.com Wed Mar 2 22:31:06 2011 From: bigcheesegs at gmail.com (Michael Spencer) Date: Wed, 2 Mar 2011 23:31:06 -0500 Subject: [llvm-commits] sys::fs::can_read() and sys::fs::can_write() for Unix In-Reply-To: References: <103727D28EE14102ABAB90CE3ED8DE80@gmail.com> <49CDBB532D70435F9C467613852704EE@gmail.com> Message-ID: On Wed, Mar 2, 2011 at 4:16 PM, Liam Staskawicz wrote: > On Wed, Mar 2, 2011 at 12:14 PM, Dan Gohman wrote: >> >> On Mar 2, 2011, at 7:54 AM, Liam Staskawicz wrote: >> >> ping. >> >> Is anybody available to review and commit if OK? ?Thanks! >> >> Liam >> Forwarded message: >> >> From:?Liam Staskawicz >> To:?llvm-commits at cs.uiuc.edu >> Date:?Monday, February 28, 2011 10:39:43 AM >> Subject:?[PATCH] sys::fs::can_read() and sys::fs::can_write() for Unix >> >> Hi - the attached patch provides implementations and tests for >> sys::fs::can_read() and sys::fs::can_write() for Unix. ?These were adapted >> from the previous implementations in lib/Support/Unix/Path.inc. >> ?can_execute() could be implemented?quite similarly, but I wasn't sure where >> the best place to add a test for it would be, so left it out for now. >> >> I'm surprised that anything in LLVM and clang is actually using >> canWrite(). >> It?appears that there is one use, in clang, and that one looks pretty >> suspicious. Perhaps?it can be removed altogether instead of ported to >> PathV2? >> Dan > > Removing it altogether would actually be fine from my perspective, though it > would be good to know what the plan is, so I can plan accordingly. ?Thanks. > > Liam The patch looks good to me, but I'm also in favor of removing it. - Michael Spencer From jaykang10 at imrc.kist.re.kr Wed Mar 2 23:00:23 2011 From: jaykang10 at imrc.kist.re.kr (Jin Gu Kang) Date: Thu, 3 Mar 2011 14:00:23 +0900 Subject: [llvm-commits] checking of inbounds for multi dimensional arrary and struct array on isInBoundsIndices() Message-ID: <3E94D039A2B82544B3E7D48F924B0B25DFA3D8800A@base.imrc.kist.re.kr> Hi all isBounsIndices() function decides to set inbounds flag and uses one-past-the-end rule about index. I think one-past-the-end rule is applied to multi-dimensional array and struct array. What do you think about this? I tested the following code. char a[3][2]; struct test { char a; int b; }; struct test foo[3]; int main(void) { a[2][1] = 1; a[3][0] = 2; a[3][1] = 3; a[3][2] = 4; foo[2].a = 5; foo[3].a = 6; foo[3].b = 7; } ------------------------------------------------------------------ define i32 @main() nounwind { entry: %retval = alloca i32 %"alloca point" = bitcast i32 0 to i32 store i8 1, i8* getelementptr inbounds ([3 x [2 x i8]]* @a, i32 0, i32 2, i32 1), align 1 store i8 2, i8* getelementptr inbounds ([3 x [2 x i8]]* @a, i32 1, i32 0, i32 0), align 1 store i8 3, i8* getelementptr ([3 x [2 x i8]]* @a, i32 1, i32 0, i32 1), align 1 store i8 4, i8* getelementptr ([3 x [2 x i8]]* @a, i32 1, i32 1, i32 0), align 1 store i8 5, i8* getelementptr inbounds ([3 x %struct.test]* @foo, i32 0, i32 2, i32 0), align 4 store i8 6, i8* getelementptr inbounds ([3 x %struct.test]* @foo, i32 1, i32 0, i32 0), align 4 store i32 7, i32* getelementptr ([3 x %struct.test]* @foo, i32 1, i32 0, i32 1), align 4 br label %return return: ; preds = %entry %retval1 = load i32* %retval ret i32 %retval1 } ------------------------------------------------------------------- isInBoundsIndices() doesn't return inbounds flag as true on a[3][1] = 3, a[3][2] = 4 and foo[3].b = 7. I made a patch to fix this. This patch has a little "if-else" statements to process some of cases. If you find a better solution, please let me know. :) Please review the attached patch. Thanks, Jin-Gu Kang -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110303/e6fe5ae1/attachment.html -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: inbounds.patch Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110303/e6fe5ae1/attachment.pl From stoklund at 2pi.dk Wed Mar 2 23:18:15 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 03 Mar 2011 05:18:15 -0000 Subject: [llvm-commits] [llvm] r126923 - /llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Message-ID: <20110303051815.9728C2A6C12C@llvm.org> Author: stoklund Date: Wed Mar 2 23:18:15 2011 New Revision: 126923 URL: http://llvm.org/viewvc/llvm-project?rev=126923&view=rev Log: Optimize SlotIndex equality tests. IndexListEntries have unique indexes, so it is not necessary to dereference pointers to them. Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=126923&r1=126922&r2=126923&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Wed Mar 2 23:18:15 2011 @@ -187,11 +187,11 @@ /// Compare two SlotIndex objects for equality. bool operator==(SlotIndex other) const { - return getIndex() == other.getIndex(); + return lie == other.lie; } /// Compare two SlotIndex objects for inequality. bool operator!=(SlotIndex other) const { - return getIndex() != other.getIndex(); + return lie != other.lie; } /// Compare two SlotIndex objects. Return true if the first index From stoklund at 2pi.dk Wed Mar 2 23:18:19 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 03 Mar 2011 05:18:19 -0000 Subject: [llvm-commits] [llvm] r126924 - in /llvm/trunk: include/llvm/CodeGen/SlotIndexes.h lib/CodeGen/RegAllocLinearScan.cpp lib/CodeGen/SimpleRegisterCoalescing.cpp Message-ID: <20110303051819.5A8562A6C12D@llvm.org> Author: stoklund Date: Wed Mar 2 23:18:19 2011 New Revision: 126924 URL: http://llvm.org/viewvc/llvm-project?rev=126924&view=rev Log: Avoid comparing invalid slot indexes, and assert that it doesn't happen. The SlotIndex created by the default construction does not represent a position in the function, and it doesn't make sense to compare it to other indexes. Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=126924&r1=126923&r2=126924&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Wed Mar 2 23:18:19 2011 @@ -135,6 +135,7 @@ } IndexListEntry& entry() const { + assert(isValid() && "Attempt to compare reserved index."); return *lie.getPointer(); } @@ -530,7 +531,7 @@ /// Returns the instruction for the given index, or null if the given /// index has no instruction associated with it. MachineInstr* getInstructionFromIndex(SlotIndex index) const { - return index.entry().getInstr(); + return index.isValid() ? index.entry().getInstr() : 0; } /// Returns the next non-null index. Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=126924&r1=126923&r2=126924&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Wed Mar 2 23:18:19 2011 @@ -458,7 +458,7 @@ const LiveRange &range = cur.ranges.front(); VNInfo *vni = range.valno; - if (vni->isUnused()) + if (vni->isUnused() || !vni->def.isValid()) return Reg; unsigned CandReg; @@ -993,7 +993,7 @@ // one, e.g. X86::mov32to32_. These move instructions are not coalescable. if (!vrm_->getRegAllocPref(cur->reg) && cur->hasAtLeastOneValue()) { VNInfo *vni = cur->begin()->valno; - if (!vni->isUnused()) { + if (!vni->isUnused() && vni->def.isValid()) { MachineInstr *CopyMI = li_->getInstructionFromIndex(vni->def); if (CopyMI && CopyMI->isCopy()) { unsigned DstSubReg = CopyMI->getOperand(0).getSubReg(); Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=126924&r1=126923&r2=126924&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Wed Mar 2 23:18:19 2011 @@ -1568,9 +1568,7 @@ if (UseMI->isIdentityCopy()) continue; SlotIndex Idx = li_->getInstructionIndex(UseMI); - // FIXME: Should this be Idx != UseIdx? SlotIndex() will return something - // that compares higher than any other interval. - if (Idx >= Start && Idx < End && Idx >= UseIdx) { + if (Idx >= Start && Idx < End && (!UseIdx.isValid() || Idx >= UseIdx)) { LastUse = &Use; UseIdx = Idx.getUseIndex(); } From stoklund at 2pi.dk Wed Mar 2 23:40:04 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 03 Mar 2011 05:40:04 -0000 Subject: [llvm-commits] [llvm] r126925 - in /llvm/trunk: include/llvm/CodeGen/SlotIndexes.h lib/CodeGen/SlotIndexes.cpp Message-ID: <20110303054004.AE7FE2A6C12C@llvm.org> Author: stoklund Date: Wed Mar 2 23:40:04 2011 New Revision: 126925 URL: http://llvm.org/viewvc/llvm-project?rev=126925&view=rev Log: Represent sentinel slot indexes with a null pointer. This is much faster than using a pointer to a ManagedStatic object accessed with a function call. The greedy register allocator is 5% faster overall just from the SlotIndex default constructor savings. Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h llvm/trunk/lib/CodeGen/SlotIndexes.cpp Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=126925&r1=126924&r2=126925&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Wed Mar 2 23:40:04 2011 @@ -34,77 +34,35 @@ /// SlotIndex & SlotIndexes classes for the public interface to this /// information. class IndexListEntry { - static const unsigned EMPTY_KEY_INDEX = ~0U & ~3U, - TOMBSTONE_KEY_INDEX = ~0U & ~7U; - IndexListEntry *next, *prev; MachineInstr *mi; unsigned index; - protected: - - typedef enum { EMPTY_KEY, TOMBSTONE_KEY } ReservedEntryType; - - // This constructor is only to be used by getEmptyKeyEntry - // & getTombstoneKeyEntry. It sets index to the given - // value and mi to zero. - IndexListEntry(ReservedEntryType r) : mi(0) { - switch(r) { - case EMPTY_KEY: index = EMPTY_KEY_INDEX; break; - case TOMBSTONE_KEY: index = TOMBSTONE_KEY_INDEX; break; - default: assert(false && "Invalid value for constructor."); - } - next = this; - prev = this; - } - public: - IndexListEntry(MachineInstr *mi, unsigned index) : mi(mi), index(index) { - assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX && - "Attempt to create invalid index. " - "Available indexes may have been exhausted?."); - } - - bool isValid() const { - return (index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX); - } + IndexListEntry(MachineInstr *mi, unsigned index) : mi(mi), index(index) {} MachineInstr* getInstr() const { return mi; } void setInstr(MachineInstr *mi) { - assert(isValid() && "Attempt to modify reserved index."); this->mi = mi; } unsigned getIndex() const { return index; } void setIndex(unsigned index) { - assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX && - "Attempt to set index to invalid value."); - assert(isValid() && "Attempt to reset reserved index value."); this->index = index; } IndexListEntry* getNext() { return next; } const IndexListEntry* getNext() const { return next; } void setNext(IndexListEntry *next) { - assert(isValid() && "Attempt to modify reserved index."); this->next = next; } IndexListEntry* getPrev() { return prev; } const IndexListEntry* getPrev() const { return prev; } void setPrev(IndexListEntry *prev) { - assert(isValid() && "Attempt to modify reserved index."); this->prev = prev; } - - // This function returns the index list entry that is to be used for empty - // SlotIndex keys. - static IndexListEntry* getEmptyKeyEntry(); - - // This function returns the index list entry that is to be used for - // tombstone SlotIndex keys. - static IndexListEntry* getTombstoneKeyEntry(); }; // Specialize PointerLikeTypeTraits for IndexListEntry. @@ -130,9 +88,7 @@ PointerIntPair lie; SlotIndex(IndexListEntry *entry, unsigned slot) - : lie(entry, slot) { - assert(entry != 0 && "Attempt to construct index with 0 pointer."); - } + : lie(entry, slot) {} IndexListEntry& entry() const { assert(isValid() && "Attempt to compare reserved index."); @@ -149,22 +105,21 @@ } static inline unsigned getHashValue(const SlotIndex &v) { - IndexListEntry *ptrVal = &v.entry(); - return (unsigned((intptr_t)ptrVal) >> 4) ^ - (unsigned((intptr_t)ptrVal) >> 9); + void *ptrVal = v.lie.getOpaqueValue(); + return (unsigned((intptr_t)ptrVal)) ^ (unsigned((intptr_t)ptrVal) >> 9); } public: static inline SlotIndex getEmptyKey() { - return SlotIndex(IndexListEntry::getEmptyKeyEntry(), 0); + return SlotIndex(0, 1); } static inline SlotIndex getTombstoneKey() { - return SlotIndex(IndexListEntry::getTombstoneKeyEntry(), 0); + return SlotIndex(0, 2); } /// Construct an invalid index. - SlotIndex() : lie(IndexListEntry::getEmptyKeyEntry(), 0) {} + SlotIndex() : lie(0, 0) {} // Construct a new slot index from the given one, and set the slot. SlotIndex(const SlotIndex &li, Slot s) @@ -176,8 +131,7 @@ /// Returns true if this is a valid index. Invalid indicies do /// not point into an index table, and cannot be compared. bool isValid() const { - IndexListEntry *entry = lie.getPointer(); - return ((entry!= 0) && (entry->isValid())); + return lie.getPointer(); } /// Print this index to the given raw_ostream. Modified: llvm/trunk/lib/CodeGen/SlotIndexes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SlotIndexes.cpp?rev=126925&r1=126924&r2=126925&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SlotIndexes.cpp (original) +++ llvm/trunk/lib/CodeGen/SlotIndexes.cpp Wed Mar 2 23:40:04 2011 @@ -13,45 +13,14 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Target/TargetInstrInfo.h" using namespace llvm; - -// Yep - these are thread safe. See the header for details. -namespace { - - - class EmptyIndexListEntry : public IndexListEntry { - public: - EmptyIndexListEntry() : IndexListEntry(EMPTY_KEY) {} - }; - - class TombstoneIndexListEntry : public IndexListEntry { - public: - TombstoneIndexListEntry() : IndexListEntry(TOMBSTONE_KEY) {} - }; - - // The following statics are thread safe. They're read only, and you - // can't step from them to any other list entries. - ManagedStatic IndexListEntryEmptyKey; - ManagedStatic IndexListEntryTombstoneKey; -} - char SlotIndexes::ID = 0; INITIALIZE_PASS(SlotIndexes, "slotindexes", "Slot index numbering", false, false) -IndexListEntry* IndexListEntry::getEmptyKeyEntry() { - return &*IndexListEntryEmptyKey; -} - -IndexListEntry* IndexListEntry::getTombstoneKeyEntry() { - return &*IndexListEntryTombstoneKey; -} - - void SlotIndexes::getAnalysisUsage(AnalysisUsage &au) const { au.setPreservesAll(); MachineFunctionPass::getAnalysisUsage(au); From ajclinto at gmail.com Thu Mar 3 00:21:54 2011 From: ajclinto at gmail.com (Andrew Clinton) Date: Thu, 3 Mar 2011 01:21:54 -0500 Subject: [llvm-commits] Patch to improve loop-simplify Message-ID: This patch improves the loop-simplify pass by avoiding the separation of inner/outer loops in cases where the pass can determine that the new outer loop would have no loop exits that are not also contained in the inner loop. In this case, what appeared to be a nested loop is really just conditional control flow within a loop. If someone could review and commit the patch that would be much appreciated. Andrew -------------- next part -------------- A non-text attachment was scrubbed... Name: nestedloops.diff Type: text/x-patch Size: 5409 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110303/d3e4ec62/attachment.bin From anton at korobeynikov.info Thu Mar 3 00:23:22 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Thu, 3 Mar 2011 09:23:22 +0300 Subject: [llvm-commits] [llvm] r126862 - in /llvm/trunk: include/llvm/CallingConv.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Target/X86/X86CallingConv.td lib/VMCore/AsmWriter.cpp In-Reply-To: References: <20110302192922.716EF2A6C12C@llvm.org> Message-ID: > Good morning, Tilmann. > > Naive question. Why didn't you reuse x86_thiscall for x64? +1. Tilmann, please submit stuff for review before commit next time. Thanks! -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From clattner at apple.com Thu Mar 3 00:26:16 2011 From: clattner at apple.com (Chris Lattner) Date: Wed, 2 Mar 2011 22:26:16 -0800 Subject: [llvm-commits] Patch to improve loop-simplify In-Reply-To: References: Message-ID: <39EBEC22-9E9B-44A1-AAB4-5771EE61D79D@apple.com> On Mar 2, 2011, at 10:21 PM, Andrew Clinton wrote: > This patch improves the loop-simplify pass by avoiding the separation > of inner/outer loops in cases where the pass can determine that the > new outer loop would have no loop exits that are not also contained in > the inner loop. In this case, what appeared to be a nested loop is > really just conditional control flow within a loop. > > If someone could review and commit the patch that would be much appreciated. Hi Andrew, Some minor coding standards stuff: + std::set BlocksInL; set is really slow, please use SmallPtrSet<> if appropriate. ProgrammersManual.html has a discussion about various datastructures and their tradeoffs. I know this isn't new, but please fix :) + BasicBlock *P = PN->getIncomingBlock(i); only one space before *. + bool OuterLoopHasExit = false; + for (unsigned i = 0; i < ExitingBlocks.size(); ++i) + { + if (!BlocksInL.count(ExitingBlocks[i])) + { + OuterLoopHasExit = true; + break; + } + } + if (!OuterLoopHasExit) + return 0; Only one space after bool, please don't execute ExitingBlocks.size() every time through the loop and please put { on the preceding lines. Cameron, can you review the algorithmic changes? -Chris From stoklund at 2pi.dk Thu Mar 3 00:29:01 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 03 Mar 2011 06:29:01 -0000 Subject: [llvm-commits] [llvm] r126926 - /llvm/trunk/lib/CodeGen/SlotIndexes.cpp Message-ID: <20110303062901.5919F2A6C12C@llvm.org> Author: stoklund Date: Thu Mar 3 00:29:01 2011 New Revision: 126926 URL: http://llvm.org/viewvc/llvm-project?rev=126926&view=rev Log: Renumber slot indexes uniformly instead of spacing according to the number of defs. There are probably much larger speedups to be had by renumbering locally instead of looping over the whole function. For now, the greedy register allocator is 25% faster. Modified: llvm/trunk/lib/CodeGen/SlotIndexes.cpp Modified: llvm/trunk/lib/CodeGen/SlotIndexes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SlotIndexes.cpp?rev=126926&r1=126925&r2=126926&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SlotIndexes.cpp (original) +++ llvm/trunk/lib/CodeGen/SlotIndexes.cpp Thu Mar 3 00:29:01 2011 @@ -129,26 +129,12 @@ // had been present. DEBUG(dbgs() << "\n*** Renumbering SlotIndexes ***\n"); - functionSize = 0; unsigned index = 0; for (IndexListEntry *curEntry = front(); curEntry != getTail(); curEntry = curEntry->getNext()) { - curEntry->setIndex(index); - - if (curEntry->getInstr() == 0) { - // MBB start entry. Just step index by 1. - index += SlotIndex::NUM; - } - else { - ++functionSize; - unsigned Slots = curEntry->getInstr()->getDesc().getNumDefs(); - if (Slots == 0) - Slots = 1; - - index += (Slots + 1) * SlotIndex::NUM; - } + index += 4*SlotIndex::NUM; } } From bob.wilson at apple.com Thu Mar 3 00:39:09 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 03 Mar 2011 06:39:09 -0000 Subject: [llvm-commits] [llvm] r126930 - /llvm/trunk/lib/Target/ARM/README.txt Message-ID: <20110303063909.6771F2A6C12C@llvm.org> Author: bwilson Date: Thu Mar 3 00:39:09 2011 New Revision: 126930 URL: http://llvm.org/viewvc/llvm-project?rev=126930&view=rev Log: Add a readme entry for the redundant movw issue for pr9370. Modified: llvm/trunk/lib/Target/ARM/README.txt Modified: llvm/trunk/lib/Target/ARM/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/README.txt?rev=126930&r1=126929&r2=126930&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/README.txt (original) +++ llvm/trunk/lib/Target/ARM/README.txt Thu Mar 3 00:39:09 2011 @@ -657,3 +657,27 @@ //===---------------------------------------------------------------------===// +When loading immediate constants with movt/movw, if there are multiple +constants needed with the same low 16 bits, and those values are not live at +the same time, it would be possible to use a single movw instruction, followed +by multiple movt instructions to rewrite the high bits to different values. +For example: + + volatile store i32 -1, i32* inttoptr (i32 1342210076 to i32*), align 4, + !tbaa +!0 + volatile store i32 -1, i32* inttoptr (i32 1342341148 to i32*), align 4, + !tbaa +!0 + +is compiled and optimized to: + + movw r0, #32796 + mov.w r1, #-1 + movt r0, #20480 + str r1, [r0] + movw r0, #32796 @ <= this MOVW is not needed, value is there already + movt r0, #20482 + str r1, [r0] + +//===---------------------------------------------------------------------===// From zwarich at apple.com Thu Mar 3 01:10:48 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Wed, 2 Mar 2011 23:10:48 -0800 Subject: [llvm-commits] Patch to improve loop-simplify In-Reply-To: References: Message-ID: Is splitting an edge to create a unique loop backedge better than creating two loops? If the inner loop's backedge is more frequently taken, then you are trading an extra unconditional branch (with phis) on loop entry for an extra unconditional branch (with phis) along the inner loop's backedge. When is this a good trade? Cameron From bob.wilson at apple.com Thu Mar 3 01:19:52 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 03 Mar 2011 07:19:52 -0000 Subject: [llvm-commits] [llvm] r126931 - in /llvm/trunk: test/MC/Disassembler/ARM/arm-tests.txt utils/TableGen/ARMDecoderEmitter.cpp Message-ID: <20110303071952.A544D2A6C12C@llvm.org> Author: bwilson Date: Thu Mar 3 01:19:52 2011 New Revision: 126931 URL: http://llvm.org/viewvc/llvm-project?rev=126931&view=rev Log: TableGen should not ignore BX instructions for the ARM disassembler. pr9368. Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt?rev=126931&r1=126930&r2=126931&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Thu Mar 3 01:19:52 2011 @@ -136,3 +136,6 @@ # CHECK: blxeq r5 0x35 0xff 0x2f 0x01 + +# CHECK: bx r12 +0x1c 0xff 0x2f 0xe1 Modified: llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp?rev=126931&r1=126930&r2=126931&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Thu Mar 3 01:19:52 2011 @@ -1631,7 +1631,7 @@ if (Name == "B") return false; // Ignore the non-Darwin BL instructions and the TPsoft (TLS) instruction. - if (Name == "BL" || Name == "BL_pred" || Name == "BLX" || Name == "BX" || + if (Name == "BL" || Name == "BL_pred" || Name == "BLX" || Name == "BLX_pred" || Name == "TPsoft") return false; From eli.friedman at gmail.com Thu Mar 3 01:24:36 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 03 Mar 2011 07:24:36 -0000 Subject: [llvm-commits] [llvm] r126933 - in /llvm/trunk: lib/MC/ELFObjectWriter.cpp test/MC/ELF/weak-relocation.s Message-ID: <20110303072436.342AB2A6C12C@llvm.org> Author: efriedma Date: Thu Mar 3 01:24:36 2011 New Revision: 126933 URL: http://llvm.org/viewvc/llvm-project?rev=126933&view=rev Log: PR9352: Always emit a relocation for weak symbols. Not emitting relocations for calls to weak symbols with a definition has the appearance of working with LLVM-generated code because weak symbol definitions are put in their own sections. Added: llvm/trunk/test/MC/ELF/weak-relocation.s Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=126933&r1=126932&r2=126933&view=diff ============================================================================== --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Thu Mar 3 01:24:36 2011 @@ -317,6 +317,13 @@ MCDataFragment *F, const MCSectionData *SD); + virtual bool + IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, + const MCSymbolData &DataA, + const MCFragment &FB, + bool InSet, + bool IsPCRel) const; + virtual void WriteObject(MCAssembler &Asm, const MCAsmLayout &Layout); virtual void WriteSection(MCAssembler &Asm, const SectionIndexMapTy &SectionIndexMap, @@ -1438,6 +1445,18 @@ } } +bool +ELFObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, + const MCSymbolData &DataA, + const MCFragment &FB, + bool InSet, + bool IsPCRel) const { + if (DataA.getFlags() & ELF_STB_Weak) + return false; + return MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl( + Asm, DataA, FB,InSet, IsPCRel); +} + MCObjectWriter *llvm::createELFObjectWriter(MCELFObjectTargetWriter *MOTW, raw_ostream &OS, bool IsLittleEndian) { Added: llvm/trunk/test/MC/ELF/weak-relocation.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/weak-relocation.s?rev=126933&view=auto ============================================================================== --- llvm/trunk/test/MC/ELF/weak-relocation.s (added) +++ llvm/trunk/test/MC/ELF/weak-relocation.s Thu Mar 3 01:24:36 2011 @@ -0,0 +1,15 @@ +// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump | FileCheck %s + +// Test that weak symbols always produce relocations + + .weak foo +foo: +bar: + call foo + +//CHECK: # Relocation 0x00000000 +//CHECK-NEXT: (('r_offset', 0x00000001) +//CHECK-NEXT: ('r_sym', 0x00000005) +//CHECK-NEXT: ('r_type', 0x00000002) +//CHECK-NEXT: ('r_addend', 0xfffffffc) +//CHECK-NEXT: ), From tilmann.scheller at googlemail.com Thu Mar 3 01:49:07 2011 From: tilmann.scheller at googlemail.com (Tilmann Scheller) Date: Thu, 03 Mar 2011 07:49:07 -0000 Subject: [llvm-commits] [llvm] r126934 - in /llvm/trunk: include/llvm/CallingConv.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Target/X86/X86CallingConv.td lib/VMCore/AsmWriter.cpp Message-ID: <20110303074907.EA4DB2A6C12C@llvm.org> Author: tilmann Date: Thu Mar 3 01:49:07 2011 New Revision: 126934 URL: http://llvm.org/viewvc/llvm-project?rev=126934&view=rev Log: Use X86_thiscall calling convention for Win64 as well. Modified: llvm/trunk/include/llvm/CallingConv.h llvm/trunk/lib/AsmParser/LLLexer.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLToken.h llvm/trunk/lib/Target/X86/X86CallingConv.td llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/include/llvm/CallingConv.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CallingConv.h?rev=126934&r1=126933&r2=126934&view=diff ============================================================================== --- llvm/trunk/include/llvm/CallingConv.h (original) +++ llvm/trunk/include/llvm/CallingConv.h Thu Mar 3 01:49:07 2011 @@ -94,10 +94,7 @@ /// MBLAZE_INTR - Calling convention used for MBlaze interrupt support /// routines (i.e. GCC's save_volatiles attribute). - MBLAZE_SVOL = 74, - - /// Win64_ThisCall - Calling convention used for method calls on Win64. - Win64_ThisCall = 75 + MBLAZE_SVOL = 74 }; } // End CallingConv namespace Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=126934&r1=126933&r2=126934&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLLexer.cpp (original) +++ llvm/trunk/lib/AsmParser/LLLexer.cpp Thu Mar 3 01:49:07 2011 @@ -549,7 +549,6 @@ KEYWORD(msp430_intrcc); KEYWORD(ptx_kernel); KEYWORD(ptx_device); - KEYWORD(win64_thiscallcc); KEYWORD(cc); KEYWORD(c); Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=126934&r1=126933&r2=126934&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Thu Mar 3 01:49:07 2011 @@ -1087,7 +1087,6 @@ /// ::= 'msp430_intrcc' /// ::= 'ptx_kernel' /// ::= 'ptx_device' -/// ::= 'win64_thiscallcc' /// ::= 'cc' UINT /// bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) { @@ -1105,7 +1104,6 @@ case lltok::kw_msp430_intrcc: CC = CallingConv::MSP430_INTR; break; case lltok::kw_ptx_kernel: CC = CallingConv::PTX_Kernel; break; case lltok::kw_ptx_device: CC = CallingConv::PTX_Device; break; - case lltok::kw_win64_thiscallcc:CC = CallingConv::Win64_ThisCall; break; case lltok::kw_cc: { unsigned ArbitraryCC; Lex.Lex(); Modified: llvm/trunk/lib/AsmParser/LLToken.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=126934&r1=126933&r2=126934&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLToken.h (original) +++ llvm/trunk/lib/AsmParser/LLToken.h Thu Mar 3 01:49:07 2011 @@ -74,7 +74,6 @@ kw_arm_apcscc, kw_arm_aapcscc, kw_arm_aapcs_vfpcc, kw_msp430_intrcc, kw_ptx_kernel, kw_ptx_device, - kw_win64_thiscallcc, kw_signext, kw_zeroext, Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CallingConv.td?rev=126934&r1=126933&r2=126934&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CallingConv.td (original) +++ llvm/trunk/lib/Target/X86/X86CallingConv.td Thu Mar 3 01:49:07 2011 @@ -218,7 +218,7 @@ // Do not pass the sret argument in RCX, the Win64 thiscall calling // convention requires "this" to be passed in RCX. - CCIfCC<"CallingConv::Win64_ThisCall", + CCIfCC<"CallingConv::X86_ThisCall", CCIfSRet>>>, Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=126934&r1=126933&r2=126934&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Thu Mar 3 01:49:07 2011 @@ -1586,7 +1586,6 @@ case CallingConv::MSP430_INTR: Out << "msp430_intrcc "; break; case CallingConv::PTX_Kernel: Out << "ptx_kernel"; break; case CallingConv::PTX_Device: Out << "ptx_device"; break; - case CallingConv::Win64_ThisCall:Out << "win64_thiscallcc "; break; default: Out << "cc" << F->getCallingConv() << " "; break; } @@ -1859,7 +1858,6 @@ case CallingConv::MSP430_INTR: Out << " msp430_intrcc "; break; case CallingConv::PTX_Kernel: Out << " ptx_kernel"; break; case CallingConv::PTX_Device: Out << " ptx_device"; break; - case CallingConv::Win64_ThisCall:Out << " win64_thiscallcc "; break; default: Out << " cc" << CI->getCallingConv(); break; } @@ -1916,7 +1914,6 @@ case CallingConv::MSP430_INTR: Out << " msp430_intrcc "; break; case CallingConv::PTX_Kernel: Out << " ptx_kernel"; break; case CallingConv::PTX_Device: Out << " ptx_device"; break; - case CallingConv::Win64_ThisCall:Out << " win64_thiscallcc "; break; default: Out << " cc" << II->getCallingConv(); break; } From tilmann.scheller at googlemail.com Thu Mar 3 01:54:51 2011 From: tilmann.scheller at googlemail.com (Tilmann Scheller) Date: Thu, 3 Mar 2011 08:54:51 +0100 Subject: [llvm-commits] [llvm] r126862 - in /llvm/trunk: include/llvm/CallingConv.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Target/X86/X86CallingConv.td lib/VMCore/AsmWriter.cpp In-Reply-To: References: <20110302192922.716EF2A6C12C@llvm.org> Message-ID: Hi Takumi, No specific reason, changed in r126934. Regards, Tilmann On Thu, Mar 3, 2011 at 12:17 AM, NAKAMURA Takumi wrote: > Good morning, Tilmann. > > Naive question. Why didn't you reuse x86_thiscall for x64? > > ...Takumi > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110303/ecfea45d/attachment.html From tilmann.scheller at googlemail.com Thu Mar 3 01:55:51 2011 From: tilmann.scheller at googlemail.com (Tilmann Scheller) Date: Thu, 3 Mar 2011 08:55:51 +0100 Subject: [llvm-commits] [llvm] r126862 - in /llvm/trunk: include/llvm/CallingConv.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Target/X86/X86CallingConv.td lib/VMCore/AsmWriter.cpp In-Reply-To: References: <20110302192922.716EF2A6C12C@llvm.org> Message-ID: Hi Anton, On Thu, Mar 3, 2011 at 7:23 AM, Anton Korobeynikov wrote: > > Good morning, Tilmann. > > > > Naive question. Why didn't you reuse x86_thiscall for x64? > +1. > Tilmann, please submit stuff for review before commit next time. > > Thanks! > Will definitely do :) Regards, Tilmann -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110303/1c6018b1/attachment.html From ajclinto at gmail.com Thu Mar 3 01:56:38 2011 From: ajclinto at gmail.com (Andrew Clinton) Date: Thu, 3 Mar 2011 02:56:38 -0500 Subject: [llvm-commits] Patch to improve loop-simplify In-Reply-To: References: Message-ID: The role of the loop-simplify pass, as described in the header, is to transform natural loops into a simpler form. The goal of this patch is not to produce the minimum number of instructions but to ensure that additional (unnecessary) complexity is not introduced by the simplification. I think this is a good change since running the natural loops analysis after this pass will then produce the expected loop nesting. Without this patch, I have found it necessary to write a new pass that merges the nested loops. I believe that other passes will clean up extra branching (CFG simplification), and PHI nodes will usually add runtime complexity only for the incoming blocks. So I wouldn't expect runtime performance to be impacted by this change. Attached is the revised diff - thank you for the feedback! Andrew On Thu, Mar 3, 2011 at 2:10 AM, Cameron Zwarich wrote: > Is splitting an edge to create a unique loop backedge better than creating two loops? If the inner loop's backedge is more frequently taken, then you are trading an extra unconditional branch (with phis) on loop entry for an extra unconditional branch (with phis) along the inner loop's backedge. When is this a good trade? > > Cameron -------------- next part -------------- A non-text attachment was scrubbed... Name: nestedloops.diff Type: text/x-patch Size: 6227 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110303/c2855a90/attachment-0001.bin From zwarich at apple.com Thu Mar 3 02:43:38 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Thu, 03 Mar 2011 00:43:38 -0800 Subject: [llvm-commits] Patch to improve loop-simplify In-Reply-To: References: Message-ID: When I compile your first test case without this patch for X86, I see 2 conditional branches in the loop body and no unconditional branches. With this patch, there is an extra unconditional branch inside the loop. Unfortunately, I don't think this is cleaned up as well as you assume. Cameron On 2011-03-02, at 11:56 PM, Andrew Clinton wrote: > The role of the loop-simplify pass, as described in the header, is to > transform natural loops into a simpler form. The goal of this patch > is not to produce the minimum number of instructions but to ensure > that additional (unnecessary) complexity is not introduced by the > simplification. I think this is a good change since running the > natural loops analysis after this pass will then produce the expected > loop nesting. Without this patch, I have found it necessary to write > a new pass that merges the nested loops. > > I believe that other passes will clean up extra branching (CFG > simplification), and PHI nodes will usually add runtime complexity > only for the incoming blocks. So I wouldn't expect runtime > performance to be impacted by this change. > > Attached is the revised diff - thank you for the feedback! > > Andrew > > On Thu, Mar 3, 2011 at 2:10 AM, Cameron Zwarich wrote: >> Is splitting an edge to create a unique loop backedge better than creating two loops? If the inner loop's backedge is more frequently taken, then you are trading an extra unconditional branch (with phis) on loop entry for an extra unconditional branch (with phis) along the inner loop's backedge. When is this a good trade? >> >> Cameron > From richard at xmos.com Thu Mar 3 07:17:52 2011 From: richard at xmos.com (Richard Osborne) Date: Thu, 03 Mar 2011 13:17:52 -0000 Subject: [llvm-commits] [llvm] r126935 - in /llvm/trunk: include/llvm/Target/TargetLibraryInfo.h lib/Target/TargetLibraryInfo.cpp lib/Transforms/Scalar/SimplifyLibCalls.cpp test/Transforms/SimplifyLibCalls/iprintf.ll Message-ID: <20110303131752.2F8D32A6C12C@llvm.org> Author: friedgold Date: Thu Mar 3 07:17:51 2011 New Revision: 126935 URL: http://llvm.org/viewvc/llvm-project?rev=126935&view=rev Log: Optimize printf -> iprintf if there are no floating point arguments and iprintf is available on the target. Currently iprintf is only marked as being available on the XCore. Added: llvm/trunk/test/Transforms/SimplifyLibCalls/iprintf.ll Modified: llvm/trunk/include/llvm/Target/TargetLibraryInfo.h llvm/trunk/lib/Target/TargetLibraryInfo.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Modified: llvm/trunk/include/llvm/Target/TargetLibraryInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLibraryInfo.h?rev=126935&r1=126934&r2=126935&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLibraryInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetLibraryInfo.h Thu Mar 3 07:17:51 2011 @@ -26,6 +26,9 @@ /// void memset_pattern16(void *b, const void *pattern16, size_t len); memset_pattern16, + /// int iprintf(const char *format, ...); + iprintf, + NumLibFuncs }; } Modified: llvm/trunk/lib/Target/TargetLibraryInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLibraryInfo.cpp?rev=126935&r1=126934&r2=126935&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLibraryInfo.cpp (original) +++ llvm/trunk/lib/Target/TargetLibraryInfo.cpp Thu Mar 3 07:17:51 2011 @@ -30,7 +30,10 @@ // memset_pattern16 is only available on iOS 3.0 and Mac OS/X 10.5 and later. if (T.getOS() != Triple::Darwin || T.getDarwinMajorNumber() < 9) TLI.setUnavailable(LibFunc::memset_pattern16); - + + // iprintf is only available on XCore. + if (T.getArch() != Triple::xcore) + TLI.setUnavailable(LibFunc::iprintf); } Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=126935&r1=126934&r2=126935&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Thu Mar 3 07:17:51 2011 @@ -49,6 +49,7 @@ protected: Function *Caller; const TargetData *TD; + const TargetLibraryInfo *TLI; LLVMContext* Context; public: LibCallOptimization() { } @@ -62,9 +63,11 @@ virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) =0; - Value *OptimizeCall(CallInst *CI, const TargetData *TD, IRBuilder<> &B) { + Value *OptimizeCall(CallInst *CI, const TargetData *TD, + const TargetLibraryInfo *TLI, IRBuilder<> &B) { Caller = CI->getParent()->getParent(); this->TD = TD; + this->TLI = TLI; if (CI->getCalledFunction()) Context = &CI->getCalledFunction()->getContext(); @@ -97,6 +100,15 @@ } return true; } + +static bool CallHasFloatingPointArgument(const CallInst *CI) { + for (CallInst::const_op_iterator it = CI->op_begin(), e = CI->op_end(); + it != e; ++it) { + if ((*it)->getType()->isFloatingPointTy()) + return true; + } + return false; +} /// IsOnlyUsedInEqualityComparison - Return true if it is only used in equality /// comparisons with With. @@ -1075,14 +1087,8 @@ // 'printf' Optimizations struct PrintFOpt : public LibCallOptimization { - virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { - // Require one fixed pointer argument and an integer/void result. - const FunctionType *FT = Callee->getFunctionType(); - if (FT->getNumParams() < 1 || !FT->getParamType(0)->isPointerTy() || - !(FT->getReturnType()->isIntegerTy() || - FT->getReturnType()->isVoidTy())) - return 0; - + Value *OptimizeFixedFormatString(Function *Callee, CallInst *CI, + IRBuilder<> &B) { // Check for a fixed format string. std::string FormatStr; if (!GetConstantStringInfo(CI->getArgOperand(0), FormatStr)) @@ -1138,6 +1144,32 @@ } return 0; } + + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { + // Require one fixed pointer argument and an integer/void result. + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() < 1 || !FT->getParamType(0)->isPointerTy() || + !(FT->getReturnType()->isIntegerTy() || + FT->getReturnType()->isVoidTy())) + return 0; + + if (Value *V = OptimizeFixedFormatString(Callee, CI, B)) { + return V; + } + + // printf(format, ...) -> iprintf(format, ...) if no floating point + // arguments. + if (TLI->has(LibFunc::iprintf) && !CallHasFloatingPointArgument(CI)) { + Module *M = B.GetInsertBlock()->getParent()->getParent(); + Constant *IPrintFFn = + M->getOrInsertFunction("iprintf", FT, Callee->getAttributes()); + CallInst *New = cast(CI->clone()); + New->setCalledFunction(IPrintFFn); + B.Insert(New); + return New; + } + return 0; + } }; //===---------------------------------------===// @@ -1545,7 +1577,7 @@ Builder.SetInsertPoint(BB, I); // Try to optimize this call. - Value *Result = LCO->OptimizeCall(CI, TD, Builder); + Value *Result = LCO->OptimizeCall(CI, TD, TLI, Builder); if (Result == 0) continue; DEBUG(dbgs() << "SimplifyLibCalls simplified: " << *CI; Added: llvm/trunk/test/Transforms/SimplifyLibCalls/iprintf.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/iprintf.ll?rev=126935&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/iprintf.ll (added) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/iprintf.ll Thu Mar 3 07:17:51 2011 @@ -0,0 +1,29 @@ +; RUN: opt < %s -simplify-libcalls -S -o %t +; RUN: FileCheck < %t %s +target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:32" +target triple = "xcore-xmos-elf" + + at .str = internal constant [4 x i8] c"%f\0A\00" ; <[4 x i8]*> [#uses=1] + at .str1 = internal constant [4 x i8] c"%d\0A\00" ; <[4 x i8]*> [#uses=1] + +; Verify printf with no floating point arguments is transformed to iprintf +define i32 @f0(i32 %x) nounwind { +entry: +; CHECK: define i32 @f0 +; CHECK: @iprintf +; CHECK: } + %0 = tail call i32 (i8*, ...)* @printf(i8* getelementptr ([4 x i8]* @.str1, i32 0, i32 0), i32 %x) ; [#uses=0] + ret i32 %0 +} + +; Verify we don't turn this into an iprintf call +define void @f1(double %x) nounwind { +entry: +; CHECK: define void @f1 +; CHECK: @printf +; CHECK: } + %0 = tail call i32 (i8*, ...)* @printf(i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), double %x) nounwind ; [#uses=0] + ret void +} + +declare i32 @printf(i8* nocapture, ...) nounwind From richard at xmos.com Thu Mar 3 07:30:18 2011 From: richard at xmos.com (Richard Osborne) Date: Thu, 3 Mar 2011 13:30:18 +0000 Subject: [llvm-commits] [PATCH] Optimize printf -> iprintf if there are no floating point arguments In-Reply-To: References: <4D6D2750.6020501@xmos.com> Message-ID: <4D6F97EA.1090909@xmos.com> On 02/03/11 01:15, Chris Lattner wrote: > On Mar 1, 2011, at 9:05 AM, Richard Osborne wrote: > >> This patch adds an optimization to SimplifyLibCalls which transforms calls to printf into iprintf calls. iprintf is a restricted version of printf provided by newlib without floating-point formatting (see http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-February/037832.html). >> >> This patch uses TargetLibraryInfo to determine whether iprintf is available. Currently it is only marked as available on the XCore target. >> >> I intend to add similar optimizations for sprintf / fprintf once this patch is accepted. Please let me know if this is OK to commit. > In addition to Frits' comment about the testcase, the patch would be simpler if you changed this: > > + // printf(format, ...) -> iprintf(format, ...) if no floating point > + // arguments. > + if (TLI->has(LibFunc::iprintf)&& !CallHasFloatingPointArgument(CI)) { > + return EmitIPrintF(CI->op_begin(), CI->op_end(), B, TD); > + } > > Instead of emitting a new IPrintF call, you can just change the callee of the existing call to be iprintf instead of printf. This would make the code look something like this: > > // printf(format, ...) -> iprintf(format, ...) if no floating point > // arguments. > if (TLI->has(LibFunc::iprintf)&& !CallHasFloatingPointArgument(CI)) { > Constant *IPrintFFn = ... > CI->setOperand(0, IPrintFFn); > return CI; > } > > This allows you to remove the EmitIPrintF implementation and should simplify the fprintf case that's coming next. > > Thanks for implementing this Richard! > > -Chris If you return the existing call then SimplifyLibCalls tries to erase it, see the following comment: /// CallOptimizer - This pure virtual method is implemented by base classes to /// do various optimizations. If this returns null then no transformation was /// performed. If it returns CI, then it transformed the call and CI is to be /// deleted. If it returns something else, replace CI with the new value and /// delete CI. I've change the code to clone the call and return the clone after changing the callee. This means EmitIPrintF is no longer needed. I've also fixed the issue in the testcase spotted by Frits. Committed in r126935 Thanks for the review comments. -- Richard Osborne | XMOS http://www.xmos.com From justin.holewinski at gmail.com Thu Mar 3 07:34:30 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Thu, 03 Mar 2011 13:34:30 -0000 Subject: [llvm-commits] [llvm] r126936 - in /llvm/trunk/lib/Target/PTX: PTXAsmPrinter.cpp PTXFrameLowering.h PTXInstrInfo.cpp PTXMCAsmStreamer.cpp Message-ID: <20110303133430.1758E2A6C12C@llvm.org> Author: jholewinski Date: Thu Mar 3 07:34:29 2011 New Revision: 126936 URL: http://llvm.org/viewvc/llvm-project?rev=126936&view=rev Log: PTX: Fix a couple of lint violations Modified: llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp llvm/trunk/lib/Target/PTX/PTXFrameLowering.h llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp Modified: llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp?rev=126936&r1=126935&r2=126936&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp Thu Mar 3 07:34:29 2011 @@ -170,7 +170,8 @@ OutStreamer.EmitRawText(Twine("\t.version " + ST.getPTXVersionString())); OutStreamer.EmitRawText(Twine("\t.target " + ST.getTargetString() + - (ST.supportsDouble() ? "" : ", map_f64_to_f32"))); + (ST.supportsDouble() ? "" + : ", map_f64_to_f32"))); OutStreamer.AddBlankLine(); // declare global variables Modified: llvm/trunk/lib/Target/PTX/PTXFrameLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXFrameLowering.h?rev=126936&r1=126935&r2=126936&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXFrameLowering.h (original) +++ llvm/trunk/lib/Target/PTX/PTXFrameLowering.h Thu Mar 3 07:34:29 2011 @@ -27,7 +27,8 @@ public: explicit PTXFrameLowering(const PTXSubtarget &sti) - : TargetFrameLowering(TargetFrameLowering::StackGrowsDown, 2, -2), STI(sti) { + : TargetFrameLowering(TargetFrameLowering::StackGrowsDown, 2, -2), + STI(sti) { } /// emitProlog/emitEpilog - These methods insert prolog and epilog code into Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp?rev=126936&r1=126935&r2=126936&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp Thu Mar 3 07:34:29 2011 @@ -42,7 +42,8 @@ for (int i = 0, e = sizeof(map)/sizeof(map[0]); i != e; ++ i) { if (map[i].cls->contains(DstReg, SrcReg)) { BuildMI(MBB, I, DL, - get(map[i].opcode), DstReg).addReg(SrcReg, getKillRegState(KillSrc)); + get(map[i].opcode), DstReg).addReg(SrcReg, + Getkillregstate(KillSrc)); return; } } Modified: llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp?rev=126936&r1=126935&r2=126936&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp Thu Mar 3 07:34:29 2011 @@ -423,7 +423,8 @@ MCStreamer::EmitFill(NumBytes, FillValue, AddrSpace); } -void PTXMCAsmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value, +void PTXMCAsmStreamer::EmitValueToAlignment(unsigned ByteAlignment, + int64_t Value, unsigned ValueSize, unsigned MaxBytesToEmit) { // Some assemblers don't support non-power of two alignments, so we always From richard at xmos.com Thu Mar 3 08:09:28 2011 From: richard at xmos.com (Richard Osborne) Date: Thu, 03 Mar 2011 14:09:28 -0000 Subject: [llvm-commits] [llvm] r126937 - in /llvm/trunk: include/llvm/Target/TargetLibraryInfo.h lib/Target/TargetLibraryInfo.cpp lib/Transforms/Scalar/SimplifyLibCalls.cpp test/Transforms/SimplifyLibCalls/iprintf.ll Message-ID: <20110303140928.3C1FA2A6C12C@llvm.org> Author: friedgold Date: Thu Mar 3 08:09:28 2011 New Revision: 126937 URL: http://llvm.org/viewvc/llvm-project?rev=126937&view=rev Log: Optimize sprintf -> siprintf if there are no floating point arguments and siprintf is available on the target. Modified: llvm/trunk/include/llvm/Target/TargetLibraryInfo.h llvm/trunk/lib/Target/TargetLibraryInfo.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp llvm/trunk/test/Transforms/SimplifyLibCalls/iprintf.ll Modified: llvm/trunk/include/llvm/Target/TargetLibraryInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLibraryInfo.h?rev=126937&r1=126936&r2=126937&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLibraryInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetLibraryInfo.h Thu Mar 3 08:09:28 2011 @@ -29,6 +29,9 @@ /// int iprintf(const char *format, ...); iprintf, + /// int siprintf(char *str, const char *format, ...); + siprintf, + NumLibFuncs }; } Modified: llvm/trunk/lib/Target/TargetLibraryInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLibraryInfo.cpp?rev=126937&r1=126936&r2=126937&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLibraryInfo.cpp (original) +++ llvm/trunk/lib/Target/TargetLibraryInfo.cpp Thu Mar 3 08:09:28 2011 @@ -31,9 +31,11 @@ if (T.getOS() != Triple::Darwin || T.getDarwinMajorNumber() < 9) TLI.setUnavailable(LibFunc::memset_pattern16); - // iprintf is only available on XCore. - if (T.getArch() != Triple::xcore) + // iprintf and friends are only available on XCore. + if (T.getArch() != Triple::xcore) { TLI.setUnavailable(LibFunc::iprintf); + TLI.setUnavailable(LibFunc::siprintf); + } } Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=126937&r1=126936&r2=126937&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Thu Mar 3 08:09:28 2011 @@ -1176,14 +1176,8 @@ // 'sprintf' Optimizations struct SPrintFOpt : public LibCallOptimization { - virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { - // Require two fixed pointer arguments and an integer result. - const FunctionType *FT = Callee->getFunctionType(); - if (FT->getNumParams() != 2 || !FT->getParamType(0)->isPointerTy() || - !FT->getParamType(1)->isPointerTy() || - !FT->getReturnType()->isIntegerTy()) - return 0; - + Value *OptimizeFixedFormatString(Function *Callee, CallInst *CI, + IRBuilder<> &B) { // Check for a fixed format string. std::string FormatStr; if (!GetConstantStringInfo(CI->getArgOperand(1), FormatStr)) @@ -1244,6 +1238,32 @@ } return 0; } + + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { + // Require two fixed pointer arguments and an integer result. + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() != 2 || !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isPointerTy() || + !FT->getReturnType()->isIntegerTy()) + return 0; + + if (Value *V = OptimizeFixedFormatString(Callee, CI, B)) { + return V; + } + + // sprintf(str, format, ...) -> iprintf(str, format, ...) if no floating + // point arguments. + if (TLI->has(LibFunc::siprintf) && !CallHasFloatingPointArgument(CI)) { + Module *M = B.GetInsertBlock()->getParent()->getParent(); + Constant *SIPrintFFn = + M->getOrInsertFunction("siprintf", FT, Callee->getAttributes()); + CallInst *New = cast(CI->clone()); + New->setCalledFunction(SIPrintFFn); + B.Insert(New); + return New; + } + return 0; + } }; //===---------------------------------------===// Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/iprintf.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/iprintf.ll?rev=126937&r1=126936&r2=126937&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/iprintf.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/iprintf.ll Thu Mar 3 08:09:28 2011 @@ -26,4 +26,25 @@ ret void } +; Verify sprintf with no floating point arguments is transformed to siprintf +define i32 @f2(i8* %p, i32 %x) nounwind { +entry: +; CHECK: define i32 @f2 +; CHECK: @siprintf +; CHECK: } + %0 = tail call i32 (i8*, i8*, ...)* @sprintf(i8 *%p, i8* getelementptr ([4 x i8]* @.str1, i32 0, i32 0), i32 %x) + ret i32 %0 +} + +; Verify we don't turn this into an siprintf call +define i32 @f3(i8* %p, double %x) nounwind { +entry: +; CHECK: define i32 @f3 +; CHECK: @sprintf +; CHECK: } + %0 = tail call i32 (i8*, i8*, ...)* @sprintf(i8 *%p, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), double %x) + ret i32 %0 +} + declare i32 @printf(i8* nocapture, ...) nounwind +declare i32 @sprintf(i8* nocapture, i8* nocapture, ...) nounwind From justin.holewinski at gmail.com Thu Mar 3 08:09:40 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Thu, 03 Mar 2011 14:09:40 -0000 Subject: [llvm-commits] [llvm] r126938 - /llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp Message-ID: <20110303140941.054152A6C12C@llvm.org> Author: jholewinski Date: Thu Mar 3 08:09:40 2011 New Revision: 126938 URL: http://llvm.org/viewvc/llvm-project?rev=126938&view=rev Log: PTX: Fix Emacs renaming a symbol Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp?rev=126938&r1=126937&r2=126938&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp Thu Mar 3 08:09:40 2011 @@ -43,7 +43,7 @@ if (map[i].cls->contains(DstReg, SrcReg)) { BuildMI(MBB, I, DL, get(map[i].opcode), DstReg).addReg(SrcReg, - Getkillregstate(KillSrc)); + getKillRegState(KillSrc)); return; } } From richard at xmos.com Thu Mar 3 08:20:23 2011 From: richard at xmos.com (Richard Osborne) Date: Thu, 03 Mar 2011 14:20:23 -0000 Subject: [llvm-commits] [llvm] r126940 - in /llvm/trunk: include/llvm/Target/TargetLibraryInfo.h lib/Target/TargetLibraryInfo.cpp lib/Transforms/Scalar/SimplifyLibCalls.cpp test/Transforms/SimplifyLibCalls/iprintf.ll Message-ID: <20110303142023.2C7E42A6C12D@llvm.org> Author: friedgold Date: Thu Mar 3 08:20:22 2011 New Revision: 126940 URL: http://llvm.org/viewvc/llvm-project?rev=126940&view=rev Log: Optimize fprintf -> iprintf if there are no floating point arguments and siprintf is available on the target. Modified: llvm/trunk/include/llvm/Target/TargetLibraryInfo.h llvm/trunk/lib/Target/TargetLibraryInfo.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp llvm/trunk/test/Transforms/SimplifyLibCalls/iprintf.ll Modified: llvm/trunk/include/llvm/Target/TargetLibraryInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLibraryInfo.h?rev=126940&r1=126939&r2=126940&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLibraryInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetLibraryInfo.h Thu Mar 3 08:20:22 2011 @@ -32,6 +32,9 @@ /// int siprintf(char *str, const char *format, ...); siprintf, + /// int fiprintf(FILE *stream, const char *format, ...); + fiprintf, + NumLibFuncs }; } Modified: llvm/trunk/lib/Target/TargetLibraryInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLibraryInfo.cpp?rev=126940&r1=126939&r2=126940&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLibraryInfo.cpp (original) +++ llvm/trunk/lib/Target/TargetLibraryInfo.cpp Thu Mar 3 08:20:22 2011 @@ -35,6 +35,7 @@ if (T.getArch() != Triple::xcore) { TLI.setUnavailable(LibFunc::iprintf); TLI.setUnavailable(LibFunc::siprintf); + TLI.setUnavailable(LibFunc::fiprintf); } } Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=126940&r1=126939&r2=126940&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Thu Mar 3 08:20:22 2011 @@ -1330,14 +1330,8 @@ // 'fprintf' Optimizations struct FPrintFOpt : public LibCallOptimization { - virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { - // Require two fixed paramters as pointers and integer result. - const FunctionType *FT = Callee->getFunctionType(); - if (FT->getNumParams() != 2 || !FT->getParamType(0)->isPointerTy() || - !FT->getParamType(1)->isPointerTy() || - !FT->getReturnType()->isIntegerTy()) - return 0; - + Value *OptimizeFixedFormatString(Function *Callee, CallInst *CI, + IRBuilder<> &B) { // All the optimizations depend on the format string. std::string FormatStr; if (!GetConstantStringInfo(CI->getArgOperand(1), FormatStr)) @@ -1382,6 +1376,32 @@ } return 0; } + + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { + // Require two fixed paramters as pointers and integer result. + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() != 2 || !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isPointerTy() || + !FT->getReturnType()->isIntegerTy()) + return 0; + + if (Value *V = OptimizeFixedFormatString(Callee, CI, B)) { + return V; + } + + // fprintf(stream, format, ...) -> fiprintf(stream, format, ...) if no + // floating point arguments. + if (TLI->has(LibFunc::fiprintf) && !CallHasFloatingPointArgument(CI)) { + Module *M = B.GetInsertBlock()->getParent()->getParent(); + Constant *FIPrintFFn = + M->getOrInsertFunction("fiprintf", FT, Callee->getAttributes()); + CallInst *New = cast(CI->clone()); + New->setCalledFunction(FIPrintFFn); + B.Insert(New); + return New; + } + return 0; + } }; //===---------------------------------------===// Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/iprintf.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/iprintf.ll?rev=126940&r1=126939&r2=126940&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/iprintf.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/iprintf.ll Thu Mar 3 08:20:22 2011 @@ -46,5 +46,26 @@ ret i32 %0 } +; Verify fprintf with no floating point arguments is transformed to fiprintf +define i32 @f4(i8* %p, i32 %x) nounwind { +entry: +; CHECK: define i32 @f4 +; CHECK: @fiprintf +; CHECK: } + %0 = tail call i32 (i8*, i8*, ...)* @fprintf(i8 *%p, i8* getelementptr ([4 x i8]* @.str1, i32 0, i32 0), i32 %x) + ret i32 %0 +} + +; Verify we don't turn this into an fiprintf call +define i32 @f5(i8* %p, double %x) nounwind { +entry: +; CHECK: define i32 @f5 +; CHECK: @fprintf +; CHECK: } + %0 = tail call i32 (i8*, i8*, ...)* @fprintf(i8 *%p, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), double %x) + ret i32 %0 +} + declare i32 @printf(i8* nocapture, ...) nounwind declare i32 @sprintf(i8* nocapture, i8* nocapture, ...) nounwind +declare i32 @fprintf(i8* nocapture, i8* nocapture, ...) nounwind From richard at xmos.com Thu Mar 3 08:21:22 2011 From: richard at xmos.com (Richard Osborne) Date: Thu, 03 Mar 2011 14:21:22 -0000 Subject: [llvm-commits] [llvm] r126941 - /llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Message-ID: <20110303142122.B23002A6C12C@llvm.org> Author: friedgold Date: Thu Mar 3 08:21:22 2011 New Revision: 126941 URL: http://llvm.org/viewvc/llvm-project?rev=126941&view=rev Log: Fix typo in comment. Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=126941&r1=126940&r2=126941&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Thu Mar 3 08:21:22 2011 @@ -1251,7 +1251,7 @@ return V; } - // sprintf(str, format, ...) -> iprintf(str, format, ...) if no floating + // sprintf(str, format, ...) -> siprintf(str, format, ...) if no floating // point arguments. if (TLI->has(LibFunc::siprintf) && !CallHasFloatingPointArgument(CI)) { Module *M = B.GetInsertBlock()->getParent()->getParent(); From jan_sjodin at yahoo.com Thu Mar 3 08:58:05 2011 From: jan_sjodin at yahoo.com (Jan Sjodin) Date: Thu, 3 Mar 2011 06:58:05 -0800 (PST) Subject: [llvm-commits] Split MCELFStreamer and ELFObjectWriter into .h and .cpp In-Reply-To: <4D6DB6C9.3030109@gmail.com> References: <919879.23172.qm@web55601.mail.re4.yahoo.com> <4D6D8989.6020109@gmail.com> <154127.95853.qm@web55605.mail.re4.yahoo.com> <4D6DB6C9.3030109@gmail.com> Message-ID: <297397.31526.qm@web55607.mail.re4.yahoo.com> I updated the patch slightly, since I was out for a day and ELFObjectWriter.cpp moved on. Committed updated patch as revision 126942. - Jan ----- Original Message ---- > From: Rafael ?vila de Esp?ndola > To: Jan Sjodin > Cc: llvm-commits at cs.uiuc.edu > Sent: Tue, March 1, 2011 10:17:29 PM > Subject: Re: Split MCELFStreamer and ELFObjectWriter into .h and .cpp > > On 2011-03-01 22:07, Jan Sjodin wrote: > > Yes, I was only wanting to get some basic refactoring in without disturbing >the > > > 2.9 release. There is no good reason to try and squeeze anything in. As far >as I > > > know this works in the JIT: > > 1. Generate code for a module in memory. > > 2. Inline asm in the code is OK. > > 3. Debug with gdb, as you would normally do e.g. C-x space for setting a > > breakpoint. > > Nice! > > Item 3 in particular is really interesting. I think the last use of the > old ELF writer in Codegen is producing debug info for the old jit. If > that can be removed I think a lot of code in Codegen could be cleaned up. > > > Things that don't work: > > 1. Lazy compilation. > > > > I need to clean up the code, which is being done as I submit patches. If you >are > > > curious to see the code I am cleaning up it is located here: > > http://gitorious.org/llvm-junkjit > > > > - Jan > > Cheers, > Rafael > From dimitry at andric.com Thu Mar 3 09:15:21 2011 From: dimitry at andric.com (Dimitry Andric) Date: Thu, 03 Mar 2011 16:15:21 +0100 Subject: [llvm-commits] [patch] Fix some tests when --disable-threads is used Message-ID: <4D6FB089.3030202@andric.com> If you configure llvm with --disable-threads, the following tests will always fail: LLVM-Unit :: VMCore/Release+Asserts/VMCoreTests/ValueMapTest/0.LocksMutex LLVM-Unit :: VMCore/Release+Asserts/VMCoreTests/ValueMapTest/1.LocksMutex LLVM-Unit :: VMCore/Release+Asserts/VMCoreTests/ValueMapTest/2.LocksMutex This is because the tests attempt to acquire a mutex, and expect it to fail, but all mutex functions simply return true when --disable-threads is used. Fix this by adding some #if guards around the tests. While here, change "#if ENABLE_THREADS" to "#if defined(ENABLE_THREADS) || ENABLE_THREADS == 1", which works better when ENABLE_THREADS is not defined at all. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: fix-valuemaptest-disable-threads.diff Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110303/6ac2618a/attachment.pl From baldrick at free.fr Thu Mar 3 09:19:08 2011 From: baldrick at free.fr (Duncan Sands) Date: Thu, 03 Mar 2011 16:19:08 +0100 Subject: [llvm-commits] [patch] Fix some tests when --disable-threads is used In-Reply-To: <4D6FB089.3030202@andric.com> References: <4D6FB089.3030202@andric.com> Message-ID: <4D6FB16C.2000701@free.fr> Hi Dimitry, > If you configure llvm with --disable-threads, the following tests will > always fail: > > LLVM-Unit :: VMCore/Release+Asserts/VMCoreTests/ValueMapTest/0.LocksMutex > LLVM-Unit :: VMCore/Release+Asserts/VMCoreTests/ValueMapTest/1.LocksMutex > LLVM-Unit :: VMCore/Release+Asserts/VMCoreTests/ValueMapTest/2.LocksMutex > > This is because the tests attempt to acquire a mutex, and expect it to > fail, but all mutex functions simply return true when --disable-threads > is used. why not change the mutexes to return false, i.e. success? Ciao, Duncan. From ajclinto at gmail.com Thu Mar 3 10:10:39 2011 From: ajclinto at gmail.com (Andrew Clinton) Date: Thu, 3 Mar 2011 11:10:39 -0500 Subject: [llvm-commits] Patch to improve loop-simplify In-Reply-To: References: Message-ID: I'm not sure why the code generator is synthesizing an additional unconditional branch. The IR is certainly simpler with this patch. -------------------------------- With patch: > opt -O3 not-nested-loop.ll -S ; ModuleID = 'not-nested-loop.ll' define i32 @_Z4testv() { ;