From clattner at apple.com Mon Jan 11 00:33:53 2010 From: clattner at apple.com (Chris Lattner) Date: Sun, 10 Jan 2010 22:33:53 -0800 Subject: [llvm-commits] patch: teach deadargelim to work on externally visible functions! In-Reply-To: <38a0d8451001102059h7c463c82k35ef5aa62252e4bf@mail.gmail.com> References: <4B414C2D.90407@mxc.ca> <4B41E903.10803@free.fr> <4B41EA8C.3040302@gmail.com> <473850DE-AA5B-4CDC-89DE-3147ED5B4389@apple.com> <4B431B40.70000@gmail.com> <38a0d8451001101956w456eb09cjac5592767f1dce1@mail.gmail.com> <0539D449-D814-43AD-96F1-52D098F887E3@apple.com> <15330807-C640-4724-B433-C151CA4EF28A@apple.com> <38a0d8451001102038x6c86e9f9p57a1bef13d5f601f@mail.gmail.com> <38a0d8451001102059h7c463c82k35ef5aa62252e4bf@mail.gmail.com> Message-ID: <9CB6D70E-01C5-47F5-A653-AF124335F800@apple.com> On Jan 10, 2010, at 8:59 PM, Rafael Espindola wrote: >> Correct . It is a very expensive feature :-( > > Thinking a bit about it. Probably the best way to fix this is > > *) Generate that linkage on ELF if the visibility is not hidden or protected > *) Add the "strong but overridable" linkage you proposed. Sounds good. How is it different than our current "weak" linkage? > *) Consider making protected-and-dont-care-about-pointer-compare the > default. That would improve out of the box performance of ELF DSOs (as > compared to gcc) and the user could always use > __attribute__((visibility ("default"))) or -fvisibility=default. Yep, we could even add an attribute for this, so you could mark malloc as overiddable or whatever. > *) As an extension, add a > protected-and-dont-care-about-pointer-compare that would be similar to > the current state but drop the @PLT This is something that would be a useful extension in any case. Right now we may miscompile this code in some cases: static const char x[] = "foo"; static const char y[] = "foo"; int test() { return x == y; } Because we (incorrectly) merge the x and y decls. We don't want to merge user variables if they have their "address taken", but we do want to merge things like C string literals (char *X = "foo"). If we had an attribute "don't care about pointer equality" we could handle this correctly. > How does this work on Darwin btw? Function pointers are not guaranteed > to compare when crossing shared library boundaries? On darwin you're not allowed to redefined something in a different dylib unless it is attribute(weak). Darwin uses a "two level namespace". This causes the static linker to resolve and remember which dylib a "use" comes from. If a third dylib starts defining that symbol, the use will still get the correct definition from the original defining dylib. This also makes dynamic symbol resolution more efficient at process start time. -Chris From sabre at nondot.org Mon Jan 11 00:55:24 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 11 Jan 2010 06:55:24 -0000 Subject: [llvm-commits] [llvm] r93147 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp test/Transforms/InstCombine/or.ll Message-ID: <201001110655.o0B6tOJq028437@zion.cs.uiuc.edu> Author: lattner Date: Mon Jan 11 00:55:24 2010 New Revision: 93147 URL: http://llvm.org/viewvc/llvm-project?rev=93147&view=rev Log: add one more bitfield optimization, allowing clang to generate good code on PR4216: _test_bitfield: ## @test_bitfield orl $32962, %edi movl $4294941946, %eax andq %rdi, %rax ret instead of: _test_bitfield: movl $4294941696, %ecx movl %edi, %eax orl $194, %edi orl $32768, %eax andq $250, %rdi andq %rax, %rcx movq %rdi, %rax orq %rcx, %rax ret Evan is looking into the remaining andq+imm -> andl optimization. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp llvm/trunk/test/Transforms/InstCombine/or.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=93147&r1=93146&r2=93147&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Mon Jan 11 00:55:24 2010 @@ -1544,9 +1544,9 @@ } } - // ((V | N) & C1) | (V & C2) --> (V|N) & (C1|C2) - // iff (C1&C2) == 0 and (N&~C1) == 0 if ((C1->getValue() & C2->getValue()) == 0) { + // ((V | N) & C1) | (V & C2) --> (V|N) & (C1|C2) + // iff (C1&C2) == 0 and (N&~C1) == 0 if (match(A, m_Or(m_Value(V1), m_Value(V2))) && ((V1 == B && MaskedValueIsZero(V2, ~C1->getValue())) || // (V|N) (V2 == B && MaskedValueIsZero(V1, ~C1->getValue())))) // (N|V) @@ -1560,6 +1560,19 @@ return BinaryOperator::CreateAnd(B, ConstantInt::get(B->getContext(), C1->getValue()|C2->getValue())); + + // ((V|C3)&C1) | ((V|C4)&C2) --> (V|C3|C4)&(C1|C2) + // iff (C1&C2) == 0 and (C3&~C1) == 0 and (C4&~C2) == 0. + ConstantInt *C3 = 0, *C4 = 0; + if (match(A, m_Or(m_Value(V1), m_ConstantInt(C3))) && + (C3->getValue() & ~C1->getValue()) == 0 && + match(B, m_Or(m_Specific(V1), m_ConstantInt(C4))) && + (C4->getValue() & ~C2->getValue()) == 0) { + V2 = Builder->CreateOr(V1, ConstantExpr::getOr(C3, C4), "bitfield"); + return BinaryOperator::CreateAnd(V2, + ConstantInt::get(B->getContext(), + C1->getValue()|C2->getValue())); + } } } Modified: llvm/trunk/test/Transforms/InstCombine/or.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/or.ll?rev=93147&r1=93146&r2=93147&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/or.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/or.ll Mon Jan 11 00:55:24 2010 @@ -320,3 +320,19 @@ ; CHECK: %E = and i32 %B, -25350 ; CHECK: ret i32 %E } + +; PR4216 +define i64 @test31(i64 %A) nounwind readnone ssp noredzone { + %B = or i64 %A, 194 + %D = and i64 %B, 250 + + %C = or i64 %A, 32768 + %E = and i64 %C, 4294941696 + + %F = or i64 %D, %E + ret i64 %F +; CHECK: @test31 +; CHECK-NEXT: %bitfield = or i64 %A, 32962 +; CHECK-NEXT: %F = and i64 %bitfield, 4294941946 +; CHECK-NEXT: ret i64 %F +} From vhernandez at apple.com Mon Jan 11 01:45:19 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Mon, 11 Jan 2010 07:45:19 -0000 Subject: [llvm-commits] [llvm] r93149 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h lib/Analysis/DebugInfo.cpp lib/VMCore/IntrinsicInst.cpp Message-ID: <201001110745.o0B7jJl8030108@zion.cs.uiuc.edu> Author: hernande Date: Mon Jan 11 01:45:19 2010 New Revision: 93149 URL: http://llvm.org/viewvc/llvm-project?rev=93149&view=rev Log: Respond to Chris' review: Make InsertDbgValueIntrinsic() and get Offset take and recieve a uint64_t. Get constness correct for getVariable() and getValue(). Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/include/llvm/IntrinsicInst.h llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/VMCore/IntrinsicInst.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=93149&r1=93148&r2=93149&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Mon Jan 11 01:45:19 2010 @@ -647,11 +647,11 @@ Instruction *InsertBefore); /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. - Instruction *InsertDbgValueIntrinsic(llvm::Value *V, llvm::Value *Offset, + 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, llvm::Value *Offset, + Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset, DIVariable D, Instruction *InsertBefore); private: Constant *GetTagConstant(unsigned TAG); Modified: llvm/trunk/include/llvm/IntrinsicInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=93149&r1=93148&r2=93149&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicInst.h (original) +++ llvm/trunk/include/llvm/IntrinsicInst.h Mon Jan 11 01:45:19 2010 @@ -99,9 +99,14 @@ /// class DbgValueInst : public DbgInfoIntrinsic { public: - Value *getValue() const; - Value *getOffset() const { return getOperand(2); } - MDNode *getVariable() const { return cast(getOperand(3)); } + const Value *getValue() const; + Value *getValue(); + uint64_t getOffset() const { + return cast( + const_cast(getOperand(2)))->getZExtValue(); + } + const MDNode *getVariable() const { return cast(getOperand(3)); } + MDNode *getVariable() { return cast(getOperand(3)); } // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const DbgValueInst *) { return true; } Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=93149&r1=93148&r2=93149&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Mon Jan 11 01:45:19 2010 @@ -1033,7 +1033,7 @@ /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, - Instruction *InsertBefore) { + Instruction *InsertBefore) { // Cast the storage to a {}* for the call to llvm.dbg.declare. Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertBefore); @@ -1046,7 +1046,7 @@ /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, - BasicBlock *InsertAtEnd) { + BasicBlock *InsertAtEnd) { // Cast the storage to a {}* for the call to llvm.dbg.declare. Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertAtEnd); @@ -1058,31 +1058,31 @@ } /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. -Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, Value *Offset, +Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, uint64_t Offset, DIVariable D, Instruction *InsertBefore) { assert(V && "no value passed to dbg.value"); - assert(Offset->getType()->isInteger(64) && "offset must be i64"); if (!ValueFn) ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value); Value *Elts[] = { V }; - Value *Args[] = { MDNode::get(V->getContext(), Elts, 1), Offset, + Value *Args[] = { MDNode::get(V->getContext(), Elts, 1), + ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset), D.getNode() }; return CallInst::Create(ValueFn, Args, Args+3, "", InsertBefore); } /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. -Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, Value *Offset, +Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, uint64_t Offset, DIVariable D, BasicBlock *InsertAtEnd) { assert(V && "no value passed to dbg.value"); - assert(Offset->getType()->isInteger(64) && "offset must be i64"); if (!ValueFn) ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value); Value *Elts[] = { V }; - Value *Args[] = { MDNode::get(V->getContext(), Elts, 1), Offset, + Value *Args[] = { MDNode::get(V->getContext(), Elts, 1), + ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset), D.getNode() }; return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd); } Modified: llvm/trunk/lib/VMCore/IntrinsicInst.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/IntrinsicInst.cpp?rev=93149&r1=93148&r2=93149&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/IntrinsicInst.cpp (original) +++ llvm/trunk/lib/VMCore/IntrinsicInst.cpp Mon Jan 11 01:45:19 2010 @@ -54,6 +54,10 @@ /// DbgValueInst - This represents the llvm.dbg.value instruction. /// -Value *DbgValueInst::getValue() const { +const Value *DbgValueInst::getValue() const { + return cast(getOperand(1))->getOperand(0); +} + +Value *DbgValueInst::getValue() { return cast(getOperand(1))->getOperand(0); } From edwintorok at gmail.com Mon Jan 11 09:41:47 2010 From: edwintorok at gmail.com (=?UTF-8?B?VMO2csO2ayBFZHdpbg==?=) Date: Mon, 11 Jan 2010 17:41:47 +0200 Subject: [llvm-commits] patch: teach deadargelim to work on externally visible functions! In-Reply-To: <38a0d8451001101958t64f6f544ua1c737f671419e79@mail.gmail.com> References: <4B414C2D.90407@mxc.ca> <4B41D1C5.9030805@gmail.com> <4B41E235.5050309@free.fr> <4B41E6A0.2050600@gmail.com> <4B41E903.10803@free.fr> <4B41EA8C.3040302@gmail.com> <473850DE-AA5B-4CDC-89DE-3147ED5B4389@apple.com> <4B431B40.70000@gmail.com> <38a0d8451001101958t64f6f544ua1c737f671419e79@mail.gmail.com> Message-ID: <4B4B46BB.1040807@gmail.com> On 01/11/2010 05:58 AM, Rafael Espindola wrote: >> - from an ELF symbol visibility point of view this would mean the >> symbols should get protected visibility, instead of default visibility >> > > Remember that protected visibility is actually more expensive because > of the need to maintain pointer equality. You probably want to use > hidden or default only unless told to do otherwise by the user. > Right, we shouldn't change the ELF visibility, however we could avoid emitting the @PLT for in-module calls (Dan says in another mail that it wouldn't affect function pointer compares). Best regards, --Edwin From greened at obbligato.org Mon Jan 11 10:29:42 2010 From: greened at obbligato.org (David Greene) Date: Mon, 11 Jan 2010 16:29:42 -0000 Subject: [llvm-commits] [llvm] r93151 - in /llvm/trunk: lib/Target/X86/X86.td lib/Target/X86/X86InstrSSE.td lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Subtarget.h test/CodeGen/X86/2010-01-07-UAMemFeature.ll Message-ID: <201001111629.o0BGThMZ000765@zion.cs.uiuc.edu> Author: greened Date: Mon Jan 11 10:29:42 2010 New Revision: 93151 URL: http://llvm.org/viewvc/llvm-project?rev=93151&view=rev Log: Implement a feature (-vector-unaligned-mem) to allow targets to ignore alignment requirements for SIMD memory operands. This is useful on architectures like the AMD 10h that do not trap on unaligned references if a status bit is twiddled at startup time. Added: llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll Modified: llvm/trunk/lib/Target/X86/X86.td llvm/trunk/lib/Target/X86/X86InstrSSE.td llvm/trunk/lib/Target/X86/X86Subtarget.cpp llvm/trunk/lib/Target/X86/X86Subtarget.h Modified: llvm/trunk/lib/Target/X86/X86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86.td?rev=93151&r1=93150&r2=93151&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86.td (original) +++ llvm/trunk/lib/Target/X86/X86.td Mon Jan 11 10:29:42 2010 @@ -23,6 +23,7 @@ def FeatureCMOV : SubtargetFeature<"cmov","HasCMov", "true", "Enable conditional move instructions">; + def FeatureMMX : SubtargetFeature<"mmx","X86SSELevel", "MMX", "Enable MMX instructions">; def FeatureSSE1 : SubtargetFeature<"sse", "X86SSELevel", "SSE1", @@ -66,6 +67,9 @@ "Enable three-operand fused multiple-add">; def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true", "Enable four-operand fused multiple-add">; +def FeatureVectorUAMem : SubtargetFeature<"vector-unaligned-mem", + "HasVectorUAMem", "true", + "Allow unaligned memory operands on vector/SIMD instructions">; //===----------------------------------------------------------------------===// // X86 processors supported. Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=93151&r1=93150&r2=93151&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Jan 11 10:29:42 2010 @@ -131,11 +131,13 @@ // Like 'load', but uses special alignment checks suitable for use in // memory operands in most SSE instructions, which are required to -// be naturally aligned on some targets but not on others. -// FIXME: Actually implement support for targets that don't require the -// alignment. This probably wants a subtarget predicate. +// be naturally aligned on some targets but not on others. If the subtarget +// allows unaligned accesses, match any load, though this may require +// setting a feature bit in the processor (on startup, for example). +// Opteron 10h and later implement such a feature. def memop : PatFrag<(ops node:$ptr), (load node:$ptr), [{ - return cast(N)->getAlignment() >= 16; + return Subtarget->hasVectorUAMem() + || cast(N)->getAlignment() >= 16; }]>; def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>; Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=93151&r1=93150&r2=93151&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Mon Jan 11 10:29:42 2010 @@ -286,6 +286,7 @@ , HasFMA3(false) , HasFMA4(false) , IsBTMemSlow(false) + , HasVectorUAMem(false) , DarwinVers(0) , stackAlignment(8) // FIXME: this is a known good value for Yonah. How about others? Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=93151&r1=93150&r2=93151&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Mon Jan 11 10:29:42 2010 @@ -78,6 +78,10 @@ /// IsBTMemSlow - True if BT (bit test) of memory instructions are slow. bool IsBTMemSlow; + /// HasVectorUAMem - True if SIMD operations can have unaligned memory operands. + /// This may require setting a feature bit in the processor. + bool HasVectorUAMem; + /// DarwinVers - Nonzero if this is a darwin platform: the numeric /// version of the platform, e.g. 8 = 10.4 (Tiger), 9 = 10.5 (Leopard), etc. unsigned char DarwinVers; // Is any darwin-x86 platform. @@ -142,6 +146,7 @@ bool hasFMA3() const { return HasFMA3; } bool hasFMA4() const { return HasFMA4; } bool isBTMemSlow() const { return IsBTMemSlow; } + bool hasVectorUAMem() const { return HasVectorUAMem; } bool isTargetDarwin() const { return TargetType == isDarwin; } bool isTargetELF() const { return TargetType == isELF; } Added: llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll?rev=93151&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll (added) +++ llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll Mon Jan 11 10:29:42 2010 @@ -0,0 +1,402 @@ +; RUN: llc -mattr=vector-unaligned-mem < %s | FileCheck %s +; CHECK: addps{{[ \t]+}}( + +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 i32 @foo(i32 %n1, float* %A2, float* %B3, float* %C4) { +"file loop.c, line 1, bb1": ; srcLine 1 + %n = alloca i32, align 4 ; [#uses=2] ; [oox.12 : sln.1] + %A = alloca float*, align 8 ; [#uses=2] ; [oox.13 : sln.1] + %B = alloca float*, align 8 ; [#uses=2] ; [oox.14 : sln.1] + %C = alloca float*, align 8 ; [#uses=2] ; [oox.15 : sln.1] + %i = alloca i32, align 4 ; [#uses=0] ; [oox.24 : sln.1] + %"$CSVL_V0" = alloca i64, align 8 ; [#uses=2] ; [oox.38 : sln.1] + %"$TC_1" = alloca i64, align 8 ; [#uses=3] ; [oox.43 : sln.1] + %"$LIS_S5" = alloca i64, align 8 ; [#uses=2] ; [oox.54 : sln.1] + %"$LIS_S7" = alloca i64, align 8 ; [#uses=2] ; [oox.56 : sln.1] + %"$LIS_S8" = alloca i64, align 8 ; [#uses=2] ; [oox.57 : sln.1] + %"$LIS_S9" = alloca i64, align 8 ; [#uses=2] ; [oox.58 : sln.1] + %"$LIS_S15" = alloca i64, align 8 ; [#uses=3] ; [oox.64 : sln.1] + %"$LIS_S17" = alloca i64, align 8 ; [#uses=3] ; [oox.66 : sln.1] + %"$LIS_S18" = alloca i64, align 8 ; [#uses=3] ; [oox.67 : sln.1] + %"$LIS_S19" = alloca i64, align 8 ; [#uses=2] ; [oox.68 : sln.1] + %"$LIS_S20" = alloca i64, align 8 ; [#uses=2] ; [oox.69 : sln.1] + %"$LIS_S21" = alloca i64, align 8 ; [#uses=2] ; [oox.70 : sln.1] + %"$MR_n_0" = alloca i32, align 4 ; [#uses=7] ; [oox.72 : sln.1] + %"$MR_C_1" = alloca float*, align 8 ; [#uses=5] ; [oox.73 : sln.1] + %"$MR_A_2" = alloca float*, align 8 ; [#uses=6] ; [oox.74 : sln.1] + %"$MR_B_3" = alloca float*, align 8 ; [#uses=5] ; [oox.75 : sln.1] + %"$LCS_0" = alloca i64, align 8 ; [#uses=6] ; [oox.82 : sln.1] + %"$LCS_1" = alloca i64, align 8 ; [#uses=5] ; [oox.83 : sln.1] + %"$LCS_2" = alloca i64, align 8 ; [#uses=3] ; [oox.84 : sln.1] + %"$LCS_1_3" = alloca i64, align 8 ; [#uses=3] ; [oox.85 : sln.1] + %"$LCS_4" = alloca i64, align 8 ; [#uses=5] ; [oox.86 : sln.1] + %"$LCS_5" = alloca i64, align 8 ; [#uses=5] ; [oox.87 : sln.1] + %"$LCS_6" = alloca i64, align 8 ; [#uses=5] ; [oox.88 : sln.1] + %"$LCS_n_7" = alloca i64, align 8 ; [#uses=3] ; [oox.89 : sln.1] + %"$i_S23" = alloca i64, align 8 ; [#uses=15] ; [oox.90 : sln.1] + %"$LC_S24" = alloca i64, align 8 ; [#uses=9] ; [oox.91 : sln.1] + %"$SI_S25" = alloca i64, align 8 ; [#uses=11] ; [oox.92 : sln.1] + store i32 %n1, i32* %n, align 4 ; [oox.12 : sln.1] + store float* %A2, float** %A, align 8 ; [oox.13 : sln.1] + store float* %B3, float** %B, align 8 ; [oox.14 : sln.1] + store float* %C4, float** %C, align 8 ; [oox.15 : sln.1] + br label %"file loop.c, line 1, bb69" ; [oox.0 : sln.0] + +"file loop.c, line 1, bb69": ; srcLine 1 ; preds = %"file loop.c, line 1, bb1" + %r = load i32* %n, align 4 ; [#uses=1] ; [oox.190 : sln.5] + store i32 %r, i32* %"$MR_n_0", align 4 ; [oox.190 : sln.5] + %r5 = load i32* %"$MR_n_0", align 4 ; [#uses=1] ; [oox.191 : sln.5] + %r6 = icmp sge i32 0, %r5 ; [#uses=1] ; [oox.191 : sln.5] + %r7 = zext i1 %r6 to i32 ; [#uses=1] ; [oox.191 : sln.5] + %r8 = icmp ne i32 %r7, 0 ; [#uses=1] ; [oox.191 : sln.5] + br i1 %r8, label %"file loop.c, line 5, bb6", label %"file loop.c, line 1, bb3" ; [oox.191 : sln.5] + +"file loop.c, line 1, bb3": ; srcLine 1 ; preds = %"file loop.c, line 1, bb69" + br label %"file loop.c, line 5, bb28" ; [oox.0 : sln.0] + +"file loop.c, line 5, bb28": ; srcLine 5 ; preds = %"file loop.c, line 1, bb3" + store i64 0, i64* %"$i_S23", align 8 ; [oox.189 : sln.5] + %r9 = load float** %C, align 8 ; [#uses=1] ; [oox.190 : sln.5] + store float* %r9, float** %"$MR_C_1", align 8 ; [oox.190 : sln.5] + %r10 = load float** %A, align 8 ; [#uses=1] ; [oox.191 : sln.5] + store float* %r10, float** %"$MR_A_2", align 8 ; [oox.191 : sln.5] + %r11 = load float** %B, align 8 ; [#uses=1] ; [oox.192 : sln.5] + store float* %r11, float** %"$MR_B_3", align 8 ; [oox.192 : sln.5] + %r12 = load float** %"$MR_A_2", align 8 ; [#uses=1] ; [oox.193 : sln.5] + %r13 = load float** %"$MR_C_1", align 8 ; [#uses=1] ; [oox.193 : sln.5] + %r14 = ptrtoint float* %r12 to i64 ; [#uses=1] ; [oox.193 : sln.5] + %r15 = ptrtoint float* %r13 to i64 ; [#uses=1] ; [oox.193 : sln.5] + %r16 = sub i64 %r14, %r15 ; [#uses=1] ; [oox.193 : sln.5] + %r17 = sdiv i64 %r16, 4 ; [#uses=1] ; [oox.193 : sln.5] + store i64 %r17, i64* %"$LCS_0", align 8 ; [oox.193 : sln.5] + %r18 = load float** %"$MR_A_2", align 8 ; [#uses=1] ; [oox.194 : sln.5] + %r19 = load float** %"$MR_B_3", align 8 ; [#uses=1] ; [oox.194 : sln.5] + %r20 = ptrtoint float* %r18 to i64 ; [#uses=1] ; [oox.194 : sln.5] + %r21 = ptrtoint float* %r19 to i64 ; [#uses=1] ; [oox.194 : sln.5] + %r22 = sub i64 %r20, %r21 ; [#uses=1] ; [oox.194 : sln.5] + %r23 = sdiv i64 %r22, 4 ; [#uses=1] ; [oox.194 : sln.5] + store i64 %r23, i64* %"$LCS_1", align 8 ; [oox.194 : sln.5] + %r24 = load i32* %"$MR_n_0", align 4 ; [#uses=1] ; [oox.195 : sln.5] + %r25 = sext i32 %r24 to i64 ; [#uses=1] ; [oox.195 : sln.5] + %r26 = add i64 -1, %r25 ; [#uses=1] ; [oox.195 : sln.5] + store i64 %r26, i64* %"$LCS_1_3", align 8 ; [oox.195 : sln.5] + %r27 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.196 : sln.5] + %r28 = icmp sgt i64 %r27, 0 ; [#uses=1] ; [oox.196 : sln.5] + %r29 = zext i1 %r28 to i64 ; [#uses=1] ; [oox.196 : sln.5] + %r30 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.196 : sln.5] + %r31 = load i64* %"$LCS_1_3", align 8 ; [#uses=1] ; [oox.196 : sln.5] + %r32 = icmp sle i64 %r30, %r31 ; [#uses=1] ; [oox.196 : sln.5] + %r33 = zext i1 %r32 to i32 ; [#uses=1] ; [oox.196 : sln.5] + %r34 = sext i32 %r33 to i64 ; [#uses=1] ; [oox.196 : sln.5] + %r35 = and i64 %r29, %r34 ; [#uses=1] ; [oox.196 : sln.5] + %r36 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.196 : sln.5] + %r37 = icmp sle i64 %r36, 4 ; [#uses=1] ; [oox.196 : sln.5] + %r38 = zext i1 %r37 to i32 ; [#uses=1] ; [oox.196 : sln.5] + %r39 = sext i32 %r38 to i64 ; [#uses=1] ; [oox.196 : sln.5] + %r40 = and i64 %r35, %r39 ; [#uses=1] ; [oox.196 : sln.5] + store i64 %r40, i64* %"$LCS_2", align 8 ; [oox.196 : sln.5] + %r41 = load i64* %"$LCS_1", align 8 ; [#uses=1] ; [oox.197 : sln.5] + %r42 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.197 : sln.5] + %r43 = load i64* %"$LCS_2", align 8 ; [#uses=1] ; [oox.197 : sln.5] + %r44 = icmp ne i64 %r43, 0 ; [#uses=1] ; [oox.197 : sln.5] + %r45 = select i1 %r44, i64 %r42, i64 4 ; [#uses=1] ; [oox.197 : sln.5] + %r46 = load i64* %"$LCS_1", align 8 ; [#uses=1] ; [oox.197 : sln.5] + %r47 = icmp sgt i64 %r46, 0 ; [#uses=1] ; [oox.197 : sln.5] + %r48 = zext i1 %r47 to i64 ; [#uses=1] ; [oox.197 : sln.5] + %r49 = load i64* %"$LCS_1", align 8 ; [#uses=1] ; [oox.197 : sln.5] + %r50 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.197 : sln.5] + %r51 = load i64* %"$LCS_2", align 8 ; [#uses=1] ; [oox.197 : sln.5] + %r52 = icmp ne i64 %r51, 0 ; [#uses=1] ; [oox.197 : sln.5] + %r53 = select i1 %r52, i64 %r50, i64 4 ; [#uses=1] ; [oox.197 : sln.5] + %r54 = icmp sle i64 %r49, %r53 ; [#uses=1] ; [oox.197 : sln.5] + %r55 = zext i1 %r54 to i32 ; [#uses=1] ; [oox.197 : sln.5] + %r56 = load i64* %"$LCS_1", align 8 ; [#uses=1] ; [oox.197 : sln.5] + %r57 = load i64* %"$LCS_1_3", align 8 ; [#uses=1] ; [oox.197 : sln.5] + %r58 = icmp sle i64 %r56, %r57 ; [#uses=1] ; [oox.197 : sln.5] + %r59 = zext i1 %r58 to i32 ; [#uses=1] ; [oox.197 : sln.5] + %r60 = and i32 %r55, %r59 ; [#uses=1] ; [oox.197 : sln.5] + %r61 = sext i32 %r60 to i64 ; [#uses=1] ; [oox.197 : sln.5] + %r62 = and i64 %r48, %r61 ; [#uses=1] ; [oox.197 : sln.5] + %r63 = icmp ne i64 %r62, 0 ; [#uses=1] ; [oox.197 : sln.5] + %r64 = select i1 %r63, i64 %r41, i64 %r45 ; [#uses=1] ; [oox.197 : sln.5] + store i64 %r64, i64* %"$CSVL_V0", align 8 ; [oox.197 : sln.5] + %r65 = load i64* %"$CSVL_V0", align 8 ; [#uses=1] ; [oox.198 : sln.5] + %r66 = icmp sgt i64 %r65, 4 ; [#uses=1] ; [oox.198 : sln.5] + %r67 = zext i1 %r66 to i32 ; [#uses=1] ; [oox.198 : sln.5] + %r68 = icmp ne i32 %r67, 0 ; [#uses=1] ; [oox.198 : sln.5] + br i1 %r68, label %"file loop.c, line 1, bb26", label %"file loop.c, line 1, bb27" ; [oox.198 : sln.5] + +"file loop.c, line 1, bb27": ; srcLine 1 ; preds = %"file loop.c, line 5, bb28" + br label %"file loop.c, line 5, bb55" ; [oox.0 : sln.0] + +"file loop.c, line 5, bb55": ; srcLine 5 ; preds = %"file loop.c, line 1, bb27" + %r69 = load i32* %"$MR_n_0", align 4 ; [#uses=1] ; [oox.189 : sln.5] + %r70 = sext i32 %r69 to i64 ; [#uses=1] ; [oox.189 : sln.5] + store i64 %r70, i64* %"$LIS_S9", align 8 ; [oox.189 : sln.5] + %r71 = load float** %"$MR_B_3", align 8 ; [#uses=1] ; [oox.190 : sln.6] + %r72 = ptrtoint float* %r71 to i64 ; [#uses=1] ; [oox.190 : sln.6] + store i64 %r72, i64* %"$LIS_S5", align 8 ; [oox.190 : sln.6] + %r73 = load float** %"$MR_C_1", align 8 ; [#uses=1] ; [oox.191 : sln.6] + %r74 = ptrtoint float* %r73 to i64 ; [#uses=1] ; [oox.191 : sln.6] + store i64 %r74, i64* %"$LIS_S7", align 8 ; [oox.191 : sln.6] + %r75 = load float** %"$MR_A_2", align 8 ; [#uses=1] ; [oox.192 : sln.6] + %r76 = ptrtoint float* %r75 to i64 ; [#uses=1] ; [oox.192 : sln.6] + store i64 %r76, i64* %"$LIS_S8", align 8 ; [oox.192 : sln.6] + br label %"file loop.c, line 1, in inner loop at depth 0, bb29" ; [oox.0 : sln.0] + +"file loop.c, line 1, in inner loop at depth 0, bb29": ; srcLine 1 ; preds = %"file loop.c, line 5, in inner loop at depth 0, bb32", %"file loop.c, line 5, bb55" + br label %"file loop.c, line 5, in inner loop at depth 0, bb32" ; [oox.0 : sln.0] + +"file loop.c, line 5, in inner loop at depth 0, bb32": ; srcLine 5 ; preds = %"file loop.c, line 1, in inner loop at depth 0, bb29" + %r77 = load i64* %"$LIS_S7", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r78 = inttoptr i64 %r77 to float* ; [#uses=1] ; [oox.189 : sln.6] + %r79 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r80 = getelementptr float* %r78, i64 %r79 ; [#uses=1] ; [oox.189 : sln.6] + %r81 = load float* %r80, align 4 ; [#uses=1] ; [oox.189 : sln.6] + %r82 = load i64* %"$LIS_S5", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r83 = inttoptr i64 %r82 to float* ; [#uses=1] ; [oox.189 : sln.6] + %r84 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r85 = getelementptr float* %r83, i64 %r84 ; [#uses=1] ; [oox.189 : sln.6] + %r86 = load float* %r85, align 4 ; [#uses=1] ; [oox.189 : sln.6] + %r87 = add float %r81, %r86 ; [#uses=1] ; [oox.189 : sln.6] + %r88 = load i64* %"$LIS_S8", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r89 = inttoptr i64 %r88 to float* ; [#uses=1] ; [oox.189 : sln.6] + %r90 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r91 = getelementptr float* %r89, i64 %r90 ; [#uses=1] ; [oox.189 : sln.6] + store float %r87, float* %r91, align 4 ; [oox.189 : sln.6] + %r92 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.190 : sln.5] + %r93 = add i64 1, %r92 ; [#uses=1] ; [oox.190 : sln.5] + store i64 %r93, i64* %"$i_S23", align 8 ; [oox.190 : sln.5] + %r94 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.191 : sln.5] + %r95 = load i64* %"$LIS_S9", align 8 ; [#uses=1] ; [oox.191 : sln.5] + %r96 = icmp slt i64 %r94, %r95 ; [#uses=1] ; [oox.191 : sln.5] + %r97 = zext i1 %r96 to i64 ; [#uses=1] ; [oox.191 : sln.5] + %r98 = icmp ne i64 %r97, 0 ; [#uses=1] ; [oox.191 : sln.5] + br i1 %r98, label %"file loop.c, line 1, in inner loop at depth 0, bb29", label %"file loop.c, line 5, bb6" ; [oox.191 : sln.5] + +"file loop.c, line 1, bb26": ; srcLine 1 ; preds = %"file loop.c, line 5, bb28" + br label %"file loop.c, line 5, bb48" ; [oox.0 : sln.0] + +"file loop.c, line 5, bb48": ; srcLine 5 ; preds = %"file loop.c, line 1, bb26" + %r99 = load i32* %"$MR_n_0", align 4 ; [#uses=1] ; [oox.189 : sln.5] + %r100 = sext i32 %r99 to i64 ; [#uses=1] ; [oox.189 : sln.5] + %r101 = icmp slt i64 %r100, 4 ; [#uses=1] ; [oox.189 : sln.5] + %r102 = zext i1 %r101 to i32 ; [#uses=1] ; [oox.189 : sln.5] + %r103 = icmp ne i32 %r102, 0 ; [#uses=1] ; [oox.189 : sln.5] + br i1 %r103, label %"file loop.c, line 5, bb50", label %"file loop.c, line 1, bb47" ; [oox.189 : sln.5] + +"file loop.c, line 1, bb47": ; srcLine 1 ; preds = %"file loop.c, line 5, bb48" + br label %"file loop.c, line 5, bb60" ; [oox.0 : sln.0] + +"file loop.c, line 5, bb60": ; srcLine 5 ; preds = %"file loop.c, line 1, bb47" + %r104 = load i32* %"$MR_n_0", align 4 ; [#uses=1] ; [oox.189 : sln.5] + %r105 = sext i32 %r104 to i64 ; [#uses=1] ; [oox.189 : sln.5] + %r106 = and i64 -4, %r105 ; [#uses=1] ; [oox.189 : sln.5] + store i64 %r106, i64* %"$TC_1", align 8 ; [oox.189 : sln.5] + %r107 = load i64* %"$TC_1", align 8 ; [#uses=1] ; [oox.190 : sln.5] + %r108 = sub i64 0, %r107 ; [#uses=1] ; [oox.190 : sln.5] + store i64 %r108, i64* %"$LC_S24", align 8 ; [oox.190 : sln.5] + store i64 0, i64* %"$SI_S25", align 8 ; [oox.191 : sln.5] + %r109 = load float** %"$MR_C_1", align 8 ; [#uses=1] ; [oox.192 : sln.6] + %r110 = ptrtoint float* %r109 to i64 ; [#uses=1] ; [oox.192 : sln.6] + store i64 %r110, i64* %"$LIS_S15", align 8 ; [oox.192 : sln.6] + %r111 = load float** %"$MR_B_3", align 8 ; [#uses=1] ; [oox.193 : sln.6] + %r112 = ptrtoint float* %r111 to i64 ; [#uses=1] ; [oox.193 : sln.6] + store i64 %r112, i64* %"$LIS_S17", align 8 ; [oox.193 : sln.6] + %r113 = load float** %"$MR_A_2", align 8 ; [#uses=1] ; [oox.194 : sln.6] + %r114 = ptrtoint float* %r113 to i64 ; [#uses=1] ; [oox.194 : sln.6] + store i64 %r114, i64* %"$LIS_S18", align 8 ; [oox.194 : sln.6] + %r115 = load i64* %"$LC_S24", align 8 ; [#uses=1] ; [oox.195 : sln.5] + %r116 = icmp sge i64 %r115, -15 ; [#uses=1] ; [oox.195 : sln.5] + %r117 = zext i1 %r116 to i32 ; [#uses=1] ; [oox.195 : sln.5] + %r118 = icmp ne i32 %r117, 0 ; [#uses=1] ; [oox.195 : sln.5] + br i1 %r118, label %"file loop.c, line 5, bb64", label %"file loop.c, line 1, bb61" ; [oox.195 : sln.5] + +"file loop.c, line 1, bb61": ; srcLine 1 ; preds = %"file loop.c, line 5, bb60" + br label %"file loop.c, line 1, in inner vector loop at depth 0, bb58" ; [oox.0 : sln.0] + +"file loop.c, line 1, in inner vector loop at depth 0, bb58": ; srcLine 1 ; preds = %"file loop.c, line 6, in inner vector loop at depth 0, bb59", %"file loop.c, line 1, bb61" + br label %"file loop.c, line 6, in inner vector loop at depth 0, bb59" ; [oox.0 : sln.0] + +"file loop.c, line 6, in inner vector loop at depth 0, bb59": ; srcLine 6 ; preds = %"file loop.c, line 1, in inner vector loop at depth 0, bb58" + %r119 = load i64* %"$LIS_S15", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r120 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r121 = add i64 %r119, %r120 ; [#uses=1] ; [oox.189 : sln.6] + store i64 %r121, i64* %"$LCS_4", align 8 ; [oox.189 : sln.6] + %r122 = load i64* %"$LIS_S17", align 8 ; [#uses=1] ; [oox.190 : sln.6] + %r123 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.190 : sln.6] + %r124 = add i64 %r122, %r123 ; [#uses=1] ; [oox.190 : sln.6] + store i64 %r124, i64* %"$LCS_5", align 8 ; [oox.190 : sln.6] + %r125 = load i64* %"$LIS_S18", align 8 ; [#uses=1] ; [oox.191 : sln.6] + %r126 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.191 : sln.6] + %r127 = add i64 %r125, %r126 ; [#uses=1] ; [oox.191 : sln.6] + store i64 %r127, i64* %"$LCS_6", align 8 ; [oox.191 : sln.6] + %r128 = load i64* %"$LCS_4", align 8 ; [#uses=1] ; [oox.192 : sln.6] + %r129 = inttoptr i64 %r128 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.192 : sln.6] + %r130 = load <4 x float>* %r129, align 4 ; <<4 x float>> [#uses=1] ; [oox.192 : sln.6] + %r131 = load i64* %"$LCS_5", align 8 ; [#uses=1] ; [oox.192 : sln.6] + %r132 = inttoptr i64 %r131 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.192 : sln.6] + %r133 = load <4 x float>* %r132, align 4 ; <<4 x float>> [#uses=1] ; [oox.192 : sln.6] + %r134 = add <4 x float> %r130, %r133 ; <<4 x float>> [#uses=1] ; [oox.192 : sln.6] + %r135 = load i64* %"$LCS_6", align 8 ; [#uses=1] ; [oox.192 : sln.6] + %r136 = inttoptr i64 %r135 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.192 : sln.6] + store <4 x float> %r134, <4 x float>* %r136, align 4 ; [oox.192 : sln.6] + %r137 = load i64* %"$LCS_4", align 8 ; [#uses=1] ; [oox.193 : sln.6] + %r138 = add i64 16, %r137 ; [#uses=1] ; [oox.193 : sln.6] + %r139 = inttoptr i64 %r138 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.193 : sln.6] + %r140 = load <4 x float>* %r139, align 4 ; <<4 x float>> [#uses=1] ; [oox.193 : sln.6] + %r141 = load i64* %"$LCS_5", align 8 ; [#uses=1] ; [oox.193 : sln.6] + %r142 = add i64 16, %r141 ; [#uses=1] ; [oox.193 : sln.6] + %r143 = inttoptr i64 %r142 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.193 : sln.6] + %r144 = load <4 x float>* %r143, align 4 ; <<4 x float>> [#uses=1] ; [oox.193 : sln.6] + %r145 = add <4 x float> %r140, %r144 ; <<4 x float>> [#uses=1] ; [oox.193 : sln.6] + %r146 = load i64* %"$LCS_6", align 8 ; [#uses=1] ; [oox.193 : sln.6] + %r147 = add i64 16, %r146 ; [#uses=1] ; [oox.193 : sln.6] + %r148 = inttoptr i64 %r147 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.193 : sln.6] + store <4 x float> %r145, <4 x float>* %r148, align 4 ; [oox.193 : sln.6] + %r149 = load i64* %"$LCS_4", align 8 ; [#uses=1] ; [oox.194 : sln.6] + %r150 = add i64 32, %r149 ; [#uses=1] ; [oox.194 : sln.6] + %r151 = inttoptr i64 %r150 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.194 : sln.6] + %r152 = load <4 x float>* %r151, align 4 ; <<4 x float>> [#uses=1] ; [oox.194 : sln.6] + %r153 = load i64* %"$LCS_5", align 8 ; [#uses=1] ; [oox.194 : sln.6] + %r154 = add i64 32, %r153 ; [#uses=1] ; [oox.194 : sln.6] + %r155 = inttoptr i64 %r154 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.194 : sln.6] + %r156 = load <4 x float>* %r155, align 4 ; <<4 x float>> [#uses=1] ; [oox.194 : sln.6] + %r157 = add <4 x float> %r152, %r156 ; <<4 x float>> [#uses=1] ; [oox.194 : sln.6] + %r158 = load i64* %"$LCS_6", align 8 ; [#uses=1] ; [oox.194 : sln.6] + %r159 = add i64 32, %r158 ; [#uses=1] ; [oox.194 : sln.6] + %r160 = inttoptr i64 %r159 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.194 : sln.6] + store <4 x float> %r157, <4 x float>* %r160, align 4 ; [oox.194 : sln.6] + %r161 = load i64* %"$LCS_4", align 8 ; [#uses=1] ; [oox.195 : sln.6] + %r162 = add i64 48, %r161 ; [#uses=1] ; [oox.195 : sln.6] + %r163 = inttoptr i64 %r162 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.195 : sln.6] + %r164 = load <4 x float>* %r163, align 4 ; <<4 x float>> [#uses=1] ; [oox.195 : sln.6] + %r165 = load i64* %"$LCS_5", align 8 ; [#uses=1] ; [oox.195 : sln.6] + %r166 = add i64 48, %r165 ; [#uses=1] ; [oox.195 : sln.6] + %r167 = inttoptr i64 %r166 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.195 : sln.6] + %r168 = load <4 x float>* %r167, align 4 ; <<4 x float>> [#uses=1] ; [oox.195 : sln.6] + %r169 = add <4 x float> %r164, %r168 ; <<4 x float>> [#uses=1] ; [oox.195 : sln.6] + %r170 = load i64* %"$LCS_6", align 8 ; [#uses=1] ; [oox.195 : sln.6] + %r171 = add i64 48, %r170 ; [#uses=1] ; [oox.195 : sln.6] + %r172 = inttoptr i64 %r171 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.195 : sln.6] + store <4 x float> %r169, <4 x float>* %r172, align 4 ; [oox.195 : sln.6] + %r173 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.196 : sln.5] + %r174 = add i64 64, %r173 ; [#uses=1] ; [oox.196 : sln.5] + store i64 %r174, i64* %"$SI_S25", align 8 ; [oox.196 : sln.5] + %r175 = load i64* %"$LC_S24", align 8 ; [#uses=1] ; [oox.197 : sln.5] + %r176 = add i64 16, %r175 ; [#uses=1] ; [oox.197 : sln.5] + store i64 %r176, i64* %"$LC_S24", align 8 ; [oox.197 : sln.5] + %r177 = load i64* %"$LC_S24", align 8 ; [#uses=1] ; [oox.198 : sln.5] + %r178 = icmp slt i64 %r177, -15 ; [#uses=1] ; [oox.198 : sln.5] + %r179 = zext i1 %r178 to i32 ; [#uses=1] ; [oox.198 : sln.5] + %r180 = icmp ne i32 %r179, 0 ; [#uses=1] ; [oox.198 : sln.5] + br i1 %r180, label %"file loop.c, line 1, in inner vector loop at depth 0, bb58", label %"file loop.c, line 5, bb64" ; [oox.198 : sln.5] + +"file loop.c, line 5, bb64": ; srcLine 5 ; preds = %"file loop.c, line 6, in inner vector loop at depth 0, bb59", %"file loop.c, line 5, bb60" + %r181 = load i64* %"$LC_S24", align 8 ; [#uses=1] ; [oox.189 : sln.5] + %r182 = icmp sge i64 %r181, 0 ; [#uses=1] ; [oox.189 : sln.5] + %r183 = zext i1 %r182 to i32 ; [#uses=1] ; [oox.189 : sln.5] + %r184 = icmp ne i32 %r183, 0 ; [#uses=1] ; [oox.189 : sln.5] + br i1 %r184, label %"file loop.c, line 5, bb45", label %"file loop.c, line 1, bb65" ; [oox.189 : sln.5] + +"file loop.c, line 1, bb65": ; srcLine 1 ; preds = %"file loop.c, line 5, bb64" + br label %"file loop.c, line 1, in inner vector loop at depth 0, bb62" ; [oox.0 : sln.0] + +"file loop.c, line 1, in inner vector loop at depth 0, bb62": ; srcLine 1 ; preds = %"file loop.c, line 6, in inner vector loop at depth 0, bb63", %"file loop.c, line 1, bb65" + br label %"file loop.c, line 6, in inner vector loop at depth 0, bb63" ; [oox.0 : sln.0] + +"file loop.c, line 6, in inner vector loop at depth 0, bb63": ; srcLine 6 ; preds = %"file loop.c, line 1, in inner vector loop at depth 0, bb62" + %r185 = load i64* %"$LIS_S17", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r186 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r187 = add i64 %r185, %r186 ; [#uses=1] ; [oox.189 : sln.6] + %r188 = inttoptr i64 %r187 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.189 : sln.6] + %r189 = load <4 x float>* %r188, align 4 ; <<4 x float>> [#uses=1] ; [oox.189 : sln.6] + %r190 = load i64* %"$LIS_S15", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r191 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r192 = add i64 %r190, %r191 ; [#uses=1] ; [oox.189 : sln.6] + %r193 = inttoptr i64 %r192 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.189 : sln.6] + %r194 = load <4 x float>* %r193, align 4 ; <<4 x float>> [#uses=1] ; [oox.189 : sln.6] + %r195 = add <4 x float> %r189, %r194 ; <<4 x float>> [#uses=1] ; [oox.189 : sln.6] + %r196 = load i64* %"$LIS_S18", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r197 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r198 = add i64 %r196, %r197 ; [#uses=1] ; [oox.189 : sln.6] + %r199 = inttoptr i64 %r198 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.189 : sln.6] + store <4 x float> %r195, <4 x float>* %r199, align 4 ; [oox.189 : sln.6] + %r200 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.190 : sln.5] + %r201 = add i64 16, %r200 ; [#uses=1] ; [oox.190 : sln.5] + store i64 %r201, i64* %"$SI_S25", align 8 ; [oox.190 : sln.5] + %r202 = load i64* %"$LC_S24", align 8 ; [#uses=1] ; [oox.191 : sln.5] + %r203 = add i64 4, %r202 ; [#uses=1] ; [oox.191 : sln.5] + store i64 %r203, i64* %"$LC_S24", align 8 ; [oox.191 : sln.5] + %r204 = load i64* %"$LC_S24", align 8 ; [#uses=1] ; [oox.192 : sln.5] + %r205 = icmp slt i64 %r204, 0 ; [#uses=1] ; [oox.192 : sln.5] + %r206 = zext i1 %r205 to i64 ; [#uses=1] ; [oox.192 : sln.5] + %r207 = icmp ne i64 %r206, 0 ; [#uses=1] ; [oox.192 : sln.5] + br i1 %r207, label %"file loop.c, line 1, in inner vector loop at depth 0, bb62", label %"file loop.c, line 5, bb45" ; [oox.192 : sln.5] + +"file loop.c, line 5, bb45": ; srcLine 5 ; preds = %"file loop.c, line 6, in inner vector loop at depth 0, bb63", %"file loop.c, line 5, bb64" + %r208 = load i64* %"$TC_1", align 8 ; [#uses=1] ; [oox.189 : sln.5] + store i64 %r208, i64* %"$i_S23", align 8 ; [oox.189 : sln.5] + br label %"file loop.c, line 5, bb50" ; [oox.0 : sln.0] + +"file loop.c, line 5, bb50": ; srcLine 5 ; preds = %"file loop.c, line 5, bb45", %"file loop.c, line 5, bb48" + %r209 = load i32* %"$MR_n_0", align 4 ; [#uses=1] ; [oox.189 : sln.5] + %r210 = sext i32 %r209 to i64 ; [#uses=1] ; [oox.189 : sln.5] + store i64 %r210, i64* %"$LCS_n_7", align 8 ; [oox.189 : sln.5] + %r211 = load i64* %"$LCS_n_7", align 8 ; [#uses=1] ; [oox.190 : sln.5] + %r212 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.190 : sln.5] + %r213 = icmp sle i64 %r211, %r212 ; [#uses=1] ; [oox.190 : sln.5] + %r214 = zext i1 %r213 to i32 ; [#uses=1] ; [oox.190 : sln.5] + %r215 = icmp ne i32 %r214, 0 ; [#uses=1] ; [oox.190 : sln.5] + br i1 %r215, label %"file loop.c, line 5, bb6", label %"file loop.c, line 1, bb49" ; [oox.190 : sln.5] + +"file loop.c, line 1, bb49": ; srcLine 1 ; preds = %"file loop.c, line 5, bb50" + br label %"file loop.c, line 6, bb57" ; [oox.0 : sln.0] + +"file loop.c, line 6, bb57": ; srcLine 6 ; preds = %"file loop.c, line 1, bb49" + %r216 = load float** %"$MR_B_3", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r217 = ptrtoint float* %r216 to i64 ; [#uses=1] ; [oox.189 : sln.6] + store i64 %r217, i64* %"$LIS_S19", align 8 ; [oox.189 : sln.6] + %r218 = load float** %"$MR_C_1", align 8 ; [#uses=1] ; [oox.190 : sln.6] + %r219 = ptrtoint float* %r218 to i64 ; [#uses=1] ; [oox.190 : sln.6] + store i64 %r219, i64* %"$LIS_S20", align 8 ; [oox.190 : sln.6] + %r220 = load float** %"$MR_A_2", align 8 ; [#uses=1] ; [oox.191 : sln.6] + %r221 = ptrtoint float* %r220 to i64 ; [#uses=1] ; [oox.191 : sln.6] + store i64 %r221, i64* %"$LIS_S21", align 8 ; [oox.191 : sln.6] + br label %"file loop.c, line 1, in inner loop at depth 0, bb51" ; [oox.0 : sln.0] + +"file loop.c, line 1, in inner loop at depth 0, bb51": ; srcLine 1 ; preds = %"file loop.c, line 5, in inner loop at depth 0, bb54", %"file loop.c, line 6, bb57" + br label %"file loop.c, line 5, in inner loop at depth 0, bb54" ; [oox.0 : sln.0] + +"file loop.c, line 5, in inner loop at depth 0, bb54": ; srcLine 5 ; preds = %"file loop.c, line 1, in inner loop at depth 0, bb51" + %r222 = load i64* %"$LIS_S20", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r223 = inttoptr i64 %r222 to float* ; [#uses=1] ; [oox.189 : sln.6] + %r224 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r225 = getelementptr float* %r223, i64 %r224 ; [#uses=1] ; [oox.189 : sln.6] + %r226 = load float* %r225, align 4 ; [#uses=1] ; [oox.189 : sln.6] + %r227 = load i64* %"$LIS_S19", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r228 = inttoptr i64 %r227 to float* ; [#uses=1] ; [oox.189 : sln.6] + %r229 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r230 = getelementptr float* %r228, i64 %r229 ; [#uses=1] ; [oox.189 : sln.6] + %r231 = load float* %r230, align 4 ; [#uses=1] ; [oox.189 : sln.6] + %r232 = add float %r226, %r231 ; [#uses=1] ; [oox.189 : sln.6] + %r233 = load i64* %"$LIS_S21", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r234 = inttoptr i64 %r233 to float* ; [#uses=1] ; [oox.189 : sln.6] + %r235 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.189 : sln.6] + %r236 = getelementptr float* %r234, i64 %r235 ; [#uses=1] ; [oox.189 : sln.6] + store float %r232, float* %r236, align 4 ; [oox.189 : sln.6] + %r237 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.190 : sln.5] + %r238 = add i64 1, %r237 ; [#uses=1] ; [oox.190 : sln.5] + store i64 %r238, i64* %"$i_S23", align 8 ; [oox.190 : sln.5] + %r239 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.191 : sln.5] + %r240 = load i64* %"$LCS_n_7", align 8 ; [#uses=1] ; [oox.191 : sln.5] + %r241 = icmp slt i64 %r239, %r240 ; [#uses=1] ; [oox.191 : sln.5] + %r242 = zext i1 %r241 to i64 ; [#uses=1] ; [oox.191 : sln.5] + %r243 = icmp ne i64 %r242, 0 ; [#uses=1] ; [oox.191 : sln.5] + br i1 %r243, label %"file loop.c, line 1, in inner loop at depth 0, bb51", label %"file loop.c, line 5, bb6" ; [oox.191 : sln.5] + +"file loop.c, line 5, bb6": ; srcLine 5 ; preds = %"file loop.c, line 5, in inner loop at depth 0, bb54", %"file loop.c, line 5, bb50", %"file loop.c, line 5, in inner loop at depth 0, bb32", %"file loop.c, line 1, bb69" + ret i32 0 ; [oox.189 : sln.10] +} From clattner at apple.com Mon Jan 11 10:46:22 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 11 Jan 2010 08:46:22 -0800 Subject: [llvm-commits] [llvm] r93149 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h lib/Analysis/DebugInfo.cpp lib/VMCore/IntrinsicInst.cpp In-Reply-To: <201001110745.o0B7jJl8030108@zion.cs.uiuc.edu> References: <201001110745.o0B7jJl8030108@zion.cs.uiuc.edu> Message-ID: On Jan 10, 2010, at 11:45 PM, Victor Hernandez wrote: > Author: hernande > Date: Mon Jan 11 01:45:19 2010 > New Revision: 93149 > > URL: http://llvm.org/viewvc/llvm-project?rev=93149&view=rev > Log: > Respond to Chris' review: > Make InsertDbgValueIntrinsic() and get Offset take and recieve a uint64_t. > Get constness correct for getVariable() and getValue(). Nice, thanks Victor. Don't forget the LangRef piece, -Chris From vhernandez at apple.com Mon Jan 11 10:58:38 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Mon, 11 Jan 2010 08:58:38 -0800 Subject: [llvm-commits] [llvm] r93149 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h lib/Analysis/DebugInfo.cpp lib/VMCore/IntrinsicInst.cpp In-Reply-To: References: <201001110745.o0B7jJl8030108@zion.cs.uiuc.edu> Message-ID: <484EA42F-585B-454E-BF6B-D8CA44111286@apple.com> Yes, that will go in today. Also for today that is pending from your reviews: > With this change, there is no difference between ConvertGlobalValIDToValue, ConvertGlobalOrMetadataValIDToValue, and ConvertValIDToValue, except for inline asm. Can they all be merged into one function now and use the PFS pointer to distinguish the function-local vs global case? Victor On Jan 11, 2010, at 8:46 AM, Chris Lattner wrote: > > On Jan 10, 2010, at 11:45 PM, Victor Hernandez wrote: > >> Author: hernande >> Date: Mon Jan 11 01:45:19 2010 >> New Revision: 93149 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=93149&view=rev >> Log: >> Respond to Chris' review: >> Make InsertDbgValueIntrinsic() and get Offset take and recieve a uint64_t. >> Get constness correct for getVariable() and getValue(). > > Nice, thanks Victor. Don't forget the LangRef piece, > > -Chris From evan.cheng at apple.com Mon Jan 11 11:03:47 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jan 2010 17:03:47 -0000 Subject: [llvm-commits] [llvm] r93152 - in /llvm/trunk: lib/Target/X86/X86Instr64bit.td lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/2009-05-23-dagcombine-shifts.ll test/CodeGen/X86/3addr-or.ll Message-ID: <201001111703.o0BH3mip002112@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jan 11 11:03:47 2010 New Revision: 93152 URL: http://llvm.org/viewvc/llvm-project?rev=93152&view=rev Log: Select an OR with immediate as an ADD if the input bits are known zero. This allow the instruction to be 3address-fied if needed. Added: llvm/trunk/test/CodeGen/X86/3addr-or.ll Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td llvm/trunk/lib/Target/X86/X86InstrInfo.td llvm/trunk/test/CodeGen/X86/2009-05-23-dagcombine-shifts.ll Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=93152&r1=93151&r2=93152&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Mon Jan 11 11:03:47 2010 @@ -1106,13 +1106,13 @@ def OR64ri8 : RIi8<0x83, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), "or{q}\t{$src2, $dst|$dst, $src2}", - [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2)), - (implicit EFLAGS)]>; + [(set GR64:$dst, (or_not_add GR64:$src1, i64immSExt8:$src2)), + (implicit EFLAGS)]>; def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), "or{q}\t{$src2, $dst|$dst, $src2}", - [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2)), - (implicit EFLAGS)]>; + [(set GR64:$dst, (or_not_add GR64:$src1, i64immSExt32:$src2)), + (implicit EFLAGS)]>; } // isTwoAddress def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), @@ -2114,6 +2114,14 @@ GR64:$src2, (i8 imm:$amt2)), addr:$dst), (SHLD64mri8 addr:$dst, GR64:$src2, (i8 imm:$amt1))>; +// (or x, c) -> (add x, c) if masked bits are known zero. +def : Pat<(parallel (or_is_add GR64:$src1, i64immSExt8:$src2), + (implicit EFLAGS)), + (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>; +def : Pat<(parallel (or_is_add GR64:$src1, i64immSExt32:$src2), + (implicit EFLAGS)), + (ADD64ri32 GR64:$src1, i64immSExt32:$src2)>; + // X86 specific add which produces a flag. def : Pat<(addc GR64:$src1, GR64:$src2), (ADD64rr GR64:$src1, GR64:$src2)>; Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=93152&r1=93151&r2=93152&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon Jan 11 11:03:47 2010 @@ -493,6 +493,18 @@ return N->hasOneUse(); }]>; +// Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero. +def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{ + if (ConstantSDNode *CN = dyn_cast(N->getOperand(1))) + return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue()); + return false; +}]>; +def or_not_add : PatFrag<(ops node:$lhs, node:$rhs),(or node:$lhs, node:$rhs),[{ + ConstantSDNode *CN = dyn_cast(N->getOperand(1)); + if (!CN) return true; + return !CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue()); +}]>; + // 'shld' and 'shrd' instruction patterns. Note that even though these have // the srl and shl in their patterns, the C++ code must still check for them, // because predicates are tested before children nodes are explored. @@ -1880,28 +1892,28 @@ def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2), "or{b}\t{$src2, $dst|$dst, $src2}", - [(set GR8:$dst, (or GR8:$src1, imm:$src2)), + [(set GR8:$dst, (or_not_add GR8:$src1, imm:$src2)), (implicit EFLAGS)]>; def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), "or{w}\t{$src2, $dst|$dst, $src2}", - [(set GR16:$dst, (or GR16:$src1, imm:$src2)), + [(set GR16:$dst, (or_not_add GR16:$src1, imm:$src2)), (implicit EFLAGS)]>, OpSize; def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2), "or{l}\t{$src2, $dst|$dst, $src2}", - [(set GR32:$dst, (or GR32:$src1, imm:$src2)), + [(set GR32:$dst, (or_not_add GR32:$src1, imm:$src2)), (implicit EFLAGS)]>; def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2), "or{w}\t{$src2, $dst|$dst, $src2}", - [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)), + [(set GR16:$dst, (or_not_add GR16:$src1, i16immSExt8:$src2)), (implicit EFLAGS)]>, OpSize; def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2), "or{l}\t{$src2, $dst|$dst, $src2}", - [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)), + [(set GR32:$dst, (or_not_add GR32:$src1, i32immSExt8:$src2)), (implicit EFLAGS)]>; let isTwoAddress = 0 in { def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src), @@ -4647,6 +4659,23 @@ def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))), (SETB_C32r)>; +// (or x, c) -> (add x, c) if masked bits are known zero. +def : Pat<(parallel (or_is_add GR8:$src1, imm:$src2), + (implicit EFLAGS)), + (ADD8ri GR8:$src1, imm:$src2)>; +def : Pat<(parallel (or_is_add GR16:$src1, imm:$src2), + (implicit EFLAGS)), + (ADD16ri GR16:$src1, imm:$src2)>; +def : Pat<(parallel (or_is_add GR32:$src1, imm:$src2), + (implicit EFLAGS)), + (ADD32ri GR32:$src1, imm:$src2)>; +def : Pat<(parallel (or_is_add GR16:$src1, i16immSExt8:$src2), + (implicit EFLAGS)), + (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>; +def : Pat<(parallel (or_is_add GR32:$src1, i32immSExt8:$src2), + (implicit EFLAGS)), + (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>; + //===----------------------------------------------------------------------===// // EFLAGS-defining Patterns //===----------------------------------------------------------------------===// Modified: llvm/trunk/test/CodeGen/X86/2009-05-23-dagcombine-shifts.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-05-23-dagcombine-shifts.ll?rev=93152&r1=93151&r2=93152&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-05-23-dagcombine-shifts.ll (original) +++ llvm/trunk/test/CodeGen/X86/2009-05-23-dagcombine-shifts.ll Mon Jan 11 11:03:47 2010 @@ -1,12 +1,18 @@ -; RUN: llc < %s | grep -E {sar|shl|mov|or} | count 4 +; RUN: llc < %s | FileCheck %s + ; Check that the shr(shl X, 56), 48) is not mistakenly turned into ; a shr (X, -8) that gets subsequently "optimized away" as undef ; PR4254 + 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-f80:128:128" target triple = "x86_64-unknown-linux-gnu" define i64 @foo(i64 %b) nounwind readnone { entry: +; CHECK: foo: +; CHECK: shlq $56, %rdi +; CHECK: sarq $48, %rdi +; CHECK: leaq 1(%rdi), %rax %shl = shl i64 %b, 56 ; [#uses=1] %shr = ashr i64 %shl, 48 ; [#uses=1] %add5 = or i64 %shr, 1 ; [#uses=1] Added: llvm/trunk/test/CodeGen/X86/3addr-or.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/3addr-or.ll?rev=93152&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/3addr-or.ll (added) +++ llvm/trunk/test/CodeGen/X86/3addr-or.ll Mon Jan 11 11:03:47 2010 @@ -0,0 +1,11 @@ +; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s +; rdar://7527734 + +define i32 @test(i32 %x) nounwind readnone ssp { +entry: +; CHECK: test: +; CHECK: leal 3(%rdi), %eax + %0 = shl i32 %x, 5 ; [#uses=1] + %1 = or i32 %0, 3 ; [#uses=1] + ret i32 %1 +} From gohman at apple.com Mon Jan 11 11:14:46 2010 From: gohman at apple.com (Dan Gohman) Date: Mon, 11 Jan 2010 17:14:46 -0000 Subject: [llvm-commits] [llvm] r93154 - /llvm/trunk/lib/Target/X86/X86FastISel.cpp Message-ID: <201001111714.o0BHEkDV002516@zion.cs.uiuc.edu> Author: djg Date: Mon Jan 11 11:14:46 2010 New Revision: 93154 URL: http://llvm.org/viewvc/llvm-project?rev=93154&view=rev Log: Reword this comment to reference a more fundamental issue. Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=93154&r1=93153&r2=93154&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Mon Jan 11 11:14:46 2010 @@ -1230,8 +1230,8 @@ CC != CallingConv::X86_FastCall) return false; - // On X86, -tailcallopt changes the fastcc ABI. FastISel doesn't - // handle this for now. + // fastcc with -tailcallopt is intended to provide a guaranteed + // tail call optimization. Fastisel doesn't know how to do that. if (CC == CallingConv::Fast && PerformTailCallOpt) return false; From nicholas at mxc.ca Mon Jan 11 11:15:01 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 11 Jan 2010 09:15:01 -0800 Subject: [llvm-commits] patch: partial dse In-Reply-To: <4B411282.3070308@mxc.ca> References: <4B411282.3070308@mxc.ca> Message-ID: <4B4B5C95.1040804@mxc.ca> Nick Lewycky wrote: > This patch implements partially-dead store elimination, turning: > > %P16 = bitcast i32* %P32 to i16 > store i32 0, i32* %P32 > store i16 -1, i16* %P16 > > into: > > store i32 65535, i32* %P32 > > Please review! Having put this patch through its paces, I've concluded that it's buggy in a way that can't be fixed without reverse-memdep. If anyone is interested, doing this transform would help consumer-typeset a lot by optimizing accesses to unions in memory (SROA already takes care of those on the stack). Nick > At the moment, it restricts itself to the case where we have TargetData. > This seems odd at first, but the problem is that DSE itself doesn't seem > to be sure how many bits will be modified by a store without it. 'i32' > and 'i16' are clear, but 'i6' less so (and which 2 bits does it leave > alone). My opinion is that the only sane behaviour for an i6* store is > that it overwrite only the first 6 bits of the pointee and no others, > which is the same rule that i16* and i32* have. However, I know that > this sort of thing is limited by actual hardware capabilities and wanted > to ask before I implement :) > > It's also restricted to integers. I don't know whether it would be > profitable to binary-and and binary-or together floats or pointers. We > could certainly do it in the case where both sides are constant values. > > Nick > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From jyasskin at google.com Mon Jan 11 11:17:52 2010 From: jyasskin at google.com (Jeffrey Yasskin) Date: Mon, 11 Jan 2010 09:17:52 -0800 Subject: [llvm-commits] [PATCH] Fix tail calls (indirect or large-code-model): PR5729 In-Reply-To: <201001111307.29238.jon@ffconsultancy.com> References: <201001100757.22653.jon@ffconsultancy.com> <201001111307.29238.jon@ffconsultancy.com> Message-ID: On Mon, Jan 11, 2010 at 5:07 AM, Jon Harrop wrote: > On Sunday 10 January 2010 06:54:32 you wrote: >> On Sat, Jan 9, 2010 at 11:57 PM, Jon Harrop wrote: >> > On Saturday 09 January 2010 19:05:45 you wrote: >> >> Committed as r93065. >> >> >> >> Your Mandelbrot test seems to work now. Let me know what's still broken. >> > >> > Awesome, thanks! >> > >> > All tests now pass with standalone compilation using "llc" and not "opt" >> > on both x86 and x86-64. >> > >> > Optimizing with "opt -std-compile-opts" generates working code that >> > honors the tail calls marked by HLVM but optimizing with "opt >> > -tailcallelim -std-compile-opts" still generates broken code that >> > segfaults on both x86 and x86-64. IIRC, that causes opt to mark all calls >> > as tail calls so presumably LLVM is intolerant of that. >> >> Could you send the smallest .bc file you have that generates good >> output without -tailcallelim and bad output or a segfault with >> -tailcallelim? Please also include the exact command lines you use to >> compile it. > > I've found some bugs in my code that could have caused segfaults and fixed > them. Now I'm only seeing a problem at a tail call on the hash table > benchmark but only when JIT compiled by HLVM and not when standalone (or with > optimizations, which now work) or even when JIT compiled with lli. > > I'm going on holiday for a week. I'll get back to this when I return... Cool. I'll be waiting for your reproducible test case. :) From gohman at apple.com Mon Jan 11 11:21:05 2010 From: gohman at apple.com (Dan Gohman) Date: Mon, 11 Jan 2010 17:21:05 -0000 Subject: [llvm-commits] [llvm] r93155 - in /llvm/trunk/lib/Target/X86: X86Instr64bit.td X86InstrInfo.td Message-ID: <201001111721.o0BHL5oe002763@zion.cs.uiuc.edu> Author: djg Date: Mon Jan 11 11:21:05 2010 New Revision: 93155 URL: http://llvm.org/viewvc/llvm-project?rev=93155&view=rev Log: Pattern top-level operators don't need to be restricted to a single user. The _su forms are intended for non-top-level nodes. Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td llvm/trunk/lib/Target/X86/X86InstrInfo.td Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=93155&r1=93154&r2=93155&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Mon Jan 11 11:21:05 2010 @@ -2029,7 +2029,7 @@ (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)), x86_subreg_8bit_hi))>, Requires<[In64BitMode]>; -def : Pat<(srl_su GR16:$src, (i8 8)), +def : Pat<(srl GR16:$src, (i8 8)), (EXTRACT_SUBREG (MOVZX32_NOREXrr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=93155&r1=93154&r2=93155&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon Jan 11 11:21:05 2010 @@ -4485,7 +4485,7 @@ (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)), x86_subreg_8bit_hi)>, Requires<[In32BitMode]>; -def : Pat<(srl_su GR16:$src, (i8 8)), +def : Pat<(srl GR16:$src, (i8 8)), (EXTRACT_SUBREG (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), From gohman at apple.com Mon Jan 11 11:23:56 2010 From: gohman at apple.com (Dan Gohman) Date: Mon, 11 Jan 2010 17:23:56 -0000 Subject: [llvm-commits] [llvm] r93156 - /llvm/trunk/test/CodeGen/X86/2009-02-26-MachineLICMBug.ll Message-ID: <201001111723.o0BHNvP5002874@zion.cs.uiuc.edu> Author: djg Date: Mon Jan 11 11:23:56 2010 New Revision: 93156 URL: http://llvm.org/viewvc/llvm-project?rev=93156&view=rev Log: Make this test less trivial, to avoid spurious failures. Modified: llvm/trunk/test/CodeGen/X86/2009-02-26-MachineLICMBug.ll Modified: llvm/trunk/test/CodeGen/X86/2009-02-26-MachineLICMBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-02-26-MachineLICMBug.ll?rev=93156&r1=93155&r2=93156&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-02-26-MachineLICMBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2009-02-26-MachineLICMBug.ll Mon Jan 11 11:23:56 2010 @@ -6,13 +6,13 @@ %struct.__Rec = type opaque %struct.__vv = type { } -define %struct.__vv* @t(%struct.Key* %desc) nounwind ssp { +define %struct.__vv* @t(%struct.Key* %desc, i64 %p) nounwind ssp { entry: br label %bb4 bb4: ; preds = %bb.i, %bb26, %bb4, %entry %0 = call i32 (...)* @xxGetOffsetForCode(i32 undef) nounwind ; [#uses=0] - %ins = or i64 0, 0 ; [#uses=1] + %ins = or i64 %p, 2097152 ; [#uses=1] %1 = call i32 (...)* @xxCalculateMidType(%struct.Key* %desc, i32 0) nounwind ; [#uses=1] %cond = icmp eq i32 %1, 1 ; [#uses=1] br i1 %cond, label %bb26, label %bb4 From gohman at apple.com Mon Jan 11 11:24:28 2010 From: gohman at apple.com (Dan Gohman) Date: Mon, 11 Jan 2010 17:24:28 -0000 Subject: [llvm-commits] [llvm] r93157 - /llvm/trunk/test/CodeGen/X86/2009-11-16-MachineLICM.ll Message-ID: <201001111724.o0BHOSOe002899@zion.cs.uiuc.edu> Author: djg Date: Mon Jan 11 11:24:27 2010 New Revision: 93157 URL: http://llvm.org/viewvc/llvm-project?rev=93157&view=rev Log: Generalize this check to avoid depending on a specific register assignment. Modified: llvm/trunk/test/CodeGen/X86/2009-11-16-MachineLICM.ll Modified: llvm/trunk/test/CodeGen/X86/2009-11-16-MachineLICM.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-11-16-MachineLICM.ll?rev=93157&r1=93156&r2=93157&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-11-16-MachineLICM.ll (original) +++ llvm/trunk/test/CodeGen/X86/2009-11-16-MachineLICM.ll Mon Jan 11 11:24:27 2010 @@ -10,7 +10,7 @@ br i1 %0, label %bb.nph, label %return bb.nph: ; preds = %entry -; CHECK: movq _g at GOTPCREL(%rip), %rcx +; CHECK: movq _g at GOTPCREL(%rip), [[REG:%[a-z]+]] %tmp = zext i32 %n to i64 ; [#uses=1] br label %bb From gohman at apple.com Mon Jan 11 11:37:58 2010 From: gohman at apple.com (Dan Gohman) Date: Mon, 11 Jan 2010 17:37:58 -0000 Subject: [llvm-commits] [llvm] r93158 - in /llvm/trunk: lib/Target/X86/AsmPrinter/X86MCInstLower.cpp lib/Target/X86/X86ISelDAGToDAG.cpp lib/Target/X86/X86Instr64bit.td lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/remat-mov-0.ll Message-ID: <201001111737.o0BHbwQE003369@zion.cs.uiuc.edu> Author: djg Date: Mon Jan 11 11:37:57 2010 New Revision: 93158 URL: http://llvm.org/viewvc/llvm-project?rev=93158&view=rev Log: Re-instate MOV64r0 and MOV16r0, with adjustments to work with the new AsmPrinter. This is perhaps less elegant than describing them in terms of MOV32r0 and subreg operations, but it allows the current register to rematerialize them. Added: llvm/trunk/test/CodeGen/X86/remat-mov-0.ll Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/trunk/lib/Target/X86/X86Instr64bit.td llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.td Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=93158&r1=93157&r2=93158&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Mon Jan 11 11:37:57 2010 @@ -399,6 +399,14 @@ OutMI.setOpcode(X86::MOVZX32rm16); lower_subreg32(&OutMI, 0); break; + case X86::MOV16r0: + OutMI.setOpcode(X86::MOV32r0); + lower_subreg32(&OutMI, 0); + break; + case X86::MOV64r0: + OutMI.setOpcode(X86::MOV32r0); + lower_subreg32(&OutMI, 0); + break; } } Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=93158&r1=93157&r2=93158&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Mon Jan 11 11:37:57 2010 @@ -1873,7 +1873,6 @@ unsigned LoReg, HiReg, ClrReg; unsigned ClrOpcode, SExtOpcode; - EVT ClrVT = NVT; switch (NVT.getSimpleVT().SimpleTy) { default: llvm_unreachable("Unsupported VT!"); case MVT::i8: @@ -1883,7 +1882,7 @@ break; case MVT::i16: LoReg = X86::AX; HiReg = X86::DX; - ClrOpcode = X86::MOV32r0; ClrReg = X86::EDX; ClrVT = MVT::i32; + ClrOpcode = X86::MOV16r0; ClrReg = X86::DX; SExtOpcode = X86::CWD; break; case MVT::i32: @@ -1893,7 +1892,7 @@ break; case MVT::i64: LoReg = X86::RAX; ClrReg = HiReg = X86::RDX; - ClrOpcode = ~0U; // NOT USED. + ClrOpcode = X86::MOV64r0; SExtOpcode = X86::CQO; break; } @@ -1932,24 +1931,8 @@ SDValue(CurDAG->getMachineNode(SExtOpcode, dl, MVT::Flag, InFlag),0); } else { // Zero out the high part, effectively zero extending the input. - SDValue ClrNode; - - if (NVT.getSimpleVT() == MVT::i64) { - ClrNode = SDValue(CurDAG->getMachineNode(X86::MOV32r0, dl, MVT::i32), - 0); - // We just did a 32-bit clear, insert it into a 64-bit register to - // clear the whole 64-bit reg. - SDValue Zero = CurDAG->getTargetConstant(0, MVT::i64); - SDValue SubRegNo = - CurDAG->getTargetConstant(X86::SUBREG_32BIT, MVT::i32); - ClrNode = - SDValue(CurDAG->getMachineNode(TargetInstrInfo::SUBREG_TO_REG, dl, - MVT::i64, Zero, ClrNode, SubRegNo), - 0); - } else { - ClrNode = SDValue(CurDAG->getMachineNode(ClrOpcode, dl, ClrVT), 0); - } - + SDValue ClrNode = + SDValue(CurDAG->getMachineNode(ClrOpcode, dl, NVT), 0); InFlag = CurDAG->getCopyToReg(CurDAG->getEntryNode(), dl, ClrReg, ClrNode, InFlag).getValue(1); } Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=93158&r1=93157&r2=93158&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Mon Jan 11 11:37:57 2010 @@ -1598,17 +1598,20 @@ // Alias Instructions //===----------------------------------------------------------------------===// -// Alias instructions that map movr0 to xor. Use xorl instead of xorq; it's -// equivalent due to implicit zero-extending, and it sometimes has a smaller -// encoding. +// We want to rewrite MOV64r0 in terms of MOV32r0, because it's sometimes a +// smaller encoding, but doing so at isel time interferes with rematerialization +// in the current register allocator. For now, this is rewritten when the +// instruction is lowered to an MCInst. // FIXME: AddedComplexity gives this a higher priority than MOV64ri32. Remove // when we have a better way to specify isel priority. -let AddedComplexity = 1 in -def : Pat<(i64 0), - (SUBREG_TO_REG (i64 0), (MOV32r0), x86_subreg_32bit)>; - - -// Materialize i64 constant where top 32-bits are zero. +let AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in +def MOV64r0 : I<0x31, MRMInitReg, (outs GR64:$dst), (ins), + "", + [(set GR64:$dst, 0)]>; + +// Materialize i64 constant where top 32-bits are zero. This could theoretically +// use MOV32ri with a SUBREG_TO_REG to represent the zero-extension, however +// that would make it more difficult to rematerialize. let AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src), "", [(set GR64:$dst, i64immZExt32:$src)]>; Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=93158&r1=93157&r2=93158&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Mon Jan 11 11:37:57 2010 @@ -1019,12 +1019,16 @@ switch (Opc) { default: break; case X86::MOV8r0: - case X86::MOV32r0: { + case X86::MOV16r0: + case X86::MOV32r0: + case X86::MOV64r0: { if (!isSafeToClobberEFLAGS(MBB, I)) { switch (Opc) { default: break; case X86::MOV8r0: Opc = X86::MOV8ri; break; + case X86::MOV16r0: Opc = X86::MOV16ri; break; case X86::MOV32r0: Opc = X86::MOV32ri; break; + case X86::MOV64r0: Opc = X86::MOV64ri; break; } Clone = false; } @@ -2291,8 +2295,12 @@ OpcodeTablePtr = &RegOp2MemOpTable2Addr; isTwoAddrFold = true; } else if (i == 0) { // If operand 0 - if (MI->getOpcode() == X86::MOV32r0) + if (MI->getOpcode() == X86::MOV64r0) + NewMI = MakeM0Inst(*this, X86::MOV64mi32, MOs, MI); + else if (MI->getOpcode() == X86::MOV32r0) NewMI = MakeM0Inst(*this, X86::MOV32mi, MOs, MI); + else if (MI->getOpcode() == X86::MOV16r0) + NewMI = MakeM0Inst(*this, X86::MOV16mi, MOs, MI); else if (MI->getOpcode() == X86::MOV8r0) NewMI = MakeM0Inst(*this, X86::MOV8mi, MOs, MI); if (NewMI) @@ -2560,7 +2568,9 @@ } else if (OpNum == 0) { // If operand 0 switch (Opc) { case X86::MOV8r0: + case X86::MOV16r0: case X86::MOV32r0: + case X86::MOV64r0: return true; default: break; } Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=93158&r1=93157&r2=93158&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon Jan 11 11:37:57 2010 @@ -3718,18 +3718,21 @@ def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "xor{b}\t$dst, $dst", [(set GR8:$dst, 0)]>; + +// We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller +// encoding and avoids a partial-register update sometimes, but doing so +// at isel time interferes with rematerialization in the current register +// allocator. For now, this is rewritten when the instruction is lowered +// to an MCInst. +def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins), + "", + [(set GR16:$dst, 0)]>, OpSize; def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "xor{l}\t$dst, $dst", [(set GR32:$dst, 0)]>; } -// Use xorl instead of xorw since we don't care about the high 16 bits, -// it's smaller, and it avoids a partial-register update. -let AddedComplexity = 1 in -def : Pat<(i16 0), - (EXTRACT_SUBREG (MOV32r0), x86_subreg_16bit)>; - //===----------------------------------------------------------------------===// // Thread Local Storage Instructions // Added: llvm/trunk/test/CodeGen/X86/remat-mov-0.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/remat-mov-0.ll?rev=93158&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/remat-mov-0.ll (added) +++ llvm/trunk/test/CodeGen/X86/remat-mov-0.ll Mon Jan 11 11:37:57 2010 @@ -0,0 +1,13 @@ +; RUN: llc < %s -march=x86-64 | grep {xorl %edi, %edi} | count 4 + +; CodeGen should remat the zero instead of spilling it. + +declare void @foo(i64 %p) + +define void @bar() nounwind { + call void @foo(i64 0) + call void @foo(i64 0) + call void @foo(i64 0) + call void @foo(i64 0) + ret void +} From clattner at apple.com Mon Jan 11 11:47:25 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 11 Jan 2010 09:47:25 -0800 Subject: [llvm-commits] [llvm] r93158 - in /llvm/trunk: lib/Target/X86/AsmPrinter/X86MCInstLower.cpp lib/Target/X86/X86ISelDAGToDAG.cpp lib/Target/X86/X86Instr64bit.td lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/remat-mov-0.ll In-Reply-To: <201001111737.o0BHbwQE003369@zion.cs.uiuc.edu> References: <201001111737.o0BHbwQE003369@zion.cs.uiuc.edu> Message-ID: <0AC13F0A-44E9-4F7E-9BE9-F0A4E95975B1@apple.com> On Jan 11, 2010, at 9:37 AM, Dan Gohman wrote: > Author: djg > Date: Mon Jan 11 11:37:57 2010 > New Revision: 93158 > > URL: http://llvm.org/viewvc/llvm-project?rev=93158&view=rev > Log: > Re-instate MOV64r0 and MOV16r0, with adjustments to work with the > new AsmPrinter. This is perhaps less elegant than describing them > in terms of MOV32r0 and subreg operations, but it allows the > current register to rematerialize them. Yuck, but ok. Thanks for the testcase. -Chris From gohman at apple.com Mon Jan 11 11:58:34 2010 From: gohman at apple.com (Dan Gohman) Date: Mon, 11 Jan 2010 17:58:34 -0000 Subject: [llvm-commits] [llvm] r93160 - in /llvm/trunk: lib/Target/X86/X86Instr64bit.td test/CodeGen/X86/x86-64-and-mask.ll Message-ID: <201001111758.o0BHwZJV004046@zion.cs.uiuc.edu> Author: djg Date: Mon Jan 11 11:58:34 2010 New Revision: 93160 URL: http://llvm.org/viewvc/llvm-project?rev=93160&view=rev Log: Use a 32-bit and with implicit zero-extension instead of a 64-bit and if it has an immediate with at least 32 bits of leading zeros, to avoid needing to materialize that immediate in a register first. FileCheckize, tidy, and extend a testcase to cover this case. This fixes rdar://7527390. Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td llvm/trunk/test/CodeGen/X86/x86-64-and-mask.ll Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=93160&r1=93159&r2=93160&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Mon Jan 11 11:58:34 2010 @@ -1966,6 +1966,17 @@ def : Pat<(store (add (loadi64 addr:$dst), 0x00000000800000000), addr:$dst), (SUB64mi32 addr:$dst, 0xffffffff80000000)>; +// Use a 32-bit and with implicit zero-extension instead of a 64-bit and if it +// has an immediate with at least 32 bits of leading zeros, to avoid needing to +// materialize that immediate in a register first. +def : Pat<(and GR64:$src, i64immZExt32:$imm), + (SUBREG_TO_REG + (i64 0), + (AND32ri + (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit), + imm:$imm), + x86_subreg_32bit)>; + // r & (2^32-1) ==> movz def : Pat<(and GR64:$src, 0x00000000FFFFFFFF), (MOVZX64rr32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit))>; Modified: llvm/trunk/test/CodeGen/X86/x86-64-and-mask.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-and-mask.ll?rev=93160&r1=93159&r2=93160&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/x86-64-and-mask.ll (original) +++ llvm/trunk/test/CodeGen/X86/x86-64-and-mask.ll Mon Jan 11 11:58:34 2010 @@ -1,12 +1,49 @@ -; RUN: llc < %s | grep {movl.*%edi, %eax} -; This should be a single mov, not a load of immediate + andq. +; RUN: llc < %s | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" target triple = "x86_64-apple-darwin8" -define i64 @test(i64 %x) nounwind { +; This should be a single mov, not a load of immediate + andq. +; CHECK: test: +; CHECK: movl %edi, %eax + +define i64 @test(i64 %x) nounwind { entry: %tmp123 = and i64 %x, 4294967295 ; [#uses=1] ret i64 %tmp123 } +; This copy can't be coalesced away because it needs the implicit zero-extend. +; CHECK: bbb: +; CHECK: movl %edi, %edi + +define void @bbb(i64 %x) nounwind { + %t = and i64 %x, 4294967295 + call void @foo(i64 %t) + ret void +} + +; This should use a 32-bit and with implicit zero-extension, not a 64-bit and +; with a separate mov to materialize the mask. +; rdar://7527390 +; CHECK: ccc: +; CHECK: andl $-1048593, %edi + +declare void @foo(i64 %x) nounwind + +define void @ccc(i64 %x) nounwind { + %t = and i64 %x, 4293918703 + call void @foo(i64 %t) + ret void +} + +; This requires a mov and a 64-bit and. +; CHECK: ddd: +; CHECK: movabsq $4294967296, %rax +; CHECK: andq %rax, %rdi + +define void @ddd(i64 %x) nounwind { + %t = and i64 %x, 4294967296 + call void @foo(i64 %t) + ret void +} From espindola at google.com Mon Jan 11 12:01:50 2010 From: espindola at google.com (Rafael Espindola) Date: Mon, 11 Jan 2010 13:01:50 -0500 Subject: [llvm-commits] patch: teach deadargelim to work on externally visible functions! In-Reply-To: <9CB6D70E-01C5-47F5-A653-AF124335F800@apple.com> References: <4B414C2D.90407@mxc.ca> <473850DE-AA5B-4CDC-89DE-3147ED5B4389@apple.com> <4B431B40.70000@gmail.com> <38a0d8451001101956w456eb09cjac5592767f1dce1@mail.gmail.com> <0539D449-D814-43AD-96F1-52D098F887E3@apple.com> <15330807-C640-4724-B433-C151CA4EF28A@apple.com> <38a0d8451001102038x6c86e9f9p57a1bef13d5f601f@mail.gmail.com> <38a0d8451001102059h7c463c82k35ef5aa62252e4bf@mail.gmail.com> <9CB6D70E-01C5-47F5-A653-AF124335F800@apple.com> Message-ID: <38a0d8451001111001s2a7952b4wd1c73af277605b3b@mail.gmail.com> >> *) Generate that linkage on ELF if the visibility is not hidden or protected >> *) Add the "strong but overridable" linkage you proposed. > > Sounds good. ?How is it different than our current "weak" linkage? It is a dynamic x static linker issue. The static linker will flag an error if two files define the same function for example. >> *) As an extension, add a >> protected-and-dont-care-about-pointer-compare that would be similar to >> the current state but drop the @PLT > > This is something that would be a useful extension in any case. ?Right now we may miscompile this code in some cases: > > static const char x[] = "foo"; > static const char y[] = "foo"; > int test() { return x == y; } > > Because we (incorrectly) merge the x and y decls. ?We don't want to merge user variables if they have their "address taken", but we do want to merge things like C string literals (char *X = "foo"). your idea is that we would lower static const char x[] = "foo"; to @x = internal constant [4 x i8] c"foo\00", align 1 and const char *x = "foo"; to @.str = private constant [4 x i8] c"foo\00", ***mergeable**** @x = global i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), align 8 Having a "mergeable" flag is probably useful, but mostly orthogonal to this issue I think. With a overridable and extern_overridable linkage type we could lower void __attribute__((visibility ("default"))) f(void); void __attribute__((visibility ("default"))) g(void) { f(); } to define overridable void @g() nounwind { entry: tail call void @f() nounwind ret void } declare extern_overridable void @f() The mergeble flag would be useful to mark functions that we know don't have the address taken so that we can merge them, but that is a different issue. A design question: Should we really add a new linkage type? We already have visibility in the IL. We could change mayBeOverridden to return true for the default visibility and lower to protected (or a new protected-and-don't-care-about-pointer-compare) by default. Another option is to go the other way and merge visibility into the linkage type. >> How does this work on Darwin btw? Function pointers are not guaranteed >> to compare when crossing shared library boundaries? > > On darwin you're not allowed to redefined something in a different dylib unless it is attribute(weak). ?Darwin uses a "two level namespace". ?This causes the static linker to resolve and remember which dylib a "use" comes from. ?If a third dylib starts defining that symbol, the use will still get the correct definition from the original defining dylib. ?This also makes dynamic symbol resolution more efficient at process start time. Very interesting design! > -Chris Cheers, -- Rafael ?vila de Esp?ndola From benny.kra at googlemail.com Mon Jan 11 12:03:25 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 11 Jan 2010 18:03:25 -0000 Subject: [llvm-commits] [llvm] r93161 - in /llvm/trunk: include/llvm/ADT/StringExtras.h lib/Support/StringExtras.cpp lib/Target/X86/X86ISelLowering.cpp lib/VMCore/Module.cpp tools/lto/LTOCodeGenerator.cpp utils/TableGen/CodeGenInstruction.cpp Message-ID: <201001111803.o0BI3PP5004207@zion.cs.uiuc.edu> Author: d0k Date: Mon Jan 11 12:03:24 2010 New Revision: 93161 URL: http://llvm.org/viewvc/llvm-project?rev=93161&view=rev Log: Reimplement getToken and SplitString as "StringRef helper functions" - getToken is modeled after StringRef::split but it can split on multiple separator chars and skips leading seperators. - SplitString is a StringRef::split variant for more than 2 elements with the same behaviour as getToken. Modified: llvm/trunk/include/llvm/ADT/StringExtras.h llvm/trunk/lib/Support/StringExtras.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/VMCore/Module.cpp llvm/trunk/tools/lto/LTOCodeGenerator.cpp llvm/trunk/utils/TableGen/CodeGenInstruction.cpp Modified: llvm/trunk/include/llvm/ADT/StringExtras.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringExtras.h?rev=93161&r1=93160&r2=93161&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringExtras.h (original) +++ llvm/trunk/include/llvm/ADT/StringExtras.h Mon Jan 11 12:03:24 2010 @@ -20,9 +20,9 @@ #include #include #include -#include namespace llvm { +template class SmallVectorImpl; /// hexdigit - Return the (uppercase) hexadecimal character for the /// given number \arg X (which should be less than 16). @@ -206,16 +206,16 @@ /// leading characters that appear in the Delimiters string, and ending the /// token at any of the characters that appear in the Delimiters string. If /// there are no tokens in the source string, an empty string is returned. -/// The Source source string is updated in place to remove the returned string -/// and any delimiter prefix from it. -std::string getToken(std::string &Source, - const char *Delimiters = " \t\n\v\f\r"); +/// The function returns a pair containing the extracted token and the +/// remaining tail string. +std::pair getToken(StringRef Source, + StringRef Delimiters = " \t\n\v\f\r"); /// SplitString - Split up the specified string according to the specified /// delimiters, appending the result fragments to the output list. -void SplitString(const std::string &Source, - std::vector &OutFragments, - const char *Delimiters = " \t\n\v\f\r"); +void SplitString(StringRef Source, + SmallVectorImpl &OutFragments, + StringRef Delimiters = " \t\n\v\f\r"); /// HashString - Hash funtion for strings. /// Modified: llvm/trunk/lib/Support/StringExtras.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringExtras.cpp?rev=93161&r1=93160&r2=93161&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringExtras.cpp (original) +++ llvm/trunk/lib/Support/StringExtras.cpp Mon Jan 11 12:03:24 2010 @@ -11,50 +11,40 @@ // //===----------------------------------------------------------------------===// -#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/SmallVector.h" -#include +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringExtras.h" using namespace llvm; /// getToken - This function extracts one token from source, ignoring any /// leading characters that appear in the Delimiters string, and ending the /// token at any of the characters that appear in the Delimiters string. If /// there are no tokens in the source string, an empty string is returned. -/// The Source source string is updated in place to remove the returned string -/// and any delimiter prefix from it. -std::string llvm::getToken(std::string &Source, const char *Delimiters) { - size_t NumDelimiters = std::strlen(Delimiters); - +/// The function returns a pair containing the extracted token and the +/// remaining tail string. +std::pair llvm::getToken(StringRef Source, + StringRef Delimiters) { // Figure out where the token starts. - std::string::size_type Start = - Source.find_first_not_of(Delimiters, 0, NumDelimiters); - if (Start == std::string::npos) Start = Source.size(); - - // Find the next occurance of the delimiter. - std::string::size_type End = - Source.find_first_of(Delimiters, Start, NumDelimiters); - if (End == std::string::npos) End = Source.size(); - - // Create the return token. - std::string Result = std::string(Source.begin()+Start, Source.begin()+End); + StringRef::size_type Start = Source.find_first_not_of(Delimiters); + if (Start == StringRef::npos) Start = Source.size(); - // Erase the token that we read in. - Source.erase(Source.begin(), Source.begin()+End); + // Find the next occurrence of the delimiter. + StringRef::size_type End = Source.find_first_of(Delimiters, Start); + if (End == StringRef::npos) End = Source.size(); - return Result; + return std::make_pair(Source.substr(Start, End), Source.substr(End)); } /// SplitString - Split up the specified string according to the specified /// delimiters, appending the result fragments to the output list. -void llvm::SplitString(const std::string &Source, - std::vector &OutFragments, - const char *Delimiters) { - std::string S = Source; - - std::string S2 = getToken(S, Delimiters); +void llvm::SplitString(StringRef Source, + SmallVectorImpl &OutFragments, + StringRef Delimiters) { + StringRef S2, S; + tie(S2, S) = getToken(Source, Delimiters); while (!S2.empty()) { OutFragments.push_back(S2); - S2 = getToken(S, Delimiters); + tie(S2, S) = getToken(S, Delimiters); } } Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=93161&r1=93160&r2=93161&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Jan 11 12:03:24 2010 @@ -9538,7 +9538,7 @@ std::string AsmStr = IA->getAsmString(); // TODO: should remove alternatives from the asmstring: "foo {a|b}" -> "foo a" - std::vector AsmPieces; + SmallVector AsmPieces; SplitString(AsmStr, AsmPieces, "\n"); // ; as separator? switch (AsmPieces.size()) { @@ -9575,7 +9575,7 @@ Constraints[0].Codes.size() == 1 && Constraints[0].Codes[0] == "A" && Constraints[1].Codes.size() == 1 && Constraints[1].Codes[0] == "0") { // bswap %eax / bswap %edx / xchgl %eax, %edx -> llvm.bswap.i64 - std::vector Words; + SmallVector Words; SplitString(AsmPieces[0], Words, " \t"); if (Words.size() == 2 && Words[0] == "bswap" && Words[1] == "%eax") { Words.clear(); Modified: llvm/trunk/lib/VMCore/Module.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=93161&r1=93160&r2=93161&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Module.cpp (original) +++ llvm/trunk/lib/VMCore/Module.cpp Mon Jan 11 12:03:24 2010 @@ -76,11 +76,12 @@ /// Target endian information... Module::Endianness Module::getEndianness() const { - std::string temp = DataLayout; + StringRef temp = DataLayout; Module::Endianness ret = AnyEndianness; while (!temp.empty()) { - std::string token = getToken(temp, "-"); + StringRef token = DataLayout; + tie(token, temp) = getToken(DataLayout, "-"); if (token[0] == 'e') { ret = LittleEndian; @@ -94,15 +95,17 @@ /// Target Pointer Size information... Module::PointerSize Module::getPointerSize() const { - std::string temp = DataLayout; + StringRef temp = DataLayout; Module::PointerSize ret = AnyPointerSize; while (!temp.empty()) { - std::string token = getToken(temp, "-"); - char signal = getToken(token, ":")[0]; + StringRef token, signalToken; + tie(token, temp) = getToken(temp, "-"); + tie(signalToken, token) = getToken(token, ":"); - if (signal == 'p') { - int size = atoi(getToken(token, ":").c_str()); + if (signalToken[0] == 'p') { + int size = 0; + getToken(token, ":").first.getAsInteger(10, size); if (size == 32) ret = Pointer32; else if (size == 64) Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=93161&r1=93160&r2=93161&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Mon Jan 11 12:03:24 2010 @@ -443,12 +443,12 @@ /// Optimize merged modules using various IPO passes void LTOCodeGenerator::setCodeGenDebugOptions(const char* options) { - std::string ops(options); - for (std::string o = getToken(ops); !o.empty(); o = getToken(ops)) { + for (std::pair o = getToken(options); + !o.first.empty(); o = getToken(o.second)) { // ParseCommandLineOptions() expects argv[0] to be program name. // Lazily add that. if ( _codegenOptions.empty() ) _codegenOptions.push_back("libLTO"); - _codegenOptions.push_back(strdup(o.c_str())); + _codegenOptions.push_back(strdup(o.first.str().c_str())); } } Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.cpp?rev=93161&r1=93160&r2=93161&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenInstruction.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenInstruction.cpp Mon Jan 11 12:03:24 2010 @@ -14,6 +14,7 @@ #include "CodeGenInstruction.h" #include "Record.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/STLExtras.h" #include using namespace llvm; @@ -224,7 +225,8 @@ // Parse the DisableEncoding field. std::string DisableEncoding = R->getValueAsString("DisableEncoding"); while (1) { - std::string OpName = getToken(DisableEncoding, " ,\t"); + std::string OpName; + tie(OpName, DisableEncoding) = getToken(DisableEncoding, " ,\t"); if (OpName.empty()) break; // Figure out which operand this is. From espindola at google.com Mon Jan 11 12:06:05 2010 From: espindola at google.com (Rafael Espindola) Date: Mon, 11 Jan 2010 13:06:05 -0500 Subject: [llvm-commits] patch: teach deadargelim to work on externally visible functions! In-Reply-To: <4B4B46BB.1040807@gmail.com> References: <4B414C2D.90407@mxc.ca> <4B41D1C5.9030805@gmail.com> <4B41E235.5050309@free.fr> <4B41E6A0.2050600@gmail.com> <4B41E903.10803@free.fr> <4B41EA8C.3040302@gmail.com> <473850DE-AA5B-4CDC-89DE-3147ED5B4389@apple.com> <4B431B40.70000@gmail.com> <38a0d8451001101958t64f6f544ua1c737f671419e79@mail.gmail.com> <4B4B46BB.1040807@gmail.com> Message-ID: <38a0d8451001111006m8c45977sf7919b9185fe87c3@mail.gmail.com> > Right, we shouldn't change the ELF visibility, however we could avoid > emitting the @PLT for in-module calls (Dan says in another mail that it > wouldn't > affect function pointer compares). It is probably a good option to have, but I am not sure it fully captures the semantics of protected. Consider -------------------------------- typedef void (*h)(void); void __attribute__((visibility ("protected"))) g(void); void f(void) { h p = g; p(); } ----------------------------- If the p=g assignment uses the PLT entry, the p() function call will be overwritten at runtime. Not sure how gcc avoids this. > Best regards, > --Edwin > > Cheers, -- Rafael ?vila de Esp?ndola From eli.friedman at gmail.com Mon Jan 11 12:19:43 2010 From: eli.friedman at gmail.com (Eli Friedman) Date: Mon, 11 Jan 2010 10:19:43 -0800 Subject: [llvm-commits] [llvm] r93151 - in /llvm/trunk: lib/Target/X86/X86.td lib/Target/X86/X86InstrSSE.td lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Subtarget.h test/CodeGen/X86/2010-01-07-UAMemFeature.ll In-Reply-To: <201001111629.o0BGThMZ000765@zion.cs.uiuc.edu> References: <201001111629.o0BGThMZ000765@zion.cs.uiuc.edu> Message-ID: On Mon, Jan 11, 2010 at 8:29 AM, David Greene wrote: > Author: greened > Date: Mon Jan 11 10:29:42 2010 > New Revision: 93151 > > URL: http://llvm.org/viewvc/llvm-project?rev=93151&view=rev > Log: > > Implement a feature (-vector-unaligned-mem) to allow targets to > ignore alignment requirements for SIMD memory operands. ?This > is useful on architectures like the AMD 10h that do not trap on > unaligned references if a status bit is twiddled at startup time. The testcase for this feature is way too big; could you come up with something smaller? -Eli From edwintorok at gmail.com Mon Jan 11 12:29:06 2010 From: edwintorok at gmail.com (=?UTF-8?B?VMO2csO2ayBFZHdpbg==?=) Date: Mon, 11 Jan 2010 20:29:06 +0200 Subject: [llvm-commits] patch: teach deadargelim to work on externally visible functions! In-Reply-To: <38a0d8451001111006m8c45977sf7919b9185fe87c3@mail.gmail.com> References: <4B414C2D.90407@mxc.ca> <4B41D1C5.9030805@gmail.com> <4B41E235.5050309@free.fr> <4B41E6A0.2050600@gmail.com> <4B41E903.10803@free.fr> <4B41EA8C.3040302@gmail.com> <473850DE-AA5B-4CDC-89DE-3147ED5B4389@apple.com> <4B431B40.70000@gmail.com> <38a0d8451001101958t64f6f544ua1c737f671419e79@mail.gmail.com> <4B4B46BB.1040807@gmail.com> <38a0d8451001111006m8c45977sf7919b9185fe87c3@mail.gmail.com> Message-ID: <4B4B6DF2.9020103@gmail.com> On 01/11/2010 08:06 PM, Rafael Espindola wrote: >> Right, we shouldn't change the ELF visibility, however we could avoid >> emitting the @PLT for in-module calls (Dan says in another mail that it >> wouldn't >> affect function pointer compares). >> > > It is probably a good option to have, but I am not sure it fully > captures the semantics of protected. Consider > > -------------------------------- > typedef void (*h)(void); > > void __attribute__((visibility ("protected"))) g(void); > void f(void) { > h p = g; > p(); > } > ----------------------------- > > If the p=g assignment uses the PLT entry, the p() function call will > be overwritten at runtime. Not sure how gcc avoids this. > > for -m64: - movq g at GOTPCREL(%rip), %rax + leaq g(%rip), %rax for -m32 - movl g at GOT(%ebx), %eax + leal g at GOTOFF(%ebx), %eax Not sure how the GOTOFF table works, but the 64-bit code is clear enough that g cannot be overridden. BTW I also found this in gcc manpage: "Note that due to ISO C++ specification requirements, operator new and operator delete must always be of default visibility." Best regards, --Edwin From benny.kra at googlemail.com Mon Jan 11 12:44:35 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 11 Jan 2010 18:44:35 -0000 Subject: [llvm-commits] [llvm] r93163 - in /llvm/trunk: include/llvm/ADT/StringExtras.h lib/Support/StringExtras.cpp Message-ID: <201001111844.o0BIiZGB005983@zion.cs.uiuc.edu> Author: d0k Date: Mon Jan 11 12:44:35 2010 New Revision: 93163 URL: http://llvm.org/viewvc/llvm-project?rev=93163&view=rev Log: Turns out llvm-gcc still uses SplitString with a vector. Add it back until I have a fix. Modified: llvm/trunk/include/llvm/ADT/StringExtras.h llvm/trunk/lib/Support/StringExtras.cpp Modified: llvm/trunk/include/llvm/ADT/StringExtras.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringExtras.h?rev=93163&r1=93162&r2=93163&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringExtras.h (original) +++ llvm/trunk/include/llvm/ADT/StringExtras.h Mon Jan 11 12:44:35 2010 @@ -20,6 +20,7 @@ #include #include #include +#include namespace llvm { template class SmallVectorImpl; @@ -217,6 +218,11 @@ SmallVectorImpl &OutFragments, StringRef Delimiters = " \t\n\v\f\r"); +// FIXME: remove when llvm-gcc doesn't use this anymore +void SplitString(StringRef Source, + std::vector &OutFragments, + StringRef Delimiters = " \t\n\v\f\r"); + /// HashString - Hash funtion for strings. /// /// This is the Bernstein hash function. Modified: llvm/trunk/lib/Support/StringExtras.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringExtras.cpp?rev=93163&r1=93162&r2=93163&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringExtras.cpp (original) +++ llvm/trunk/lib/Support/StringExtras.cpp Mon Jan 11 12:44:35 2010 @@ -48,6 +48,18 @@ } } +// FIXME: remove when llvm-gcc doesn't use this anymore +void llvm::SplitString(StringRef Source, + std::vector &OutFragments, + StringRef Delimiters) { + StringRef S2, S; + tie(S2, S) = getToken(Source, Delimiters); + while (!S2.empty()) { + OutFragments.push_back(S2); + tie(S2, S) = getToken(S, Delimiters); + } +} + void llvm::StringRef::split(SmallVectorImpl &A, StringRef Separators, int MaxSplit, bool KeepEmpty) const { From dpatel at apple.com Mon Jan 11 12:52:34 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 11 Jan 2010 18:52:34 -0000 Subject: [llvm-commits] [llvm] r93165 - in /llvm/trunk/lib: Bitcode/Reader/BitcodeReader.cpp CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <201001111852.o0BIqYOn006390@zion.cs.uiuc.edu> Author: dpatel Date: Mon Jan 11 12:52:33 2010 New Revision: 93165 URL: http://llvm.org/viewvc/llvm-project?rev=93165&view=rev Log: s/NextValueNo/NextMDValueNo while processing metadata. Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=93165&r1=93164&r2=93165&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Jan 11 12:52:33 2010 @@ -737,7 +737,7 @@ } bool BitcodeReader::ParseMetadata() { - unsigned NextValueNo = MDValueList.size(); + unsigned NextMDValueNo = MDValueList.size(); if (Stream.EnterSubBlock(bitc::METADATA_BLOCK_ID)) return Error("Malformed block record"); @@ -801,8 +801,7 @@ } Value *V = NamedMDNode::Create(Context, Name.str(), Elts.data(), Elts.size(), TheModule); - // FIXME: This shouldn't poke NextValueNo? - MDValueList.AssignValue(V, NextValueNo++); + MDValueList.AssignValue(V, NextMDValueNo++); break; } case bitc::METADATA_FN_NODE: @@ -826,7 +825,7 @@ Value *V = MDNode::getWhenValsUnresolved(Context, &Elts[0], Elts.size(), IsFunctionLocal); IsFunctionLocal = false; - MDValueList.AssignValue(V, NextValueNo++); + MDValueList.AssignValue(V, NextMDValueNo++); break; } case bitc::METADATA_STRING: { @@ -837,7 +836,7 @@ String[i] = Record[i]; Value *V = MDString::get(Context, StringRef(String.data(), String.size())); - MDValueList.AssignValue(V, NextValueNo++); + MDValueList.AssignValue(V, NextMDValueNo++); break; } case bitc::METADATA_KIND: { Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=93165&r1=93164&r2=93165&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Jan 11 12:52:33 2010 @@ -2138,13 +2138,14 @@ } // Clear debug info - CurrentFnDbgScope = NULL; - DbgScopeMap.clear(); - DbgScopeBeginMap.clear(); - DbgScopeEndMap.clear(); - ConcreteScopes.clear(); - AbstractScopesList.clear(); - + if (CurrentFnDbgScope) { + CurrentFnDbgScope = NULL; + DbgScopeMap.clear(); + DbgScopeBeginMap.clear(); + DbgScopeEndMap.clear(); + ConcreteScopes.clear(); + AbstractScopesList.clear(); + } Lines.clear(); if (TimePassesIsEnabled) From jyasskin at google.com Mon Jan 11 12:53:48 2010 From: jyasskin at google.com (Jeffrey Yasskin) Date: Mon, 11 Jan 2010 18:53:48 -0000 Subject: [llvm-commits] [llvm] r93167 - /llvm/trunk/docs/CodeGenerator.html Message-ID: <201001111853.o0BIrmug006449@zion.cs.uiuc.edu> Author: jyasskin Date: Mon Jan 11 12:53:47 2010 New Revision: 93167 URL: http://llvm.org/viewvc/llvm-project?rev=93167&view=rev Log: Update the -tailcallopt description to match djg's improvements to the calling convention. Modified: llvm/trunk/docs/CodeGenerator.html Modified: llvm/trunk/docs/CodeGenerator.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CodeGenerator.html?rev=93167&r1=93166&r2=93167&view=diff ============================================================================== --- llvm/trunk/docs/CodeGenerator.html (original) +++ llvm/trunk/docs/CodeGenerator.html Mon Jan 11 12:53:47 2010 @@ -1731,11 +1731,6 @@ (because one or more of above constraints are not met) to be followed by a readjustment of the stack. So performance might be worse in such cases.

-

On x86 and x86-64 one register is reserved for indirect tail calls (e.g via a - function pointer). So there is one less register for integer argument - passing. For x86 this means 2 registers (if inreg parameter - attribute is used) and for x86-64 this means 5 register are used.

-
From espindola at google.com Mon Jan 11 12:56:21 2010 From: espindola at google.com (Rafael Espindola) Date: Mon, 11 Jan 2010 13:56:21 -0500 Subject: [llvm-commits] patch: teach deadargelim to work on externally visible functions! In-Reply-To: <4B4B6DF2.9020103@gmail.com> References: <4B414C2D.90407@mxc.ca> <4B41E6A0.2050600@gmail.com> <4B41E903.10803@free.fr> <4B41EA8C.3040302@gmail.com> <473850DE-AA5B-4CDC-89DE-3147ED5B4389@apple.com> <4B431B40.70000@gmail.com> <38a0d8451001101958t64f6f544ua1c737f671419e79@mail.gmail.com> <4B4B46BB.1040807@gmail.com> <38a0d8451001111006m8c45977sf7919b9185fe87c3@mail.gmail.com> <4B4B6DF2.9020103@gmail.com> Message-ID: <38a0d8451001111056h4148de6aj177641af0d99933@mail.gmail.com> > for -m64: > - ? ? ? movq ? ?g at GOTPCREL(%rip), %rax > + ? ? ? leaq ? ?g(%rip), %rax This is very odd. Since a protected function can be used from another library this would create the need to patch the text segment in the dynamic linker. Trying to put the resulting .o in a shared library fails when using gnu ld: gcc -shared -o test.so test.c /usr/bin/ld: /tmp/ccqwpSKK.o: relocation R_X86_64_32S against `g' can not be used when making a shared object; recompile with -fPIC /tmp/ccqwpSKK.o: could not read symbols: Bad value My take is that protected is broken enough that we can implement a best effort :-) > > BTW I also found this in gcc manpage: > "Note that due to ISO C++ ?specification requirements, operator new and > operator delete must > always be of default visibility." > > Best regards, > --Edwin > Cheers, -- Rafael ?vila de Esp?ndola From dalej at apple.com Mon Jan 11 13:02:01 2010 From: dalej at apple.com (Dale Johannesen) Date: Mon, 11 Jan 2010 11:02:01 -0800 Subject: [llvm-commits] [llvm] r93030 - in /llvm/trunk: include/llvm/Target/Target.td include/llvm/Target/TargetInstrInfo.h utils/TableGen/CodeEmitterGen.cpp utils/TableGen/CodeGenTarget.cpp utils/TableGen/InstrInfoEmitter.cpp In-Reply-To: References: <201001082351.o08NpQLE025356@zion.cs.uiuc.edu> Message-ID: <347DB32D-58A0-44F1-9954-148C10D6C55D@apple.com> On Jan 8, 2010, at 11:21 PMPST, Chris Lattner wrote: > > On Jan 8, 2010, at 3:51 PM, Dale Johannesen wrote: > >> Author: johannes >> Date: Fri Jan 8 17:51:25 2010 >> New Revision: 93030 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=93030&view=rev >> Log: >> Add DEBUG_VALUE. Not used yet. > > Hi Dale, > > How do you envision this working? How will this represent memory > and register operands? It is intended to be a direct mapping of llvm.dbg.value as described in your 9/24/2009 document. I don't know most of the details yet. From jyasskin at google.com Mon Jan 11 13:19:26 2010 From: jyasskin at google.com (Jeffrey Yasskin) Date: Mon, 11 Jan 2010 19:19:26 -0000 Subject: [llvm-commits] [llvm] r93170 - /llvm/trunk/docs/LangRef.html Message-ID: <201001111919.o0BJJQEw007494@zion.cs.uiuc.edu> Author: jyasskin Date: Mon Jan 11 13:19:26 2010 New Revision: 93170 URL: http://llvm.org/viewvc/llvm-project?rev=93170&view=rev Log: Improve unclear bits and inaccuracies in structure and insertvalue documentation. Patch by Dustin Laurence! 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=93170&r1=93169&r2=93170&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Mon Jan 11 13:19:26 2010 @@ -1656,10 +1656,12 @@ underlying processor. The elements of a structure may be any type that has a size.

-

Structures are accessed using 'load and - 'store' by getting a pointer to a field with - the 'getelementptr' instruction.

- +

Structures in memory are accessed using 'load' + and 'store' by getting a pointer to a field + with the 'getelementptr' instruction. + Structures in registers are accessed using the + 'extractvalue' and + 'insertvalue' instructions.

Syntax:
   { <type list> }
@@ -3858,7 +3860,7 @@
 
 
Syntax:
-  <result> = insertvalue <aggregate type> <val>, <ty> <val>, <idx>    ; yields <n x <ty>>
+  <result> = insertvalue <aggregate type> <val>, <ty> <elt>, <idx>    ; yields <aggregate type>
 
Overview:
@@ -3883,7 +3885,8 @@
Example:
-  <result> = insertvalue {i32, float} %agg, i32 1, 0    ; yields {i32, float}
+  %agg1 = insertvalue {i32, float} undef, i32 1, 0         ; yields {i32 1, float undef}
+  %agg2 = insertvalue {i32, float} %agg1, float %val, 1    ; yields {i32 1, float %val}
 
From dpatel at apple.com Mon Jan 11 13:35:55 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 11 Jan 2010 19:35:55 -0000 Subject: [llvm-commits] [llvm] r93172 - /llvm/trunk/docs/LangRef.html Message-ID: <201001111935.o0BJZum0008199@zion.cs.uiuc.edu> Author: dpatel Date: Mon Jan 11 13:35:55 2010 New Revision: 93172 URL: http://llvm.org/viewvc/llvm-project?rev=93172&view=rev Log: Add top level section for named metadata. 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=93172&r1=93171&r2=93172&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Mon Jan 11 13:35:55 2010 @@ -43,6 +43,7 @@
  • Global Variables
  • Functions
  • Aliases
  • +
  • Named Metadata
  • Parameter Attributes
  • Function Attributes
  • Garbage Collector Names
  • @@ -85,12 +86,12 @@
  • Undefined Values
  • Addresses of Basic Blocks
  • Constant Expressions
  • -
  • Embedded Metadata
  • Other Values
    1. Inline Assembler Expressions
    2. +
    3. Metadata Nodes and Metadata Strings
  • Intrinsic Global Variables @@ -498,14 +499,19 @@ ; Call puts function to write out the string to stdout. call i32 @puts(i8 * %cast210) ; i32 - ret i32 0
    }
    + ret i32 0
    } + +; Named metadata +!1 = metadata !{i32 41} +!foo = !{!1, null}

    This example is made up of a global variable named - ".LC0", an external declaration of the "puts" function, and + ".LC0", an external declaration of the "puts" function, a function definition for - "main".

    + "main" and named metadata + "foo".

    In general, a module is made up of a list of global values, where both functions and global variables are global values. Global values are @@ -912,6 +918,27 @@ +

    + +
    + +

    Named metadata is a collection of metadata. Metadata + node and null are the only valid named metadata operands. + Metadata strings are not allowed as an named metadata operand.

    + +
    Syntax:
    +
    +
    +!1 = metadata !{metadata !"one"}
    +!name = !{null, !1}
    +
    +
    + +
    + +
    @@ -2314,12 +2341,12 @@
    -
    Embedded Metadata +
    -

    Embedded metadata provides a way to attach arbitrary data to the instruction +

    Metadata provides a way to attach arbitrary data to the instruction stream without affecting the behaviour of the program. There are two metadata primitives, strings and nodes. All metadata has the metadata type and is identified in syntax by a preceding exclamation @@ -2338,8 +2365,8 @@ event that a value is deleted, it will be replaced with a typeless "null", such as "metadata !{null, i32 10}".

    -

    A named metadata is a collection of metadata nodes. For example: "!foo = - metadata !{!4, !3}". +

    A named metadata is a collection of + metadata nodes. For example: "!foo = metadata !{!4, !3}".

    Optimizations may rely on metadata to provide additional information about the program that isn't available in the instructions, or that isn't easily From dpatel at apple.com Mon Jan 11 13:36:12 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 11 Jan 2010 11:36:12 -0800 Subject: [llvm-commits] [llvm] r92761 - in /llvm/trunk: docs/LangRef.html include/llvm/Metadata.h lib/AsmParser/LLParser.cpp lib/Bitcode/Reader/BitcodeReader.cpp lib/VMCore/Metadata.cpp unittests/VMCore/MetadataTest.cpp In-Reply-To: References: <201001052041.o05KfW1V024015@zion.cs.uiuc.edu> Message-ID: On Jan 8, 2010, at 11:45 AM, Chris Lattner wrote: >> +++ llvm/trunk/docs/LangRef.html Tue Jan 5 14:41:31 2010 > > You should also mention these in #modulestructure and add a top > level section to "High Level Structure" after #aliasstructure > describing these. Please describe what the constraints are on > these: the operand has to be an MDNode or null. > > @@ -2329,6 +2329,9 @@ >> event that a value is deleted, it will be replaced with a typeless >> "null", such as "metadata !{null, i32 10}".

    >> >> +

    A named metadata is a collection of metadata nodes. For >> example: "!foo = >> + metadata !{!4, !3}". > > Please link to the section you add above. > > In the TOC and in the document, Embedded Metadata should not be > listed under Constants anymore, it should move to Other Values. The > Embedded Metadata section should be renamed "Metadata Nodes and > Metadata Strings". Done. - Devang > From benny.kra at googlemail.com Mon Jan 11 13:45:19 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 11 Jan 2010 19:45:19 -0000 Subject: [llvm-commits] [llvm] r93174 - in /llvm/trunk: include/llvm/ADT/StringExtras.h lib/Support/StringExtras.cpp Message-ID: <201001111945.o0BJjJfe008583@zion.cs.uiuc.edu> Author: d0k Date: Mon Jan 11 13:45:18 2010 New Revision: 93174 URL: http://llvm.org/viewvc/llvm-project?rev=93174&view=rev Log: Add StrInStrNoCase, a StringRef version of CStrInCStrNoCase. Modified: llvm/trunk/include/llvm/ADT/StringExtras.h llvm/trunk/lib/Support/StringExtras.cpp Modified: llvm/trunk/include/llvm/ADT/StringExtras.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringExtras.h?rev=93174&r1=93173&r2=93174&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringExtras.h (original) +++ llvm/trunk/include/llvm/ADT/StringExtras.h Mon Jan 11 13:45:18 2010 @@ -203,6 +203,11 @@ return *I2 == '\0' ? s1 : 0; } +/// StrInStrNoCase - Portable version of strcasestr. Locates the first +/// occurrence of string 's1' in string 's2', ignoring case. Returns +/// the offset of s2 in s1 or npos if s2 cannot be found. +StringRef::size_type StrInStrNoCase(StringRef s1, StringRef s2); + /// getToken - This function extracts one token from source, ignoring any /// leading characters that appear in the Delimiters string, and ending the /// token at any of the characters that appear in the Delimiters string. If Modified: llvm/trunk/lib/Support/StringExtras.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringExtras.cpp?rev=93174&r1=93173&r2=93174&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringExtras.cpp (original) +++ llvm/trunk/lib/Support/StringExtras.cpp Mon Jan 11 13:45:18 2010 @@ -16,6 +16,19 @@ #include "llvm/ADT/StringExtras.h" using namespace llvm; +/// StrInStrNoCase - Portable version of strcasestr. Locates the first +/// occurrence of string 's1' in string 's2', ignoring case. Returns +/// the offset of s2 in s1 or npos if s2 cannot be found. +StringRef::size_type llvm::StrInStrNoCase(StringRef s1, StringRef s2) { + size_t N = s2.size(), M = s1.size(); + if (N > M) + return StringRef::npos; + for (size_t i = 0, e = M - N + 1; i != e; ++i) + if (s1.substr(i, N).equals_lower(s2)) + return i; + return StringRef::npos; +} + /// getToken - This function extracts one token from source, ignoring any /// leading characters that appear in the Delimiters string, and ending the /// token at any of the characters that appear in the Delimiters string. If From benny.kra at googlemail.com Mon Jan 11 13:47:09 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 11 Jan 2010 19:47:09 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93176 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <201001111947.o0BJl9aI008657@zion.cs.uiuc.edu> Author: d0k Date: Mon Jan 11 13:47:08 2010 New Revision: 93176 URL: http://llvm.org/viewvc/llvm-project?rev=93176&view=rev Log: Use the SmallVector SplitString overload. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=93176&r1=93175&r2=93176&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Jan 11 13:47:08 2010 @@ -434,9 +434,12 @@ std::vector LLVM_Optns; // Avoid deallocation before opts parsed! if (llvm_optns) { - SplitString(llvm_optns, LLVM_Optns); - for(unsigned i = 0, e = LLVM_Optns.size(); i != e; ++i) - Args.push_back(LLVM_Optns[i].c_str()); + llvm::SmallVector Buf; + SplitString(llvm_optns, Buf); + for(unsigned i = 0, e = Buf.size(); i != e; ++i) { + LLVM_Optns.push_back(Buf[i]); + Args.push_back(LLVM_Optns.back().c_str()); + } } Args.push_back(0); // Null terminator. From wangmp at apple.com Mon Jan 11 14:12:50 2010 From: wangmp at apple.com (Mon P Wang) Date: Mon, 11 Jan 2010 20:12:50 -0000 Subject: [llvm-commits] [llvm] r93180 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Message-ID: <201001112012.o0BKCoLn009697@zion.cs.uiuc.edu> Author: wangmp Date: Mon Jan 11 14:12:49 2010 New Revision: 93180 URL: http://llvm.org/viewvc/llvm-project?rev=93180&view=rev Log: Disable transformation of select of two loads to a select of address and then a load if the loads are not in the default address space because the transformation discards src value info. 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=93180&r1=93179&r2=93180&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Jan 11 14:12:49 2010 @@ -5792,35 +5792,48 @@ if (LLD->getMemoryVT() == RLD->getMemoryVT()) { // FIXME: this discards src value information. This is // over-conservative. It would be beneficial to be able to remember - // both potential memory locations. + // both potential memory locations. Since we are discarding + // src value info, don't do the transformation if the memory + // locations are not in the default address space. + unsigned LLDAddrSpace = 0, RLDAddrSpace = 0; + if (const Value *LLDVal = LLD->getMemOperand()->getValue()) { + if (const PointerType *PT = dyn_cast(LLDVal->getType())) + LLDAddrSpace = PT->getAddressSpace(); + } + if (const Value *RLDVal = RLD->getMemOperand()->getValue()) { + if (const PointerType *PT = dyn_cast(RLDVal->getType())) + RLDAddrSpace = PT->getAddressSpace(); + } SDValue Addr; - if (TheSelect->getOpcode() == ISD::SELECT) { - // Check that the condition doesn't reach either load. If so, folding - // this will induce a cycle into the DAG. - if ((!LLD->hasAnyUseOfValue(1) || - !LLD->isPredecessorOf(TheSelect->getOperand(0).getNode())) && - (!RLD->hasAnyUseOfValue(1) || - !RLD->isPredecessorOf(TheSelect->getOperand(0).getNode()))) { - Addr = DAG.getNode(ISD::SELECT, TheSelect->getDebugLoc(), - LLD->getBasePtr().getValueType(), - TheSelect->getOperand(0), LLD->getBasePtr(), - RLD->getBasePtr()); - } - } else { - // Check that the condition doesn't reach either load. If so, folding - // this will induce a cycle into the DAG. - if ((!LLD->hasAnyUseOfValue(1) || - (!LLD->isPredecessorOf(TheSelect->getOperand(0).getNode()) && - !LLD->isPredecessorOf(TheSelect->getOperand(1).getNode()))) && - (!RLD->hasAnyUseOfValue(1) || - (!RLD->isPredecessorOf(TheSelect->getOperand(0).getNode()) && - !RLD->isPredecessorOf(TheSelect->getOperand(1).getNode())))) { - Addr = DAG.getNode(ISD::SELECT_CC, TheSelect->getDebugLoc(), - LLD->getBasePtr().getValueType(), - TheSelect->getOperand(0), - TheSelect->getOperand(1), - LLD->getBasePtr(), RLD->getBasePtr(), - TheSelect->getOperand(4)); + if (LLDAddrSpace == 0 && RLDAddrSpace == 0) { + if (TheSelect->getOpcode() == ISD::SELECT) { + // Check that the condition doesn't reach either load. If so, folding + // this will induce a cycle into the DAG. + if ((!LLD->hasAnyUseOfValue(1) || + !LLD->isPredecessorOf(TheSelect->getOperand(0).getNode())) && + (!RLD->hasAnyUseOfValue(1) || + !RLD->isPredecessorOf(TheSelect->getOperand(0).getNode()))) { + Addr = DAG.getNode(ISD::SELECT, TheSelect->getDebugLoc(), + LLD->getBasePtr().getValueType(), + TheSelect->getOperand(0), LLD->getBasePtr(), + RLD->getBasePtr()); + } + } else { + // Check that the condition doesn't reach either load. If so, folding + // this will induce a cycle into the DAG. + if ((!LLD->hasAnyUseOfValue(1) || + (!LLD->isPredecessorOf(TheSelect->getOperand(0).getNode()) && + !LLD->isPredecessorOf(TheSelect->getOperand(1).getNode()))) && + (!RLD->hasAnyUseOfValue(1) || + (!RLD->isPredecessorOf(TheSelect->getOperand(0).getNode()) && + !RLD->isPredecessorOf(TheSelect->getOperand(1).getNode())))) { + Addr = DAG.getNode(ISD::SELECT_CC, TheSelect->getDebugLoc(), + LLD->getBasePtr().getValueType(), + TheSelect->getOperand(0), + TheSelect->getOperand(1), + LLD->getBasePtr(), RLD->getBasePtr(), + TheSelect->getOperand(4)); + } } } From evan.cheng at apple.com Mon Jan 11 14:18:04 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jan 2010 20:18:04 -0000 Subject: [llvm-commits] [llvm] r93182 - /llvm/trunk/lib/Target/X86/X86InstrInfo.td Message-ID: <201001112018.o0BKI48q009867@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jan 11 14:18:04 2010 New Revision: 93182 URL: http://llvm.org/viewvc/llvm-project?rev=93182&view=rev Log: Do not turn 8-bit OR to ADD since ADD8ri is not 3-addressfiable. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=93182&r1=93181&r2=93182&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon Jan 11 14:18:04 2010 @@ -1892,7 +1892,7 @@ def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2), "or{b}\t{$src2, $dst|$dst, $src2}", - [(set GR8:$dst, (or_not_add GR8:$src1, imm:$src2)), + [(set GR8:$dst, (or GR8:$src1, imm:$src2)), (implicit EFLAGS)]>; def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), @@ -4663,9 +4663,6 @@ (SETB_C32r)>; // (or x, c) -> (add x, c) if masked bits are known zero. -def : Pat<(parallel (or_is_add GR8:$src1, imm:$src2), - (implicit EFLAGS)), - (ADD8ri GR8:$src1, imm:$src2)>; def : Pat<(parallel (or_is_add GR16:$src1, imm:$src2), (implicit EFLAGS)), (ADD16ri GR16:$src1, imm:$src2)>; From benny.kra at googlemail.com Mon Jan 11 14:33:12 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 11 Jan 2010 20:33:12 -0000 Subject: [llvm-commits] [llvm] r93183 - in /llvm/trunk: include/llvm/ADT/StringExtras.h lib/Support/StringExtras.cpp Message-ID: <201001112033.o0BKXDIq010568@zion.cs.uiuc.edu> Author: d0k Date: Mon Jan 11 14:33:12 2010 New Revision: 93183 URL: http://llvm.org/viewvc/llvm-project?rev=93183&view=rev Log: Remove unused string functions. Modified: llvm/trunk/include/llvm/ADT/StringExtras.h llvm/trunk/lib/Support/StringExtras.cpp Modified: llvm/trunk/include/llvm/ADT/StringExtras.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringExtras.h?rev=93183&r1=93182&r2=93183&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringExtras.h (original) +++ llvm/trunk/include/llvm/ADT/StringExtras.h Mon Jan 11 14:33:12 2010 @@ -137,72 +137,6 @@ return result; } -/// StringsEqualNoCase - Return true if the two strings are equal, ignoring -/// case. -static inline bool StringsEqualNoCase(const std::string &LHS, - const std::string &RHS) { - if (LHS.size() != RHS.size()) return false; - for (unsigned i = 0, e = static_cast(LHS.size()); i != e; ++i) - if (tolower(LHS[i]) != tolower(RHS[i])) return false; - return true; -} - -/// StringsEqualNoCase - Return true if the two strings are equal, ignoring -/// case. -static inline bool StringsEqualNoCase(const std::string &LHS, - const char *RHS) { - for (unsigned i = 0, e = static_cast(LHS.size()); i != e; ++i) { - if (RHS[i] == 0) return false; // RHS too short. - if (tolower(LHS[i]) != tolower(RHS[i])) return false; - } - return RHS[LHS.size()] == 0; // Not too long? -} - -/// StringsEqualNoCase - Return true if the two null-terminated C strings are -/// equal, ignoring - -static inline bool StringsEqualNoCase(const char *LHS, const char *RHS, - unsigned len) { - - for (unsigned i = 0; i < len; ++i) { - if (tolower(LHS[i]) != tolower(RHS[i])) - return false; - - // If RHS[i] == 0 then LHS[i] == 0 or otherwise we would have returned - // at the previous branch as tolower('\0') == '\0'. - if (RHS[i] == 0) - return true; - } - - return true; -} - -/// CStrInCStrNoCase - Portable version of strcasestr. Locates the first -/// occurance of c-string 's2' in string 's1', ignoring case. Returns -/// NULL if 's2' cannot be found. -static inline const char* CStrInCStrNoCase(const char *s1, const char *s2) { - - // Are either strings NULL or empty? - if (!s1 || !s2 || s1[0] == '\0' || s2[0] == '\0') - return 0; - - if (s1 == s2) - return s1; - - const char *I1=s1, *I2=s2; - - while (*I1 != '\0' && *I2 != '\0' ) - if (tolower(*I1) != tolower(*I2)) { // No match. Start over. - ++s1; I1 = s1; I2 = s2; - } - else { // Character match. Advance to the next character. - ++I1; ++I2; - } - - // If we exhausted all of the characters in 's2', then 's2' appears in 's1'. - return *I2 == '\0' ? s1 : 0; -} - /// StrInStrNoCase - Portable version of strcasestr. Locates the first /// occurrence of string 's1' in string 's2', ignoring case. Returns /// the offset of s2 in s1 or npos if s2 cannot be found. @@ -223,11 +157,6 @@ SmallVectorImpl &OutFragments, StringRef Delimiters = " \t\n\v\f\r"); -// FIXME: remove when llvm-gcc doesn't use this anymore -void SplitString(StringRef Source, - std::vector &OutFragments, - StringRef Delimiters = " \t\n\v\f\r"); - /// HashString - Hash funtion for strings. /// /// This is the Bernstein hash function. Modified: llvm/trunk/lib/Support/StringExtras.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringExtras.cpp?rev=93183&r1=93182&r2=93183&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringExtras.cpp (original) +++ llvm/trunk/lib/Support/StringExtras.cpp Mon Jan 11 14:33:12 2010 @@ -61,18 +61,6 @@ } } -// FIXME: remove when llvm-gcc doesn't use this anymore -void llvm::SplitString(StringRef Source, - std::vector &OutFragments, - StringRef Delimiters) { - StringRef S2, S; - tie(S2, S) = getToken(Source, Delimiters); - while (!S2.empty()) { - OutFragments.push_back(S2); - tie(S2, S) = getToken(S, Delimiters); - } -} - void llvm::StringRef::split(SmallVectorImpl &A, StringRef Separators, int MaxSplit, bool KeepEmpty) const { From dag at cray.com Mon Jan 11 14:59:18 2010 From: dag at cray.com (David Greene) Date: Mon, 11 Jan 2010 14:59:18 -0600 Subject: [llvm-commits] [llvm] r93151 - in /llvm/trunk: lib/Target/X86/X86.td lib/Target/X86/X86InstrSSE.td lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Subtarget.h test/CodeGen/X86/2010-01-07-UAMemFeature.ll In-Reply-To: References: <201001111629.o0BGThMZ000765@zion.cs.uiuc.edu> Message-ID: <201001111459.19029.dag@cray.com> On Monday 11 January 2010 12:19, Eli Friedman wrote: > On Mon, Jan 11, 2010 at 8:29 AM, David Greene wrote: > > Author: greened > > Date: Mon Jan 11 10:29:42 2010 > > New Revision: 93151 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=93151&view=rev > > Log: > > > > Implement a feature (-vector-unaligned-mem) to allow targets to > > ignore alignment requirements for SIMD memory operands. ?This > > is useful on architectures like the AMD 10h that do not trap on > > unaligned references if a status bit is twiddled at startup time. > > The testcase for this feature is way too big; could you come up with > something smaller? I'll see what I can do. I might be able to turn off selected code restructuring passes in our vectorizer. BTW, what's the definition of "way too big?" -Dave From stoklund at 2pi.dk Mon Jan 11 15:02:33 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 11 Jan 2010 21:02:33 -0000 Subject: [llvm-commits] [llvm] r93184 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp test/CodeGen/X86/2010-01-11-ExtraPHIArg.ll Message-ID: <201001112102.o0BL2X6M011568@zion.cs.uiuc.edu> Author: stoklund Date: Mon Jan 11 15:02:33 2010 New Revision: 93184 URL: http://llvm.org/viewvc/llvm-project?rev=93184&view=rev Log: Avoid adding PHI arguments for a predecessor that has gone away when a BRCOND was constant folded. This fixes PR5980. Added: llvm/trunk/test/CodeGen/X86/2010-01-11-ExtraPHIArg.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=93184&r1=93183&r2=93184&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Jan 11 15:02:33 2010 @@ -1017,8 +1017,7 @@ for (unsigned j = 0, ej = SDB->BitTestCases[i].Cases.size(); j != ej; ++j) { MachineBasicBlock* cBB = SDB->BitTestCases[i].Cases[j].ThisBB; - if (cBB->succ_end() != - std::find(cBB->succ_begin(),cBB->succ_end(), PHIBB)) { + if (cBB->isSuccessor(PHIBB)) { PHI->addOperand(MachineOperand::CreateReg(SDB->PHINodesToUpdate[pi].second, false)); PHI->addOperand(MachineOperand::CreateMBB(cBB)); @@ -1067,7 +1066,7 @@ (MachineOperand::CreateMBB(SDB->JTCases[i].first.HeaderBB)); } // JT BB. Just iterate over successors here - if (BB->succ_end() != std::find(BB->succ_begin(),BB->succ_end(), PHIBB)) { + if (BB->isSuccessor(PHIBB)) { PHI->addOperand (MachineOperand::CreateReg(SDB->PHINodesToUpdate[pi].second, false)); PHI->addOperand(MachineOperand::CreateMBB(BB)); @@ -1113,17 +1112,23 @@ SDB->EdgeMapping.find(BB); if (EI != SDB->EdgeMapping.end()) ThisBB = EI->second; - for (MachineBasicBlock::iterator Phi = BB->begin(); - Phi != BB->end() && Phi->getOpcode() == TargetInstrInfo::PHI; ++Phi){ - // This value for this PHI node is recorded in PHINodesToUpdate, get it. - for (unsigned pn = 0; ; ++pn) { - assert(pn != SDB->PHINodesToUpdate.size() && - "Didn't find PHI entry!"); - if (SDB->PHINodesToUpdate[pn].first == Phi) { - Phi->addOperand(MachineOperand::CreateReg(SDB->PHINodesToUpdate[pn]. - second, false)); - Phi->addOperand(MachineOperand::CreateMBB(ThisBB)); - break; + + // BB may have been removed from the CFG if a branch was constant folded. + if (ThisBB->isSuccessor(BB)) { + for (MachineBasicBlock::iterator Phi = BB->begin(); + Phi != BB->end() && Phi->getOpcode() == TargetInstrInfo::PHI; + ++Phi) { + // This value for this PHI node is recorded in PHINodesToUpdate. + for (unsigned pn = 0; ; ++pn) { + assert(pn != SDB->PHINodesToUpdate.size() && + "Didn't find PHI entry!"); + if (SDB->PHINodesToUpdate[pn].first == Phi) { + Phi->addOperand(MachineOperand:: + CreateReg(SDB->PHINodesToUpdate[pn].second, + false)); + Phi->addOperand(MachineOperand::CreateMBB(ThisBB)); + break; + } } } } Added: llvm/trunk/test/CodeGen/X86/2010-01-11-ExtraPHIArg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-01-11-ExtraPHIArg.ll?rev=93184&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-01-11-ExtraPHIArg.ll (added) +++ llvm/trunk/test/CodeGen/X86/2010-01-11-ExtraPHIArg.ll Mon Jan 11 15:02:33 2010 @@ -0,0 +1,97 @@ +; RUN: llc -verify-machineinstrs < %s +; +; The lowering of a switch combined with constand folding would leave spurious extra arguments on a PHI instruction. +; +target triple = "x86_64-apple-darwin10" + +define void @foo() { + br label %cond_true813.i + +cond_true813.i: ; preds = %0 + br i1 false, label %cond_true818.i, label %cond_next1146.i + +cond_true818.i: ; preds = %cond_true813.i + br i1 false, label %recog_memoized.exit52, label %cond_next1146.i + +recog_memoized.exit52: ; preds = %cond_true818.i + switch i32 0, label %bb886.i.preheader [ + i32 0, label %bb907.i + i32 44, label %bb866.i + i32 103, label %bb874.i + i32 114, label %bb874.i + ] + +bb857.i: ; preds = %bb886.i, %bb866.i + %tmp862.i494.24 = phi i8* [ null, %bb866.i ], [ %tmp862.i494.26, %bb886.i ] ; [#uses=1] + switch i32 0, label %bb886.i.preheader [ + i32 0, label %bb907.i + i32 44, label %bb866.i + i32 103, label %bb874.i + i32 114, label %bb874.i + ] + +bb866.i.loopexit: ; preds = %bb874.i + br label %bb866.i + +bb866.i.loopexit31: ; preds = %cond_true903.i + br label %bb866.i + +bb866.i: ; preds = %bb866.i.loopexit31, %bb866.i.loopexit, %bb857.i, %recog_memoized.exit52 + br i1 false, label %bb907.i, label %bb857.i + +bb874.i.preheader.loopexit: ; preds = %cond_true903.i, %cond_true903.i + ret void + +bb874.i: ; preds = %bb857.i, %bb857.i, %recog_memoized.exit52, %recog_memoized.exit52 + switch i32 0, label %bb886.i.preheader.loopexit [ + i32 0, label %bb907.i + i32 44, label %bb866.i.loopexit + i32 103, label %bb874.i.backedge + i32 114, label %bb874.i.backedge + ] + +bb874.i.backedge: ; preds = %bb874.i, %bb874.i + ret void + +bb886.i.preheader.loopexit: ; preds = %bb874.i + ret void + +bb886.i.preheader: ; preds = %bb857.i, %recog_memoized.exit52 + %tmp862.i494.26 = phi i8* [ undef, %recog_memoized.exit52 ], [ %tmp862.i494.24, %bb857.i ] ; [#uses=1] + br label %bb886.i + +bb886.i: ; preds = %cond_true903.i, %bb886.i.preheader + br i1 false, label %bb857.i, label %cond_true903.i + +cond_true903.i: ; preds = %bb886.i + switch i32 0, label %bb886.i [ + i32 0, label %bb907.i + i32 44, label %bb866.i.loopexit31 + i32 103, label %bb874.i.preheader.loopexit + i32 114, label %bb874.i.preheader.loopexit + ] + +bb907.i: ; preds = %cond_true903.i, %bb874.i, %bb866.i, %bb857.i, %recog_memoized.exit52 + br i1 false, label %cond_next1146.i, label %cond_true910.i + +cond_true910.i: ; preds = %bb907.i + ret void + +cond_next1146.i: ; preds = %bb907.i, %cond_true818.i, %cond_true813.i + ret void + +bb2060.i: ; No predecessors! + br i1 false, label %cond_true2064.i, label %bb2067.i + +cond_true2064.i: ; preds = %bb2060.i + unreachable + +bb2067.i: ; preds = %bb2060.i + ret void + +cond_next3473: ; No predecessors! + ret void + +cond_next3521: ; No predecessors! + ret void +} From eli.friedman at gmail.com Mon Jan 11 15:11:32 2010 From: eli.friedman at gmail.com (Eli Friedman) Date: Mon, 11 Jan 2010 13:11:32 -0800 Subject: [llvm-commits] [llvm] r93151 - in /llvm/trunk: lib/Target/X86/X86.td lib/Target/X86/X86InstrSSE.td lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Subtarget.h test/CodeGen/X86/2010-01-07-UAMemFeature.ll In-Reply-To: <201001111459.19029.dag@cray.com> References: <201001111629.o0BGThMZ000765@zion.cs.uiuc.edu> <201001111459.19029.dag@cray.com> Message-ID: On Mon, Jan 11, 2010 at 12:59 PM, David Greene wrote: > On Monday 11 January 2010 12:19, Eli Friedman wrote: >> On Mon, Jan 11, 2010 at 8:29 AM, David Greene wrote: >> > Author: greened >> > Date: Mon Jan 11 10:29:42 2010 >> > New Revision: 93151 >> > >> > URL: http://llvm.org/viewvc/llvm-project?rev=93151&view=rev >> > Log: >> > >> > Implement a feature (-vector-unaligned-mem) to allow targets to >> > ignore alignment requirements for SIMD memory operands. ?This >> > is useful on architectures like the AMD 10h that do not trap on >> > unaligned references if a status bit is twiddled at startup time. >> >> The testcase for this feature is way too big; could you come up with >> something smaller? > > I'll see what I can do. ?I might be able to turn off selected code > restructuring passes in our vectorizer. > > BTW, what's the definition of "way too big?" Given the feature in question, anything more than 10 LLVM instructions qualifies as "way too big". Testcases are supposed to be feature tests, not real-world code. -Eli From evan.cheng at apple.com Mon Jan 11 15:12:06 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jan 2010 13:12:06 -0800 Subject: [llvm-commits] [llvm] r93158 - in /llvm/trunk: lib/Target/X86/AsmPrinter/X86MCInstLower.cpp lib/Target/X86/X86ISelDAGToDAG.cpp lib/Target/X86/X86Instr64bit.td lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/remat-mov-0.ll In-Reply-To: <201001111737.o0BHbwQE003369@zion.cs.uiuc.edu> References: <201001111737.o0BHbwQE003369@zion.cs.uiuc.edu> Message-ID: Dan, this is breaking a bunch of x86_64 tests. e.g. 464.h264ref. I'll back it out for now. Evan On Jan 11, 2010, at 9:37 AM, Dan Gohman wrote: > Author: djg > Date: Mon Jan 11 11:37:57 2010 > New Revision: 93158 > > URL: http://llvm.org/viewvc/llvm-project?rev=93158&view=rev > Log: > Re-instate MOV64r0 and MOV16r0, with adjustments to work with the > new AsmPrinter. This is perhaps less elegant than describing them > in terms of MOV32r0 and subreg operations, but it allows the > current register to rematerialize them. > > Added: > llvm/trunk/test/CodeGen/X86/remat-mov-0.ll > Modified: > llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp > llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp > llvm/trunk/lib/Target/X86/X86Instr64bit.td > llvm/trunk/lib/Target/X86/X86InstrInfo.cpp > llvm/trunk/lib/Target/X86/X86InstrInfo.td > > Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=93158&r1=93157&r2=93158&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) > +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Mon Jan 11 11:37:57 2010 > @@ -399,6 +399,14 @@ > OutMI.setOpcode(X86::MOVZX32rm16); > lower_subreg32(&OutMI, 0); > break; > + case X86::MOV16r0: > + OutMI.setOpcode(X86::MOV32r0); > + lower_subreg32(&OutMI, 0); > + break; > + case X86::MOV64r0: > + OutMI.setOpcode(X86::MOV32r0); > + lower_subreg32(&OutMI, 0); > + break; > } > } > > > Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=93158&r1=93157&r2=93158&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Mon Jan 11 11:37:57 2010 > @@ -1873,7 +1873,6 @@ > > unsigned LoReg, HiReg, ClrReg; > unsigned ClrOpcode, SExtOpcode; > - EVT ClrVT = NVT; > switch (NVT.getSimpleVT().SimpleTy) { > default: llvm_unreachable("Unsupported VT!"); > case MVT::i8: > @@ -1883,7 +1882,7 @@ > break; > case MVT::i16: > LoReg = X86::AX; HiReg = X86::DX; > - ClrOpcode = X86::MOV32r0; ClrReg = X86::EDX; ClrVT = MVT::i32; > + ClrOpcode = X86::MOV16r0; ClrReg = X86::DX; > SExtOpcode = X86::CWD; > break; > case MVT::i32: > @@ -1893,7 +1892,7 @@ > break; > case MVT::i64: > LoReg = X86::RAX; ClrReg = HiReg = X86::RDX; > - ClrOpcode = ~0U; // NOT USED. > + ClrOpcode = X86::MOV64r0; > SExtOpcode = X86::CQO; > break; > } > @@ -1932,24 +1931,8 @@ > SDValue(CurDAG->getMachineNode(SExtOpcode, dl, MVT::Flag, InFlag),0); > } else { > // Zero out the high part, effectively zero extending the input. > - SDValue ClrNode; > - > - if (NVT.getSimpleVT() == MVT::i64) { > - ClrNode = SDValue(CurDAG->getMachineNode(X86::MOV32r0, dl, MVT::i32), > - 0); > - // We just did a 32-bit clear, insert it into a 64-bit register to > - // clear the whole 64-bit reg. > - SDValue Zero = CurDAG->getTargetConstant(0, MVT::i64); > - SDValue SubRegNo = > - CurDAG->getTargetConstant(X86::SUBREG_32BIT, MVT::i32); > - ClrNode = > - SDValue(CurDAG->getMachineNode(TargetInstrInfo::SUBREG_TO_REG, dl, > - MVT::i64, Zero, ClrNode, SubRegNo), > - 0); > - } else { > - ClrNode = SDValue(CurDAG->getMachineNode(ClrOpcode, dl, ClrVT), 0); > - } > - > + SDValue ClrNode = > + SDValue(CurDAG->getMachineNode(ClrOpcode, dl, NVT), 0); > InFlag = CurDAG->getCopyToReg(CurDAG->getEntryNode(), dl, ClrReg, > ClrNode, InFlag).getValue(1); > } > > Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=93158&r1=93157&r2=93158&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) > +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Mon Jan 11 11:37:57 2010 > @@ -1598,17 +1598,20 @@ > // Alias Instructions > //===----------------------------------------------------------------------===// > > -// Alias instructions that map movr0 to xor. Use xorl instead of xorq; it's > -// equivalent due to implicit zero-extending, and it sometimes has a smaller > -// encoding. > +// We want to rewrite MOV64r0 in terms of MOV32r0, because it's sometimes a > +// smaller encoding, but doing so at isel time interferes with rematerialization > +// in the current register allocator. For now, this is rewritten when the > +// instruction is lowered to an MCInst. > // FIXME: AddedComplexity gives this a higher priority than MOV64ri32. Remove > // when we have a better way to specify isel priority. > -let AddedComplexity = 1 in > -def : Pat<(i64 0), > - (SUBREG_TO_REG (i64 0), (MOV32r0), x86_subreg_32bit)>; > - > - > -// Materialize i64 constant where top 32-bits are zero. > +let AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in > +def MOV64r0 : I<0x31, MRMInitReg, (outs GR64:$dst), (ins), > + "", > + [(set GR64:$dst, 0)]>; > + > +// Materialize i64 constant where top 32-bits are zero. This could theoretically > +// use MOV32ri with a SUBREG_TO_REG to represent the zero-extension, however > +// that would make it more difficult to rematerialize. > let AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in > def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src), > "", [(set GR64:$dst, i64immZExt32:$src)]>; > > Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=93158&r1=93157&r2=93158&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Mon Jan 11 11:37:57 2010 > @@ -1019,12 +1019,16 @@ > switch (Opc) { > default: break; > case X86::MOV8r0: > - case X86::MOV32r0: { > + case X86::MOV16r0: > + case X86::MOV32r0: > + case X86::MOV64r0: { > if (!isSafeToClobberEFLAGS(MBB, I)) { > switch (Opc) { > default: break; > case X86::MOV8r0: Opc = X86::MOV8ri; break; > + case X86::MOV16r0: Opc = X86::MOV16ri; break; > case X86::MOV32r0: Opc = X86::MOV32ri; break; > + case X86::MOV64r0: Opc = X86::MOV64ri; break; > } > Clone = false; > } > @@ -2291,8 +2295,12 @@ > OpcodeTablePtr = &RegOp2MemOpTable2Addr; > isTwoAddrFold = true; > } else if (i == 0) { // If operand 0 > - if (MI->getOpcode() == X86::MOV32r0) > + if (MI->getOpcode() == X86::MOV64r0) > + NewMI = MakeM0Inst(*this, X86::MOV64mi32, MOs, MI); > + else if (MI->getOpcode() == X86::MOV32r0) > NewMI = MakeM0Inst(*this, X86::MOV32mi, MOs, MI); > + else if (MI->getOpcode() == X86::MOV16r0) > + NewMI = MakeM0Inst(*this, X86::MOV16mi, MOs, MI); > else if (MI->getOpcode() == X86::MOV8r0) > NewMI = MakeM0Inst(*this, X86::MOV8mi, MOs, MI); > if (NewMI) > @@ -2560,7 +2568,9 @@ > } else if (OpNum == 0) { // If operand 0 > switch (Opc) { > case X86::MOV8r0: > + case X86::MOV16r0: > case X86::MOV32r0: > + case X86::MOV64r0: > return true; > default: break; > } > > Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=93158&r1=93157&r2=93158&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) > +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon Jan 11 11:37:57 2010 > @@ -3718,18 +3718,21 @@ > def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), > "xor{b}\t$dst, $dst", > [(set GR8:$dst, 0)]>; > + > +// We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller > +// encoding and avoids a partial-register update sometimes, but doing so > +// at isel time interferes with rematerialization in the current register > +// allocator. For now, this is rewritten when the instruction is lowered > +// to an MCInst. > +def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins), > + "", > + [(set GR16:$dst, 0)]>, OpSize; > > def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), > "xor{l}\t$dst, $dst", > [(set GR32:$dst, 0)]>; > } > > -// Use xorl instead of xorw since we don't care about the high 16 bits, > -// it's smaller, and it avoids a partial-register update. > -let AddedComplexity = 1 in > -def : Pat<(i16 0), > - (EXTRACT_SUBREG (MOV32r0), x86_subreg_16bit)>; > - > //===----------------------------------------------------------------------===// > // Thread Local Storage Instructions > // > > Added: llvm/trunk/test/CodeGen/X86/remat-mov-0.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/remat-mov-0.ll?rev=93158&view=auto > > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/remat-mov-0.ll (added) > +++ llvm/trunk/test/CodeGen/X86/remat-mov-0.ll Mon Jan 11 11:37:57 2010 > @@ -0,0 +1,13 @@ > +; RUN: llc < %s -march=x86-64 | grep {xorl %edi, %edi} | count 4 > + > +; CodeGen should remat the zero instead of spilling it. > + > +declare void @foo(i64 %p) > + > +define void @bar() nounwind { > + call void @foo(i64 0) > + call void @foo(i64 0) > + call void @foo(i64 0) > + call void @foo(i64 0) > + ret void > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Mon Jan 11 15:13:42 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jan 2010 21:13:42 -0000 Subject: [llvm-commits] [llvm] r93185 - in /llvm/trunk: lib/Target/X86/AsmPrinter/X86MCInstLower.cpp lib/Target/X86/X86ISelDAGToDAG.cpp lib/Target/X86/X86Instr64bit.td lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/remat-mov-0.ll Message-ID: <201001112113.o0BLDh5K012008@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jan 11 15:13:41 2010 New Revision: 93185 URL: http://llvm.org/viewvc/llvm-project?rev=93185&view=rev Log: Revert 93158. It's breaking quite a few x86_64 tests. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/trunk/lib/Target/X86/X86Instr64bit.td llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.td llvm/trunk/test/CodeGen/X86/remat-mov-0.ll Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=93185&r1=93184&r2=93185&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Mon Jan 11 15:13:41 2010 @@ -399,14 +399,6 @@ OutMI.setOpcode(X86::MOVZX32rm16); lower_subreg32(&OutMI, 0); break; - case X86::MOV16r0: - OutMI.setOpcode(X86::MOV32r0); - lower_subreg32(&OutMI, 0); - break; - case X86::MOV64r0: - OutMI.setOpcode(X86::MOV32r0); - lower_subreg32(&OutMI, 0); - break; } } Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=93185&r1=93184&r2=93185&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Mon Jan 11 15:13:41 2010 @@ -1873,6 +1873,7 @@ unsigned LoReg, HiReg, ClrReg; unsigned ClrOpcode, SExtOpcode; + EVT ClrVT = NVT; switch (NVT.getSimpleVT().SimpleTy) { default: llvm_unreachable("Unsupported VT!"); case MVT::i8: @@ -1882,7 +1883,7 @@ break; case MVT::i16: LoReg = X86::AX; HiReg = X86::DX; - ClrOpcode = X86::MOV16r0; ClrReg = X86::DX; + ClrOpcode = X86::MOV32r0; ClrReg = X86::EDX; ClrVT = MVT::i32; SExtOpcode = X86::CWD; break; case MVT::i32: @@ -1892,7 +1893,7 @@ break; case MVT::i64: LoReg = X86::RAX; ClrReg = HiReg = X86::RDX; - ClrOpcode = X86::MOV64r0; + ClrOpcode = ~0U; // NOT USED. SExtOpcode = X86::CQO; break; } @@ -1931,8 +1932,24 @@ SDValue(CurDAG->getMachineNode(SExtOpcode, dl, MVT::Flag, InFlag),0); } else { // Zero out the high part, effectively zero extending the input. - SDValue ClrNode = - SDValue(CurDAG->getMachineNode(ClrOpcode, dl, NVT), 0); + SDValue ClrNode; + + if (NVT.getSimpleVT() == MVT::i64) { + ClrNode = SDValue(CurDAG->getMachineNode(X86::MOV32r0, dl, MVT::i32), + 0); + // We just did a 32-bit clear, insert it into a 64-bit register to + // clear the whole 64-bit reg. + SDValue Zero = CurDAG->getTargetConstant(0, MVT::i64); + SDValue SubRegNo = + CurDAG->getTargetConstant(X86::SUBREG_32BIT, MVT::i32); + ClrNode = + SDValue(CurDAG->getMachineNode(TargetInstrInfo::SUBREG_TO_REG, dl, + MVT::i64, Zero, ClrNode, SubRegNo), + 0); + } else { + ClrNode = SDValue(CurDAG->getMachineNode(ClrOpcode, dl, ClrVT), 0); + } + InFlag = CurDAG->getCopyToReg(CurDAG->getEntryNode(), dl, ClrReg, ClrNode, InFlag).getValue(1); } Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=93185&r1=93184&r2=93185&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Mon Jan 11 15:13:41 2010 @@ -1598,20 +1598,17 @@ // Alias Instructions //===----------------------------------------------------------------------===// -// We want to rewrite MOV64r0 in terms of MOV32r0, because it's sometimes a -// smaller encoding, but doing so at isel time interferes with rematerialization -// in the current register allocator. For now, this is rewritten when the -// instruction is lowered to an MCInst. +// Alias instructions that map movr0 to xor. Use xorl instead of xorq; it's +// equivalent due to implicit zero-extending, and it sometimes has a smaller +// encoding. // FIXME: AddedComplexity gives this a higher priority than MOV64ri32. Remove // when we have a better way to specify isel priority. -let AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in -def MOV64r0 : I<0x31, MRMInitReg, (outs GR64:$dst), (ins), - "", - [(set GR64:$dst, 0)]>; - -// Materialize i64 constant where top 32-bits are zero. This could theoretically -// use MOV32ri with a SUBREG_TO_REG to represent the zero-extension, however -// that would make it more difficult to rematerialize. +let AddedComplexity = 1 in +def : Pat<(i64 0), + (SUBREG_TO_REG (i64 0), (MOV32r0), x86_subreg_32bit)>; + + +// Materialize i64 constant where top 32-bits are zero. let AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src), "", [(set GR64:$dst, i64immZExt32:$src)]>; Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=93185&r1=93184&r2=93185&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Mon Jan 11 15:13:41 2010 @@ -1019,16 +1019,12 @@ switch (Opc) { default: break; case X86::MOV8r0: - case X86::MOV16r0: - case X86::MOV32r0: - case X86::MOV64r0: { + case X86::MOV32r0: { if (!isSafeToClobberEFLAGS(MBB, I)) { switch (Opc) { default: break; case X86::MOV8r0: Opc = X86::MOV8ri; break; - case X86::MOV16r0: Opc = X86::MOV16ri; break; case X86::MOV32r0: Opc = X86::MOV32ri; break; - case X86::MOV64r0: Opc = X86::MOV64ri; break; } Clone = false; } @@ -2295,12 +2291,8 @@ OpcodeTablePtr = &RegOp2MemOpTable2Addr; isTwoAddrFold = true; } else if (i == 0) { // If operand 0 - if (MI->getOpcode() == X86::MOV64r0) - NewMI = MakeM0Inst(*this, X86::MOV64mi32, MOs, MI); - else if (MI->getOpcode() == X86::MOV32r0) + if (MI->getOpcode() == X86::MOV32r0) NewMI = MakeM0Inst(*this, X86::MOV32mi, MOs, MI); - else if (MI->getOpcode() == X86::MOV16r0) - NewMI = MakeM0Inst(*this, X86::MOV16mi, MOs, MI); else if (MI->getOpcode() == X86::MOV8r0) NewMI = MakeM0Inst(*this, X86::MOV8mi, MOs, MI); if (NewMI) @@ -2568,9 +2560,7 @@ } else if (OpNum == 0) { // If operand 0 switch (Opc) { case X86::MOV8r0: - case X86::MOV16r0: case X86::MOV32r0: - case X86::MOV64r0: return true; default: break; } Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=93185&r1=93184&r2=93185&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon Jan 11 15:13:41 2010 @@ -3718,21 +3718,18 @@ def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "xor{b}\t$dst, $dst", [(set GR8:$dst, 0)]>; - -// We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller -// encoding and avoids a partial-register update sometimes, but doing so -// at isel time interferes with rematerialization in the current register -// allocator. For now, this is rewritten when the instruction is lowered -// to an MCInst. -def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins), - "", - [(set GR16:$dst, 0)]>, OpSize; def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "xor{l}\t$dst, $dst", [(set GR32:$dst, 0)]>; } +// Use xorl instead of xorw since we don't care about the high 16 bits, +// it's smaller, and it avoids a partial-register update. +let AddedComplexity = 1 in +def : Pat<(i16 0), + (EXTRACT_SUBREG (MOV32r0), x86_subreg_16bit)>; + //===----------------------------------------------------------------------===// // Thread Local Storage Instructions // Modified: llvm/trunk/test/CodeGen/X86/remat-mov-0.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/remat-mov-0.ll?rev=93185&r1=93184&r2=93185&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/remat-mov-0.ll (original) +++ llvm/trunk/test/CodeGen/X86/remat-mov-0.ll Mon Jan 11 15:13:41 2010 @@ -1,4 +1,5 @@ ; RUN: llc < %s -march=x86-64 | grep {xorl %edi, %edi} | count 4 +; XFAIL: * ; CodeGen should remat the zero instead of spilling it. From resistor at mac.com Mon Jan 11 15:13:30 2010 From: resistor at mac.com (Owen Anderson) Date: Mon, 11 Jan 2010 13:13:30 -0800 Subject: [llvm-commits] [llvm] r93151 - in /llvm/trunk: lib/Target/X86/X86.td lib/Target/X86/X86InstrSSE.td lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Subtarget.h test/CodeGen/X86/2010-01-07-UAMemFeature.ll In-Reply-To: <201001111459.19029.dag@cray.com> References: <201001111629.o0BGThMZ000765@zion.cs.uiuc.edu> <201001111459.19029.dag@cray.com> Message-ID: <0168EDD4-FC81-42F6-9E7A-A459D7BD733D@mac.com> On Jan 11, 2010, at 12:59 PM, David Greene wrote: > On Monday 11 January 2010 12:19, Eli Friedman wrote: >> On Mon, Jan 11, 2010 at 8:29 AM, David Greene wrote: >>> Author: greened >>> Date: Mon Jan 11 10:29:42 2010 >>> New Revision: 93151 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=93151&view=rev >>> Log: >>> >>> Implement a feature (-vector-unaligned-mem) to allow targets to >>> ignore alignment requirements for SIMD memory operands. This >>> is useful on architectures like the AMD 10h that do not trap on >>> unaligned references if a status bit is twiddled at startup time. >> >> The testcase for this feature is way too big; could you come up with >> something smaller? > > I'll see what I can do. I might be able to turn off selected code > restructuring passes in our vectorizer. > > BTW, what's the definition of "way too big?" My working definition would be that a regression test should be small enough that, if it fails, a human can look at it and tell (without lots of effort) why it's failing. --Owen From greened at obbligato.org Mon Jan 11 15:50:35 2010 From: greened at obbligato.org (David Greene) Date: Mon, 11 Jan 2010 21:50:35 -0000 Subject: [llvm-commits] [llvm] r93187 - /llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll Message-ID: <201001112150.o0BLoZsO013526@zion.cs.uiuc.edu> Author: greened Date: Mon Jan 11 15:50:35 2010 New Revision: 93187 URL: http://llvm.org/viewvc/llvm-project?rev=93187&view=rev Log: Shorten up this testcase. Modified: llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll Modified: llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll?rev=93187&r1=93186&r2=93187&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll Mon Jan 11 15:50:35 2010 @@ -6,233 +6,10 @@ define i32 @foo(i32 %n1, float* %A2, float* %B3, float* %C4) { "file loop.c, line 1, bb1": ; srcLine 1 - %n = alloca i32, align 4 ; [#uses=2] ; [oox.12 : sln.1] - %A = alloca float*, align 8 ; [#uses=2] ; [oox.13 : sln.1] - %B = alloca float*, align 8 ; [#uses=2] ; [oox.14 : sln.1] - %C = alloca float*, align 8 ; [#uses=2] ; [oox.15 : sln.1] - %i = alloca i32, align 4 ; [#uses=0] ; [oox.24 : sln.1] - %"$CSVL_V0" = alloca i64, align 8 ; [#uses=2] ; [oox.38 : sln.1] - %"$TC_1" = alloca i64, align 8 ; [#uses=3] ; [oox.43 : sln.1] - %"$LIS_S5" = alloca i64, align 8 ; [#uses=2] ; [oox.54 : sln.1] - %"$LIS_S7" = alloca i64, align 8 ; [#uses=2] ; [oox.56 : sln.1] - %"$LIS_S8" = alloca i64, align 8 ; [#uses=2] ; [oox.57 : sln.1] - %"$LIS_S9" = alloca i64, align 8 ; [#uses=2] ; [oox.58 : sln.1] - %"$LIS_S15" = alloca i64, align 8 ; [#uses=3] ; [oox.64 : sln.1] - %"$LIS_S17" = alloca i64, align 8 ; [#uses=3] ; [oox.66 : sln.1] - %"$LIS_S18" = alloca i64, align 8 ; [#uses=3] ; [oox.67 : sln.1] - %"$LIS_S19" = alloca i64, align 8 ; [#uses=2] ; [oox.68 : sln.1] - %"$LIS_S20" = alloca i64, align 8 ; [#uses=2] ; [oox.69 : sln.1] - %"$LIS_S21" = alloca i64, align 8 ; [#uses=2] ; [oox.70 : sln.1] - %"$MR_n_0" = alloca i32, align 4 ; [#uses=7] ; [oox.72 : sln.1] - %"$MR_C_1" = alloca float*, align 8 ; [#uses=5] ; [oox.73 : sln.1] - %"$MR_A_2" = alloca float*, align 8 ; [#uses=6] ; [oox.74 : sln.1] - %"$MR_B_3" = alloca float*, align 8 ; [#uses=5] ; [oox.75 : sln.1] - %"$LCS_0" = alloca i64, align 8 ; [#uses=6] ; [oox.82 : sln.1] - %"$LCS_1" = alloca i64, align 8 ; [#uses=5] ; [oox.83 : sln.1] - %"$LCS_2" = alloca i64, align 8 ; [#uses=3] ; [oox.84 : sln.1] - %"$LCS_1_3" = alloca i64, align 8 ; [#uses=3] ; [oox.85 : sln.1] %"$LCS_4" = alloca i64, align 8 ; [#uses=5] ; [oox.86 : sln.1] %"$LCS_5" = alloca i64, align 8 ; [#uses=5] ; [oox.87 : sln.1] %"$LCS_6" = alloca i64, align 8 ; [#uses=5] ; [oox.88 : sln.1] - %"$LCS_n_7" = alloca i64, align 8 ; [#uses=3] ; [oox.89 : sln.1] - %"$i_S23" = alloca i64, align 8 ; [#uses=15] ; [oox.90 : sln.1] - %"$LC_S24" = alloca i64, align 8 ; [#uses=9] ; [oox.91 : sln.1] - %"$SI_S25" = alloca i64, align 8 ; [#uses=11] ; [oox.92 : sln.1] - store i32 %n1, i32* %n, align 4 ; [oox.12 : sln.1] - store float* %A2, float** %A, align 8 ; [oox.13 : sln.1] - store float* %B3, float** %B, align 8 ; [oox.14 : sln.1] - store float* %C4, float** %C, align 8 ; [oox.15 : sln.1] - br label %"file loop.c, line 1, bb69" ; [oox.0 : sln.0] -"file loop.c, line 1, bb69": ; srcLine 1 ; preds = %"file loop.c, line 1, bb1" - %r = load i32* %n, align 4 ; [#uses=1] ; [oox.190 : sln.5] - store i32 %r, i32* %"$MR_n_0", align 4 ; [oox.190 : sln.5] - %r5 = load i32* %"$MR_n_0", align 4 ; [#uses=1] ; [oox.191 : sln.5] - %r6 = icmp sge i32 0, %r5 ; [#uses=1] ; [oox.191 : sln.5] - %r7 = zext i1 %r6 to i32 ; [#uses=1] ; [oox.191 : sln.5] - %r8 = icmp ne i32 %r7, 0 ; [#uses=1] ; [oox.191 : sln.5] - br i1 %r8, label %"file loop.c, line 5, bb6", label %"file loop.c, line 1, bb3" ; [oox.191 : sln.5] - -"file loop.c, line 1, bb3": ; srcLine 1 ; preds = %"file loop.c, line 1, bb69" - br label %"file loop.c, line 5, bb28" ; [oox.0 : sln.0] - -"file loop.c, line 5, bb28": ; srcLine 5 ; preds = %"file loop.c, line 1, bb3" - store i64 0, i64* %"$i_S23", align 8 ; [oox.189 : sln.5] - %r9 = load float** %C, align 8 ; [#uses=1] ; [oox.190 : sln.5] - store float* %r9, float** %"$MR_C_1", align 8 ; [oox.190 : sln.5] - %r10 = load float** %A, align 8 ; [#uses=1] ; [oox.191 : sln.5] - store float* %r10, float** %"$MR_A_2", align 8 ; [oox.191 : sln.5] - %r11 = load float** %B, align 8 ; [#uses=1] ; [oox.192 : sln.5] - store float* %r11, float** %"$MR_B_3", align 8 ; [oox.192 : sln.5] - %r12 = load float** %"$MR_A_2", align 8 ; [#uses=1] ; [oox.193 : sln.5] - %r13 = load float** %"$MR_C_1", align 8 ; [#uses=1] ; [oox.193 : sln.5] - %r14 = ptrtoint float* %r12 to i64 ; [#uses=1] ; [oox.193 : sln.5] - %r15 = ptrtoint float* %r13 to i64 ; [#uses=1] ; [oox.193 : sln.5] - %r16 = sub i64 %r14, %r15 ; [#uses=1] ; [oox.193 : sln.5] - %r17 = sdiv i64 %r16, 4 ; [#uses=1] ; [oox.193 : sln.5] - store i64 %r17, i64* %"$LCS_0", align 8 ; [oox.193 : sln.5] - %r18 = load float** %"$MR_A_2", align 8 ; [#uses=1] ; [oox.194 : sln.5] - %r19 = load float** %"$MR_B_3", align 8 ; [#uses=1] ; [oox.194 : sln.5] - %r20 = ptrtoint float* %r18 to i64 ; [#uses=1] ; [oox.194 : sln.5] - %r21 = ptrtoint float* %r19 to i64 ; [#uses=1] ; [oox.194 : sln.5] - %r22 = sub i64 %r20, %r21 ; [#uses=1] ; [oox.194 : sln.5] - %r23 = sdiv i64 %r22, 4 ; [#uses=1] ; [oox.194 : sln.5] - store i64 %r23, i64* %"$LCS_1", align 8 ; [oox.194 : sln.5] - %r24 = load i32* %"$MR_n_0", align 4 ; [#uses=1] ; [oox.195 : sln.5] - %r25 = sext i32 %r24 to i64 ; [#uses=1] ; [oox.195 : sln.5] - %r26 = add i64 -1, %r25 ; [#uses=1] ; [oox.195 : sln.5] - store i64 %r26, i64* %"$LCS_1_3", align 8 ; [oox.195 : sln.5] - %r27 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.196 : sln.5] - %r28 = icmp sgt i64 %r27, 0 ; [#uses=1] ; [oox.196 : sln.5] - %r29 = zext i1 %r28 to i64 ; [#uses=1] ; [oox.196 : sln.5] - %r30 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.196 : sln.5] - %r31 = load i64* %"$LCS_1_3", align 8 ; [#uses=1] ; [oox.196 : sln.5] - %r32 = icmp sle i64 %r30, %r31 ; [#uses=1] ; [oox.196 : sln.5] - %r33 = zext i1 %r32 to i32 ; [#uses=1] ; [oox.196 : sln.5] - %r34 = sext i32 %r33 to i64 ; [#uses=1] ; [oox.196 : sln.5] - %r35 = and i64 %r29, %r34 ; [#uses=1] ; [oox.196 : sln.5] - %r36 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.196 : sln.5] - %r37 = icmp sle i64 %r36, 4 ; [#uses=1] ; [oox.196 : sln.5] - %r38 = zext i1 %r37 to i32 ; [#uses=1] ; [oox.196 : sln.5] - %r39 = sext i32 %r38 to i64 ; [#uses=1] ; [oox.196 : sln.5] - %r40 = and i64 %r35, %r39 ; [#uses=1] ; [oox.196 : sln.5] - store i64 %r40, i64* %"$LCS_2", align 8 ; [oox.196 : sln.5] - %r41 = load i64* %"$LCS_1", align 8 ; [#uses=1] ; [oox.197 : sln.5] - %r42 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.197 : sln.5] - %r43 = load i64* %"$LCS_2", align 8 ; [#uses=1] ; [oox.197 : sln.5] - %r44 = icmp ne i64 %r43, 0 ; [#uses=1] ; [oox.197 : sln.5] - %r45 = select i1 %r44, i64 %r42, i64 4 ; [#uses=1] ; [oox.197 : sln.5] - %r46 = load i64* %"$LCS_1", align 8 ; [#uses=1] ; [oox.197 : sln.5] - %r47 = icmp sgt i64 %r46, 0 ; [#uses=1] ; [oox.197 : sln.5] - %r48 = zext i1 %r47 to i64 ; [#uses=1] ; [oox.197 : sln.5] - %r49 = load i64* %"$LCS_1", align 8 ; [#uses=1] ; [oox.197 : sln.5] - %r50 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.197 : sln.5] - %r51 = load i64* %"$LCS_2", align 8 ; [#uses=1] ; [oox.197 : sln.5] - %r52 = icmp ne i64 %r51, 0 ; [#uses=1] ; [oox.197 : sln.5] - %r53 = select i1 %r52, i64 %r50, i64 4 ; [#uses=1] ; [oox.197 : sln.5] - %r54 = icmp sle i64 %r49, %r53 ; [#uses=1] ; [oox.197 : sln.5] - %r55 = zext i1 %r54 to i32 ; [#uses=1] ; [oox.197 : sln.5] - %r56 = load i64* %"$LCS_1", align 8 ; [#uses=1] ; [oox.197 : sln.5] - %r57 = load i64* %"$LCS_1_3", align 8 ; [#uses=1] ; [oox.197 : sln.5] - %r58 = icmp sle i64 %r56, %r57 ; [#uses=1] ; [oox.197 : sln.5] - %r59 = zext i1 %r58 to i32 ; [#uses=1] ; [oox.197 : sln.5] - %r60 = and i32 %r55, %r59 ; [#uses=1] ; [oox.197 : sln.5] - %r61 = sext i32 %r60 to i64 ; [#uses=1] ; [oox.197 : sln.5] - %r62 = and i64 %r48, %r61 ; [#uses=1] ; [oox.197 : sln.5] - %r63 = icmp ne i64 %r62, 0 ; [#uses=1] ; [oox.197 : sln.5] - %r64 = select i1 %r63, i64 %r41, i64 %r45 ; [#uses=1] ; [oox.197 : sln.5] - store i64 %r64, i64* %"$CSVL_V0", align 8 ; [oox.197 : sln.5] - %r65 = load i64* %"$CSVL_V0", align 8 ; [#uses=1] ; [oox.198 : sln.5] - %r66 = icmp sgt i64 %r65, 4 ; [#uses=1] ; [oox.198 : sln.5] - %r67 = zext i1 %r66 to i32 ; [#uses=1] ; [oox.198 : sln.5] - %r68 = icmp ne i32 %r67, 0 ; [#uses=1] ; [oox.198 : sln.5] - br i1 %r68, label %"file loop.c, line 1, bb26", label %"file loop.c, line 1, bb27" ; [oox.198 : sln.5] - -"file loop.c, line 1, bb27": ; srcLine 1 ; preds = %"file loop.c, line 5, bb28" - br label %"file loop.c, line 5, bb55" ; [oox.0 : sln.0] - -"file loop.c, line 5, bb55": ; srcLine 5 ; preds = %"file loop.c, line 1, bb27" - %r69 = load i32* %"$MR_n_0", align 4 ; [#uses=1] ; [oox.189 : sln.5] - %r70 = sext i32 %r69 to i64 ; [#uses=1] ; [oox.189 : sln.5] - store i64 %r70, i64* %"$LIS_S9", align 8 ; [oox.189 : sln.5] - %r71 = load float** %"$MR_B_3", align 8 ; [#uses=1] ; [oox.190 : sln.6] - %r72 = ptrtoint float* %r71 to i64 ; [#uses=1] ; [oox.190 : sln.6] - store i64 %r72, i64* %"$LIS_S5", align 8 ; [oox.190 : sln.6] - %r73 = load float** %"$MR_C_1", align 8 ; [#uses=1] ; [oox.191 : sln.6] - %r74 = ptrtoint float* %r73 to i64 ; [#uses=1] ; [oox.191 : sln.6] - store i64 %r74, i64* %"$LIS_S7", align 8 ; [oox.191 : sln.6] - %r75 = load float** %"$MR_A_2", align 8 ; [#uses=1] ; [oox.192 : sln.6] - %r76 = ptrtoint float* %r75 to i64 ; [#uses=1] ; [oox.192 : sln.6] - store i64 %r76, i64* %"$LIS_S8", align 8 ; [oox.192 : sln.6] - br label %"file loop.c, line 1, in inner loop at depth 0, bb29" ; [oox.0 : sln.0] - -"file loop.c, line 1, in inner loop at depth 0, bb29": ; srcLine 1 ; preds = %"file loop.c, line 5, in inner loop at depth 0, bb32", %"file loop.c, line 5, bb55" - br label %"file loop.c, line 5, in inner loop at depth 0, bb32" ; [oox.0 : sln.0] - -"file loop.c, line 5, in inner loop at depth 0, bb32": ; srcLine 5 ; preds = %"file loop.c, line 1, in inner loop at depth 0, bb29" - %r77 = load i64* %"$LIS_S7", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r78 = inttoptr i64 %r77 to float* ; [#uses=1] ; [oox.189 : sln.6] - %r79 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r80 = getelementptr float* %r78, i64 %r79 ; [#uses=1] ; [oox.189 : sln.6] - %r81 = load float* %r80, align 4 ; [#uses=1] ; [oox.189 : sln.6] - %r82 = load i64* %"$LIS_S5", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r83 = inttoptr i64 %r82 to float* ; [#uses=1] ; [oox.189 : sln.6] - %r84 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r85 = getelementptr float* %r83, i64 %r84 ; [#uses=1] ; [oox.189 : sln.6] - %r86 = load float* %r85, align 4 ; [#uses=1] ; [oox.189 : sln.6] - %r87 = add float %r81, %r86 ; [#uses=1] ; [oox.189 : sln.6] - %r88 = load i64* %"$LIS_S8", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r89 = inttoptr i64 %r88 to float* ; [#uses=1] ; [oox.189 : sln.6] - %r90 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r91 = getelementptr float* %r89, i64 %r90 ; [#uses=1] ; [oox.189 : sln.6] - store float %r87, float* %r91, align 4 ; [oox.189 : sln.6] - %r92 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.190 : sln.5] - %r93 = add i64 1, %r92 ; [#uses=1] ; [oox.190 : sln.5] - store i64 %r93, i64* %"$i_S23", align 8 ; [oox.190 : sln.5] - %r94 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.191 : sln.5] - %r95 = load i64* %"$LIS_S9", align 8 ; [#uses=1] ; [oox.191 : sln.5] - %r96 = icmp slt i64 %r94, %r95 ; [#uses=1] ; [oox.191 : sln.5] - %r97 = zext i1 %r96 to i64 ; [#uses=1] ; [oox.191 : sln.5] - %r98 = icmp ne i64 %r97, 0 ; [#uses=1] ; [oox.191 : sln.5] - br i1 %r98, label %"file loop.c, line 1, in inner loop at depth 0, bb29", label %"file loop.c, line 5, bb6" ; [oox.191 : sln.5] - -"file loop.c, line 1, bb26": ; srcLine 1 ; preds = %"file loop.c, line 5, bb28" - br label %"file loop.c, line 5, bb48" ; [oox.0 : sln.0] - -"file loop.c, line 5, bb48": ; srcLine 5 ; preds = %"file loop.c, line 1, bb26" - %r99 = load i32* %"$MR_n_0", align 4 ; [#uses=1] ; [oox.189 : sln.5] - %r100 = sext i32 %r99 to i64 ; [#uses=1] ; [oox.189 : sln.5] - %r101 = icmp slt i64 %r100, 4 ; [#uses=1] ; [oox.189 : sln.5] - %r102 = zext i1 %r101 to i32 ; [#uses=1] ; [oox.189 : sln.5] - %r103 = icmp ne i32 %r102, 0 ; [#uses=1] ; [oox.189 : sln.5] - br i1 %r103, label %"file loop.c, line 5, bb50", label %"file loop.c, line 1, bb47" ; [oox.189 : sln.5] - -"file loop.c, line 1, bb47": ; srcLine 1 ; preds = %"file loop.c, line 5, bb48" - br label %"file loop.c, line 5, bb60" ; [oox.0 : sln.0] - -"file loop.c, line 5, bb60": ; srcLine 5 ; preds = %"file loop.c, line 1, bb47" - %r104 = load i32* %"$MR_n_0", align 4 ; [#uses=1] ; [oox.189 : sln.5] - %r105 = sext i32 %r104 to i64 ; [#uses=1] ; [oox.189 : sln.5] - %r106 = and i64 -4, %r105 ; [#uses=1] ; [oox.189 : sln.5] - store i64 %r106, i64* %"$TC_1", align 8 ; [oox.189 : sln.5] - %r107 = load i64* %"$TC_1", align 8 ; [#uses=1] ; [oox.190 : sln.5] - %r108 = sub i64 0, %r107 ; [#uses=1] ; [oox.190 : sln.5] - store i64 %r108, i64* %"$LC_S24", align 8 ; [oox.190 : sln.5] - store i64 0, i64* %"$SI_S25", align 8 ; [oox.191 : sln.5] - %r109 = load float** %"$MR_C_1", align 8 ; [#uses=1] ; [oox.192 : sln.6] - %r110 = ptrtoint float* %r109 to i64 ; [#uses=1] ; [oox.192 : sln.6] - store i64 %r110, i64* %"$LIS_S15", align 8 ; [oox.192 : sln.6] - %r111 = load float** %"$MR_B_3", align 8 ; [#uses=1] ; [oox.193 : sln.6] - %r112 = ptrtoint float* %r111 to i64 ; [#uses=1] ; [oox.193 : sln.6] - store i64 %r112, i64* %"$LIS_S17", align 8 ; [oox.193 : sln.6] - %r113 = load float** %"$MR_A_2", align 8 ; [#uses=1] ; [oox.194 : sln.6] - %r114 = ptrtoint float* %r113 to i64 ; [#uses=1] ; [oox.194 : sln.6] - store i64 %r114, i64* %"$LIS_S18", align 8 ; [oox.194 : sln.6] - %r115 = load i64* %"$LC_S24", align 8 ; [#uses=1] ; [oox.195 : sln.5] - %r116 = icmp sge i64 %r115, -15 ; [#uses=1] ; [oox.195 : sln.5] - %r117 = zext i1 %r116 to i32 ; [#uses=1] ; [oox.195 : sln.5] - %r118 = icmp ne i32 %r117, 0 ; [#uses=1] ; [oox.195 : sln.5] - br i1 %r118, label %"file loop.c, line 5, bb64", label %"file loop.c, line 1, bb61" ; [oox.195 : sln.5] - -"file loop.c, line 1, bb61": ; srcLine 1 ; preds = %"file loop.c, line 5, bb60" - br label %"file loop.c, line 1, in inner vector loop at depth 0, bb58" ; [oox.0 : sln.0] - -"file loop.c, line 1, in inner vector loop at depth 0, bb58": ; srcLine 1 ; preds = %"file loop.c, line 6, in inner vector loop at depth 0, bb59", %"file loop.c, line 1, bb61" - br label %"file loop.c, line 6, in inner vector loop at depth 0, bb59" ; [oox.0 : sln.0] - -"file loop.c, line 6, in inner vector loop at depth 0, bb59": ; srcLine 6 ; preds = %"file loop.c, line 1, in inner vector loop at depth 0, bb58" - %r119 = load i64* %"$LIS_S15", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r120 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r121 = add i64 %r119, %r120 ; [#uses=1] ; [oox.189 : sln.6] - store i64 %r121, i64* %"$LCS_4", align 8 ; [oox.189 : sln.6] - %r122 = load i64* %"$LIS_S17", align 8 ; [#uses=1] ; [oox.190 : sln.6] - %r123 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.190 : sln.6] - %r124 = add i64 %r122, %r123 ; [#uses=1] ; [oox.190 : sln.6] - store i64 %r124, i64* %"$LCS_5", align 8 ; [oox.190 : sln.6] - %r125 = load i64* %"$LIS_S18", align 8 ; [#uses=1] ; [oox.191 : sln.6] - %r126 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.191 : sln.6] - %r127 = add i64 %r125, %r126 ; [#uses=1] ; [oox.191 : sln.6] - store i64 %r127, i64* %"$LCS_6", align 8 ; [oox.191 : sln.6] %r128 = load i64* %"$LCS_4", align 8 ; [#uses=1] ; [oox.192 : sln.6] %r129 = inttoptr i64 %r128 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.192 : sln.6] %r130 = load <4 x float>* %r129, align 4 ; <<4 x float>> [#uses=1] ; [oox.192 : sln.6] @@ -243,160 +20,5 @@ %r135 = load i64* %"$LCS_6", align 8 ; [#uses=1] ; [oox.192 : sln.6] %r136 = inttoptr i64 %r135 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.192 : sln.6] store <4 x float> %r134, <4 x float>* %r136, align 4 ; [oox.192 : sln.6] - %r137 = load i64* %"$LCS_4", align 8 ; [#uses=1] ; [oox.193 : sln.6] - %r138 = add i64 16, %r137 ; [#uses=1] ; [oox.193 : sln.6] - %r139 = inttoptr i64 %r138 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.193 : sln.6] - %r140 = load <4 x float>* %r139, align 4 ; <<4 x float>> [#uses=1] ; [oox.193 : sln.6] - %r141 = load i64* %"$LCS_5", align 8 ; [#uses=1] ; [oox.193 : sln.6] - %r142 = add i64 16, %r141 ; [#uses=1] ; [oox.193 : sln.6] - %r143 = inttoptr i64 %r142 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.193 : sln.6] - %r144 = load <4 x float>* %r143, align 4 ; <<4 x float>> [#uses=1] ; [oox.193 : sln.6] - %r145 = add <4 x float> %r140, %r144 ; <<4 x float>> [#uses=1] ; [oox.193 : sln.6] - %r146 = load i64* %"$LCS_6", align 8 ; [#uses=1] ; [oox.193 : sln.6] - %r147 = add i64 16, %r146 ; [#uses=1] ; [oox.193 : sln.6] - %r148 = inttoptr i64 %r147 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.193 : sln.6] - store <4 x float> %r145, <4 x float>* %r148, align 4 ; [oox.193 : sln.6] - %r149 = load i64* %"$LCS_4", align 8 ; [#uses=1] ; [oox.194 : sln.6] - %r150 = add i64 32, %r149 ; [#uses=1] ; [oox.194 : sln.6] - %r151 = inttoptr i64 %r150 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.194 : sln.6] - %r152 = load <4 x float>* %r151, align 4 ; <<4 x float>> [#uses=1] ; [oox.194 : sln.6] - %r153 = load i64* %"$LCS_5", align 8 ; [#uses=1] ; [oox.194 : sln.6] - %r154 = add i64 32, %r153 ; [#uses=1] ; [oox.194 : sln.6] - %r155 = inttoptr i64 %r154 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.194 : sln.6] - %r156 = load <4 x float>* %r155, align 4 ; <<4 x float>> [#uses=1] ; [oox.194 : sln.6] - %r157 = add <4 x float> %r152, %r156 ; <<4 x float>> [#uses=1] ; [oox.194 : sln.6] - %r158 = load i64* %"$LCS_6", align 8 ; [#uses=1] ; [oox.194 : sln.6] - %r159 = add i64 32, %r158 ; [#uses=1] ; [oox.194 : sln.6] - %r160 = inttoptr i64 %r159 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.194 : sln.6] - store <4 x float> %r157, <4 x float>* %r160, align 4 ; [oox.194 : sln.6] - %r161 = load i64* %"$LCS_4", align 8 ; [#uses=1] ; [oox.195 : sln.6] - %r162 = add i64 48, %r161 ; [#uses=1] ; [oox.195 : sln.6] - %r163 = inttoptr i64 %r162 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.195 : sln.6] - %r164 = load <4 x float>* %r163, align 4 ; <<4 x float>> [#uses=1] ; [oox.195 : sln.6] - %r165 = load i64* %"$LCS_5", align 8 ; [#uses=1] ; [oox.195 : sln.6] - %r166 = add i64 48, %r165 ; [#uses=1] ; [oox.195 : sln.6] - %r167 = inttoptr i64 %r166 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.195 : sln.6] - %r168 = load <4 x float>* %r167, align 4 ; <<4 x float>> [#uses=1] ; [oox.195 : sln.6] - %r169 = add <4 x float> %r164, %r168 ; <<4 x float>> [#uses=1] ; [oox.195 : sln.6] - %r170 = load i64* %"$LCS_6", align 8 ; [#uses=1] ; [oox.195 : sln.6] - %r171 = add i64 48, %r170 ; [#uses=1] ; [oox.195 : sln.6] - %r172 = inttoptr i64 %r171 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.195 : sln.6] - store <4 x float> %r169, <4 x float>* %r172, align 4 ; [oox.195 : sln.6] - %r173 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.196 : sln.5] - %r174 = add i64 64, %r173 ; [#uses=1] ; [oox.196 : sln.5] - store i64 %r174, i64* %"$SI_S25", align 8 ; [oox.196 : sln.5] - %r175 = load i64* %"$LC_S24", align 8 ; [#uses=1] ; [oox.197 : sln.5] - %r176 = add i64 16, %r175 ; [#uses=1] ; [oox.197 : sln.5] - store i64 %r176, i64* %"$LC_S24", align 8 ; [oox.197 : sln.5] - %r177 = load i64* %"$LC_S24", align 8 ; [#uses=1] ; [oox.198 : sln.5] - %r178 = icmp slt i64 %r177, -15 ; [#uses=1] ; [oox.198 : sln.5] - %r179 = zext i1 %r178 to i32 ; [#uses=1] ; [oox.198 : sln.5] - %r180 = icmp ne i32 %r179, 0 ; [#uses=1] ; [oox.198 : sln.5] - br i1 %r180, label %"file loop.c, line 1, in inner vector loop at depth 0, bb58", label %"file loop.c, line 5, bb64" ; [oox.198 : sln.5] - -"file loop.c, line 5, bb64": ; srcLine 5 ; preds = %"file loop.c, line 6, in inner vector loop at depth 0, bb59", %"file loop.c, line 5, bb60" - %r181 = load i64* %"$LC_S24", align 8 ; [#uses=1] ; [oox.189 : sln.5] - %r182 = icmp sge i64 %r181, 0 ; [#uses=1] ; [oox.189 : sln.5] - %r183 = zext i1 %r182 to i32 ; [#uses=1] ; [oox.189 : sln.5] - %r184 = icmp ne i32 %r183, 0 ; [#uses=1] ; [oox.189 : sln.5] - br i1 %r184, label %"file loop.c, line 5, bb45", label %"file loop.c, line 1, bb65" ; [oox.189 : sln.5] - -"file loop.c, line 1, bb65": ; srcLine 1 ; preds = %"file loop.c, line 5, bb64" - br label %"file loop.c, line 1, in inner vector loop at depth 0, bb62" ; [oox.0 : sln.0] - -"file loop.c, line 1, in inner vector loop at depth 0, bb62": ; srcLine 1 ; preds = %"file loop.c, line 6, in inner vector loop at depth 0, bb63", %"file loop.c, line 1, bb65" - br label %"file loop.c, line 6, in inner vector loop at depth 0, bb63" ; [oox.0 : sln.0] - -"file loop.c, line 6, in inner vector loop at depth 0, bb63": ; srcLine 6 ; preds = %"file loop.c, line 1, in inner vector loop at depth 0, bb62" - %r185 = load i64* %"$LIS_S17", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r186 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r187 = add i64 %r185, %r186 ; [#uses=1] ; [oox.189 : sln.6] - %r188 = inttoptr i64 %r187 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.189 : sln.6] - %r189 = load <4 x float>* %r188, align 4 ; <<4 x float>> [#uses=1] ; [oox.189 : sln.6] - %r190 = load i64* %"$LIS_S15", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r191 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r192 = add i64 %r190, %r191 ; [#uses=1] ; [oox.189 : sln.6] - %r193 = inttoptr i64 %r192 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.189 : sln.6] - %r194 = load <4 x float>* %r193, align 4 ; <<4 x float>> [#uses=1] ; [oox.189 : sln.6] - %r195 = add <4 x float> %r189, %r194 ; <<4 x float>> [#uses=1] ; [oox.189 : sln.6] - %r196 = load i64* %"$LIS_S18", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r197 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r198 = add i64 %r196, %r197 ; [#uses=1] ; [oox.189 : sln.6] - %r199 = inttoptr i64 %r198 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.189 : sln.6] - store <4 x float> %r195, <4 x float>* %r199, align 4 ; [oox.189 : sln.6] - %r200 = load i64* %"$SI_S25", align 8 ; [#uses=1] ; [oox.190 : sln.5] - %r201 = add i64 16, %r200 ; [#uses=1] ; [oox.190 : sln.5] - store i64 %r201, i64* %"$SI_S25", align 8 ; [oox.190 : sln.5] - %r202 = load i64* %"$LC_S24", align 8 ; [#uses=1] ; [oox.191 : sln.5] - %r203 = add i64 4, %r202 ; [#uses=1] ; [oox.191 : sln.5] - store i64 %r203, i64* %"$LC_S24", align 8 ; [oox.191 : sln.5] - %r204 = load i64* %"$LC_S24", align 8 ; [#uses=1] ; [oox.192 : sln.5] - %r205 = icmp slt i64 %r204, 0 ; [#uses=1] ; [oox.192 : sln.5] - %r206 = zext i1 %r205 to i64 ; [#uses=1] ; [oox.192 : sln.5] - %r207 = icmp ne i64 %r206, 0 ; [#uses=1] ; [oox.192 : sln.5] - br i1 %r207, label %"file loop.c, line 1, in inner vector loop at depth 0, bb62", label %"file loop.c, line 5, bb45" ; [oox.192 : sln.5] - -"file loop.c, line 5, bb45": ; srcLine 5 ; preds = %"file loop.c, line 6, in inner vector loop at depth 0, bb63", %"file loop.c, line 5, bb64" - %r208 = load i64* %"$TC_1", align 8 ; [#uses=1] ; [oox.189 : sln.5] - store i64 %r208, i64* %"$i_S23", align 8 ; [oox.189 : sln.5] - br label %"file loop.c, line 5, bb50" ; [oox.0 : sln.0] - -"file loop.c, line 5, bb50": ; srcLine 5 ; preds = %"file loop.c, line 5, bb45", %"file loop.c, line 5, bb48" - %r209 = load i32* %"$MR_n_0", align 4 ; [#uses=1] ; [oox.189 : sln.5] - %r210 = sext i32 %r209 to i64 ; [#uses=1] ; [oox.189 : sln.5] - store i64 %r210, i64* %"$LCS_n_7", align 8 ; [oox.189 : sln.5] - %r211 = load i64* %"$LCS_n_7", align 8 ; [#uses=1] ; [oox.190 : sln.5] - %r212 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.190 : sln.5] - %r213 = icmp sle i64 %r211, %r212 ; [#uses=1] ; [oox.190 : sln.5] - %r214 = zext i1 %r213 to i32 ; [#uses=1] ; [oox.190 : sln.5] - %r215 = icmp ne i32 %r214, 0 ; [#uses=1] ; [oox.190 : sln.5] - br i1 %r215, label %"file loop.c, line 5, bb6", label %"file loop.c, line 1, bb49" ; [oox.190 : sln.5] - -"file loop.c, line 1, bb49": ; srcLine 1 ; preds = %"file loop.c, line 5, bb50" - br label %"file loop.c, line 6, bb57" ; [oox.0 : sln.0] - -"file loop.c, line 6, bb57": ; srcLine 6 ; preds = %"file loop.c, line 1, bb49" - %r216 = load float** %"$MR_B_3", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r217 = ptrtoint float* %r216 to i64 ; [#uses=1] ; [oox.189 : sln.6] - store i64 %r217, i64* %"$LIS_S19", align 8 ; [oox.189 : sln.6] - %r218 = load float** %"$MR_C_1", align 8 ; [#uses=1] ; [oox.190 : sln.6] - %r219 = ptrtoint float* %r218 to i64 ; [#uses=1] ; [oox.190 : sln.6] - store i64 %r219, i64* %"$LIS_S20", align 8 ; [oox.190 : sln.6] - %r220 = load float** %"$MR_A_2", align 8 ; [#uses=1] ; [oox.191 : sln.6] - %r221 = ptrtoint float* %r220 to i64 ; [#uses=1] ; [oox.191 : sln.6] - store i64 %r221, i64* %"$LIS_S21", align 8 ; [oox.191 : sln.6] - br label %"file loop.c, line 1, in inner loop at depth 0, bb51" ; [oox.0 : sln.0] - -"file loop.c, line 1, in inner loop at depth 0, bb51": ; srcLine 1 ; preds = %"file loop.c, line 5, in inner loop at depth 0, bb54", %"file loop.c, line 6, bb57" - br label %"file loop.c, line 5, in inner loop at depth 0, bb54" ; [oox.0 : sln.0] - -"file loop.c, line 5, in inner loop at depth 0, bb54": ; srcLine 5 ; preds = %"file loop.c, line 1, in inner loop at depth 0, bb51" - %r222 = load i64* %"$LIS_S20", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r223 = inttoptr i64 %r222 to float* ; [#uses=1] ; [oox.189 : sln.6] - %r224 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r225 = getelementptr float* %r223, i64 %r224 ; [#uses=1] ; [oox.189 : sln.6] - %r226 = load float* %r225, align 4 ; [#uses=1] ; [oox.189 : sln.6] - %r227 = load i64* %"$LIS_S19", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r228 = inttoptr i64 %r227 to float* ; [#uses=1] ; [oox.189 : sln.6] - %r229 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r230 = getelementptr float* %r228, i64 %r229 ; [#uses=1] ; [oox.189 : sln.6] - %r231 = load float* %r230, align 4 ; [#uses=1] ; [oox.189 : sln.6] - %r232 = add float %r226, %r231 ; [#uses=1] ; [oox.189 : sln.6] - %r233 = load i64* %"$LIS_S21", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r234 = inttoptr i64 %r233 to float* ; [#uses=1] ; [oox.189 : sln.6] - %r235 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.189 : sln.6] - %r236 = getelementptr float* %r234, i64 %r235 ; [#uses=1] ; [oox.189 : sln.6] - store float %r232, float* %r236, align 4 ; [oox.189 : sln.6] - %r237 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.190 : sln.5] - %r238 = add i64 1, %r237 ; [#uses=1] ; [oox.190 : sln.5] - store i64 %r238, i64* %"$i_S23", align 8 ; [oox.190 : sln.5] - %r239 = load i64* %"$i_S23", align 8 ; [#uses=1] ; [oox.191 : sln.5] - %r240 = load i64* %"$LCS_n_7", align 8 ; [#uses=1] ; [oox.191 : sln.5] - %r241 = icmp slt i64 %r239, %r240 ; [#uses=1] ; [oox.191 : sln.5] - %r242 = zext i1 %r241 to i64 ; [#uses=1] ; [oox.191 : sln.5] - %r243 = icmp ne i64 %r242, 0 ; [#uses=1] ; [oox.191 : sln.5] - br i1 %r243, label %"file loop.c, line 1, in inner loop at depth 0, bb51", label %"file loop.c, line 5, bb6" ; [oox.191 : sln.5] - -"file loop.c, line 5, bb6": ; srcLine 5 ; preds = %"file loop.c, line 5, in inner loop at depth 0, bb54", %"file loop.c, line 5, bb50", %"file loop.c, line 5, in inner loop at depth 0, bb32", %"file loop.c, line 1, bb69" ret i32 0 ; [oox.189 : sln.10] } From clattner at apple.com Mon Jan 11 15:54:39 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 11 Jan 2010 13:54:39 -0800 Subject: [llvm-commits] [llvm] r93030 - in /llvm/trunk: include/llvm/Target/Target.td include/llvm/Target/TargetInstrInfo.h utils/TableGen/CodeEmitterGen.cpp utils/TableGen/CodeGenTarget.cpp utils/TableGen/InstrInfoEmitter.cpp In-Reply-To: <347DB32D-58A0-44F1-9954-148C10D6C55D@apple.com> References: <201001082351.o08NpQLE025356@zion.cs.uiuc.edu> <347DB32D-58A0-44F1-9954-148C10D6C55D@apple.com> Message-ID: <85C5C442-8FF0-4295-8326-E67663E8A57C@apple.com> On Jan 11, 2010, at 11:02 AM, Dale Johannesen wrote: >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=93030&view=rev >>> Log: >>> Add DEBUG_VALUE. Not used yet. >> >> Hi Dale, >> >> How do you envision this working? How will this represent memory >> and register operands? > > It is intended to be a direct mapping of llvm.dbg.value as described > in your 9/24/2009 document. I don't know most of the details yet. The representation of mem and reg operands seems like a pretty important thing to the machine-level design, it would be good to decide on how this will work before implementing much. This is much easier at the IR level, because llvm.dbg.value doesn't work on lowered addresses. -Chris From sabre at nondot.org Mon Jan 11 15:58:19 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 11 Jan 2010 21:58:19 -0000 Subject: [llvm-commits] [llvm] r93189 - /llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll Message-ID: <201001112158.o0BLwJGM013869@zion.cs.uiuc.edu> Author: lattner Date: Mon Jan 11 15:58:19 2010 New Revision: 93189 URL: http://llvm.org/viewvc/llvm-project?rev=93189&view=rev Log: reduce this to a sensible testcase. Modified: llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll Modified: llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll?rev=93189&r1=93188&r2=93189&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll Mon Jan 11 15:58:19 2010 @@ -1,24 +1,11 @@ ; RUN: llc -mattr=vector-unaligned-mem < %s | FileCheck %s -; CHECK: addps{{[ \t]+}}( +; CHECK: addps ( 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 i32 @foo(i32 %n1, float* %A2, float* %B3, float* %C4) { -"file loop.c, line 1, bb1": ; srcLine 1 - %"$LCS_4" = alloca i64, align 8 ; [#uses=5] ; [oox.86 : sln.1] - %"$LCS_5" = alloca i64, align 8 ; [#uses=5] ; [oox.87 : sln.1] - %"$LCS_6" = alloca i64, align 8 ; [#uses=5] ; [oox.88 : sln.1] - - %r128 = load i64* %"$LCS_4", align 8 ; [#uses=1] ; [oox.192 : sln.6] - %r129 = inttoptr i64 %r128 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.192 : sln.6] - %r130 = load <4 x float>* %r129, align 4 ; <<4 x float>> [#uses=1] ; [oox.192 : sln.6] - %r131 = load i64* %"$LCS_5", align 8 ; [#uses=1] ; [oox.192 : sln.6] - %r132 = inttoptr i64 %r131 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.192 : sln.6] - %r133 = load <4 x float>* %r132, align 4 ; <<4 x float>> [#uses=1] ; [oox.192 : sln.6] - %r134 = add <4 x float> %r130, %r133 ; <<4 x float>> [#uses=1] ; [oox.192 : sln.6] - %r135 = load i64* %"$LCS_6", align 8 ; [#uses=1] ; [oox.192 : sln.6] - %r136 = inttoptr i64 %r135 to <4 x float>* ; <<4 x float>*> [#uses=1] ; [oox.192 : sln.6] - store <4 x float> %r134, <4 x float>* %r136, align 4 ; [oox.192 : sln.6] - ret i32 0 ; [oox.189 : sln.10] +define <4 x float> @foo(<4 x float>* %P, <4 x float> %In) nounwind { + %A = load <4 x float>* %P, align 4 + %B = add <4 x float> %A, %In + ret <4 x float> %B } From evan.cheng at apple.com Mon Jan 11 16:03:29 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jan 2010 22:03:29 -0000 Subject: [llvm-commits] [llvm] r93191 - in /llvm/trunk: lib/Target/X86/X86Instr64bit.td lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/3addr-or.ll test/CodeGen/X86/fast-isel.ll Message-ID: <201001112203.o0BM3Tlm014122@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jan 11 16:03:29 2010 New Revision: 93191 URL: http://llvm.org/viewvc/llvm-project?rev=93191&view=rev Log: Extend r93152 to work on OR r, r. If the source set bits are known not to overlap, then select as an ADD instead. Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td llvm/trunk/lib/Target/X86/X86InstrInfo.td llvm/trunk/test/CodeGen/X86/3addr-or.ll llvm/trunk/test/CodeGen/X86/fast-isel.ll Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=93191&r1=93190&r2=93191&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Mon Jan 11 16:03:29 2010 @@ -1093,7 +1093,7 @@ def OR64rr : RI<0x09, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), "or{q}\t{$src2, $dst|$dst, $src2}", - [(set GR64:$dst, (or GR64:$src1, GR64:$src2)), + [(set GR64:$dst, (or_not_add GR64:$src1, GR64:$src2)), (implicit EFLAGS)]>; def OR64rr_REV : RI<0x0B, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), @@ -2125,13 +2125,16 @@ GR64:$src2, (i8 imm:$amt2)), addr:$dst), (SHLD64mri8 addr:$dst, GR64:$src2, (i8 imm:$amt1))>; -// (or x, c) -> (add x, c) if masked bits are known zero. +// (or x1, x2) -> (add x1, x2) if two operands are known not to share bits. def : Pat<(parallel (or_is_add GR64:$src1, i64immSExt8:$src2), (implicit EFLAGS)), (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>; def : Pat<(parallel (or_is_add GR64:$src1, i64immSExt32:$src2), (implicit EFLAGS)), (ADD64ri32 GR64:$src1, i64immSExt32:$src2)>; +def : Pat<(parallel (or_is_add GR64:$src1, GR64:$src2), + (implicit EFLAGS)), + (ADD64rr GR64:$src1, GR64:$src2)>; // X86 specific add which produces a flag. def : Pat<(addc GR64:$src1, GR64:$src2), Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=93191&r1=93190&r2=93191&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon Jan 11 16:03:29 2010 @@ -497,12 +497,28 @@ def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{ if (ConstantSDNode *CN = dyn_cast(N->getOperand(1))) return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue()); - return false; + else { + unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits(); + APInt Mask = APInt::getAllOnesValue(BitWidth); + APInt KnownZero0, KnownOne0; + CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0); + APInt KnownZero1, KnownOne1; + CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0); + return (~KnownZero0 & ~KnownZero1) == 0; + } }]>; def or_not_add : PatFrag<(ops node:$lhs, node:$rhs),(or node:$lhs, node:$rhs),[{ - ConstantSDNode *CN = dyn_cast(N->getOperand(1)); - if (!CN) return true; - return !CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue()); + if (ConstantSDNode *CN = dyn_cast(N->getOperand(1))) + return !CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue()); + else { + unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits(); + APInt Mask = APInt::getAllOnesValue(BitWidth); + APInt KnownZero0, KnownOne0; + CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0); + APInt KnownZero1, KnownOne1; + CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0); + return (~KnownZero0 & ~KnownZero1) != 0; + } }]>; // 'shld' and 'shrd' instruction patterns. Note that even though these have @@ -1853,12 +1869,12 @@ def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), "or{w}\t{$src2, $dst|$dst, $src2}", - [(set GR16:$dst, (or GR16:$src1, GR16:$src2)), + [(set GR16:$dst, (or_not_add GR16:$src1, GR16:$src2)), (implicit EFLAGS)]>, OpSize; def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2), "or{l}\t{$src2, $dst|$dst, $src2}", - [(set GR32:$dst, (or GR32:$src1, GR32:$src2)), + [(set GR32:$dst, (or_not_add GR32:$src1, GR32:$src2)), (implicit EFLAGS)]>; } @@ -4659,7 +4675,7 @@ def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))), (SETB_C32r)>; -// (or x, c) -> (add x, c) if masked bits are known zero. +// (or x1, x2) -> (add x1, x2) if two operands are known not to share bits. def : Pat<(parallel (or_is_add GR16:$src1, imm:$src2), (implicit EFLAGS)), (ADD16ri GR16:$src1, imm:$src2)>; @@ -4672,6 +4688,12 @@ def : Pat<(parallel (or_is_add GR32:$src1, i32immSExt8:$src2), (implicit EFLAGS)), (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>; +def : Pat<(parallel (or_is_add GR16:$src1, GR16:$src2), + (implicit EFLAGS)), + (ADD16rr GR16:$src1, GR16:$src2)>; +def : Pat<(parallel (or_is_add GR32:$src1, GR32:$src2), + (implicit EFLAGS)), + (ADD32rr GR32:$src1, GR32:$src2)>; //===----------------------------------------------------------------------===// // EFLAGS-defining Patterns Modified: llvm/trunk/test/CodeGen/X86/3addr-or.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/3addr-or.ll?rev=93191&r1=93190&r2=93191&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/3addr-or.ll (original) +++ llvm/trunk/test/CodeGen/X86/3addr-or.ll Mon Jan 11 16:03:29 2010 @@ -9,3 +9,19 @@ %1 = or i32 %0, 3 ; [#uses=1] ret i32 %1 } + +define i64 @test2(i8 %A, i8 %B) nounwind { +; CHECK: test2: +; CHECK: shrq $4 +; CHECK-NOT: movq +; CHECK-NOT: orq +; CHECK: leaq +; CHECK: ret + %C = zext i8 %A to i64 ; [#uses=1] + %D = shl i64 %C, 4 ; [#uses=1] + %E = and i64 %D, 48 ; [#uses=1] + %F = zext i8 %B to i64 ; [#uses=1] + %G = lshr i64 %F, 4 ; [#uses=1] + %H = or i64 %G, %E ; [#uses=1] + ret i64 %H +} Modified: llvm/trunk/test/CodeGen/X86/fast-isel.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel.ll?rev=93191&r1=93190&r2=93191&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fast-isel.ll (original) +++ llvm/trunk/test/CodeGen/X86/fast-isel.ll Mon Jan 11 16:03:29 2010 @@ -14,7 +14,7 @@ %t1 = mul i32 %t0, %s %t2 = sub i32 %t1, %s %t3 = and i32 %t2, %s - %t4 = or i32 %t3, %s + %t4 = xor i32 %t3, 3 %t5 = xor i32 %t4, %s %t6 = add i32 %t5, 2 %t7 = getelementptr i32* %y, i32 1 From stoklund at 2pi.dk Mon Jan 11 16:10:27 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 11 Jan 2010 22:10:27 -0000 Subject: [llvm-commits] [test-suite] r93193 - /test-suite/trunk/Makefile.programs Message-ID: <201001112210.o0BMARc1014442@zion.cs.uiuc.edu> Author: stoklund Date: Mon Jan 11 16:10:27 2010 New Revision: 93193 URL: http://llvm.org/viewvc/llvm-project?rev=93193&view=rev Log: Insert -pre-regalloc-taildup for x86, x86_64, arm, and thumb. Modified: test-suite/trunk/Makefile.programs Modified: test-suite/trunk/Makefile.programs URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.programs?rev=93193&r1=93192&r2=93193&view=diff ============================================================================== --- test-suite/trunk/Makefile.programs (original) +++ test-suite/trunk/Makefile.programs Mon Jan 11 16:10:27 2010 @@ -225,38 +225,19 @@ LLCBETAOPTION := -sched=simple endif ifeq ($(ARCH),x86_64) -LLCBETAOPTION := -disable-16bit -#-split-gep-gvn -#-combiner-alias-analysis -#-pre-alloc-split -#-remat-pic-stub-load +LLCBETAOPTION := -pre-regalloc-taildup endif ifeq ($(ARCH),x86) -LLCBETAOPTION := -disable-16bit -#-split-gep-gvn -#-combiner-alias-analysis -#-pre-alloc-split -#-remat-pic-stub-load -#-combiner-global-alias-analysis -#-fast-isel -#-new-spilling-heuristic -#-enable-value-prop -#-schedule-livein-copies -#-tailcallopt -#-regalloc=local -O0 -#-disable-fp-elim +LLCBETAOPTION := -pre-regalloc-taildup endif ifeq ($(ARCH),Sparc) LLCBETAOPTION := -enable-sparc-v9-insts endif ifeq ($(ARCH),ARM) -LLCBETAOPTION := -split-gep-gvn -#-schedule-livein-copies +LLCBETAOPTION := -pre-regalloc-taildup endif ifeq ($(ARCH),THUMB) -LLCBETAOPTION := -split-gep-gvn -#-combiner-alias-analysis -#-enable-thumb-reg-scavenging +LLCBETAOPTION := -pre-regalloc-taildup endif print-llcbeta-option: From grosser at fim.uni-passau.de Mon Jan 11 16:22:32 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 11 Jan 2010 22:22:32 -0000 Subject: [llvm-commits] [llvm] r93194 - /llvm/trunk/include/llvm/Analysis/PostDominators.h Message-ID: <201001112222.o0BMMWU9015095@zion.cs.uiuc.edu> Author: grosser Date: Mon Jan 11 16:22:32 2010 New Revision: 93194 URL: http://llvm.org/viewvc/llvm-project?rev=93194&view=rev Log: Add getNode() to post dominators. Implement the same interface as already available for dominators. Modified: llvm/trunk/include/llvm/Analysis/PostDominators.h Modified: llvm/trunk/include/llvm/Analysis/PostDominators.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/PostDominators.h?rev=93194&r1=93193&r2=93194&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/PostDominators.h (original) +++ llvm/trunk/include/llvm/Analysis/PostDominators.h Mon Jan 11 16:22:32 2010 @@ -49,6 +49,10 @@ return DT->getNode(BB); } + inline DomTreeNode *getNode(BasicBlock *BB) const { + return DT->getNode(BB); + } + inline bool dominates(DomTreeNode* A, DomTreeNode* B) const { return DT->dominates(A, B); } From grosser at fim.uni-passau.de Mon Jan 11 16:22:47 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 11 Jan 2010 22:22:47 -0000 Subject: [llvm-commits] [llvm] r93195 - /llvm/trunk/include/llvm/Analysis/PostDominators.h Message-ID: <201001112222.o0BMMlD9015115@zion.cs.uiuc.edu> Author: grosser Date: Mon Jan 11 16:22:46 2010 New Revision: 93195 URL: http://llvm.org/viewvc/llvm-project?rev=93195&view=rev Log: Remove trailing white spaces in post dominators header file Modified: llvm/trunk/include/llvm/Analysis/PostDominators.h Modified: llvm/trunk/include/llvm/Analysis/PostDominators.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/PostDominators.h?rev=93195&r1=93194&r2=93195&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/PostDominators.h (original) +++ llvm/trunk/include/llvm/Analysis/PostDominators.h Mon Jan 11 16:22:46 2010 @@ -36,19 +36,19 @@ virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); } - + inline const std::vector &getRoots() const { return DT->getRoots(); } - + inline DomTreeNode *getRootNode() const { return DT->getRootNode(); } - + inline DomTreeNode *operator[](BasicBlock *BB) const { return DT->getNode(BB); } - + inline DomTreeNode *getNode(BasicBlock *BB) const { return DT->getNode(BB); } @@ -64,7 +64,7 @@ inline bool properlyDominates(const DomTreeNode* A, DomTreeNode* B) const { return DT->properlyDominates(A, B); } - + inline bool properlyDominates(BasicBlock* A, BasicBlock* B) const { return DT->properlyDominates(A, B); } @@ -101,7 +101,7 @@ /// struct PostDominanceFrontier : public DominanceFrontierBase { static char ID; - PostDominanceFrontier() + PostDominanceFrontier() : DominanceFrontierBase(&ID, true) {} virtual bool runOnFunction(Function &) { From vhernandez at apple.com Mon Jan 11 16:31:59 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Mon, 11 Jan 2010 22:31:59 -0000 Subject: [llvm-commits] [llvm] r93197 - in /llvm/trunk/lib/AsmParser: LLParser.cpp LLParser.h Message-ID: <201001112231.o0BMVxqZ015563@zion.cs.uiuc.edu> Author: hernande Date: Mon Jan 11 16:31:58 2010 New Revision: 93197 URL: http://llvm.org/viewvc/llvm-project?rev=93197&view=rev Log: Consolidate ConvertGlobalValIDToValue, ConvertGlobalOrMetadataValIDToValue, and ConvertValIDToValue into a more powerful ConvertValIDToValue() that does all three's work Modified: llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLParser.h Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=93197&r1=93196&r2=93197&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Jan 11 16:31:58 2010 @@ -2358,30 +2358,85 @@ } /// ParseGlobalValue - Parse a global value with the specified type. -bool LLParser::ParseGlobalValue(const Type *Ty, Constant *&V) { - V = 0; +bool LLParser::ParseGlobalValue(const Type *Ty, Constant *&C) { + C = 0; ValID ID; - return ParseValID(ID) || - ConvertGlobalValIDToValue(Ty, ID, V); + Value *V = NULL; + bool Parsed = ParseValID(ID) || + ConvertValIDToValue(Ty, ID, V, NULL); + if (V && !(C = dyn_cast(V))) + return Error(ID.Loc, "global values must be constants"); + return Parsed; +} + +bool LLParser::ParseGlobalTypeAndValue(Constant *&V) { + PATypeHolder Type(Type::getVoidTy(Context)); + return ParseType(Type) || + ParseGlobalValue(Type, V); +} + +/// ParseGlobalValueVector +/// ::= /*empty*/ +/// ::= TypeAndValue (',' TypeAndValue)* +bool LLParser::ParseGlobalValueVector(SmallVectorImpl &Elts) { + // Empty list. + if (Lex.getKind() == lltok::rbrace || + Lex.getKind() == lltok::rsquare || + Lex.getKind() == lltok::greater || + Lex.getKind() == lltok::rparen) + return false; + + Constant *C; + if (ParseGlobalTypeAndValue(C)) return true; + Elts.push_back(C); + + while (EatIfPresent(lltok::comma)) { + if (ParseGlobalTypeAndValue(C)) return true; + Elts.push_back(C); + } + + return false; } -/// ConvertGlobalValIDToValue - Apply a type to a ValID to get a fully resolved -/// constant. -bool LLParser::ConvertGlobalValIDToValue(const Type *Ty, ValID &ID, - Constant *&V) { + +//===----------------------------------------------------------------------===// +// Function Parsing. +//===----------------------------------------------------------------------===// + +bool LLParser::ConvertValIDToValue(const Type *Ty, ValID &ID, Value *&V, + PerFunctionState *PFS) { if (isa(Ty)) return Error(ID.Loc, "functions are not values, refer to them as pointers"); switch (ID.Kind) { default: llvm_unreachable("Unknown ValID!"); - case ValID::t_MDNode: - case ValID::t_MDString: - return Error(ID.Loc, "invalid use of metadata"); case ValID::t_LocalID: + if (!PFS) return Error(ID.Loc, "invalid use of function-local name"); + V = PFS->GetVal(ID.UIntVal, Ty, ID.Loc); + return (V == 0); case ValID::t_LocalName: - return Error(ID.Loc, "invalid use of function-local name"); - case ValID::t_InlineAsm: - return Error(ID.Loc, "inline asm can only be an operand of call/invoke"); + if (!PFS) return Error(ID.Loc, "invalid use of function-local name"); + V = PFS->GetVal(ID.StrVal, Ty, ID.Loc); + return (V == 0); + case ValID::t_InlineAsm: { + const PointerType *PTy = dyn_cast(Ty); + const FunctionType *FTy = + PTy ? dyn_cast(PTy->getElementType()) : 0; + if (!FTy || !InlineAsm::Verify(FTy, ID.StrVal2)) + return Error(ID.Loc, "invalid type for inline asm constraint string"); + V = InlineAsm::get(FTy, ID.StrVal, ID.StrVal2, ID.UIntVal&1, ID.UIntVal>>1); + return false; + } + case ValID::t_MDNode: + if (!Ty->isMetadataTy()) + return Error(ID.Loc, "metadata value must have metadata type"); + V = ID.MDNodeVal; + return false; + case ValID::t_MDString: + if (!Ty->isMetadataTy()) + return Error(ID.Loc, "metadata value must have metadata type"); + V = ID.MDStringVal; + return false; case ValID::t_GlobalName: V = GetGlobalVal(ID.StrVal, Ty, ID.Loc); return V == 0; @@ -2445,100 +2500,11 @@ } } -/// ConvertGlobalOrMetadataValIDToValue - Apply a type to a ValID to get a fully -/// resolved constant, metadata, or function-local value. PFS is used to -/// convert a function-local ValID and can be null when parsing a global or a -/// non-function-local metadata ValID. - -bool LLParser::ConvertGlobalOrMetadataValIDToValue(const Type *Ty, ValID &ID, - Value *&V, - PerFunctionState *PFS) { - switch (ID.Kind) { - case ValID::t_MDNode: - if (!Ty->isMetadataTy()) - return Error(ID.Loc, "metadata value must have metadata type"); - V = ID.MDNodeVal; - return false; - case ValID::t_MDString: - if (!Ty->isMetadataTy()) - return Error(ID.Loc, "metadata value must have metadata type"); - V = ID.MDStringVal; - return false; - case ValID::t_LocalID: - case ValID::t_LocalName: - if (!PFS) - return Error(ID.Loc, "invalid use of function-local name"); - if (ConvertValIDToValue(Ty, ID, V, *PFS)) return true; - return false; - default: - Constant *C; - if (ConvertGlobalValIDToValue(Ty, ID, C)) return true; - V = C; - return false; - } -} - - -bool LLParser::ParseGlobalTypeAndValue(Constant *&V) { - PATypeHolder Type(Type::getVoidTy(Context)); - return ParseType(Type) || - ParseGlobalValue(Type, V); -} - -/// ParseGlobalValueVector -/// ::= /*empty*/ -/// ::= TypeAndValue (',' TypeAndValue)* -bool LLParser::ParseGlobalValueVector(SmallVectorImpl &Elts) { - // Empty list. - if (Lex.getKind() == lltok::rbrace || - Lex.getKind() == lltok::rsquare || - Lex.getKind() == lltok::greater || - Lex.getKind() == lltok::rparen) - return false; - - Constant *C; - if (ParseGlobalTypeAndValue(C)) return true; - Elts.push_back(C); - - while (EatIfPresent(lltok::comma)) { - if (ParseGlobalTypeAndValue(C)) return true; - Elts.push_back(C); - } - - return false; -} - - -//===----------------------------------------------------------------------===// -// Function Parsing. -//===----------------------------------------------------------------------===// - -bool LLParser::ConvertValIDToValue(const Type *Ty, ValID &ID, Value *&V, - PerFunctionState &PFS) { - switch (ID.Kind) { - case ValID::t_LocalID: V = PFS.GetVal(ID.UIntVal, Ty, ID.Loc); break; - case ValID::t_LocalName: V = PFS.GetVal(ID.StrVal, Ty, ID.Loc); break; - case ValID::t_InlineAsm: { - const PointerType *PTy = dyn_cast(Ty); - const FunctionType *FTy = - PTy ? dyn_cast(PTy->getElementType()) : 0; - if (!FTy || !InlineAsm::Verify(FTy, ID.StrVal2)) - return Error(ID.Loc, "invalid type for inline asm constraint string"); - V = InlineAsm::get(FTy, ID.StrVal, ID.StrVal2, ID.UIntVal&1, ID.UIntVal>>1); - return false; - } - default: - return ConvertGlobalOrMetadataValIDToValue(Ty, ID, V, &PFS); - } - - return V == 0; -} - bool LLParser::ParseValue(const Type *Ty, Value *&V, PerFunctionState &PFS) { V = 0; ValID ID; return ParseValID(ID, &PFS) || - ConvertValIDToValue(Ty, ID, V, PFS); + ConvertValIDToValue(Ty, ID, V, &PFS); } bool LLParser::ParseTypeAndValue(Value *&V, PerFunctionState &PFS) { @@ -3250,7 +3216,7 @@ // Look up the callee. Value *Callee; - if (ConvertValIDToValue(PFTy, CalleeID, Callee, PFS)) return true; + if (ConvertValIDToValue(PFTy, CalleeID, Callee, &PFS)) return true; // FIXME: In LLVM 3.0, stop accepting zext, sext and inreg as optional // function attributes. @@ -3596,7 +3562,7 @@ // Look up the callee. Value *Callee; - if (ConvertValIDToValue(PFTy, CalleeID, Callee, PFS)) return true; + if (ConvertValIDToValue(PFTy, CalleeID, Callee, &PFS)) return true; // FIXME: In LLVM 3.0, stop accepting zext, sext and inreg as optional // function attributes. @@ -3871,7 +3837,7 @@ PATypeHolder Ty(Type::getVoidTy(Context)); ValID ID; if (ParseType(Ty) || ParseValID(ID, PFS) || - ConvertGlobalOrMetadataValIDToValue(Ty, ID, V, PFS)) + ConvertValIDToValue(Ty, ID, V, PFS)) return true; Elts.push_back(V); Modified: llvm/trunk/lib/AsmParser/LLParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=93197&r1=93196&r2=93197&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.h (original) +++ llvm/trunk/lib/AsmParser/LLParser.h Mon Jan 11 16:31:58 2010 @@ -259,7 +259,7 @@ }; bool ConvertValIDToValue(const Type *Ty, ValID &ID, Value *&V, - PerFunctionState &PFS); + PerFunctionState *PFS); bool ParseValue(const Type *Ty, Value *&V, PerFunctionState &PFS); bool ParseValue(const Type *Ty, Value *&V, LocTy &Loc, @@ -292,9 +292,6 @@ // Constant Parsing. bool ParseValID(ValID &ID, PerFunctionState *PFS = NULL); - bool ConvertGlobalValIDToValue(const Type *Ty, ValID &ID, Constant *&V); - bool ConvertGlobalOrMetadataValIDToValue(const Type *Ty, ValID &ID, - Value *&V, PerFunctionState *PFS); bool ParseGlobalValue(const Type *Ty, Constant *&V); bool ParseGlobalTypeAndValue(Constant *&V); bool ParseGlobalValueVector(SmallVectorImpl &Elts); From vhernandez at apple.com Mon Jan 11 16:33:19 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Mon, 11 Jan 2010 14:33:19 -0800 Subject: [llvm-commits] [llvm] r92793 - in /llvm/trunk: lib/AsmParser/LLParser.cpp lib/AsmParser/LLParser.h test/Assembler/functionlocal-metadata.ll In-Reply-To: References: <201001052222.o05MMEGV028443@zion.cs.uiuc.edu> Message-ID: <4D372DD2-A3F0-431C-9CFD-27A71F4EA8C7@apple.com> Fixed in 93108 and 93197. Victor On Jan 8, 2010, at 10:11 AM, Chris Lattner wrote: > > On Jan 5, 2010, at 2:22 PM, Victor Hernandez wrote: > >> Author: hernande >> Date: Tue Jan 5 16:22:14 2010 >> New Revision: 92793 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=92793&view=rev >> Log: >> Re-add parsing of function-local metadata; this time with testcase. > > Ok, > >> @@ -1885,7 +1885,7 @@ >> /// type implied. For example, if we parse "4" we don't know what integer type >> /// it has. The value will later be combined with its type and checked for >> /// sanity. >> -bool LLParser::ParseValID(ValID &ID) { >> +bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) { > > Please document the new argument, explicitly mentioning that it can be null and why. > >> >> /// ConvertGlobalOrMetadataValIDToValue - Apply a type to a ValID to get a fully >> -/// resolved constant or metadata value. >> +/// resolved constant, metadata, or function-local value > > Likewise. Also, end your sentence with a period. > >> @@ -2458,6 +2459,12 @@ >> return Error(ID.Loc, "metadata value must have metadata type"); >> V = ID.MDStringVal; >> return false; >> + case ValID::t_LocalID: >> + case ValID::t_LocalName: >> + if (!PFS) >> + return Error(ID.Loc, "invalid use of function-local name"); >> + if (ConvertValIDToValue(Ty, ID, V, *PFS)) return true; >> + return false; > > With this change, there is no difference between ConvertGlobalValIDToValue, ConvertGlobalOrMetadataValIDToValue, and ConvertValIDToValue, except for inline asm. Can they all be merged into one function now and use the PFS pointer to distinguish the function-local vs global case? > > -Chris > From sabre at nondot.org Mon Jan 11 16:45:25 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 11 Jan 2010 22:45:25 -0000 Subject: [llvm-commits] [llvm] r93200 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Message-ID: <201001112245.o0BMjPBf016141@zion.cs.uiuc.edu> Author: lattner Date: Mon Jan 11 16:45:25 2010 New Revision: 93200 URL: http://llvm.org/viewvc/llvm-project?rev=93200&view=rev Log: Disable folding sext(trunc(x)) -> x (and other similar cast/cast cases) when the trunc has multiple uses. Codegen is not able to coalesce the subreg case correctly and so this leads to higher register pressure and spilling (see PR5997). This speeds up 256.bzip2 from 8.60 -> 8.04s on my machine, ~7%. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=93200&r1=93199&r2=93200&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Mon Jan 11 16:45:25 2010 @@ -325,8 +325,11 @@ const Type *OrigTy = V->getType(); - // If this is an extension from the dest type, we can eliminate it. - if ((isa(I) || isa(I)) && + // If this is an extension from the dest type, we can eliminate it, even if it + // has multiple uses. + // FIXME: This is currently disabled until codegen can handle this without + // pessimizing code, PR5997. + if (0 && (isa(I) || isa(I)) && I->getOperand(0)->getType() == Ty) return true; @@ -606,8 +609,10 @@ if (!I) return false; // If the input is a truncate from the destination type, we can trivially - // eliminate it. - if (isa(I) && I->getOperand(0)->getType() == Ty) + // eliminate it, even if it has multiple uses. + // FIXME: This is currently disabled until codegen can handle this without + // pessimizing code, PR5997. + if (0 && isa(I) && I->getOperand(0)->getType() == Ty) return true; // We can't extend or shrink something that has multiple uses: doing so would @@ -853,8 +858,11 @@ Instruction *I = dyn_cast(V); if (!I) return false; - // If this is a truncate from the dest type, we can trivially eliminate it. - if (isa(I) && I->getOperand(0)->getType() == Ty) + // If this is a truncate from the dest type, we can trivially eliminate it, + // even if it has multiple uses. + // FIXME: This is currently disabled until codegen can handle this without + // pessimizing code, PR5997. + if (0 && isa(I) && I->getOperand(0)->getType() == Ty) return true; // We can't extend or shrink something that has multiple uses: doing so would From sabre at nondot.org Mon Jan 11 16:49:41 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 11 Jan 2010 22:49:41 -0000 Subject: [llvm-commits] [llvm] r93202 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Message-ID: <201001112249.o0BMnfKd016308@zion.cs.uiuc.edu> Author: lattner Date: Mon Jan 11 16:49:40 2010 New Revision: 93202 URL: http://llvm.org/viewvc/llvm-project?rev=93202&view=rev Log: reenable the piece that turns trunc(zext(x)) -> x even if zext has multiple uses, codegen has no apparent problem with the trunc version of this, because it turns into a simple subreg idiom Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=93202&r1=93201&r2=93202&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Mon Jan 11 16:49:40 2010 @@ -327,9 +327,7 @@ // If this is an extension from the dest type, we can eliminate it, even if it // has multiple uses. - // FIXME: This is currently disabled until codegen can handle this without - // pessimizing code, PR5997. - if (0 && (isa(I) || isa(I)) && + if ((isa(I) || isa(I)) && I->getOperand(0)->getType() == Ty) return true; From vhernandez at apple.com Mon Jan 11 16:53:49 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Mon, 11 Jan 2010 22:53:49 -0000 Subject: [llvm-commits] [llvm] r93203 - /llvm/trunk/docs/SourceLevelDebugging.html Message-ID: <201001112253.o0BMrn72016542@zion.cs.uiuc.edu> Author: hernande Date: Mon Jan 11 16:53:48 2010 New Revision: 93203 URL: http://llvm.org/viewvc/llvm-project?rev=93203&view=rev Log: Add documentation for llvm.dbg.value intrinsic Modified: llvm/trunk/docs/SourceLevelDebugging.html Modified: llvm/trunk/docs/SourceLevelDebugging.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/SourceLevelDebugging.html?rev=93203&r1=93202&r2=93203&view=diff ============================================================================== --- llvm/trunk/docs/SourceLevelDebugging.html (original) +++ llvm/trunk/docs/SourceLevelDebugging.html Mon Jan 11 16:53:48 2010 @@ -38,6 +38,7 @@

  • Debugger intrinsic functions
  • Object lifetimes and scoping
  • @@ -775,6 +776,25 @@ + + +
    +
    +  void %llvm.dbg.value( metadata, i64, metadata )
    +
    + +

    This intrinsic provides information when a user source variable is set to a + new value. The first argument is the new value (wrapped as metadata). The + second argument is the offset in the user source variable where the new value + is written. The third argument is + the %llvm.dbg.variable containing + the description of the user source variable.

    + +
    + + From vhernandez at apple.com Mon Jan 11 16:57:47 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Mon, 11 Jan 2010 14:57:47 -0800 Subject: [llvm-commits] [llvm] r90788 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp In-Reply-To: References: <200912071936.nB7JaZDe016960@zion.cs.uiuc.edu> Message-ID: Fixed in r93203 and r93149. Victor On Jan 8, 2010, at 11:25 PM, Chris Lattner wrote: > On Dec 7, 2009, at 11:36 AM, Victor Hernandez wrote: >> Date: Mon Dec 7 13:36:34 2009 >> New Revision: 90788 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=90788&view=rev >> Log: >> Introduce the "@llvm.dbg.value" debug intrinsic. >> >> The semantics of llvm.dbg.value are that starting from where it is executed, an offset into the specified user source variable is specified to get a new value. >> >> An example: >> call void @llvm.dbg.value(metadata !{ i32 7 }, i64 0, metadata !2) >> Here the user source variable associated with metadata #2 gets the value "i32 7" at offset 0. > > Hi Victor, > > Sorry just getting to this old patch. First comment is that you need to document this intrinsic in the debug info doc, presumably right after llvm.declare: > http://llvm.org/docs/SourceLevelDebugging.html#format_common_intrinsics > > >> +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Mon Dec 7 13:36:34 2009 >> @@ -639,6 +640,13 @@ >> Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D, >> Instruction *InsertBefore); >> >> + /// InsertValue - Insert a new llvm.dbg.value intrinsic call. >> + Instruction *InsertValue(llvm::Value *V, llvm::Value *Offset, >> + DIVariable D, BasicBlock *InsertAtEnd); >> + >> + /// InsertValue - Insert a new llvm.dbg.value intrinsic call. >> + Instruction *InsertValue(llvm::Value *V, llvm::Value *Offset, >> + DIVariable D, Instruction *InsertBefore); > > Thank you for renaming these to InsertDbgValueIntrinsic as Devang suggested. Also, please change the 'Offset' argument to be a uint64_t instead of Value*. It is not allowed to be a variable. > >> +++ llvm/trunk/include/llvm/IntrinsicInst.h Mon Dec 7 13:36:34 2009 >> @@ -171,6 +172,25 @@ >> } >> }; >> >> + /// DbgValueInst - This represents the llvm.dbg.value instruction. >> + /// >> + struct DbgValueInst : public DbgInfoIntrinsic { >> + Value *getValue() const { >> + return cast(getOperand(1))->getElement(0); >> + } >> + Value *getOffset() const { return getOperand(2); } > > This should return the offset as a uint64_t instead of a Value*. > >> + MDNode *getVariable() const { return cast(getOperand(3)); } > > This should be two methods to get the constness right: >> + const MDNode *getVariable() const { return cast(getOperand(3)); } >> + MDNode *getVariable() { return cast(getOperand(3)); } > > Likewise for getValue(). > > -Chris From evan.cheng at apple.com Mon Jan 11 16:59:27 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jan 2010 22:59:27 -0000 Subject: [llvm-commits] [llvm] r93204 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel.ll Message-ID: <201001112259.o0BMxRcR016736@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jan 11 16:59:27 2010 New Revision: 93204 URL: http://llvm.org/viewvc/llvm-project?rev=93204&view=rev Log: Add manual ISD::OR fastisel selection routines. TableGen is no longer autogen them after 93152 and 93191. Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp llvm/trunk/test/CodeGen/X86/fast-isel.ll Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=93204&r1=93203&r2=93204&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Mon Jan 11 16:59:27 2010 @@ -104,6 +104,8 @@ bool X86SelectBranch(Instruction *I); + bool X86SelectOR(Instruction *I); + bool X86SelectShift(Instruction *I); bool X86SelectSelect(Instruction *I); @@ -945,6 +947,44 @@ return true; } +bool X86FastISel::X86SelectOR(Instruction *I) { + // FIXME: This is necessary because tablegen stopped generate fastisel + // patterns after 93152 and 93191 (which turns OR to ADD if the set + // bits in the source operands are known not to overlap). + const TargetRegisterClass *RC = NULL; + unsigned OpReg = 0, OpImm = 0; + if (I->getType()->isInteger(16)) { + RC = X86::GR16RegisterClass; + OpReg = X86::OR16rr; OpImm = X86::OR16ri; + } else if (I->getType()->isInteger(32)) { + RC = X86::GR32RegisterClass; + OpReg = X86::OR32rr; OpImm = X86::OR32ri; + } else if (I->getType()->isInteger(64)) { + RC = X86::GR64RegisterClass; + OpReg = X86::OR32rr; OpImm = X86::OR32ri; + } else + return false; + + unsigned Op0Reg = getRegForValue(I->getOperand(0)); + if (Op0Reg == 0) return false; + + if (ConstantInt *CI = dyn_cast(I->getOperand(1))) { + unsigned ResultReg = createResultReg(RC); + BuildMI(MBB, DL, TII.get(OpImm), ResultReg).addReg(Op0Reg) + .addImm(CI->getZExtValue()); + UpdateValueMap(I, ResultReg); + return true; + } + + unsigned Op1Reg = getRegForValue(I->getOperand(1)); + if (Op1Reg == 0) return false; + + unsigned ResultReg = createResultReg(RC); + BuildMI(MBB, DL, TII.get(OpReg), ResultReg).addReg(Op0Reg).addReg(Op1Reg); + UpdateValueMap(I, ResultReg); + return true; +} + bool X86FastISel::X86SelectShift(Instruction *I) { unsigned CReg = 0, OpReg = 0, OpImm = 0; const TargetRegisterClass *RC = NULL; @@ -1534,6 +1574,8 @@ return X86SelectBranch(I); case Instruction::Call: return X86SelectCall(I); + case Instruction::Or: + return X86SelectOR(I); case Instruction::LShr: case Instruction::AShr: case Instruction::Shl: Modified: llvm/trunk/test/CodeGen/X86/fast-isel.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel.ll?rev=93204&r1=93203&r2=93204&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fast-isel.ll (original) +++ llvm/trunk/test/CodeGen/X86/fast-isel.ll Mon Jan 11 16:59:27 2010 @@ -14,7 +14,7 @@ %t1 = mul i32 %t0, %s %t2 = sub i32 %t1, %s %t3 = and i32 %t2, %s - %t4 = xor i32 %t3, 3 + %t4 = or i32 %t3, %s %t5 = xor i32 %t4, %s %t6 = add i32 %t5, 2 %t7 = getelementptr i32* %y, i32 1 From sabre at nondot.org Mon Jan 11 17:18:35 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 11 Jan 2010 23:18:35 -0000 Subject: [llvm-commits] [llvm] r93206 - /llvm/trunk/test/Transforms/InstCombine/cast.ll Message-ID: <201001112318.o0BNIZeq017524@zion.cs.uiuc.edu> Author: lattner Date: Mon Jan 11 17:18:33 2010 New Revision: 93206 URL: http://llvm.org/viewvc/llvm-project?rev=93206&view=rev Log: disable this testcase, PR5997 Modified: llvm/trunk/test/Transforms/InstCombine/cast.ll Modified: llvm/trunk/test/Transforms/InstCombine/cast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast.ll?rev=93206&r1=93205&r2=93206&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/cast.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/cast.ll Mon Jan 11 17:18:33 2010 @@ -490,12 +490,14 @@ %F = sext i32 %E to i64 ret i64 %F ; CHECK: @test51 -; CHECK-NEXT: %C = and i64 %A, 4294967294 -; CHECK-NEXT: %D = or i64 %A, 1 -; CHECK-NEXT: %E = select i1 %cond, i64 %C, i64 %D -; CHECK-NEXT: %sext = shl i64 %E, 32 -; CHECK-NEXT: %F = ashr i64 %sext, 32 -; CHECK-NEXT: ret i64 %F + +; FIXME: disabled, see PR5997 +; HECK-NEXT: %C = and i64 %A, 4294967294 +; HECK-NEXT: %D = or i64 %A, 1 +; HECK-NEXT: %E = select i1 %cond, i64 %C, i64 %D +; HECK-NEXT: %sext = shl i64 %E, 32 +; HECK-NEXT: %F = ashr i64 %sext, 32 +; HECK-NEXT: ret i64 %F } define i32 @test52(i64 %A) { From grosser at fim.uni-passau.de Mon Jan 11 17:36:29 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 12 Jan 2010 00:36:29 +0100 Subject: [llvm-commits] [PATCH 0/2] Some SuccIterator improvements Message-ID: OK to commit? Tobias Grosser (2): Extend SuccIterator Add getSource() to SuccIterator include/llvm/Support/CFG.h | 68 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 67 insertions(+), 1 deletions(-) From grosser at fim.uni-passau.de Mon Jan 11 17:36:31 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 12 Jan 2010 00:36:31 +0100 Subject: [llvm-commits] [PATCH 2/2] Add getSource() to SuccIterator In-Reply-To: References: Message-ID: <1c4b0b493785abc788bae2af36045f02bcdf85ad.1263252928.git.grosser@fim.uni-passau.de> Get the source BB of an iterator. --- include/llvm/Support/CFG.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) -------------- next part -------------- A non-text attachment was scrubbed... Name: 0002-Add-getSource-to-SuccIterator.patch Type: text/x-patch Size: 438 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100112/102ecd94/attachment.bin From grosser at fim.uni-passau.de Mon Jan 11 17:36:30 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 12 Jan 2010 00:36:30 +0100 Subject: [llvm-commits] [PATCH 1/2] Extend SuccIterator In-Reply-To: References: Message-ID: <696c556ec1eb9711328c99fcc3cdce51b7546e09.1263252928.git.grosser@fim.uni-passau.de> Implement most of the missing methods to make SuccIterator random access. operator[] is still missing. --- include/llvm/Support/CFG.h | 63 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 62 insertions(+), 1 deletions(-) -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Extend-SuccIterator.patch Type: text/x-patch Size: 3083 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100112/e9210688/attachment.bin From sabre at nondot.org Mon Jan 11 17:41:10 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 11 Jan 2010 23:41:10 -0000 Subject: [llvm-commits] [llvm] r93208 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <201001112341.o0BNfA1C018411@zion.cs.uiuc.edu> Author: lattner Date: Mon Jan 11 17:41:09 2010 New Revision: 93208 URL: http://llvm.org/viewvc/llvm-project?rev=93208&view=rev Log: some cleanup, and make it obvious that ProcessJumpOnPHI only works on branches by renaming it and checking for a branch at the call site. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=93208&r1=93207&r2=93208&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon Jan 11 17:41:09 2010 @@ -102,7 +102,7 @@ bool ProcessBranchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); bool ProcessSwitchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); - bool ProcessJumpOnPHI(PHINode *PN); + bool ProcessBranchOnPHI(PHINode *PN); bool SimplifyPartiallyRedundantLoad(LoadInst *LI); }; @@ -550,11 +550,6 @@ } - // See if this is a phi node in the current block. - if (PHINode *PN = dyn_cast(CondInst)) - if (PN->getParent() == BB) - return ProcessJumpOnPHI(PN); - if (CmpInst *CondCmp = dyn_cast(CondInst)) { if (!LVI && (!isa(CondCmp->getOperand(0)) || @@ -583,8 +578,6 @@ // we see one, check to see if it's partially redundant. If so, insert a PHI // which can then be used to thread the values. // - // This is particularly important because reg2mem inserts loads and stores all - // over the place, and this blocks jump threading if we don't zap them. Value *SimplifyValue = CondInst; if (CmpInst *CondCmp = dyn_cast(SimplifyValue)) if (isa(CondCmp->getOperand(1))) @@ -604,9 +597,14 @@ if (ProcessThreadableEdges(CondInst, BB)) return true; + // If this is an otherwise-unfoldable branch on a phi node in the current + // block, see if we can simplify. + if (PHINode *PN = dyn_cast(CondInst)) + if (PN->getParent() == BB && isa(BB->getTerminator())) + return ProcessBranchOnPHI(PN); // TODO: If we have: "br (X > 0)" and we have a predecessor where we know - // "(X == 4)" thread through this block. + // "(X == 4)", thread through this block. return false; } @@ -1068,24 +1066,17 @@ return ThreadEdge(BB, PredsToFactor, MostPopularDest); } -/// ProcessJumpOnPHI - We have a conditional branch or switch on a PHI node in -/// the current block. See if there are any simplifications we can do based on -/// inputs to the phi node. +/// ProcessBranchOnPHI - We have an otherwise unthreadable conditional branch on +/// a PHI node in the current block. See if there are any simplifications we +/// can do based on inputs to the phi node. /// -bool JumpThreading::ProcessJumpOnPHI(PHINode *PN) { +bool JumpThreading::ProcessBranchOnPHI(PHINode *PN) { BasicBlock *BB = PN->getParent(); // If any of the predecessor blocks end in an unconditional branch, we can - // *duplicate* the jump into that block in order to further encourage jump - // threading and to eliminate cases where we have branch on a phi of an icmp - // (branch on icmp is much better). - - // We don't want to do this tranformation for switches, because we don't - // really want to duplicate a switch. - if (isa(BB->getTerminator())) - return false; - - // Look for unconditional branch predecessors. + // *duplicate* the conditional branch into that block in order to further + // encourage jump threading and to eliminate cases where we have branch on a + // phi of an icmp (branch on icmp is much better). for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { BasicBlock *PredBB = PN->getIncomingBlock(i); if (BranchInst *PredBr = dyn_cast(PredBB->getTerminator())) @@ -1098,7 +1089,6 @@ return false; } - /// AddPHINodeEntriesForMappedBlock - We're adding 'NewPred' as a new /// predecessor to the PHIBB block. If it has PHI nodes, add entries for /// NewPred using the entries from OldPred (suitably mapped). From clattner at apple.com Mon Jan 11 17:58:41 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 11 Jan 2010 15:58:41 -0800 Subject: [llvm-commits] [PATCH 0/2] Some SuccIterator improvements In-Reply-To: References: Message-ID: <2B25418A-7897-4308-877B-6446D2E05CF9@apple.com> On Jan 11, 2010, at 3:36 PM, Tobias Grosser wrote: > OK to commit? > > Tobias Grosser (2): > Extend SuccIterator > Add getSource() to SuccIterator ENOPATCH :) -Chris From grosser at fim.uni-passau.de Mon Jan 11 18:03:30 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 12 Jan 2010 01:03:30 +0100 Subject: [llvm-commits] [PATCH 0/2] Some SuccIterator improvements In-Reply-To: <14346_1263254292_4B4BBB14_14346_5124_1_2B25418A-7897-4308-877B-6446D2E05CF9@apple.com> References: <14346_1263254292_4B4BBB14_14346_5124_1_2B25418A-7897-4308-877B-6446D2E05CF9@apple.com> Message-ID: <4B4BBC52.2070105@fim.uni-passau.de> On 01/12/10 00:58, Chris Lattner wrote: > > On Jan 11, 2010, at 3:36 PM, Tobias Grosser wrote: > >> OK to commit? This should be just a cover letter, to summerize the changes and to include the "OK to commit?" question. The patches are in the next two mails: >> Extend SuccIterator >> Add getSource() to SuccIterator > > ENOPATCH :) More like EBADTHREADING or EUSELESSCOVERLETTER. ;-) I should change it the for the next patch. Tobias From evan.cheng at apple.com Mon Jan 11 18:09:38 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 12 Jan 2010 00:09:38 -0000 Subject: [llvm-commits] [llvm] r93210 - in /llvm/trunk: include/llvm/Target/TargetInstrInfo.h lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.h Message-ID: <201001120009.o0C09cjq019523@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jan 11 18:09:37 2010 New Revision: 93210 URL: http://llvm.org/viewvc/llvm-project?rev=93210&view=rev Log: Add TargetInstrInfo::isCoalescableInstr. It returns true if the specified instruction is copy like where the source and destination registers can overlap. This is to be used by the coalescable to coalesce the source and destination registers of instructions like X86::MOVSX64rr32. Apparently some crazy people believe the coalescer is too simple. Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.h Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=93210&r1=93209&r2=93210&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Mon Jan 11 18:09:37 2010 @@ -149,6 +149,19 @@ return false; } + /// isCoalescableInstr - Return true if the instruction is "coalescable". That + /// is, it's like a copy where it's legal for the source to overlap the + /// destination. e.g. X86::MOVSX64rr32. + virtual bool isCoalescableInstr(const MachineInstr &MI, bool &isCopy, + unsigned &SrcReg, unsigned &DstReg, + unsigned &SrcSubIdx, unsigned &DstSubIdx) const { + if (isMoveInstr(MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx)) { + isCopy = true; + return true; + } + return false; + } + /// isIdentityCopy - Return true if the instruction is a copy (or /// extract_subreg, insert_subreg, subreg_to_reg) where the source and /// destination registers are the same. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=93210&r1=93209&r2=93210&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Mon Jan 11 18:09:37 2010 @@ -712,6 +712,59 @@ } } +bool +X86InstrInfo::isCoalescableInstr(const MachineInstr &MI, bool &isCopy, + unsigned &SrcReg, unsigned &DstReg, + unsigned &SrcSubIdx, unsigned &DstSubIdx) const { + switch (MI.getOpcode()) { + default: break; + case X86::MOVSX16rr8: + case X86::MOVZX16rr8: + case X86::MOVSX32rr8: + case X86::MOVZX32rr8: + case X86::MOVSX64rr8: + case X86::MOVZX64rr8: + case X86::MOVSX32rr16: + case X86::MOVZX32rr16: + case X86::MOVSX64rr16: + case X86::MOVZX64rr16: + case X86::MOVSX64rr32: + case X86::MOVZX64rr32: { + if (MI.getOperand(0).getSubReg() || MI.getOperand(1).getSubReg()) + // Be conservative. + return false; + isCopy = false; + SrcReg = MI.getOperand(1).getReg(); + DstReg = MI.getOperand(0).getReg(); + DstSubIdx = 0; + switch (MI.getOpcode()) { + default: + llvm_unreachable(0); + break; + case X86::MOVSX16rr8: + case X86::MOVZX16rr8: + case X86::MOVSX32rr8: + case X86::MOVZX32rr8: + case X86::MOVSX64rr8: + case X86::MOVZX64rr8: + SrcSubIdx = 1; + break; + case X86::MOVSX32rr16: + case X86::MOVZX32rr16: + case X86::MOVSX64rr16: + case X86::MOVZX64rr16: + SrcSubIdx = 3; + break; + case X86::MOVSX64rr32: + case X86::MOVZX64rr32: + SrcSubIdx = 4; + break; + } + } + } + return isMoveInstr(MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx); +} + /// isFrameOperand - Return true and the FrameIndex if the specified /// operand and follow operands form a reference to the stack frame. bool X86InstrInfo::isFrameOperand(const MachineInstr *MI, unsigned int Op, Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=93210&r1=93209&r2=93210&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Mon Jan 11 18:09:37 2010 @@ -448,6 +448,14 @@ unsigned &SrcReg, unsigned &DstReg, unsigned &SrcSubIdx, unsigned &DstSubIdx) const; + /// isCoalescableInstr - Return true if the instruction is "coalescable". That + /// is, it's like a copy where it's legal for the source to overlap the + /// destination. e.g. X86::MOVSX64rr32. + virtual bool isCoalescableInstr(const MachineInstr &MI, bool &isCopy, + unsigned &SrcReg, unsigned &DstReg, + unsigned &SrcSubIdx, unsigned &DstSubIdx) const; + + unsigned isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const; /// isLoadFromStackSlotPostFE - Check for post-frame ptr elimination /// stack locations as well. This uses a heuristic so it isn't From dalej at apple.com Mon Jan 11 20:01:53 2010 From: dalej at apple.com (Dale Johannesen) Date: Tue, 12 Jan 2010 02:01:53 -0000 Subject: [llvm-commits] [llvm] r93220 - /llvm/trunk/include/llvm/CodeGen/MachineOperand.h Message-ID: <201001120201.o0C21sAH023798@zion.cs.uiuc.edu> Author: johannes Date: Mon Jan 11 20:01:53 2010 New Revision: 93220 URL: http://llvm.org/viewvc/llvm-project?rev=93220&view=rev Log: Add MO_Metadata as an operand kind. Not used yet. Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineOperand.h?rev=93220&r1=93219&r2=93220&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineOperand.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineOperand.h Mon Jan 11 20:01:53 2010 @@ -26,6 +26,7 @@ class MachineInstr; class TargetMachine; class MachineRegisterInfo; +class MDNode; class raw_ostream; /// MachineOperand class - Representation of each machine instruction operand. @@ -42,7 +43,8 @@ MO_JumpTableIndex, ///< Address of indexed Jump Table for switch MO_ExternalSymbol, ///< Name of external global symbol MO_GlobalAddress, ///< Address of a global value - MO_BlockAddress ///< Address of a basic block + MO_BlockAddress, ///< Address of a basic block + MO_Metadata ///< Metadata reference (for debug info) }; private: @@ -94,6 +96,7 @@ MachineBasicBlock *MBB; // For MO_MachineBasicBlock. const ConstantFP *CFP; // For MO_FPImmediate. int64_t ImmVal; // For MO_Immediate. + MDNode *MD; // For MO_Metadata. struct { // For MO_Register. unsigned RegNo; @@ -158,6 +161,8 @@ bool isSymbol() const { return OpKind == MO_ExternalSymbol; } /// isBlockAddress - Tests if this is a MO_BlockAddress operand. bool isBlockAddress() const { return OpKind == MO_BlockAddress; } + /// isMetadata - Tests if this is a MO_Metadata operand. + bool isMetadata() const { return OpKind == MO_Metadata; } //===--------------------------------------------------------------------===// // Accessors for Register Operands @@ -311,6 +316,11 @@ assert(isSymbol() && "Wrong MachineOperand accessor"); return Contents.OffsetedInfo.Val.SymbolName; } + + MDNode *getMetadata() const { + assert(isMetadata() && "Wrong MachineOperand accessor"); + return Contents.MD; + } //===--------------------------------------------------------------------===// // Mutators for various operand types. @@ -443,6 +453,13 @@ Op.setTargetFlags(TargetFlags); return Op; } + static MachineOperand CreateMetadata(MDNode *Meta, + unsigned char TargetFlags = 0) { + MachineOperand Op(MachineOperand::MO_Metadata); + Op.Contents.MD = Meta; + Op.setTargetFlags(TargetFlags); + return Op; + } friend class MachineInstr; friend class MachineRegisterInfo; From sabre at nondot.org Mon Jan 11 20:07:17 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 12 Jan 2010 02:07:17 -0000 Subject: [llvm-commits] [llvm] r93221 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/basic.ll Message-ID: <201001120207.o0C27HfE024002@zion.cs.uiuc.edu> Author: lattner Date: Mon Jan 11 20:07:17 2010 New Revision: 93221 URL: http://llvm.org/viewvc/llvm-project?rev=93221&view=rev Log: Teach jump threading to duplicate small blocks when the branch condition is a xor with a phi node. This eliminates nonsense like this from 176.gcc in several places: LBB166_84: testl %eax, %eax - setne %al - xorb %cl, %al - notb %al - testb $1, %al - je LBB166_85 + je LBB166_69 + jmp LBB166_85 This is rdar://7391699 Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/test/Transforms/JumpThreading/basic.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=93221&r1=93220&r2=93221&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon Jan 11 20:07:17 2010 @@ -89,7 +89,7 @@ bool ThreadEdge(BasicBlock *BB, const SmallVectorImpl &PredBBs, BasicBlock *SuccBB); bool DuplicateCondBranchOnPHIIntoPred(BasicBlock *BB, - BasicBlock *PredBB); + const SmallVectorImpl &PredBBs); typedef SmallVectorImpl > PredValueInfo; @@ -103,6 +103,7 @@ bool ProcessSwitchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); bool ProcessBranchOnPHI(PHINode *PN); + bool ProcessBranchOnXOR(BinaryOperator *BO); bool SimplifyPartiallyRedundantLoad(LoadInst *LI); }; @@ -603,6 +604,13 @@ if (PN->getParent() == BB && isa(BB->getTerminator())) return ProcessBranchOnPHI(PN); + + // If this is an otherwise-unfoldable branch on a XOR, see if we can simplify. + if (CondInst->getOpcode() == Instruction::Xor && + CondInst->getParent() == BB && isa(BB->getTerminator())) + return ProcessBranchOnXOR(cast(CondInst)); + + // TODO: If we have: "br (X > 0)" and we have a predecessor where we know // "(X == 4)", thread through this block. @@ -1073,6 +1081,11 @@ bool JumpThreading::ProcessBranchOnPHI(PHINode *PN) { BasicBlock *BB = PN->getParent(); + // TODO: We could make use of this to do it once for blocks with common PHI + // values. + SmallVector PredBBs; + PredBBs.resize(1); + // If any of the predecessor blocks end in an unconditional branch, we can // *duplicate* the conditional branch into that block in order to further // encourage jump threading and to eliminate cases where we have branch on a @@ -1080,15 +1093,96 @@ for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { BasicBlock *PredBB = PN->getIncomingBlock(i); if (BranchInst *PredBr = dyn_cast(PredBB->getTerminator())) - if (PredBr->isUnconditional() && - // Try to duplicate BB into PredBB. - DuplicateCondBranchOnPHIIntoPred(BB, PredBB)) - return true; + if (PredBr->isUnconditional()) { + PredBBs[0] = PredBB; + // Try to duplicate BB into PredBB. + if (DuplicateCondBranchOnPHIIntoPred(BB, PredBBs)) + return true; + } } return false; } +/// ProcessBranchOnXOR - We have an otherwise unthreadable conditional branch on +/// a xor instruction in the current block. See if there are any +/// simplifications we can do based on inputs to the xor. +/// +bool JumpThreading::ProcessBranchOnXOR(BinaryOperator *BO) { + BasicBlock *BB = BO->getParent(); + + // If either the LHS or RHS of the xor is a constant, don't do this + // optimization. + if (isa(BO->getOperand(0)) || + isa(BO->getOperand(1))) + return false; + + // If we have a xor as the branch input to this block, and we know that the + // LHS or RHS of the xor in any predecessor is true/false, then we can clone + // the condition into the predecessor and fix that value to true, saving some + // logical ops on that path and encouraging other paths to simplify. + // + // This copies something like this: + // + // BB: + // %X = phi i1 [1], [%X'] + // %Y = icmp eq i32 %A, %B + // %Z = xor i1 %X, %Y + // br i1 %Z, ... + // + // Into: + // BB': + // %Y = icmp ne i32 %A, %B + // br i1 %Z, ... + + SmallVector, 8> XorOpValues; + bool isLHS = true; + if (!ComputeValueKnownInPredecessors(BO->getOperand(0), BB, XorOpValues)) { + assert(XorOpValues.empty()); + if (!ComputeValueKnownInPredecessors(BO->getOperand(1), BB, XorOpValues)) + return false; + isLHS = false; + } + + assert(!XorOpValues.empty() && + "ComputeValueKnownInPredecessors returned true with no values"); + + // Scan the information to see which is most popular: true or false. The + // predecessors can be of the set true, false, or undef. + unsigned NumTrue = 0, NumFalse = 0; + for (unsigned i = 0, e = XorOpValues.size(); i != e; ++i) { + if (!XorOpValues[i].first) continue; // Ignore undefs for the count. + if (XorOpValues[i].first->isZero()) + ++NumFalse; + else + ++NumTrue; + } + + // Determine which value to split on, true, false, or undef if neither. + ConstantInt *SplitVal = 0; + if (NumTrue > NumFalse) + SplitVal = ConstantInt::getTrue(BB->getContext()); + else if (NumTrue != 0 || NumFalse != 0) + SplitVal = ConstantInt::getFalse(BB->getContext()); + + // Collect all of the blocks that this can be folded into so that we can + // factor this once and clone it once. + SmallVector BlocksToFoldInto; + for (unsigned i = 0, e = XorOpValues.size(); i != e; ++i) { + if (XorOpValues[i].first != SplitVal && XorOpValues[i].first != 0) continue; + + BlocksToFoldInto.push_back(XorOpValues[i].second); + } + + // Try to duplicate BB into PredBB. + if (DuplicateCondBranchOnPHIIntoPred(BB, BlocksToFoldInto)) { +// errs() << "CLONE XOR COND: " << *BB << "Into PRED: " << *BlocksToFoldInto[0]; + return true; + } + return false; +} + + /// AddPHINodeEntriesForMappedBlock - We're adding 'NewPred' as a new /// predecessor to the PHIBB block. If it has PHI nodes, add entries for /// NewPred using the entries from OldPred (suitably mapped). @@ -1277,13 +1371,15 @@ /// improves the odds that the branch will be on an analyzable instruction like /// a compare. bool JumpThreading::DuplicateCondBranchOnPHIIntoPred(BasicBlock *BB, - BasicBlock *PredBB) { + const SmallVectorImpl &PredBBs) { + assert(!PredBBs.empty() && "Can't handle an empty set"); + // If BB is a loop header, then duplicating this block outside the loop would // cause us to transform this into an irreducible loop, don't do this. // See the comments above FindLoopHeaders for justifications and caveats. if (LoopHeaders.count(BB)) { DEBUG(dbgs() << " Not duplicating loop header '" << BB->getName() - << "' into predecessor block '" << PredBB->getName() + << "' into predecessor block '" << PredBBs[0]->getName() << "' - it might create an irreducible loop!\n"); return false; } @@ -1295,12 +1391,32 @@ return false; } + // And finally, do it! Start by factoring the predecessors is needed. + BasicBlock *PredBB; + if (PredBBs.size() == 1) + PredBB = PredBBs[0]; + else { + DEBUG(dbgs() << " Factoring out " << PredBBs.size() + << " common predecessors.\n"); + PredBB = SplitBlockPredecessors(BB, &PredBBs[0], PredBBs.size(), + ".thr_comm", this); + } + // Okay, we decided to do this! Clone all the instructions in BB onto the end // of PredBB. DEBUG(dbgs() << " Duplicating block '" << BB->getName() << "' into end of '" << PredBB->getName() << "' to eliminate branch on phi. Cost: " << DuplicationCost << " block is:" << *BB << "\n"); + // Unless PredBB ends with an unconditional branch, split the edge so that we + // can just clone the bits from BB into the end of the new PredBB. + BranchInst *OldPredBranch = cast(PredBB->getTerminator()); + + if (!OldPredBranch->isUnconditional()) { + PredBB = SplitEdge(PredBB, BB, this); + OldPredBranch = cast(PredBB->getTerminator()); + } + // We are going to have to map operands from the original BB block into the // PredBB block. Evaluate PHI nodes in BB. DenseMap ValueMapping; @@ -1309,8 +1425,6 @@ for (; PHINode *PN = dyn_cast(BI); ++BI) ValueMapping[PN] = PN->getIncomingValueForBlock(PredBB); - BranchInst *OldPredBranch = cast(PredBB->getTerminator()); - // Clone the non-phi instructions of BB into PredBB, keeping track of the // mapping and using it to remap operands in the cloned instructions. for (; BI != BB->end(); ++BI) { Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=93221&r1=93220&r2=93221&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Mon Jan 11 20:07:17 2010 @@ -383,11 +383,11 @@ } -;;; Duplicate condition to avoid xor of cond. -;;; TODO: Make this happen. -define i32 @testXX(i1 %cond, i1 %cond2) { +;; Duplicate condition to avoid xor of cond. +;; rdar://7391699 +define i32 @test13(i1 %cond, i1 %cond2) { Entry: -; CHECK: @testXX +; CHECK: @test13 %v1 = call i32 @f1() br i1 %cond, label %Merge, label %F1 @@ -396,7 +396,8 @@ Merge: %B = phi i1 [true, %Entry], [%cond2, %F1] - %M = icmp eq i32 %v1, 192 + %C = phi i32 [192, %Entry], [%v1, %F1] + %M = icmp eq i32 %C, 192 %N = xor i1 %B, %M br i1 %N, label %T2, label %F2 @@ -405,6 +406,18 @@ F2: ret i32 %v1 + +;; FIXME: CONSTANT FOLD on clone and when phi gets eliminated. + +; CHECK: Entry.Merge_crit_edge: +; CHECK-NEXT: %M1 = icmp eq i32 192, 192 +; CHECK-NEXT: %N2 = xor i1 true, %M1 +; CHECK-NEXT: br i1 %N2, label %T2, label %F2 + +; CHECK: Merge: +; CHECK-NEXT: %M = icmp eq i32 %v1, 192 +; CHECK-NEXT: %N = xor i1 %cond2, %M +; CHECK-NEXT: br i1 %N, label %T2, label %F2 } From sabre at nondot.org Mon Jan 11 20:07:51 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 12 Jan 2010 02:07:51 -0000 Subject: [llvm-commits] [llvm] r93222 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <201001120207.o0C27pdb024053@zion.cs.uiuc.edu> Author: lattner Date: Mon Jan 11 20:07:50 2010 New Revision: 93222 URL: http://llvm.org/viewvc/llvm-project?rev=93222&view=rev Log: tidy up Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=93222&r1=93221&r2=93222&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon Jan 11 20:07:50 2010 @@ -1175,11 +1175,7 @@ } // Try to duplicate BB into PredBB. - if (DuplicateCondBranchOnPHIIntoPred(BB, BlocksToFoldInto)) { -// errs() << "CLONE XOR COND: " << *BB << "Into PRED: " << *BlocksToFoldInto[0]; - return true; - } - return false; + return DuplicateCondBranchOnPHIIntoPred(BB, BlocksToFoldInto); } From gohman at apple.com Mon Jan 11 22:30:28 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 12 Jan 2010 04:30:28 -0000 Subject: [llvm-commits] [llvm] r93227 - /llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Message-ID: <201001120430.o0C4USuN028836@zion.cs.uiuc.edu> Author: djg Date: Mon Jan 11 22:30:26 2010 New Revision: 93227 URL: http://llvm.org/viewvc/llvm-project?rev=93227&view=rev Log: Fix a typo in a comment. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=93227&r1=93226&r2=93227&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Mon Jan 11 22:30:26 2010 @@ -78,7 +78,7 @@ // Look up the value to see if we already have a register for it. We // cache values defined by Instructions across blocks, and other values // only locally. This is because Instructions already have the SSA - // def-dominatess-use requirement enforced. + // def-dominates-use requirement enforced. if (ValueMap.count(V)) return ValueMap[V]; unsigned Reg = LocalValueMap[V]; From gohman at apple.com Mon Jan 11 22:32:35 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 12 Jan 2010 04:32:35 -0000 Subject: [llvm-commits] [llvm] r93228 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <201001120432.o0C4WaT3028909@zion.cs.uiuc.edu> Author: djg Date: Mon Jan 11 22:32:35 2010 New Revision: 93228 URL: http://llvm.org/viewvc/llvm-project?rev=93228&view=rev Log: Update a partially obsolete comment. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=93228&r1=93227&r2=93228&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Jan 11 22:32:35 2010 @@ -865,7 +865,7 @@ SetDebugLoc(MDDbgKind, BI, SDB, FastIS, &MF); - // First try normal tablegen-generated "fast" selection. + // Try to select the instruction with FastISel. if (FastIS->SelectInstruction(BI)) { ResetDebugLoc(SDB, FastIS); continue; From gohman at apple.com Mon Jan 11 22:42:54 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 12 Jan 2010 04:42:54 -0000 Subject: [llvm-commits] [llvm] r93229 - in /llvm/trunk: lib/Target/X86/AsmPrinter/X86MCInstLower.cpp lib/Target/X86/X86ISelDAGToDAG.cpp lib/Target/X86/X86Instr64bit.td lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/remat-mov-0.ll Message-ID: <201001120442.o0C4gtUu029433@zion.cs.uiuc.edu> Author: djg Date: Mon Jan 11 22:42:54 2010 New Revision: 93229 URL: http://llvm.org/viewvc/llvm-project?rev=93229&view=rev Log: Reapply the MOV64r0 patch, with a fix: MOV64r0 clobbers EFLAGS. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/trunk/lib/Target/X86/X86Instr64bit.td llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.td llvm/trunk/test/CodeGen/X86/remat-mov-0.ll Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=93229&r1=93228&r2=93229&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Mon Jan 11 22:42:54 2010 @@ -399,6 +399,14 @@ OutMI.setOpcode(X86::MOVZX32rm16); lower_subreg32(&OutMI, 0); break; + case X86::MOV16r0: + OutMI.setOpcode(X86::MOV32r0); + lower_subreg32(&OutMI, 0); + break; + case X86::MOV64r0: + OutMI.setOpcode(X86::MOV32r0); + lower_subreg32(&OutMI, 0); + break; } } Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=93229&r1=93228&r2=93229&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Mon Jan 11 22:42:54 2010 @@ -1873,7 +1873,6 @@ unsigned LoReg, HiReg, ClrReg; unsigned ClrOpcode, SExtOpcode; - EVT ClrVT = NVT; switch (NVT.getSimpleVT().SimpleTy) { default: llvm_unreachable("Unsupported VT!"); case MVT::i8: @@ -1883,7 +1882,7 @@ break; case MVT::i16: LoReg = X86::AX; HiReg = X86::DX; - ClrOpcode = X86::MOV32r0; ClrReg = X86::EDX; ClrVT = MVT::i32; + ClrOpcode = X86::MOV16r0; ClrReg = X86::DX; SExtOpcode = X86::CWD; break; case MVT::i32: @@ -1893,7 +1892,7 @@ break; case MVT::i64: LoReg = X86::RAX; ClrReg = HiReg = X86::RDX; - ClrOpcode = ~0U; // NOT USED. + ClrOpcode = X86::MOV64r0; SExtOpcode = X86::CQO; break; } @@ -1932,24 +1931,8 @@ SDValue(CurDAG->getMachineNode(SExtOpcode, dl, MVT::Flag, InFlag),0); } else { // Zero out the high part, effectively zero extending the input. - SDValue ClrNode; - - if (NVT.getSimpleVT() == MVT::i64) { - ClrNode = SDValue(CurDAG->getMachineNode(X86::MOV32r0, dl, MVT::i32), - 0); - // We just did a 32-bit clear, insert it into a 64-bit register to - // clear the whole 64-bit reg. - SDValue Zero = CurDAG->getTargetConstant(0, MVT::i64); - SDValue SubRegNo = - CurDAG->getTargetConstant(X86::SUBREG_32BIT, MVT::i32); - ClrNode = - SDValue(CurDAG->getMachineNode(TargetInstrInfo::SUBREG_TO_REG, dl, - MVT::i64, Zero, ClrNode, SubRegNo), - 0); - } else { - ClrNode = SDValue(CurDAG->getMachineNode(ClrOpcode, dl, ClrVT), 0); - } - + SDValue ClrNode = + SDValue(CurDAG->getMachineNode(ClrOpcode, dl, NVT), 0); InFlag = CurDAG->getCopyToReg(CurDAG->getEntryNode(), dl, ClrReg, ClrNode, InFlag).getValue(1); } Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=93229&r1=93228&r2=93229&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Mon Jan 11 22:42:54 2010 @@ -1598,17 +1598,21 @@ // Alias Instructions //===----------------------------------------------------------------------===// -// Alias instructions that map movr0 to xor. Use xorl instead of xorq; it's -// equivalent due to implicit zero-extending, and it sometimes has a smaller -// encoding. +// We want to rewrite MOV64r0 in terms of MOV32r0, because it's sometimes a +// smaller encoding, but doing so at isel time interferes with rematerialization +// in the current register allocator. For now, this is rewritten when the +// instruction is lowered to an MCInst. // FIXME: AddedComplexity gives this a higher priority than MOV64ri32. Remove // when we have a better way to specify isel priority. -let AddedComplexity = 1 in -def : Pat<(i64 0), - (SUBREG_TO_REG (i64 0), (MOV32r0), x86_subreg_32bit)>; - - -// Materialize i64 constant where top 32-bits are zero. +let Defs = [EFLAGS], + AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in +def MOV64r0 : I<0x31, MRMInitReg, (outs GR64:$dst), (ins), + "", + [(set GR64:$dst, 0)]>; + +// Materialize i64 constant where top 32-bits are zero. This could theoretically +// use MOV32ri with a SUBREG_TO_REG to represent the zero-extension, however +// that would make it more difficult to rematerialize. let AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src), "", [(set GR64:$dst, i64immZExt32:$src)]>; Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=93229&r1=93228&r2=93229&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Mon Jan 11 22:42:54 2010 @@ -1072,12 +1072,16 @@ switch (Opc) { default: break; case X86::MOV8r0: - case X86::MOV32r0: { + case X86::MOV16r0: + case X86::MOV32r0: + case X86::MOV64r0: { if (!isSafeToClobberEFLAGS(MBB, I)) { switch (Opc) { default: break; case X86::MOV8r0: Opc = X86::MOV8ri; break; + case X86::MOV16r0: Opc = X86::MOV16ri; break; case X86::MOV32r0: Opc = X86::MOV32ri; break; + case X86::MOV64r0: Opc = X86::MOV64ri; break; } Clone = false; } @@ -2344,8 +2348,12 @@ OpcodeTablePtr = &RegOp2MemOpTable2Addr; isTwoAddrFold = true; } else if (i == 0) { // If operand 0 - if (MI->getOpcode() == X86::MOV32r0) + if (MI->getOpcode() == X86::MOV64r0) + NewMI = MakeM0Inst(*this, X86::MOV64mi32, MOs, MI); + else if (MI->getOpcode() == X86::MOV32r0) NewMI = MakeM0Inst(*this, X86::MOV32mi, MOs, MI); + else if (MI->getOpcode() == X86::MOV16r0) + NewMI = MakeM0Inst(*this, X86::MOV16mi, MOs, MI); else if (MI->getOpcode() == X86::MOV8r0) NewMI = MakeM0Inst(*this, X86::MOV8mi, MOs, MI); if (NewMI) @@ -2613,7 +2621,9 @@ } else if (OpNum == 0) { // If operand 0 switch (Opc) { case X86::MOV8r0: + case X86::MOV16r0: case X86::MOV32r0: + case X86::MOV64r0: return true; default: break; } Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=93229&r1=93228&r2=93229&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon Jan 11 22:42:54 2010 @@ -3734,18 +3734,21 @@ def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "xor{b}\t$dst, $dst", [(set GR8:$dst, 0)]>; + +// We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller +// encoding and avoids a partial-register update sometimes, but doing so +// at isel time interferes with rematerialization in the current register +// allocator. For now, this is rewritten when the instruction is lowered +// to an MCInst. +def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins), + "", + [(set GR16:$dst, 0)]>, OpSize; def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "xor{l}\t$dst, $dst", [(set GR32:$dst, 0)]>; } -// Use xorl instead of xorw since we don't care about the high 16 bits, -// it's smaller, and it avoids a partial-register update. -let AddedComplexity = 1 in -def : Pat<(i16 0), - (EXTRACT_SUBREG (MOV32r0), x86_subreg_16bit)>; - //===----------------------------------------------------------------------===// // Thread Local Storage Instructions // Modified: llvm/trunk/test/CodeGen/X86/remat-mov-0.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/remat-mov-0.ll?rev=93229&r1=93228&r2=93229&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/remat-mov-0.ll (original) +++ llvm/trunk/test/CodeGen/X86/remat-mov-0.ll Mon Jan 11 22:42:54 2010 @@ -1,5 +1,4 @@ ; RUN: llc < %s -march=x86-64 | grep {xorl %edi, %edi} | count 4 -; XFAIL: * ; CodeGen should remat the zero instead of spilling it. From gohman at apple.com Mon Jan 11 22:52:48 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 12 Jan 2010 04:52:48 -0000 Subject: [llvm-commits] [llvm] r93230 - in /llvm/trunk/test: CodeGen/X86/2006-05-11-InstrSched.ll CodeGen/X86/lsr-sort.ll CodeGen/X86/stride-nine-with-base-reg.ll Transforms/LoopStrengthReduce/2009-04-28-no-reduce-mul.ll Transforms/LoopStrengthReduce/dont_reverse.ll Message-ID: <201001120452.o0C4qmKb029726@zion.cs.uiuc.edu> Author: djg Date: Mon Jan 11 22:52:47 2010 New Revision: 93230 URL: http://llvm.org/viewvc/llvm-project?rev=93230&view=rev Log: Make several tests less fragile. Modified: llvm/trunk/test/CodeGen/X86/2006-05-11-InstrSched.ll llvm/trunk/test/CodeGen/X86/lsr-sort.ll llvm/trunk/test/CodeGen/X86/stride-nine-with-base-reg.ll llvm/trunk/test/Transforms/LoopStrengthReduce/2009-04-28-no-reduce-mul.ll llvm/trunk/test/Transforms/LoopStrengthReduce/dont_reverse.ll Modified: llvm/trunk/test/CodeGen/X86/2006-05-11-InstrSched.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2006-05-11-InstrSched.ll?rev=93230&r1=93229&r2=93230&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2006-05-11-InstrSched.ll (original) +++ llvm/trunk/test/CodeGen/X86/2006-05-11-InstrSched.ll Mon Jan 11 22:52:47 2010 @@ -10,9 +10,8 @@ cond_true: ; preds = %cond_true, %entry %indvar = phi i32 [ 0, %entry ], [ %indvar.next, %cond_true ] ; [#uses=2] %tmp. = shl i32 %indvar, 2 ; [#uses=1] - %tmp.10 = add i32 %tmp., 1 ; [#uses=2] - %k.0.0 = bitcast i32 %tmp.10 to i32 ; [#uses=2] - %tmp31 = add i32 %k.0.0, -1 ; [#uses=4] + %tmp.10 = add nsw i32 %tmp., 1 ; [#uses=2] + %tmp31 = add nsw i32 %tmp.10, -1 ; [#uses=4] %tmp32 = getelementptr i32* %mpp, i32 %tmp31 ; [#uses=1] %tmp34 = bitcast i32* %tmp32 to <16 x i8>* ; [#uses=1] %tmp = load <16 x i8>* %tmp34, align 1 @@ -37,14 +36,13 @@ %tmp111 = and <2 x i64> %tmp110, %tmp55.upgrd.2 ; <<2 x i64>> [#uses=1] %tmp121 = and <2 x i64> %tmp99.upgrd.5, %tmp88.upgrd.4 ; <<2 x i64>> [#uses=1] %tmp131 = or <2 x i64> %tmp121, %tmp111 ; <<2 x i64>> [#uses=1] - %gep.upgrd.6 = zext i32 %tmp.10 to i64 ; [#uses=1] - %tmp137 = getelementptr i32* %mc, i64 %gep.upgrd.6 ; [#uses=1] + %tmp137 = getelementptr i32* %mc, i32 %tmp.10 ; [#uses=1] %tmp137.upgrd.7 = bitcast i32* %tmp137 to <2 x i64>* ; <<2 x i64>*> [#uses=1] store <2 x i64> %tmp131, <2 x i64>* %tmp137.upgrd.7 - %tmp147 = add i32 %k.0.0, 8 ; [#uses=1] - %tmp.upgrd.8 = icmp sgt i32 %tmp147, %M ; [#uses=1] + %tmp147 = add nsw i32 %tmp.10, 8 ; [#uses=1] + %tmp.upgrd.8 = icmp slt i32 %tmp147, %M ; [#uses=1] %indvar.next = add i32 %indvar, 1 ; [#uses=1] - br i1 %tmp.upgrd.8, label %return, label %cond_true + br i1 %tmp.upgrd.8, label %cond_true, label %return return: ; preds = %cond_true, %entry ret void Modified: llvm/trunk/test/CodeGen/X86/lsr-sort.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/lsr-sort.ll?rev=93230&r1=93229&r2=93230&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/lsr-sort.ll (original) +++ llvm/trunk/test/CodeGen/X86/lsr-sort.ll Mon Jan 11 22:52:47 2010 @@ -4,7 +4,7 @@ @X = common global i16 0 ; [#uses=1] -define void @foo(i32 %N) nounwind { +define i32 @foo(i32 %N) nounwind { entry: %0 = icmp sgt i32 %N, 0 ; [#uses=1] br i1 %0, label %bb, label %return @@ -18,5 +18,6 @@ br i1 %exitcond, label %return, label %bb return: ; preds = %bb, %entry - ret void + %h = phi i32 [ 0, %entry ], [ %indvar.next, %bb ] + ret i32 %h } Modified: llvm/trunk/test/CodeGen/X86/stride-nine-with-base-reg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/stride-nine-with-base-reg.ll?rev=93230&r1=93229&r2=93230&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/stride-nine-with-base-reg.ll (original) +++ llvm/trunk/test/CodeGen/X86/stride-nine-with-base-reg.ll Mon Jan 11 22:52:47 2010 @@ -7,6 +7,7 @@ @B = external global [1000 x i8], align 32 @A = external global [1000 x i8], align 32 @P = external global [1000 x i8], align 32 + at Q = external global [1000 x i8], align 32 define void @foo(i32 %m, i32 %p) nounwind { entry: @@ -24,6 +25,8 @@ %tmp0 = add i32 %tmp8, %p %tmp10 = getelementptr [1000 x i8]* @P, i32 0, i32 %tmp0 store i8 17, i8* %tmp10, align 4 + %tmp11 = getelementptr [1000 x i8]* @Q, i32 0, i32 %tmp0 + store i8 19, i8* %tmp11, align 4 %indvar.next = add i32 %i.019.0, 1 %exitcond = icmp eq i32 %indvar.next, %m br i1 %exitcond, label %return, label %bb Modified: llvm/trunk/test/Transforms/LoopStrengthReduce/2009-04-28-no-reduce-mul.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/2009-04-28-no-reduce-mul.ll?rev=93230&r1=93229&r2=93230&view=diff ============================================================================== --- llvm/trunk/test/Transforms/LoopStrengthReduce/2009-04-28-no-reduce-mul.ll (original) +++ llvm/trunk/test/Transforms/LoopStrengthReduce/2009-04-28-no-reduce-mul.ll Mon Jan 11 22:52:47 2010 @@ -1,8 +1,12 @@ -; RUN: opt < %s -loop-reduce -S \ -; RUN: | grep {getelementptr.*%lsr.iv.*%lsr.iv.*} +; RUN: opt < %s -loop-reduce -S | FileCheck %s + ; The multiply in bb2 must not be reduced to an add, as the sext causes the ; %1 argument to become negative after a while. -; ModuleID = '' + +; CHECK: sext i8 +; CHECK: mul i32 +; CHECK: store i32 + target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i386-apple-darwin9.6" @table = common global [32 x [256 x i32]] zeroinitializer, align 32 ; <[32 x [256 x i32]]*> [#uses=2] Modified: llvm/trunk/test/Transforms/LoopStrengthReduce/dont_reverse.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/dont_reverse.ll?rev=93230&r1=93229&r2=93230&view=diff ============================================================================== --- llvm/trunk/test/Transforms/LoopStrengthReduce/dont_reverse.ll (original) +++ llvm/trunk/test/Transforms/LoopStrengthReduce/dont_reverse.ll Mon Jan 11 22:52:47 2010 @@ -4,14 +4,14 @@ ; Don't reverse the iteration if the rhs of the compare is defined ; inside the loop. -define void @Fill_Buffer() nounwind { +define void @Fill_Buffer(i2* %p) nounwind { entry: br label %bb8 bb8: %indvar34 = phi i32 [ 0, %entry ], [ %indvar.next35, %bb8 ] %indvar3451 = trunc i32 %indvar34 to i2 - %xmp4344 = xor i2 0, -1 + %xmp4344 = load i2* %p %xmp104 = icmp eq i2 %indvar3451, %xmp4344 %indvar.next35 = add i32 %indvar34, 1 br i1 %xmp104, label %bb10, label %bb8 From gohman at apple.com Tue Jan 12 00:49:22 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 12 Jan 2010 06:49:22 -0000 Subject: [llvm-commits] [test-suite] r93232 - /test-suite/trunk/SingleSource/Benchmarks/Misc/lowercase.c Message-ID: <201001120649.o0C6nMNi000949@zion.cs.uiuc.edu> Author: djg Date: Tue Jan 12 00:49:21 2010 New Revision: 93232 URL: http://llvm.org/viewvc/llvm-project?rev=93232&view=rev Log: Fix a heap corruption bug. Modified: test-suite/trunk/SingleSource/Benchmarks/Misc/lowercase.c Modified: test-suite/trunk/SingleSource/Benchmarks/Misc/lowercase.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/Misc/lowercase.c?rev=93232&r1=93231&r2=93232&view=diff ============================================================================== --- test-suite/trunk/SingleSource/Benchmarks/Misc/lowercase.c (original) +++ test-suite/trunk/SingleSource/Benchmarks/Misc/lowercase.c Tue Jan 12 00:49:21 2010 @@ -30,7 +30,7 @@ static void doTest(size_t numberOfIterations) { const size_t numberOfCharacters = numberOfIterations; - const size_t testDataLength = (numberOfCharacters + staticDataLength) / staticDataLength; + const size_t testDataLength = ((numberOfCharacters + staticDataLength - 1) / staticDataLength) * staticDataLength; UChar* testData = malloc(sizeof(UChar) * testDataLength); size_t i; for (i = 0; i < testDataLength; i += staticDataLength) From baldrick at free.fr Tue Jan 12 02:21:08 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 12 Jan 2010 08:21:08 -0000 Subject: [llvm-commits] [llvm] r93234 - /llvm/trunk/lib/Target/X86/X86Subtarget.h Message-ID: <201001120821.o0C8L8ZY003955@zion.cs.uiuc.edu> Author: baldrick Date: Tue Jan 12 02:21:07 2010 New Revision: 93234 URL: http://llvm.org/viewvc/llvm-project?rev=93234&view=rev Log: Tweak commit 91745, which changed target data for both Mingw and Cygwin, to not touch Cygwin: the change caused llvm-gcc build failures due to long double getting the wrong size. Patch by Aaron Gray. Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=93234&r1=93233&r2=93234&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Tue Jan 12 02:21:07 2010 @@ -174,7 +174,7 @@ p = "e-p:64:64-s:64-f64:64:64-i64:64:64-f80:128:128-n8:16:32:64"; else if (isTargetDarwin()) p = "e-p:32:32-f64:32:64-i64:32:64-f80:128:128-n8:16:32"; - else if (isTargetCygMing() || isTargetWindows()) + else if (isTargetMing() || isTargetWindows()) p = "e-p:32:32-f64:64:64-i64:64:64-f80:128:128-n8:16:32"; else p = "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32"; From baldrick at free.fr Tue Jan 12 02:30:46 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 12 Jan 2010 08:30:46 -0000 Subject: [llvm-commits] [llvm] r93235 - /llvm/trunk/lib/Target/X86/X86Subtarget.h Message-ID: <201001120830.o0C8Ul0Q004368@zion.cs.uiuc.edu> Author: baldrick Date: Tue Jan 12 02:30:46 2010 New Revision: 93235 URL: http://llvm.org/viewvc/llvm-project?rev=93235&view=rev Log: Fix typo. Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=93235&r1=93234&r2=93235&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Tue Jan 12 02:30:46 2010 @@ -174,7 +174,7 @@ p = "e-p:64:64-s:64-f64:64:64-i64:64:64-f80:128:128-n8:16:32:64"; else if (isTargetDarwin()) p = "e-p:32:32-f64:32:64-i64:32:64-f80:128:128-n8:16:32"; - else if (isTargetMing() || isTargetWindows()) + else if (isTargetMingw() || isTargetWindows()) p = "e-p:32:32-f64:64:64-i64:64:64-f80:128:128-n8:16:32"; else p = "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32"; From baldrick at free.fr Tue Jan 12 02:37:00 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 12 Jan 2010 09:37:00 +0100 Subject: [llvm-commits] [llvm] r93234 - /llvm/trunk/lib/Target/X86/X86Subtarget.h In-Reply-To: References: <201001120821.o0C8L8ZY003955@zion.cs.uiuc.edu> Message-ID: <4B4C34AC.6080901@free.fr> Hi Anton, >> - else if (isTargetCygMing() || isTargetWindows()) >> + else if (isTargetMing() || isTargetWindows()) > This won't compile (no such method) I since corrected it to isTargetMingw. Sorry for the noise. Ciao, Duncan. From anton at korobeynikov.info Tue Jan 12 02:38:12 2010 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 12 Jan 2010 11:38:12 +0300 Subject: [llvm-commits] [llvm] r93234 - /llvm/trunk/lib/Target/X86/X86Subtarget.h In-Reply-To: <4B4C34AC.6080901@free.fr> References: <201001120821.o0C8L8ZY003955@zion.cs.uiuc.edu> <4B4C34AC.6080901@free.fr> Message-ID: >>> - ? ?else if (isTargetCygMing() || isTargetWindows()) >>> + ? ?else if (isTargetMing() || isTargetWindows()) >> >> This won't compile (no such method) > > I since corrected it to isTargetMingw. ?Sorry for the noise. Thanks! -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From echristo at apple.com Tue Jan 12 02:47:08 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 12 Jan 2010 08:47:08 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93236 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <201001120847.o0C8l8QU006744@zion.cs.uiuc.edu> Author: echristo Date: Tue Jan 12 02:47:07 2010 New Revision: 93236 URL: http://llvm.org/viewvc/llvm-project?rev=93236&view=rev Log: This is always going to be a ConstantInt. 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=93236&r1=93235&r2=93236&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Jan 12 02:47:07 2010 @@ -4985,8 +4985,7 @@ // LLVM doesn't handle type 1 or type 3. Deal with that here. Value *Tmp = Emit(ObjTy, 0); - ConstantInt *CI = dyn_cast(Tmp); - assert(CI); + ConstantInt *CI = cast(Tmp); // Clear the bottom bit since we only handle whole objects and shift to turn // the second bit into our boolean. From echristo at apple.com Tue Jan 12 02:47:19 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 12 Jan 2010 00:47:19 -0800 Subject: [llvm-commits] [llvm] r93026 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp In-Reply-To: <4B4831BF.9090008@free.fr> References: <201001082137.o08LbB9A020373@zion.cs.uiuc.edu> <4B4831BF.9090008@free.fr> Message-ID: <2E6AAA2E-DD1C-4F19-9F23-9D7AE83B42E8@apple.com> On Jan 8, 2010, at 11:35 PM, Duncan Sands wrote: > Hi Eric, > >> - ConstantInt *Const = dyn_cast(II->getOperand(2)); >> - >> - if (!Const) return 0; >> - >> + ConstantInt *Const = cast(II->getOperand(2)); > > can you please make the same change in the llvm-gcc code, where you also used > "dyn_cast + assert" rather than "cast". Yep. Got it. -eric From benny.kra at googlemail.com Tue Jan 12 07:27:09 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 12 Jan 2010 14:27:09 +0100 Subject: [llvm-commits] [llvm] r93204 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel.ll In-Reply-To: <201001112259.o0BMxRcR016736@zion.cs.uiuc.edu> References: <201001112259.o0BMxRcR016736@zion.cs.uiuc.edu> Message-ID: Am 11.01.2010 um 23:59 schrieb Evan Cheng: > Author: evancheng > Date: Mon Jan 11 16:59:27 2010 > New Revision: 93204 > > URL: http://llvm.org/viewvc/llvm-project?rev=93204&view=rev > Log: > Add manual ISD::OR fastisel selection routines. TableGen is no longer autogen them after 93152 and 93191. > > Modified: > llvm/trunk/lib/Target/X86/X86FastISel.cpp > llvm/trunk/test/CodeGen/X86/fast-isel.ll > > Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=93204&r1=93203&r2=93204&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Mon Jan 11 16:59:27 2010 > @@ -104,6 +104,8 @@ > > bool X86SelectBranch(Instruction *I); > > + bool X86SelectOR(Instruction *I); > + > bool X86SelectShift(Instruction *I); > > bool X86SelectSelect(Instruction *I); > @@ -945,6 +947,44 @@ > return true; > } > > +bool X86FastISel::X86SelectOR(Instruction *I) { > + // FIXME: This is necessary because tablegen stopped generate fastisel > + // patterns after 93152 and 93191 (which turns OR to ADD if the set > + // bits in the source operands are known not to overlap). > + const TargetRegisterClass *RC = NULL; > + unsigned OpReg = 0, OpImm = 0; > + if (I->getType()->isInteger(16)) { > + RC = X86::GR16RegisterClass; > + OpReg = X86::OR16rr; OpImm = X86::OR16ri; > + } else if (I->getType()->isInteger(32)) { > + RC = X86::GR32RegisterClass; > + OpReg = X86::OR32rr; OpImm = X86::OR32ri; > + } else if (I->getType()->isInteger(64)) { > + RC = X86::GR64RegisterClass; > + OpReg = X86::OR32rr; OpImm = X86::OR32ri; ^^ ^^ Hi Evan, I believe this patch is breaking bootstrap on x86_64. Testcase attached. -------------- next part -------------- A non-text attachment was scrubbed... Name: 2010-01-12-FastISelOR64.ll Type: application/octet-stream Size: 167 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100112/b155d35e/attachment.obj From baldrick at free.fr Tue Jan 12 10:44:03 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 12 Jan 2010 16:44:03 -0000 Subject: [llvm-commits] [dragonegg] r93239 - in /dragonegg/trunk: llvm-convert.cpp llvm-internal.h Message-ID: <201001121644.o0CGi32A006079@zion.cs.uiuc.edu> Author: baldrick Date: Tue Jan 12 10:44:01 2010 New Revision: 93239 URL: http://llvm.org/viewvc/llvm-project?rev=93239&view=rev Log: Reorder some function bodies and tweak some names. No functionality change intended. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-internal.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=93239&r1=93238&r2=93239&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Jan 12 10:44:01 2010 @@ -910,7 +910,7 @@ Function *TreeToLLVM::FinishFunctionBody() { // Insert the return block at the end of the function. - EmitBlock(ReturnBB); + BeginBlock(ReturnBB); SmallVector RetVals; @@ -1053,7 +1053,7 @@ // Avoid outputting a pointless branch at the end of the entry block. if (bb != ENTRY_BLOCK_PTR) - EmitBlock(getBasicBlock(bb)); + BeginBlock(getBasicBlock(bb)); // Create an LLVM phi node for each GCC phi and define the associated ssa name // using it. Do not populate with operands at this point since some ssa names @@ -1357,9 +1357,9 @@ return MemRef(AI, AI->getAlignment(), false); } -/// EmitBlock - Add the specified basic block to the end of the function. If +/// BeginBlock - Add the specified basic block to the end of the function. If /// the previous block falls through into it, add an explicit branch. -void TreeToLLVM::EmitBlock(BasicBlock *BB) { +void TreeToLLVM::BeginBlock(BasicBlock *BB) { BasicBlock *CurBB = Builder.GetInsertBlock(); // If the previous block falls through to BB, add an explicit branch. if (CurBB->getTerminator() == 0) { @@ -1531,7 +1531,6 @@ } /// EmitAggregateZero - Zero the elements of DestLoc. -/// void TreeToLLVM::EmitAggregateZero(MemRef DestLoc, tree type) { // If the type is small, copy the elements instead of using a block copy. if (TREE_CODE(TYPE_SIZE(type)) == INTEGER_CST && @@ -1822,7 +1821,7 @@ CreateExceptionValues(); - EmitBlock(LandingPad); + BeginBlock(LandingPad); // Fetch and store the exception. Value *Ex = Builder.CreateCall(FuncEHException, "eh_ptr"); @@ -1928,7 +1927,7 @@ CreateExceptionValues(); - EmitBlock(PostPad); + BeginBlock(PostPad); abort();//FIXME //FIXME eh_region region = get_eh_region(i); @@ -1951,7 +1950,7 @@ //FIXME // Branch on the compare. //FIXME BasicBlock *NoFilterBB = BasicBlock::Create(Context, "nofilter"); //FIXME Builder.CreateCondBr(Compare, Dest, NoFilterBB); -//FIXME EmitBlock(NoFilterBB); +//FIXME BeginBlock(NoFilterBB); //FIXME } else if (RegionKind > 0) { //FIXME // Catch //FIXME tree TypeList = get_eh_type_list(region); @@ -1997,7 +1996,7 @@ //FIXME NoCatchBB = BasicBlock::Create(Context, "nocatch"); //FIXME // Branch on the compare. //FIXME Builder.CreateCondBr(Cond, Dest, NoCatchBB); -//FIXME EmitBlock(NoCatchBB); +//FIXME BeginBlock(NoCatchBB); //FIXME } //FIXME //FIXME // Emit a RESX_EXPR which skips handlers with no post landing pad. @@ -2035,7 +2034,7 @@ void TreeToLLVM::EmitUnwindBlock() { if (UnwindBB) { CreateExceptionValues(); - EmitBlock(UnwindBB); + BeginBlock(UnwindBB); abort();//FIXME //FIXME // Fetch and store exception handler. //FIXME Value *Arg = Builder.CreateLoad(ExceptionValue, "eh_ptr"); @@ -2080,170 +2079,6 @@ return false; } -/// EmitSSA_NAME - Return the defining value of the given SSA_NAME. -/// Only creates code in the entry block. -Value *TreeToLLVM::EmitSSA_NAME(tree reg) { - assert(TREE_CODE(reg) == SSA_NAME && "Expected an SSA name!"); - assert(is_gimple_reg_type(TREE_TYPE(reg)) && "Not of register type!"); - - // If we already found the definition of the SSA name, return it. - if (Value *ExistingValue = SSANames[reg]) { - assert(ExistingValue->getType() == ConvertType(TREE_TYPE(reg)) && - "SSA name has wrong type!"); - if (!isSSAPlaceholder(ExistingValue)) - return ExistingValue; - } - - // If this is not the definition of the SSA name, return a placeholder value. - if (!SSA_NAME_IS_DEFAULT_DEF(reg)) { - if (Value *ExistingValue = SSANames[reg]) - return ExistingValue; - return SSANames[reg] = GetSSAPlaceholder(ConvertType(TREE_TYPE(reg))); - } - - // This SSA name is the default definition for the underlying symbol. - - // The underlying symbol is an SSA variable. - tree var = SSA_NAME_VAR(reg); - assert(SSA_VAR_P(var) && "Not an SSA variable!"); - - // If the variable is itself an ssa name, use its LLVM value. - if (TREE_CODE (var) == SSA_NAME) { - Value *Val = EmitSSA_NAME(var); - assert(Val->getType() == ConvertType(TREE_TYPE(reg)) && - "SSA name has wrong type!"); - return DefineSSAName(reg, Val); - } - - // Otherwise the symbol is a VAR_DECL, PARM_DECL or RESULT_DECL. Since a - // default definition is only created if the very first reference to the - // variable in the function is a read operation, and refers to the value - // read, it has an undefined value except for PARM_DECLs. - if (TREE_CODE(var) != PARM_DECL) - return DefineSSAName(reg, UndefValue::get(ConvertType(TREE_TYPE(reg)))); - - // Read the initial value of the parameter and associate it with the ssa name. - assert(DECL_LOCAL_IF_SET(var) && "Parameter not laid out?"); - - unsigned Alignment = DECL_ALIGN(var); - assert(Alignment != 0 && "Parameter with unknown alignment!"); - - const Type *Ty = ConvertType(TREE_TYPE(reg)); - - // Perform the load in the entry block, after all parameters have been set up - // with their initial values, and before any modifications to their values. - LoadInst *LI = new LoadInst(DECL_LOCAL_IF_SET(var), "", SSAInsertionPoint); - LI->setAlignment(Alignment); - - // Potentially perform a useless type conversion (useless_type_conversion_p). - Value *Def = LI; - if (LI->getType() != Ty) - Def = new BitCastInst(Def, Ty, "", SSAInsertionPoint); - if (flag_verbose_asm) - NameValue(Def, reg); - return DefineSSAName(reg, Def); -} - -/// EmitInvariantAddress - The given address is constant in this function. -/// Return the corresponding LLVM value. Only creates code in the entry block. -Value *TreeToLLVM::EmitInvariantAddress(tree addr) { - assert(is_gimple_invariant_address(addr) && - "Expected a locally constant address!"); - assert(is_gimple_reg_type(TREE_TYPE(addr)) && "Not of register type!"); - - // Any generated code goes in the entry block. - BasicBlock *EntryBlock = Fn->begin(); - - // Note the current builder position. - BasicBlock *SavedInsertBB = Builder.GetInsertBlock(); - BasicBlock::iterator SavedInsertPoint = Builder.GetInsertPoint(); - - // Pop the entry block terminator. There may not be a terminator if we are - // recursing or if the entry block was not yet finished. - Instruction *Terminator = EntryBlock->getTerminator(); - assert(((SavedInsertBB != EntryBlock && Terminator) || - (SavedInsertPoint == EntryBlock->end() && !Terminator)) && - "Insertion point doesn't make sense!"); - if (Terminator) - Terminator->removeFromParent(); - - // Point the builder at the end of the entry block. - Builder.SetInsertPoint(EntryBlock); - - // Calculate the address. - assert(TREE_CODE(addr) == ADDR_EXPR && "Invariant address not ADDR_EXPR!"); - Value *Address = EmitADDR_EXPR(addr); - - // Restore the entry block terminator. - if (Terminator) - EntryBlock->getInstList().push_back(Terminator); - - // Restore the builder insertion point. - if (SavedInsertBB != EntryBlock) - Builder.SetInsertPoint(SavedInsertBB, SavedInsertPoint); - - assert(Address->getType() == ConvertType(TREE_TYPE(addr)) && - "Invariant address has wrong type!"); - return Address; -} - -/// EmitRegisterConstant - Convert the given global constant of register type to -/// an LLVM constant. Creates no code, only constants. -Constant *TreeToLLVM::EmitRegisterConstant(tree reg) { -#ifndef NDEBUG - if (!is_gimple_constant(reg)) { - debug_tree(reg); - llvm_unreachable("Not a gimple constant!"); - } -#endif - assert(is_gimple_reg_type(TREE_TYPE(reg)) && "Not of register type!"); - - Constant *C; - switch (TREE_CODE(reg)) { - default: - debug_tree(reg); - llvm_unreachable("Unhandled GIMPLE constant!"); - - case INTEGER_CST: - C = TreeConstantToLLVM::ConvertINTEGER_CST(reg); - break; - case REAL_CST: - C = TreeConstantToLLVM::ConvertREAL_CST(reg); - break; - case COMPLEX_CST: - C = TreeConstantToLLVM::ConvertCOMPLEX_CST(reg); - break; - case VECTOR_CST: - C = TreeConstantToLLVM::ConvertVECTOR_CST(reg); - break; - case CONSTRUCTOR: - C = TreeConstantToLLVM::ConvertCONSTRUCTOR(reg); - break; - } - assert(C->getType() == ConvertType(TREE_TYPE(reg)) && - "Constant has wrong type!"); - return C; -} - -/// EmitMinInvariant - The given value is constant in this function. Return the -/// corresponding LLVM value. Only creates code in the entry block. -Value *TreeToLLVM::EmitMinInvariant(tree reg) { - Value *V = (TREE_CODE(reg) == ADDR_EXPR) ? - EmitInvariantAddress(reg) : EmitRegisterConstant(reg); - assert(V->getType() == ConvertType(TREE_TYPE(reg)) && - "Gimple min invariant has wrong type!"); - return V; -} - -/// EmitRegister - Convert the specified gimple register or local constant of -/// register type to an LLVM value. Only creates code in the entry block. -Value *TreeToLLVM::EmitRegister(tree reg) { - while (TREE_CODE(reg) == OBJ_TYPE_REF) reg = OBJ_TYPE_REF_EXPR(reg); - Value *V = (TREE_CODE(reg) == SSA_NAME) ? - EmitSSA_NAME(reg) : EmitMinInvariant(reg); - return Builder.CreateBitCast(V, ConvertType(TREE_TYPE(reg))); -} - /// EmitLoadOfLValue - When an l-value expression is used in a context that /// requires an r-value, this method emits the lvalue computation, then loads /// the result. @@ -2442,280 +2277,75 @@ return 0; } -Value *TreeToLLVM::EmitGimpleAssignSingleRHS(tree rhs) { - assert(!AGGREGATE_TYPE_P(TREE_TYPE(rhs)) && "Expected a scalar type!"); - - Value *Result = 0; +/// llvm_load_scalar_argument - Load value located at LOC. +static Value *llvm_load_scalar_argument(Value *L, + const llvm::Type *LLVMTy, + unsigned RealSize, + LLVMBuilder &Builder) { + if (!RealSize) + return UndefValue::get(LLVMTy); - switch (TREE_CODE(rhs)) { - default: Result = EmitRegister(rhs); break; + // Not clear what this is supposed to do on big endian machines... + assert(!BYTES_BIG_ENDIAN && "Unsupported case - please report"); + assert(isa(LLVMTy) && "Expected an integer value!"); + const Type *LoadType = IntegerType::get(Context, RealSize * 8); + L = Builder.CreateBitCast(L, LoadType->getPointerTo()); + Value *Val = Builder.CreateLoad(L); + if (LoadType->getPrimitiveSizeInBits() >= LLVMTy->getPrimitiveSizeInBits()) + Val = Builder.CreateTrunc(Val, LLVMTy); + else + Val = Builder.CreateZExt(Val, LLVMTy); + return Val; +} - // Exception handling. -//FIXME case EXC_PTR_EXPR: Result = EmitEXC_PTR_EXPR(rhs); break; -//FIXME case FILTER_EXPR: Result = EmitFILTER_EXPR(rhs); break; +#ifndef LLVM_LOAD_SCALAR_ARGUMENT +#define LLVM_LOAD_SCALAR_ARGUMENT(LOC,TY,SIZE,BUILDER) \ + llvm_load_scalar_argument((LOC),(TY),(SIZE),(BUILDER)) +#endif - // References (tcc_reference). - case ARRAY_REF: - case ARRAY_RANGE_REF: - case BIT_FIELD_REF: - case COMPONENT_REF: - case IMAGPART_EXPR: - case INDIRECT_REF: - case REALPART_EXPR: - case VIEW_CONVERT_EXPR: - // Declarations (tcc_declaration). - case PARM_DECL: - case RESULT_DECL: - case VAR_DECL: - // Constants (tcc_constant). - case STRING_CST: - Result = EmitLoadOfLValue(rhs); - break; +namespace { + /// FunctionCallArgumentConversion - This helper class is driven by the ABI + /// definition for this target to figure out how to pass arguments into the + /// stack/regs for a function call. + struct FunctionCallArgumentConversion : public DefaultABIClient { + SmallVector &CallOperands; + SmallVector LocStack; + const FunctionType *FTy; + const MemRef *DestLoc; + bool useReturnSlot; + LLVMBuilder &Builder; + Value *TheValue; + MemRef RetBuf; + CallingConv::ID &CallingConv; + bool isShadowRet; + bool isAggrRet; + unsigned Offset; - // Expressions (tcc_expression). - case ADDR_EXPR: Result = EmitADDR_EXPR(rhs); break; - case OBJ_TYPE_REF: Result = EmitOBJ_TYPE_REF(rhs); break; + FunctionCallArgumentConversion(SmallVector &ops, + const FunctionType *FnTy, + const MemRef *destloc, + bool ReturnSlotOpt, + LLVMBuilder &b, + CallingConv::ID &CC) + : CallOperands(ops), FTy(FnTy), DestLoc(destloc), + useReturnSlot(ReturnSlotOpt), Builder(b), CallingConv(CC), + isShadowRet(false), isAggrRet(false), Offset(0) { } - // Exceptional (tcc_exceptional). - case CONSTRUCTOR: Result = EmitCONSTRUCTOR(rhs, 0); break; - } + /// getCallingConv - This provides the desired CallingConv for the function. + CallingConv::ID& getCallingConv(void) { return CallingConv; } - // Check that the type of the result matches that of the tree node. - assert(Result && "Expected a scalar, got an aggregate!"); - assert(Result->getType() == ConvertType(TREE_TYPE(rhs)) && - "Value has wrong type!"); - return Result; -} + // Push the address of an argument. + void pushAddress(Value *Loc) { + assert(Loc && "Invalid location!"); + LocStack.push_back(Loc); + } -Value *TreeToLLVM::EmitGimpleAssignRHS(gimple stmt) { - if (get_gimple_rhs_class(gimple_expr_code(stmt)) == GIMPLE_SINGLE_RHS) - return EmitGimpleAssignSingleRHS(gimple_assign_rhs1 (stmt)); - - tree type = TREE_TYPE(gimple_assign_lhs(stmt)); - tree_code code = gimple_assign_rhs_code(stmt); - tree rhs1 = gimple_assign_rhs1(stmt); - tree rhs2 = gimple_assign_rhs2(stmt); - - switch (code) { - default: - dump(stmt); - llvm_unreachable("Unhandled GIMPLE assignment!"); - - // Unary expressions. - case ABS_EXPR: - return EmitABS_EXPR(rhs1); - case BIT_NOT_EXPR: - return EmitBIT_NOT_EXPR(rhs1); - case CONJ_EXPR: - return EmitCONJ_EXPR(rhs1); - case CONVERT_EXPR: - case FIX_TRUNC_EXPR: - case FLOAT_EXPR: - return EmitCONVERT_EXPR(type, rhs1); - case NEGATE_EXPR: - return EmitNEGATE_EXPR(rhs1); - case NOP_EXPR: - return EmitNOP_EXPR(type, rhs1); - case PAREN_EXPR: - return EmitPAREN_EXPR(rhs1); - case TRUTH_NOT_EXPR: - return EmitTRUTH_NOT_EXPR(type, rhs1); - - // Comparisons. - case EQ_EXPR: - case GE_EXPR: - case GT_EXPR: - case LE_EXPR: - case LT_EXPR: - case LTGT_EXPR: - case NE_EXPR: - case ORDERED_EXPR: - case UNEQ_EXPR: - case UNGE_EXPR: - case UNGT_EXPR: - case UNLE_EXPR: - case UNLT_EXPR: - case UNORDERED_EXPR: - // The GCC result may be of any integer type. - return Builder.CreateZExt(EmitCompare(rhs1, rhs2, code), ConvertType(type)); - - // Binary expressions. - case BIT_AND_EXPR: - return EmitBinOp(type, code, rhs1, rhs2, Instruction::And); - case BIT_IOR_EXPR: - return EmitBinOp(type, code, rhs1, rhs2, Instruction::Or); - case BIT_XOR_EXPR: - return EmitBinOp(type, code, rhs1, rhs2, Instruction::Xor); - case CEIL_DIV_EXPR: - return EmitCEIL_DIV_EXPR(type, rhs1, rhs2); - case COMPLEX_EXPR: - return EmitCOMPLEX_EXPR(rhs1, rhs2); - case EXACT_DIV_EXPR: - return EmitBinOp(type, code, rhs1, rhs2, TYPE_UNSIGNED(type) ? - Instruction::UDiv : Instruction::SDiv); - case FLOOR_DIV_EXPR: - return EmitFLOOR_DIV_EXPR(type, rhs1, rhs2); - case FLOOR_MOD_EXPR: - return EmitFLOOR_MOD_EXPR(type, rhs1, rhs2); - case LROTATE_EXPR: - return EmitRotateOp(type, rhs1, rhs2, Instruction::Shl, Instruction::LShr); - case LSHIFT_EXPR: - return EmitShiftOp(rhs1, rhs2, Instruction::Shl); - case MAX_EXPR: - return EmitMinMaxExpr(type, rhs1, rhs2, ICmpInst::ICMP_UGE, - ICmpInst::ICMP_SGE, FCmpInst::FCMP_OGE, true); - case MIN_EXPR: - return EmitMinMaxExpr(type, rhs1, rhs2, ICmpInst::ICMP_ULE, - ICmpInst::ICMP_SLE, FCmpInst::FCMP_OLE, false); - case MINUS_EXPR: - return EmitBinOp(type, code, rhs1, rhs2, FLOAT_TYPE_P(type) ? - Instruction::FSub : Instruction::Sub); - case MULT_EXPR: - return EmitBinOp(type, code, rhs1, rhs2, FLOAT_TYPE_P(type) ? - Instruction::FMul : Instruction::Mul); - case PLUS_EXPR: - return EmitBinOp(type, code, rhs1, rhs2, FLOAT_TYPE_P(type) ? - Instruction::FAdd : Instruction::Add); - case POINTER_PLUS_EXPR: - return EmitPOINTER_PLUS_EXPR(type, rhs1, rhs2); - case RDIV_EXPR: - return EmitBinOp(type, code, rhs1, rhs2, Instruction::FDiv); - case ROUND_DIV_EXPR: - return EmitROUND_DIV_EXPR(type, rhs1, rhs2); - case RROTATE_EXPR: - return EmitRotateOp(type, rhs1, rhs2, Instruction::LShr, Instruction::Shl); - case RSHIFT_EXPR: - return EmitShiftOp(rhs1, rhs2, TYPE_UNSIGNED(type) ? - Instruction::LShr : Instruction::AShr); - case TRUNC_DIV_EXPR: - return EmitBinOp(type, code, rhs1, rhs2, TYPE_UNSIGNED(type) ? - Instruction::UDiv : Instruction::SDiv); - case TRUNC_MOD_EXPR: - return EmitBinOp(type, code, rhs1, rhs2, TYPE_UNSIGNED(type) ? - Instruction::URem : Instruction::SRem); - case TRUTH_AND_EXPR: - return EmitTruthOp(type, rhs1, rhs2, Instruction::And); - case TRUTH_OR_EXPR: - return EmitTruthOp(type, rhs1, rhs2, Instruction::Or); - case TRUTH_XOR_EXPR: - return EmitTruthOp(type, rhs1, rhs2, Instruction::Xor); - } -} - -Value *TreeToLLVM::EmitGimpleCallRHS(gimple stmt, const MemRef *DestLoc) { - // Check for a built-in function call. If we can lower it directly, do so - // now. - tree fndecl = gimple_call_fndecl(stmt); - if (fndecl && DECL_BUILT_IN(fndecl) && - DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_FRONTEND) { - Value *Res = 0; - if (EmitBuiltinCall(stmt, fndecl, DestLoc, Res)) - return Res; - } - - tree call_expr = gimple_call_fn(stmt); - assert(TREE_TYPE (call_expr) && - (TREE_CODE(TREE_TYPE (call_expr)) == POINTER_TYPE || - TREE_CODE(TREE_TYPE (call_expr)) == REFERENCE_TYPE) - && "Not calling a function pointer?"); - - tree function_type = TREE_TYPE(TREE_TYPE (call_expr)); - Value *Callee = EmitRegister(call_expr); - CallingConv::ID CallingConv; - AttrListPtr PAL; - - const Type *Ty = - TheTypeConverter->ConvertFunctionType(function_type, - fndecl, - gimple_call_chain(stmt), - CallingConv, PAL); - - // If this is a direct call to a function using a static chain then we need - // to ensure the function type is the one just calculated: it has an extra - // parameter for the chain. - Callee = Builder.CreateBitCast(Callee, Ty->getPointerTo()); - - Value *Result = EmitCallOf(Callee, stmt, DestLoc, PAL); - - // When calling a "noreturn" function output an unreachable instruction right - // after the function to prevent LLVM from thinking that control flow will - // fall into the subsequent block. - if (gimple_call_flags(stmt) & ECF_NORETURN) { - Builder.CreateUnreachable(); - EmitBlock(BasicBlock::Create(Context)); - } - return Result; -} - -/// llvm_load_scalar_argument - Load value located at LOC. -static Value *llvm_load_scalar_argument(Value *L, - const llvm::Type *LLVMTy, - unsigned RealSize, - LLVMBuilder &Builder) { - if (!RealSize) - return UndefValue::get(LLVMTy); - - // Not clear what this is supposed to do on big endian machines... - assert(!BYTES_BIG_ENDIAN && "Unsupported case - please report"); - assert(isa(LLVMTy) && "Expected an integer value!"); - const Type *LoadType = IntegerType::get(Context, RealSize * 8); - L = Builder.CreateBitCast(L, LoadType->getPointerTo()); - Value *Val = Builder.CreateLoad(L); - if (LoadType->getPrimitiveSizeInBits() >= LLVMTy->getPrimitiveSizeInBits()) - Val = Builder.CreateTrunc(Val, LLVMTy); - else - Val = Builder.CreateZExt(Val, LLVMTy); - return Val; -} - -#ifndef LLVM_LOAD_SCALAR_ARGUMENT -#define LLVM_LOAD_SCALAR_ARGUMENT(LOC,TY,SIZE,BUILDER) \ - llvm_load_scalar_argument((LOC),(TY),(SIZE),(BUILDER)) -#endif - -namespace { - /// FunctionCallArgumentConversion - This helper class is driven by the ABI - /// definition for this target to figure out how to pass arguments into the - /// stack/regs for a function call. - struct FunctionCallArgumentConversion : public DefaultABIClient { - SmallVector &CallOperands; - SmallVector LocStack; - const FunctionType *FTy; - const MemRef *DestLoc; - bool useReturnSlot; - LLVMBuilder &Builder; - Value *TheValue; - MemRef RetBuf; - CallingConv::ID &CallingConv; - bool isShadowRet; - bool isAggrRet; - unsigned Offset; - - FunctionCallArgumentConversion(SmallVector &ops, - const FunctionType *FnTy, - const MemRef *destloc, - bool ReturnSlotOpt, - LLVMBuilder &b, - CallingConv::ID &CC) - : CallOperands(ops), FTy(FnTy), DestLoc(destloc), - useReturnSlot(ReturnSlotOpt), Builder(b), CallingConv(CC), - isShadowRet(false), isAggrRet(false), Offset(0) { } - - /// getCallingConv - This provides the desired CallingConv for the function. - CallingConv::ID& getCallingConv(void) { return CallingConv; } - - // Push the address of an argument. - void pushAddress(Value *Loc) { - assert(Loc && "Invalid location!"); - LocStack.push_back(Loc); - } - - // Push the value of an argument. - void pushValue(Value *V) { - assert(LocStack.empty() && "Value only allowed at top level!"); - LocStack.push_back(NULL); - TheValue = V; - } + // Push the value of an argument. + void pushValue(Value *V) { + assert(LocStack.empty() && "Value only allowed at top level!"); + LocStack.push_back(NULL); + TheValue = V; + } // Get the address of the current location. Value *getAddress(void) { @@ -3061,7 +2691,7 @@ CallOperands.begin(), CallOperands.end()); cast(Call)->setCallingConv(CallingConvention); cast(Call)->setAttributes(PAL); - EmitBlock(NextBlock); + BeginBlock(NextBlock); } if (Client.isShadowReturn()) @@ -4665,7 +4295,7 @@ Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::trap)); // Emit an explicit unreachable instruction. Builder.CreateUnreachable(); - EmitBlock(BasicBlock::Create(Context)); + BeginBlock(BasicBlock::Create(Context)); return true; //TODO // Convert annotation built-in to llvm.annotation intrinsic. @@ -5690,7 +5320,7 @@ Builder.CreateCall(Intrinsic::getDeclaration(TheModule, IID), Args.begin(), Args.end()); Result = Builder.CreateUnreachable(); - EmitBlock(BasicBlock::Create(Context)); + BeginBlock(BasicBlock::Create(Context)); return true; } @@ -6497,90 +6127,581 @@ } } - const Type *Ty = ConvertType(TREE_TYPE(exp)); - // If we have "extern void foo", make the global have type {} instead of - // type void. - if (Ty->isVoidTy()) Ty = StructType::get(Context); - const PointerType *PTy = Ty->getPointerTo(); - unsigned Alignment = Ty->isSized() ? TD.getABITypeAlignment(Ty) : 1; - if (DECL_ALIGN(exp)) { - if (DECL_USER_ALIGN(exp) || 8 * Alignment < (unsigned)DECL_ALIGN(exp)) - Alignment = DECL_ALIGN(exp) / 8; + const Type *Ty = ConvertType(TREE_TYPE(exp)); + // If we have "extern void foo", make the global have type {} instead of + // type void. + if (Ty->isVoidTy()) Ty = StructType::get(Context); + const PointerType *PTy = Ty->getPointerTo(); + unsigned Alignment = Ty->isSized() ? TD.getABITypeAlignment(Ty) : 1; + if (DECL_ALIGN(exp)) { + if (DECL_USER_ALIGN(exp) || 8 * Alignment < (unsigned)DECL_ALIGN(exp)) + Alignment = DECL_ALIGN(exp) / 8; + } + + return LValue(Builder.CreateBitCast(Decl, PTy), Alignment); +} + +LValue TreeToLLVM::EmitLV_EXC_PTR_EXPR(tree exp) { + CreateExceptionValues(); + // Cast the address pointer to the expected type. + unsigned Alignment = TD.getABITypeAlignment(cast(ExceptionValue-> + getType())->getElementType()); + return LValue(Builder.CreateBitCast(ExceptionValue, + PointerType::getUnqual(ConvertType(TREE_TYPE(exp)))), + Alignment); +} + +LValue TreeToLLVM::EmitLV_FILTER_EXPR(tree exp) { + CreateExceptionValues(); + unsigned Alignment = + TD.getABITypeAlignment(cast(ExceptionSelectorValue-> + getType())->getElementType()); + return LValue(ExceptionSelectorValue, Alignment); +} + +LValue TreeToLLVM::EmitLV_INDIRECT_REF(tree exp) { + // The lvalue is just the address. + LValue LV = LValue(EmitRegister(TREE_OPERAND(exp, 0)), expr_align(exp) / 8); + // May need a useless type conversion (useless_type_conversion_p), for example + // when INDIRECT_REF is applied to a void*, resulting in a non-void type. + LV.Ptr = Builder.CreateBitCast(LV.Ptr, + ConvertType(TREE_TYPE(exp))->getPointerTo()); + return LV; +} + +LValue TreeToLLVM::EmitLV_VIEW_CONVERT_EXPR(tree exp) { + // The address is the address of the operand. + LValue LV = EmitLV(TREE_OPERAND(exp, 0)); + // The type is the type of the expression. + LV.Ptr = Builder.CreateBitCast(LV.Ptr, + ConvertType(TREE_TYPE(exp))->getPointerTo()); + return LV; +} + +LValue TreeToLLVM::EmitLV_WITH_SIZE_EXPR(tree exp) { + // The address is the address of the operand. + return EmitLV(TREE_OPERAND(exp, 0)); +} + +LValue TreeToLLVM::EmitLV_XXXXPART_EXPR(tree exp, unsigned Idx) { + LValue Ptr = EmitLV(TREE_OPERAND(exp, 0)); + assert(!Ptr.isBitfield() && + "REALPART_EXPR / IMAGPART_EXPR operands cannot be bitfields!"); + unsigned Alignment; + if (Idx == 0) + // REALPART alignment is same as the complex operand. + Alignment = Ptr.getAlignment(); + else + // IMAGPART alignment = MinAlign(Ptr.Alignment, sizeof field); + Alignment = MinAlign(Ptr.getAlignment(), + TD.getTypeAllocSize(Ptr.Ptr->getType())); + return LValue(Builder.CreateStructGEP(Ptr.Ptr, Idx), Alignment); +} + +LValue TreeToLLVM::EmitLV_SSA_NAME(tree exp) { + // TODO: Check the ssa name is being used as an rvalue, see EmitLoadOfLValue. + Value *Temp = CreateTemporary(ConvertType(TREE_TYPE(exp))); + Builder.CreateStore(EmitSSA_NAME(exp), Temp); + return LValue(Temp, 1); +} + +Constant *TreeToLLVM::EmitLV_LABEL_DECL(tree exp) { + return BlockAddress::get(Fn, getLabelDeclBlock(exp)); +} + + +//===----------------------------------------------------------------------===// +// ... Emit helpers ... +//===----------------------------------------------------------------------===// + +/// EmitMinInvariant - The given value is constant in this function. Return the +/// corresponding LLVM value. Only creates code in the entry block. +Value *TreeToLLVM::EmitMinInvariant(tree reg) { + Value *V = (TREE_CODE(reg) == ADDR_EXPR) ? + EmitInvariantAddress(reg) : EmitRegisterConstant(reg); + assert(V->getType() == ConvertType(TREE_TYPE(reg)) && + "Gimple min invariant has wrong type!"); + return V; +} + +/// EmitInvariantAddress - The given address is constant in this function. +/// Return the corresponding LLVM value. Only creates code in the entry block. +Value *TreeToLLVM::EmitInvariantAddress(tree addr) { + assert(is_gimple_invariant_address(addr) && + "Expected a locally constant address!"); + assert(is_gimple_reg_type(TREE_TYPE(addr)) && "Not of register type!"); + + // Any generated code goes in the entry block. + BasicBlock *EntryBlock = Fn->begin(); + + // Note the current builder position. + BasicBlock *SavedInsertBB = Builder.GetInsertBlock(); + BasicBlock::iterator SavedInsertPoint = Builder.GetInsertPoint(); + + // Pop the entry block terminator. There may not be a terminator if we are + // recursing or if the entry block was not yet finished. + Instruction *Terminator = EntryBlock->getTerminator(); + assert(((SavedInsertBB != EntryBlock && Terminator) || + (SavedInsertPoint == EntryBlock->end() && !Terminator)) && + "Insertion point doesn't make sense!"); + if (Terminator) + Terminator->removeFromParent(); + + // Point the builder at the end of the entry block. + Builder.SetInsertPoint(EntryBlock); + + // Calculate the address. + assert(TREE_CODE(addr) == ADDR_EXPR && "Invariant address not ADDR_EXPR!"); + Value *Address = EmitADDR_EXPR(addr); + + // Restore the entry block terminator. + if (Terminator) + EntryBlock->getInstList().push_back(Terminator); + + // Restore the builder insertion point. + if (SavedInsertBB != EntryBlock) + Builder.SetInsertPoint(SavedInsertBB, SavedInsertPoint); + + assert(Address->getType() == ConvertType(TREE_TYPE(addr)) && + "Invariant address has wrong type!"); + return Address; +} + +/// EmitRegisterConstant - Convert the given global constant of register type to +/// an LLVM constant. Creates no code, only constants. +Constant *TreeToLLVM::EmitRegisterConstant(tree reg) { +#ifndef NDEBUG + if (!is_gimple_constant(reg)) { + debug_tree(reg); + llvm_unreachable("Not a gimple constant!"); + } +#endif + assert(is_gimple_reg_type(TREE_TYPE(reg)) && "Not of register type!"); + + Constant *C; + switch (TREE_CODE(reg)) { + default: + debug_tree(reg); + llvm_unreachable("Unhandled GIMPLE constant!"); + + case INTEGER_CST: + C = TreeConstantToLLVM::ConvertINTEGER_CST(reg); + break; + case REAL_CST: + C = TreeConstantToLLVM::ConvertREAL_CST(reg); + break; + case COMPLEX_CST: + C = TreeConstantToLLVM::ConvertCOMPLEX_CST(reg); + break; + case VECTOR_CST: + C = TreeConstantToLLVM::ConvertVECTOR_CST(reg); + break; + case CONSTRUCTOR: + C = TreeConstantToLLVM::ConvertCONSTRUCTOR(reg); + break; + } + assert(C->getType() == ConvertType(TREE_TYPE(reg)) && + "Constant has wrong type!"); + return C; +} + + +//===----------------------------------------------------------------------===// +// ... Emit* - Convert register expression to LLVM... +//===----------------------------------------------------------------------===// + +/// EmitRegister - Convert the specified gimple register or local constant of +/// register type to an LLVM value. Only creates code in the entry block. +Value *TreeToLLVM::EmitRegister(tree reg) { + while (TREE_CODE(reg) == OBJ_TYPE_REF) reg = OBJ_TYPE_REF_EXPR(reg); + Value *V = (TREE_CODE(reg) == SSA_NAME) ? + EmitSSA_NAME(reg) : EmitMinInvariant(reg); + return Builder.CreateBitCast(V, ConvertType(TREE_TYPE(reg))); +} + +/// EmitSSA_NAME - Return the defining value of the given SSA_NAME. +/// Only creates code in the entry block. +Value *TreeToLLVM::EmitSSA_NAME(tree reg) { + assert(TREE_CODE(reg) == SSA_NAME && "Expected an SSA name!"); + assert(is_gimple_reg_type(TREE_TYPE(reg)) && "Not of register type!"); + + // If we already found the definition of the SSA name, return it. + if (Value *ExistingValue = SSANames[reg]) { + assert(ExistingValue->getType() == ConvertType(TREE_TYPE(reg)) && + "SSA name has wrong type!"); + if (!isSSAPlaceholder(ExistingValue)) + return ExistingValue; + } + + // If this is not the definition of the SSA name, return a placeholder value. + if (!SSA_NAME_IS_DEFAULT_DEF(reg)) { + if (Value *ExistingValue = SSANames[reg]) + return ExistingValue; + return SSANames[reg] = GetSSAPlaceholder(ConvertType(TREE_TYPE(reg))); + } + + // This SSA name is the default definition for the underlying symbol. + + // The underlying symbol is an SSA variable. + tree var = SSA_NAME_VAR(reg); + assert(SSA_VAR_P(var) && "Not an SSA variable!"); + + // If the variable is itself an ssa name, use its LLVM value. + if (TREE_CODE (var) == SSA_NAME) { + Value *Val = EmitSSA_NAME(var); + assert(Val->getType() == ConvertType(TREE_TYPE(reg)) && + "SSA name has wrong type!"); + return DefineSSAName(reg, Val); + } + + // Otherwise the symbol is a VAR_DECL, PARM_DECL or RESULT_DECL. Since a + // default definition is only created if the very first reference to the + // variable in the function is a read operation, and refers to the value + // read, it has an undefined value except for PARM_DECLs. + if (TREE_CODE(var) != PARM_DECL) + return DefineSSAName(reg, UndefValue::get(ConvertType(TREE_TYPE(reg)))); + + // Read the initial value of the parameter and associate it with the ssa name. + assert(DECL_LOCAL_IF_SET(var) && "Parameter not laid out?"); + + unsigned Alignment = DECL_ALIGN(var); + assert(Alignment != 0 && "Parameter with unknown alignment!"); + + const Type *Ty = ConvertType(TREE_TYPE(reg)); + + // Perform the load in the entry block, after all parameters have been set up + // with their initial values, and before any modifications to their values. + LoadInst *LI = new LoadInst(DECL_LOCAL_IF_SET(var), "", SSAInsertionPoint); + LI->setAlignment(Alignment); + + // Potentially perform a useless type conversion (useless_type_conversion_p). + Value *Def = LI; + if (LI->getType() != Ty) + Def = new BitCastInst(Def, Ty, "", SSAInsertionPoint); + if (flag_verbose_asm) + NameValue(Def, reg); + return DefineSSAName(reg, Def); +} + + +//===----------------------------------------------------------------------===// +// ... Render helpers ... +//===----------------------------------------------------------------------===// + +/// EmitAssignRHS - Convert the RHS of a scalar GIMPLE_ASSIGN to LLVM. +Value *TreeToLLVM::EmitAssignRHS(gimple stmt) { + // Loads from memory and other non-register expressions are handled by + // EmitAssignSingleRHS. + if (get_gimple_rhs_class(gimple_expr_code(stmt)) == GIMPLE_SINGLE_RHS) + return EmitAssignSingleRHS(gimple_assign_rhs1 (stmt)); + + // The RHS is a register expression. Emit it now. + tree type = TREE_TYPE(gimple_assign_lhs(stmt)); + tree_code code = gimple_assign_rhs_code(stmt); + tree rhs1 = gimple_assign_rhs1(stmt); + tree rhs2 = gimple_assign_rhs2(stmt); + + switch (code) { + default: + dump(stmt); + llvm_unreachable("Unhandled GIMPLE assignment!"); + + // Unary expressions. + case ABS_EXPR: + return EmitABS_EXPR(rhs1); + case BIT_NOT_EXPR: + return EmitBIT_NOT_EXPR(rhs1); + case CONJ_EXPR: + return EmitCONJ_EXPR(rhs1); + case CONVERT_EXPR: + case FIX_TRUNC_EXPR: + case FLOAT_EXPR: + return EmitCONVERT_EXPR(type, rhs1); + case NEGATE_EXPR: + return EmitNEGATE_EXPR(rhs1); + case NOP_EXPR: + return EmitNOP_EXPR(type, rhs1); + case PAREN_EXPR: + return EmitPAREN_EXPR(rhs1); + case TRUTH_NOT_EXPR: + return EmitTRUTH_NOT_EXPR(type, rhs1); + + // Comparisons. + case EQ_EXPR: + case GE_EXPR: + case GT_EXPR: + case LE_EXPR: + case LT_EXPR: + case LTGT_EXPR: + case NE_EXPR: + case ORDERED_EXPR: + case UNEQ_EXPR: + case UNGE_EXPR: + case UNGT_EXPR: + case UNLE_EXPR: + case UNLT_EXPR: + case UNORDERED_EXPR: + // The GCC result may be of any integer type. + return Builder.CreateZExt(EmitCompare(rhs1, rhs2, code), ConvertType(type)); + + // Binary expressions. + case BIT_AND_EXPR: + return EmitBinOp(type, code, rhs1, rhs2, Instruction::And); + case BIT_IOR_EXPR: + return EmitBinOp(type, code, rhs1, rhs2, Instruction::Or); + case BIT_XOR_EXPR: + return EmitBinOp(type, code, rhs1, rhs2, Instruction::Xor); + case CEIL_DIV_EXPR: + return EmitCEIL_DIV_EXPR(type, rhs1, rhs2); + case COMPLEX_EXPR: + return EmitCOMPLEX_EXPR(rhs1, rhs2); + case EXACT_DIV_EXPR: + return EmitBinOp(type, code, rhs1, rhs2, TYPE_UNSIGNED(type) ? + Instruction::UDiv : Instruction::SDiv); + case FLOOR_DIV_EXPR: + return EmitFLOOR_DIV_EXPR(type, rhs1, rhs2); + case FLOOR_MOD_EXPR: + return EmitFLOOR_MOD_EXPR(type, rhs1, rhs2); + case LROTATE_EXPR: + return EmitRotateOp(type, rhs1, rhs2, Instruction::Shl, Instruction::LShr); + case LSHIFT_EXPR: + return EmitShiftOp(rhs1, rhs2, Instruction::Shl); + case MAX_EXPR: + return EmitMinMaxExpr(type, rhs1, rhs2, ICmpInst::ICMP_UGE, + ICmpInst::ICMP_SGE, FCmpInst::FCMP_OGE, true); + case MIN_EXPR: + return EmitMinMaxExpr(type, rhs1, rhs2, ICmpInst::ICMP_ULE, + ICmpInst::ICMP_SLE, FCmpInst::FCMP_OLE, false); + case MINUS_EXPR: + return EmitBinOp(type, code, rhs1, rhs2, FLOAT_TYPE_P(type) ? + Instruction::FSub : Instruction::Sub); + case MULT_EXPR: + return EmitBinOp(type, code, rhs1, rhs2, FLOAT_TYPE_P(type) ? + Instruction::FMul : Instruction::Mul); + case PLUS_EXPR: + return EmitBinOp(type, code, rhs1, rhs2, FLOAT_TYPE_P(type) ? + Instruction::FAdd : Instruction::Add); + case POINTER_PLUS_EXPR: + return EmitPOINTER_PLUS_EXPR(type, rhs1, rhs2); + case RDIV_EXPR: + return EmitBinOp(type, code, rhs1, rhs2, Instruction::FDiv); + case ROUND_DIV_EXPR: + return EmitROUND_DIV_EXPR(type, rhs1, rhs2); + case RROTATE_EXPR: + return EmitRotateOp(type, rhs1, rhs2, Instruction::LShr, Instruction::Shl); + case RSHIFT_EXPR: + return EmitShiftOp(rhs1, rhs2, TYPE_UNSIGNED(type) ? + Instruction::LShr : Instruction::AShr); + case TRUNC_DIV_EXPR: + return EmitBinOp(type, code, rhs1, rhs2, TYPE_UNSIGNED(type) ? + Instruction::UDiv : Instruction::SDiv); + case TRUNC_MOD_EXPR: + return EmitBinOp(type, code, rhs1, rhs2, TYPE_UNSIGNED(type) ? + Instruction::URem : Instruction::SRem); + case TRUTH_AND_EXPR: + return EmitTruthOp(type, rhs1, rhs2, Instruction::And); + case TRUTH_OR_EXPR: + return EmitTruthOp(type, rhs1, rhs2, Instruction::Or); + case TRUTH_XOR_EXPR: + return EmitTruthOp(type, rhs1, rhs2, Instruction::Xor); + } +} + +/// EmitAssignSingleRHS - Helper for EmitAssignRHS. Handles those RHS that are +/// not register expressions. +Value *TreeToLLVM::EmitAssignSingleRHS(tree rhs) { + assert(!AGGREGATE_TYPE_P(TREE_TYPE(rhs)) && "Expected a scalar type!"); + + switch (TREE_CODE(rhs)) { + // Catch-all for SSA names, constants etc. + default: return EmitRegister(rhs); + + // Expressions (tcc_expression). + case ADDR_EXPR: return EmitADDR_EXPR(rhs); + case OBJ_TYPE_REF: return EmitOBJ_TYPE_REF(rhs); + + // Exceptional (tcc_exceptional). + case CONSTRUCTOR: return EmitCONSTRUCTOR(rhs, 0); + + // References (tcc_reference). + case ARRAY_REF: + case ARRAY_RANGE_REF: + case BIT_FIELD_REF: + case COMPONENT_REF: + case IMAGPART_EXPR: + case INDIRECT_REF: + case REALPART_EXPR: + case VIEW_CONVERT_EXPR: + return EmitLoadOfLValue(rhs); // Load from memory. + + // Declarations (tcc_declaration). + case PARM_DECL: + case RESULT_DECL: + case VAR_DECL: + return EmitLoadOfLValue(rhs); // Load from memory. + + // Constants (tcc_constant). + case STRING_CST: + return EmitLoadOfLValue(rhs); // Load from memory. + } +} + +/// OutputCallRHS - Convert the RHS of a GIMPLE_CALL. +Value *TreeToLLVM::OutputCallRHS(gimple stmt, const MemRef *DestLoc) { + // Check for a built-in function call. If we can lower it directly, do so + // now. + tree fndecl = gimple_call_fndecl(stmt); + if (fndecl && DECL_BUILT_IN(fndecl) && + DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_FRONTEND) { + Value *Res = 0; + if (EmitBuiltinCall(stmt, fndecl, DestLoc, Res)) + return Res; + } + + tree call_expr = gimple_call_fn(stmt); + assert(TREE_TYPE (call_expr) && + (TREE_CODE(TREE_TYPE (call_expr)) == POINTER_TYPE || + TREE_CODE(TREE_TYPE (call_expr)) == REFERENCE_TYPE) + && "Not calling a function pointer?"); + + tree function_type = TREE_TYPE(TREE_TYPE (call_expr)); + Value *Callee = EmitRegister(call_expr); + CallingConv::ID CallingConv; + AttrListPtr PAL; + + const Type *Ty = + TheTypeConverter->ConvertFunctionType(function_type, + fndecl, + gimple_call_chain(stmt), + CallingConv, PAL); + + // If this is a direct call to a function using a static chain then we need + // to ensure the function type is the one just calculated: it has an extra + // parameter for the chain. + Callee = Builder.CreateBitCast(Callee, Ty->getPointerTo()); + + Value *Result = EmitCallOf(Callee, stmt, DestLoc, PAL); + + // When calling a "noreturn" function output an unreachable instruction right + // after the function to prevent LLVM from thinking that control flow will + // fall into the subsequent block. + if (gimple_call_flags(stmt) & ECF_NORETURN) { + Builder.CreateUnreachable(); + BeginBlock(BasicBlock::Create(Context)); + } + return Result; +} + +/// WriteScalarToLHS - Store RHS, a non-aggregate value, into the given LHS. +void TreeToLLVM::WriteScalarToLHS(tree lhs, Value *RHS) { + // Perform a useless type conversion (useless_type_conversion_p). + RHS = Builder.CreateBitCast(RHS, ConvertType(TREE_TYPE(lhs))); + + // If this is the definition of an ssa name, record it in the SSANames map. + if (TREE_CODE(lhs) == SSA_NAME) { + if (flag_verbose_asm) + NameValue(RHS, lhs); + DefineSSAName(lhs, RHS); + return; + } + + if (canEmitRegisterVariable(lhs)) { + // If this is a store to a register variable, EmitLV can't handle the dest + // (there is no l-value of a register variable). Emit an inline asm node + // that copies the value into the specified register. + EmitModifyOfRegisterVariable(lhs, RHS); + return; + } + + LValue LV = EmitLV(lhs); + bool isVolatile = TREE_THIS_VOLATILE(lhs); + unsigned Alignment = LV.getAlignment(); + + if (!LV.isBitfield()) { + // Non-bitfield, scalar value. Just emit a store. + StoreInst *SI = Builder.CreateStore(RHS, LV.Ptr, isVolatile); + SI->setAlignment(Alignment); + return; } - return LValue(Builder.CreateBitCast(Decl, PTy), Alignment); -} + // Last case, this is a store to a bitfield, so we have to emit a + // read/modify/write sequence. -LValue TreeToLLVM::EmitLV_EXC_PTR_EXPR(tree exp) { - CreateExceptionValues(); - // Cast the address pointer to the expected type. - unsigned Alignment = TD.getABITypeAlignment(cast(ExceptionValue-> - getType())->getElementType()); - return LValue(Builder.CreateBitCast(ExceptionValue, - PointerType::getUnqual(ConvertType(TREE_TYPE(exp)))), - Alignment); -} + if (!LV.BitSize) + return; -LValue TreeToLLVM::EmitLV_FILTER_EXPR(tree exp) { - CreateExceptionValues(); - unsigned Alignment = - TD.getABITypeAlignment(cast(ExceptionSelectorValue-> - getType())->getElementType()); - return LValue(ExceptionSelectorValue, Alignment); -} + const Type *ValTy = cast(LV.Ptr->getType())->getElementType(); + unsigned ValSizeInBits = ValTy->getPrimitiveSizeInBits(); -LValue TreeToLLVM::EmitLV_INDIRECT_REF(tree exp) { - // The lvalue is just the address. - LValue LV = LValue(EmitRegister(TREE_OPERAND(exp, 0)), expr_align(exp) / 8); - // May need a useless type conversion (useless_type_conversion_p), for example - // when INDIRECT_REF is applied to a void*, resulting in a non-void type. - LV.Ptr = Builder.CreateBitCast(LV.Ptr, - ConvertType(TREE_TYPE(exp))->getPointerTo()); - return LV; -} + // The number of stores needed to write the entire bitfield. + unsigned Strides = 1 + (LV.BitStart + LV.BitSize - 1) / ValSizeInBits; -LValue TreeToLLVM::EmitLV_VIEW_CONVERT_EXPR(tree exp) { - // The address is the address of the operand. - LValue LV = EmitLV(TREE_OPERAND(exp, 0)); - // The type is the type of the expression. - LV.Ptr = Builder.CreateBitCast(LV.Ptr, - ConvertType(TREE_TYPE(exp))->getPointerTo()); - return LV; -} + assert(ValTy->isInteger() && "Invalid bitfield lvalue!"); + assert(ValSizeInBits > LV.BitStart && "Bad bitfield lvalue!"); + assert(ValSizeInBits >= LV.BitSize && "Bad bitfield lvalue!"); + assert(2*ValSizeInBits > LV.BitSize+LV.BitStart && "Bad bitfield lvalue!"); -LValue TreeToLLVM::EmitLV_WITH_SIZE_EXPR(tree exp) { - // The address is the address of the operand. - return EmitLV(TREE_OPERAND(exp, 0)); -} + bool Signed = !TYPE_UNSIGNED(TREE_TYPE(lhs)); + RHS = CastToAnyType(RHS, Signed, ValTy, Signed); -LValue TreeToLLVM::EmitLV_XXXXPART_EXPR(tree exp, unsigned Idx) { - LValue Ptr = EmitLV(TREE_OPERAND(exp, 0)); - assert(!Ptr.isBitfield() && - "REALPART_EXPR / IMAGPART_EXPR operands cannot be bitfields!"); - unsigned Alignment; - if (Idx == 0) - // REALPART alignment is same as the complex operand. - Alignment = Ptr.getAlignment(); - else - // IMAGPART alignment = MinAlign(Ptr.Alignment, sizeof field); - Alignment = MinAlign(Ptr.getAlignment(), - TD.getTypeAllocSize(Ptr.Ptr->getType())); - return LValue(Builder.CreateStructGEP(Ptr.Ptr, Idx), Alignment); -} + for (unsigned I = 0; I < Strides; I++) { + unsigned Index = BYTES_BIG_ENDIAN ? Strides - I - 1 : I; // LSB first + unsigned ThisFirstBit = Index * ValSizeInBits; + unsigned ThisLastBitPlusOne = ThisFirstBit + ValSizeInBits; + if (ThisFirstBit < LV.BitStart) + ThisFirstBit = LV.BitStart; + if (ThisLastBitPlusOne > LV.BitStart+LV.BitSize) + ThisLastBitPlusOne = LV.BitStart+LV.BitSize; -LValue TreeToLLVM::EmitLV_SSA_NAME(tree exp) { - // TODO: Check the ssa name is being used as an rvalue, see EmitLoadOfLValue. - Value *Temp = CreateTemporary(ConvertType(TREE_TYPE(exp))); - Builder.CreateStore(EmitSSA_NAME(exp), Temp); - return LValue(Temp, 1); -} + Value *Ptr = Index ? + Builder.CreateGEP(LV.Ptr, ConstantInt::get(Type::getInt32Ty(Context), Index)) : + LV.Ptr; + LoadInst *LI = Builder.CreateLoad(Ptr, isVolatile); + LI->setAlignment(Alignment); + Value *OldVal = LI; + Value *NewVal = RHS; -Constant *TreeToLLVM::EmitLV_LABEL_DECL(tree exp) { - return BlockAddress::get(Fn, getLabelDeclBlock(exp)); + unsigned BitsInVal = ThisLastBitPlusOne - ThisFirstBit; + unsigned FirstBitInVal = ThisFirstBit % ValSizeInBits; + + if (BYTES_BIG_ENDIAN) + FirstBitInVal = ValSizeInBits-FirstBitInVal-BitsInVal; + + // If not storing into the zero'th bit, shift the Src value to the left. + if (FirstBitInVal) { + Value *ShAmt = ConstantInt::get(ValTy, FirstBitInVal); + NewVal = Builder.CreateShl(NewVal, ShAmt); + } + + // Next, if this doesn't touch the top bit, mask out any bits that shouldn't + // be set in the result. + uint64_t MaskVal = ((1ULL << BitsInVal)-1) << FirstBitInVal; + Constant *Mask = ConstantInt::get(Type::getInt64Ty(Context), MaskVal); + Mask = Builder.getFolder().CreateTruncOrBitCast(Mask, ValTy); + + if (FirstBitInVal+BitsInVal != ValSizeInBits) + NewVal = Builder.CreateAnd(NewVal, Mask); + + // Next, mask out the bits this bit-field should include from the old value. + Mask = Builder.getFolder().CreateNot(Mask); + OldVal = Builder.CreateAnd(OldVal, Mask); + + // Finally, merge the two together and store it. + NewVal = Builder.CreateOr(OldVal, NewVal); + + StoreInst *SI = Builder.CreateStore(NewVal, Ptr, isVolatile); + SI->setAlignment(Alignment); + + if (I + 1 < Strides) { + Value *ShAmt = ConstantInt::get(ValTy, BitsInVal); + RHS = Builder.CreateLShr(RHS, ShAmt); + } + } } + //===----------------------------------------------------------------------===// -// ... Convert GIMPLE to LLVM ... +// ... Render* - Convert GIMPLE to LLVM ... //===----------------------------------------------------------------------===// void TreeToLLVM::RenderGIMPLE_ASM(gimple stmt) { @@ -7028,7 +7149,7 @@ EmitAggregate(gimple_assign_rhs1 (stmt), NewLoc); return; } - WriteScalarToLHS(lhs, EmitGimpleAssignRHS(stmt)); + WriteScalarToLHS(lhs, EmitAssignRHS(stmt)); } void TreeToLLVM::RenderGIMPLE_CALL(gimple stmt) { @@ -7036,24 +7157,24 @@ if (!lhs) { // The returned value is not used. if (!AGGREGATE_TYPE_P(gimple_call_return_type(stmt))) { - EmitGimpleCallRHS(stmt, 0); + OutputCallRHS(stmt, 0); return; } // Create a temporary to hold the returned value. // TODO: Figure out how to avoid creating this temporary and the // associated useless code that stores the returned value into it. MemRef Loc = CreateTempLoc(ConvertType(gimple_call_return_type(stmt))); - EmitGimpleCallRHS(stmt, &Loc); + OutputCallRHS(stmt, &Loc); return; } if (AGGREGATE_TYPE_P(TREE_TYPE(lhs))) { LValue LV = EmitLV(lhs); MemRef NewLoc(LV.Ptr, LV.getAlignment(), TREE_THIS_VOLATILE(lhs)); - EmitGimpleCallRHS(stmt, &NewLoc); + OutputCallRHS(stmt, &NewLoc); return; } - WriteScalarToLHS(lhs, EmitGimpleCallRHS(stmt, 0)); + WriteScalarToLHS(lhs, OutputCallRHS(stmt, 0)); } void TreeToLLVM::RenderGIMPLE_COND(gimple stmt) { @@ -7184,14 +7305,14 @@ // The range is too big to add to the switch - emit an "if". if (!IfBlock) { IfBlock = BasicBlock::Create(Context); - EmitBlock(IfBlock); + BeginBlock(IfBlock); } Value *Diff = Builder.CreateSub(Index, LowC); Value *Cond = Builder.CreateICmpULE(Diff, ConstantInt::get(Context, Range)); BasicBlock *False_Block = BasicBlock::Create(Context); Builder.CreateCondBr(Cond, Dest, False_Block); - EmitBlock(False_Block); + BeginBlock(False_Block); } } @@ -8386,114 +8507,3 @@ "It's a bitfield reference or we didn't get to the field!"); return FieldPtr; } - -//===----------------------------------------------------------------------===// -// ... GIMPLE conversion helpers ... -//===----------------------------------------------------------------------===// - -/// WriteScalarToLHS - Store RHS, a non-aggregate value, into the given LHS. -void TreeToLLVM::WriteScalarToLHS(tree lhs, Value *RHS) { - // Perform a useless type conversion (useless_type_conversion_p). - RHS = Builder.CreateBitCast(RHS, ConvertType(TREE_TYPE(lhs))); - - // If this is the definition of an ssa name, record it in the SSANames map. - if (TREE_CODE(lhs) == SSA_NAME) { - if (flag_verbose_asm) - NameValue(RHS, lhs); - DefineSSAName(lhs, RHS); - return; - } - - if (canEmitRegisterVariable(lhs)) { - // If this is a store to a register variable, EmitLV can't handle the dest - // (there is no l-value of a register variable). Emit an inline asm node - // that copies the value into the specified register. - EmitModifyOfRegisterVariable(lhs, RHS); - return; - } - - LValue LV = EmitLV(lhs); - bool isVolatile = TREE_THIS_VOLATILE(lhs); - unsigned Alignment = LV.getAlignment(); - - if (!LV.isBitfield()) { - // Non-bitfield, scalar value. Just emit a store. - StoreInst *SI = Builder.CreateStore(RHS, LV.Ptr, isVolatile); - SI->setAlignment(Alignment); - return; - } - - // Last case, this is a store to a bitfield, so we have to emit a - // read/modify/write sequence. - - if (!LV.BitSize) - return; - - const Type *ValTy = cast(LV.Ptr->getType())->getElementType(); - unsigned ValSizeInBits = ValTy->getPrimitiveSizeInBits(); - - // The number of stores needed to write the entire bitfield. - unsigned Strides = 1 + (LV.BitStart + LV.BitSize - 1) / ValSizeInBits; - - assert(ValTy->isInteger() && "Invalid bitfield lvalue!"); - assert(ValSizeInBits > LV.BitStart && "Bad bitfield lvalue!"); - assert(ValSizeInBits >= LV.BitSize && "Bad bitfield lvalue!"); - assert(2*ValSizeInBits > LV.BitSize+LV.BitStart && "Bad bitfield lvalue!"); - - bool Signed = !TYPE_UNSIGNED(TREE_TYPE(lhs)); - RHS = CastToAnyType(RHS, Signed, ValTy, Signed); - - for (unsigned I = 0; I < Strides; I++) { - unsigned Index = BYTES_BIG_ENDIAN ? Strides - I - 1 : I; // LSB first - unsigned ThisFirstBit = Index * ValSizeInBits; - unsigned ThisLastBitPlusOne = ThisFirstBit + ValSizeInBits; - if (ThisFirstBit < LV.BitStart) - ThisFirstBit = LV.BitStart; - if (ThisLastBitPlusOne > LV.BitStart+LV.BitSize) - ThisLastBitPlusOne = LV.BitStart+LV.BitSize; - - Value *Ptr = Index ? - Builder.CreateGEP(LV.Ptr, ConstantInt::get(Type::getInt32Ty(Context), Index)) : - LV.Ptr; - LoadInst *LI = Builder.CreateLoad(Ptr, isVolatile); - LI->setAlignment(Alignment); - Value *OldVal = LI; - Value *NewVal = RHS; - - unsigned BitsInVal = ThisLastBitPlusOne - ThisFirstBit; - unsigned FirstBitInVal = ThisFirstBit % ValSizeInBits; - - if (BYTES_BIG_ENDIAN) - FirstBitInVal = ValSizeInBits-FirstBitInVal-BitsInVal; - - // If not storing into the zero'th bit, shift the Src value to the left. - if (FirstBitInVal) { - Value *ShAmt = ConstantInt::get(ValTy, FirstBitInVal); - NewVal = Builder.CreateShl(NewVal, ShAmt); - } - - // Next, if this doesn't touch the top bit, mask out any bits that shouldn't - // be set in the result. - uint64_t MaskVal = ((1ULL << BitsInVal)-1) << FirstBitInVal; - Constant *Mask = ConstantInt::get(Type::getInt64Ty(Context), MaskVal); - Mask = Builder.getFolder().CreateTruncOrBitCast(Mask, ValTy); - - if (FirstBitInVal+BitsInVal != ValSizeInBits) - NewVal = Builder.CreateAnd(NewVal, Mask); - - // Next, mask out the bits this bit-field should include from the old value. - Mask = Builder.getFolder().CreateNot(Mask); - OldVal = Builder.CreateAnd(OldVal, Mask); - - // Finally, merge the two together and store it. - NewVal = Builder.CreateOr(OldVal, NewVal); - - StoreInst *SI = Builder.CreateStore(NewVal, Ptr, isVolatile); - SI->setAlignment(Alignment); - - if (I + 1 < Strides) { - Value *ShAmt = ConstantInt::get(ValTy, BitsInVal); - RHS = Builder.CreateLShr(RHS, ShAmt); - } - } -} Modified: dragonegg/trunk/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=93239&r1=93238&r2=93239&view=diff ============================================================================== --- dragonegg/trunk/llvm-internal.h (original) +++ dragonegg/trunk/llvm-internal.h Tue Jan 12 10:44:01 2010 @@ -522,32 +522,11 @@ /// name. Returns the provided value as a convenience. Value *DefineSSAName(tree_node *reg, Value *Val); - /// EmitSSA_NAME - Return the defining value of the given SSA_NAME. - /// Only creates code in the entry block. - Value *EmitSSA_NAME(tree_node *reg); - - /// EmitInvariantAddress - The given address is constant in this function. - /// Return the corresponding LLVM value. Only creates code in the entry block. - Value *EmitInvariantAddress(tree_node *addr); - - /// EmitRegisterConstant - Convert the given global constant of register type - /// to an LLVM constant. Creates no code, only constants. - Constant *EmitRegisterConstant(tree_node *reg); - - /// EmitMinInvariant - The given value is constant in this function. Return - /// the corresponding LLVM value. Only creates code in the entry block. - Value *EmitMinInvariant(tree_node *reg); - - /// EmitRegister - Convert the specified gimple register or local constant of - /// register type to an LLVM value. Only creates code in the entry block. - Value *EmitRegister(tree_node *reg); - - /// EmitBlock - Add the specified basic block to the end of the function. If + /// BeginBlock - Add the specified basic block to the end of the function. If /// the previous block falls through into it, add an explicit branch. - void EmitBlock(BasicBlock *BB); + void BeginBlock(BasicBlock *BB); /// EmitAggregateZero - Zero the elements of DestLoc. - /// void EmitAggregateZero(MemRef DestLoc, tree_node *GCCType); /// EmitMemCpy/EmitMemMove/EmitMemSet - Emit an llvm.memcpy/llvm.memmove or @@ -577,8 +556,18 @@ BasicBlock *getPostPad(unsigned RegionNo); private: + void EmitAutomaticVariableDecl(tree_node *decl); + + /// EmitAnnotateIntrinsic - Emits call to annotate attr intrinsic + void EmitAnnotateIntrinsic(Value *V, tree_node *decl); + + /// EmitTypeGcroot - Emits call to make type a gcroot + void EmitTypeGcroot(Value *V, tree_node *decl); + +private: + + //===------------------ Render* - Convert GIMPLE to LLVM ----------------===// - // Render* - Convert GIMPLE to LLVM. void RenderGIMPLE_ASM(gimple stmt); void RenderGIMPLE_ASSIGN(gimple stmt); void RenderGIMPLE_CALL(gimple stmt); @@ -589,56 +578,70 @@ void RenderGIMPLE_SWITCH(gimple stmt); // Render helpers. + + /// EmitAssignRHS - Convert the RHS of a scalar GIMPLE_ASSIGN to LLVM. + Value *EmitAssignRHS(gimple stmt); + + /// EmitAssignSingleRHS - Helper for EmitAssignRHS. Handles those RHS that + /// are not register expressions. + Value *EmitAssignSingleRHS(tree_node *rhs); + + /// OutputCallRHS - Convert the RHS of a GIMPLE_CALL. + Value *OutputCallRHS(gimple stmt, const MemRef *DestLoc); + + /// WriteScalarToLHS - Store RHS, a non-aggregate value, into the given LHS. void WriteScalarToLHS(tree lhs, Value *Scalar); private: - void EmitAutomaticVariableDecl(tree_node *decl); - /// isNoopCast - Return true if a cast from V to Ty does not change any bits. - /// - static bool isNoopCast(Value *V, const Type *Ty); + //===------------ Emit* - Convert register expression to LLVM -----------===// - /// EmitAnnotateIntrinsic - Emits call to annotate attr intrinsic - void EmitAnnotateIntrinsic(Value *V, tree_node *decl); + /// EmitRegister - Convert the specified gimple register or local constant of + /// register type to an LLVM value. Only creates code in the entry block. + Value *EmitRegister(tree_node *reg); - /// EmitTypeGcroot - Emits call to make type a gcroot - void EmitTypeGcroot(Value *V, tree_node *decl); -private: + /// EmitSSA_NAME - Return the defining value of the given SSA_NAME. + /// Only creates code in the entry block. + Value *EmitSSA_NAME(tree_node *reg); - // Expressions. - Value *EmitGimpleAssignSingleRHS(tree_node *rhs); - Value *EmitGimpleAssignRHS(gimple stmt); - Value *EmitGimpleCallRHS(gimple stmt, const MemRef *DestLoc); - Value *EmitLoadOfLValue(tree_node *exp); - Value *EmitADDR_EXPR(tree_node *exp); - Value *EmitOBJ_TYPE_REF(tree_node *exp); - Value *EmitCallOf(Value *Callee, gimple stmt, const MemRef *DestLoc, - const AttrListPtr &PAL); - Value *EmitNOP_EXPR(tree_node *type, tree_node *op); - Value *EmitCONVERT_EXPR(tree_node *type, tree_node *op); - Value *EmitNEGATE_EXPR(tree_node *op); - Value *EmitCONJ_EXPR(tree_node *op); + // Unary expressions. Value *EmitABS_EXPR(tree_node *op); Value *EmitBIT_NOT_EXPR(tree_node *op); + Value *EmitCONJ_EXPR(tree_node *op); + Value *EmitCONVERT_EXPR(tree_node *type, tree_node *op); + Value *EmitNEGATE_EXPR(tree_node *op); + Value *EmitNOP_EXPR(tree_node *type, tree_node *op); + Value *EmitPAREN_EXPR(tree_node *exp); Value *EmitTRUTH_NOT_EXPR(tree_node *type, tree_node *op); + + // Comparisons. Value *EmitCompare(tree_node *lhs, tree_node *rhs, tree_code code); + + // Binary expressions. Value *EmitBinOp(tree_node *type, tree_code code, tree_node *op0, tree_node *op1, unsigned Opc); - Value *EmitTruthOp(tree_node *type, tree_node *op0, tree_node *op1, - unsigned Opc); - Value *EmitShiftOp(tree_node *op0, tree_node* op1, unsigned Opc); - Value *EmitRotateOp(tree_node *type, tree_node *op0, tree_node *op1, - unsigned Opc1, unsigned Opc2); Value *EmitMinMaxExpr(tree_node *type, tree_node *op0, tree_node* op1, unsigned UIPred, unsigned SIPred, unsigned Opc, bool isMax); - Value *EmitFLOOR_MOD_EXPR(tree_node *type, tree_node *op0, tree_node *op1); + Value *EmitRotateOp(tree_node *type, tree_node *op0, tree_node *op1, + unsigned Opc1, unsigned Opc2); + Value *EmitShiftOp(tree_node *op0, tree_node* op1, unsigned Opc); + Value *EmitTruthOp(tree_node *type, tree_node *op0, tree_node *op1, + unsigned Opc); Value *EmitCEIL_DIV_EXPR(tree_node *type, tree_node *op0, tree_node *op1); + Value *EmitCOMPLEX_EXPR(tree op0, tree op1); Value *EmitFLOOR_DIV_EXPR(tree_node *type, tree_node *op0, tree_node *op1); + Value *EmitFLOOR_MOD_EXPR(tree_node *type, tree_node *op0, tree_node *op1); + Value *EmitPOINTER_PLUS_EXPR(tree_node *type, tree_node *op0, tree_node *op1); Value *EmitROUND_DIV_EXPR(tree_node *type, tree_node *op0, tree_node *op1); + + + Value *EmitLoadOfLValue(tree_node *exp); + Value *EmitOBJ_TYPE_REF(tree_node *exp); + Value *EmitADDR_EXPR(tree_node *exp); + Value *EmitCallOf(Value *Callee, gimple stmt, const MemRef *DestLoc, + const AttrListPtr &PAL); Value *EmitFieldAnnotation(Value *FieldPtr, tree_node *FieldDecl); - Value *EmitPOINTER_PLUS_EXPR(tree_node *type, tree_node *op0, tree_node *op1); - Value *EmitPAREN_EXPR(tree_node *exp); // Exception Handling. Value *EmitEXC_PTR_EXPR(tree_node *exp); @@ -696,7 +699,6 @@ // Complex Math Expressions. Value *CreateComplex(Value *Real, Value *Imag); void SplitComplex(Value *Complex, Value *&Real, Value *&Imag); - Value *EmitCOMPLEX_EXPR(tree op0, tree op1); Value *EmitComplexBinOp(tree_code code, tree_node *op0, tree_node *op1); // L-Value Expressions. @@ -717,6 +719,22 @@ Value *EmitREAL_CST(tree_node *exp); Value *EmitCONSTRUCTOR(tree_node *exp, const MemRef *DestLoc); + + // Emit helpers. + + /// EmitMinInvariant - The given value is constant in this function. Return + /// the corresponding LLVM value. Only creates code in the entry block. + Value *EmitMinInvariant(tree_node *reg); + + /// EmitInvariantAddress - The given address is constant in this function. + /// Return the corresponding LLVM value. Only creates code in the entry block. + Value *EmitInvariantAddress(tree_node *addr); + + /// EmitRegisterConstant - Convert the given global constant of register type + /// to an LLVM constant. Creates no code, only constants. + Constant *EmitRegisterConstant(tree_node *reg); + +private: // Optional target defined builtin intrinsic expanding function. bool TargetIntrinsicLower(gimple stmt, tree_node *fndecl, From baldrick at free.fr Tue Jan 12 11:46:17 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 12 Jan 2010 17:46:17 -0000 Subject: [llvm-commits] [llvm] r93242 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel.ll Message-ID: <201001121746.o0CHkI4a008420@zion.cs.uiuc.edu> Author: baldrick Date: Tue Jan 12 11:46:16 2010 New Revision: 93242 URL: http://llvm.org/viewvc/llvm-project?rev=93242&view=rev Log: Revert commit 93204, since it causes the assembler to barf on x86-64 linux with messages like this: Error: Incorrect register `%r14' used with `l' suffix Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp llvm/trunk/test/CodeGen/X86/fast-isel.ll Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=93242&r1=93241&r2=93242&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Tue Jan 12 11:46:16 2010 @@ -104,8 +104,6 @@ bool X86SelectBranch(Instruction *I); - bool X86SelectOR(Instruction *I); - bool X86SelectShift(Instruction *I); bool X86SelectSelect(Instruction *I); @@ -947,44 +945,6 @@ return true; } -bool X86FastISel::X86SelectOR(Instruction *I) { - // FIXME: This is necessary because tablegen stopped generate fastisel - // patterns after 93152 and 93191 (which turns OR to ADD if the set - // bits in the source operands are known not to overlap). - const TargetRegisterClass *RC = NULL; - unsigned OpReg = 0, OpImm = 0; - if (I->getType()->isInteger(16)) { - RC = X86::GR16RegisterClass; - OpReg = X86::OR16rr; OpImm = X86::OR16ri; - } else if (I->getType()->isInteger(32)) { - RC = X86::GR32RegisterClass; - OpReg = X86::OR32rr; OpImm = X86::OR32ri; - } else if (I->getType()->isInteger(64)) { - RC = X86::GR64RegisterClass; - OpReg = X86::OR32rr; OpImm = X86::OR32ri; - } else - return false; - - unsigned Op0Reg = getRegForValue(I->getOperand(0)); - if (Op0Reg == 0) return false; - - if (ConstantInt *CI = dyn_cast(I->getOperand(1))) { - unsigned ResultReg = createResultReg(RC); - BuildMI(MBB, DL, TII.get(OpImm), ResultReg).addReg(Op0Reg) - .addImm(CI->getZExtValue()); - UpdateValueMap(I, ResultReg); - return true; - } - - unsigned Op1Reg = getRegForValue(I->getOperand(1)); - if (Op1Reg == 0) return false; - - unsigned ResultReg = createResultReg(RC); - BuildMI(MBB, DL, TII.get(OpReg), ResultReg).addReg(Op0Reg).addReg(Op1Reg); - UpdateValueMap(I, ResultReg); - return true; -} - bool X86FastISel::X86SelectShift(Instruction *I) { unsigned CReg = 0, OpReg = 0, OpImm = 0; const TargetRegisterClass *RC = NULL; @@ -1574,8 +1534,6 @@ return X86SelectBranch(I); case Instruction::Call: return X86SelectCall(I); - case Instruction::Or: - return X86SelectOR(I); case Instruction::LShr: case Instruction::AShr: case Instruction::Shl: Modified: llvm/trunk/test/CodeGen/X86/fast-isel.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel.ll?rev=93242&r1=93241&r2=93242&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fast-isel.ll (original) +++ llvm/trunk/test/CodeGen/X86/fast-isel.ll Tue Jan 12 11:46:16 2010 @@ -14,7 +14,7 @@ %t1 = mul i32 %t0, %s %t2 = sub i32 %t1, %s %t3 = and i32 %t2, %s - %t4 = or i32 %t3, %s + %t4 = xor i32 %t3, 3 %t5 = xor i32 %t4, %s %t6 = add i32 %t5, 2 %t7 = getelementptr i32* %y, i32 1 From gohman at apple.com Tue Jan 12 12:03:46 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 12 Jan 2010 10:03:46 -0800 Subject: [llvm-commits] [llvm] r93204 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel.ll In-Reply-To: <201001112259.o0BMxRcR016736@zion.cs.uiuc.edu> References: <201001112259.o0BMxRcR016736@zion.cs.uiuc.edu> Message-ID: On Jan 11, 2010, at 2:59 PM, Evan Cheng wrote: > Author: evancheng > Date: Mon Jan 11 16:59:27 2010 > New Revision: 93204 > > URL: http://llvm.org/viewvc/llvm-project?rev=93204&view=rev > Log: > Add manual ISD::OR fastisel selection routines. TableGen is no > longer autogen them after 93152 and 93191. Hi Evan, Would it work to use AddedComplexity on the or_is_flag pattern, instead of having or_not_add? If so, we wouldn't need this code in fastisel. Dan > From evan.cheng at apple.com Tue Jan 12 12:29:24 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 12 Jan 2010 18:29:24 -0000 Subject: [llvm-commits] [llvm] r93244 - /llvm/trunk/test/CodeGen/X86/2007-02-04-OrAddrMode.ll Message-ID: <201001121829.o0CITOLh010229@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jan 12 12:29:23 2010 New Revision: 93244 URL: http://llvm.org/viewvc/llvm-project?rev=93244&view=rev Log: Add nounwind. Modified: llvm/trunk/test/CodeGen/X86/2007-02-04-OrAddrMode.ll Modified: llvm/trunk/test/CodeGen/X86/2007-02-04-OrAddrMode.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-02-04-OrAddrMode.ll?rev=93244&r1=93243&r2=93244&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2007-02-04-OrAddrMode.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-02-04-OrAddrMode.ll Tue Jan 12 12:29:23 2010 @@ -2,7 +2,7 @@ ; RUN: llc < %s -march=x86 | grep {leal 3(,%eax,8)} ;; This example can't fold the or into an LEA. -define i32 @test(float ** %tmp2, i32 %tmp12) { +define i32 @test(float ** %tmp2, i32 %tmp12) nounwind { %tmp3 = load float** %tmp2 %tmp132 = shl i32 %tmp12, 2 ; [#uses=1] %tmp4 = bitcast float* %tmp3 to i8* ; [#uses=1] @@ -14,7 +14,7 @@ ;; This can! -define i32 @test2(i32 %a, i32 %b) { +define i32 @test2(i32 %a, i32 %b) nounwind { %c = shl i32 %a, 3 %d = or i32 %c, 3 ret i32 %d From evan.cheng at apple.com Tue Jan 12 12:31:19 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 12 Jan 2010 18:31:19 -0000 Subject: [llvm-commits] [llvm] r93245 - in /llvm/trunk/lib/Target/X86: X86Instr64bit.td X86InstrInfo.td Message-ID: <201001121831.o0CIVK6P010316@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jan 12 12:31:19 2010 New Revision: 93245 URL: http://llvm.org/viewvc/llvm-project?rev=93245&view=rev Log: Eliminate or_not_add and just use AddedComplexity so isel tries or_is_add patterns first. Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td llvm/trunk/lib/Target/X86/X86InstrInfo.td Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=93245&r1=93244&r2=93245&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Tue Jan 12 12:31:19 2010 @@ -1093,7 +1093,7 @@ def OR64rr : RI<0x09, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), "or{q}\t{$src2, $dst|$dst, $src2}", - [(set GR64:$dst, (or_not_add GR64:$src1, GR64:$src2)), + [(set GR64:$dst, (or GR64:$src1, GR64:$src2)), (implicit EFLAGS)]>; def OR64rr_REV : RI<0x0B, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), @@ -1106,12 +1106,12 @@ def OR64ri8 : RIi8<0x83, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), "or{q}\t{$src2, $dst|$dst, $src2}", - [(set GR64:$dst, (or_not_add GR64:$src1, i64immSExt8:$src2)), + [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2)), (implicit EFLAGS)]>; def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), "or{q}\t{$src2, $dst|$dst, $src2}", - [(set GR64:$dst, (or_not_add GR64:$src1, i64immSExt32:$src2)), + [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2)), (implicit EFLAGS)]>; } // isTwoAddress @@ -2130,6 +2130,7 @@ (SHLD64mri8 addr:$dst, GR64:$src2, (i8 imm:$amt1))>; // (or x1, x2) -> (add x1, x2) if two operands are known not to share bits. +let AddedComplexity = 5 in { // Try this before the selecting to OR def : Pat<(parallel (or_is_add GR64:$src1, i64immSExt8:$src2), (implicit EFLAGS)), (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>; @@ -2139,6 +2140,7 @@ def : Pat<(parallel (or_is_add GR64:$src1, GR64:$src2), (implicit EFLAGS)), (ADD64rr GR64:$src1, GR64:$src2)>; +} // AddedComplexity // X86 specific add which produces a flag. def : Pat<(addc GR64:$src1, GR64:$src2), Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=93245&r1=93244&r2=93245&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Tue Jan 12 12:31:19 2010 @@ -507,19 +507,6 @@ return (~KnownZero0 & ~KnownZero1) == 0; } }]>; -def or_not_add : PatFrag<(ops node:$lhs, node:$rhs),(or node:$lhs, node:$rhs),[{ - if (ConstantSDNode *CN = dyn_cast(N->getOperand(1))) - return !CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue()); - else { - unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits(); - APInt Mask = APInt::getAllOnesValue(BitWidth); - APInt KnownZero0, KnownOne0; - CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0); - APInt KnownZero1, KnownOne1; - CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0); - return (~KnownZero0 & ~KnownZero1) != 0; - } -}]>; // 'shld' and 'shrd' instruction patterns. Note that even though these have // the srl and shl in their patterns, the C++ code must still check for them, @@ -1869,12 +1856,12 @@ def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), "or{w}\t{$src2, $dst|$dst, $src2}", - [(set GR16:$dst, (or_not_add GR16:$src1, GR16:$src2)), + [(set GR16:$dst, (or GR16:$src1, GR16:$src2)), (implicit EFLAGS)]>, OpSize; def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2), "or{l}\t{$src2, $dst|$dst, $src2}", - [(set GR32:$dst, (or_not_add GR32:$src1, GR32:$src2)), + [(set GR32:$dst, (or GR32:$src1, GR32:$src2)), (implicit EFLAGS)]>; } @@ -1913,23 +1900,23 @@ def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), "or{w}\t{$src2, $dst|$dst, $src2}", - [(set GR16:$dst, (or_not_add GR16:$src1, imm:$src2)), + [(set GR16:$dst, (or GR16:$src1, imm:$src2)), (implicit EFLAGS)]>, OpSize; def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2), "or{l}\t{$src2, $dst|$dst, $src2}", - [(set GR32:$dst, (or_not_add GR32:$src1, imm:$src2)), + [(set GR32:$dst, (or GR32:$src1, imm:$src2)), (implicit EFLAGS)]>; def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2), "or{w}\t{$src2, $dst|$dst, $src2}", - [(set GR16:$dst, (or_not_add GR16:$src1, i16immSExt8:$src2)), + [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)), (implicit EFLAGS)]>, OpSize; def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2), "or{l}\t{$src2, $dst|$dst, $src2}", - [(set GR32:$dst, (or_not_add GR32:$src1, i32immSExt8:$src2)), + [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)), (implicit EFLAGS)]>; let isTwoAddress = 0 in { def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src), @@ -4679,6 +4666,7 @@ (SETB_C32r)>; // (or x1, x2) -> (add x1, x2) if two operands are known not to share bits. +let AddedComplexity = 5 in { // Try this before the selecting to OR def : Pat<(parallel (or_is_add GR16:$src1, imm:$src2), (implicit EFLAGS)), (ADD16ri GR16:$src1, imm:$src2)>; @@ -4697,6 +4685,7 @@ def : Pat<(parallel (or_is_add GR32:$src1, GR32:$src2), (implicit EFLAGS)), (ADD32rr GR32:$src1, GR32:$src2)>; +} // AddedComplexity //===----------------------------------------------------------------------===// // EFLAGS-defining Patterns From dpatel at apple.com Tue Jan 12 12:34:06 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 12 Jan 2010 18:34:06 -0000 Subject: [llvm-commits] [llvm] r93247 - in /llvm/trunk: include/llvm/Metadata.h include/llvm/Module.h include/llvm/ValueSymbolTable.h lib/VMCore/Metadata.cpp lib/VMCore/Module.cpp Message-ID: <201001121834.o0CIY6j5010460@zion.cs.uiuc.edu> Author: dpatel Date: Tue Jan 12 12:34:06 2010 New Revision: 93247 URL: http://llvm.org/viewvc/llvm-project?rev=93247&view=rev Log: Use ilist_tratis to autoinsert and remove NamedMDNode from MDSymbolTable. Modified: llvm/trunk/include/llvm/Metadata.h llvm/trunk/include/llvm/Module.h llvm/trunk/include/llvm/ValueSymbolTable.h llvm/trunk/lib/VMCore/Metadata.cpp llvm/trunk/lib/VMCore/Module.cpp Modified: llvm/trunk/include/llvm/Metadata.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=93247&r1=93246&r2=93247&view=diff ============================================================================== --- llvm/trunk/include/llvm/Metadata.h (original) +++ llvm/trunk/include/llvm/Metadata.h Tue Jan 12 12:34:06 2010 @@ -184,8 +184,8 @@ /// NamedMDNode is always named. All NamedMDNode operand has a type of metadata. class NamedMDNode : public Value, public ilist_node { friend class SymbolTableListTraits; + friend class ilist_traits; friend class LLVMContextImpl; - NamedMDNode(const NamedMDNode &); // DO NOT IMPLEMENT std::string Name; Modified: llvm/trunk/include/llvm/Module.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Module.h?rev=93247&r1=93246&r2=93247&view=diff ============================================================================== --- llvm/trunk/include/llvm/Module.h (original) +++ llvm/trunk/include/llvm/Module.h Tue Jan 12 12:34:06 2010 @@ -57,6 +57,7 @@ static GlobalAlias *createSentinel(); static void destroySentinel(GlobalAlias *GA) { delete GA; } }; + template<> struct ilist_traits : public SymbolTableListTraits { // createSentinel is used to get hold of a node that marks the end of @@ -69,6 +70,8 @@ NamedMDNode *provideInitialHead() const { return createSentinel(); } NamedMDNode *ensureHead(NamedMDNode*) const { return createSentinel(); } static void noteHead(NamedMDNode*, NamedMDNode*) {} + void addNodeToList(NamedMDNode *N); + void removeNodeFromList(NamedMDNode *N); private: mutable ilist_node Sentinel; }; @@ -324,10 +327,6 @@ /// NamedMDNode with the specified name is not found. NamedMDNode *getOrInsertNamedMetadata(StringRef Name); - /// addMDNodeName - Insert an entry in the NamedMDNode symbol table mapping - /// Name to NMD. - void addMDNodeName(StringRef Name, NamedMDNode *NMD); - /// @} /// @name Type Accessors /// @{ Modified: llvm/trunk/include/llvm/ValueSymbolTable.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ValueSymbolTable.h?rev=93247&r1=93246&r2=93247&view=diff ============================================================================== --- llvm/trunk/include/llvm/ValueSymbolTable.h (original) +++ llvm/trunk/include/llvm/ValueSymbolTable.h Tue Jan 12 12:34:06 2010 @@ -17,6 +17,7 @@ #include "llvm/Value.h" #include "llvm/ADT/StringMap.h" #include "llvm/System/DataTypes.h" +#include "llvm/ADT/ilist_node.h" namespace llvm { template @@ -39,7 +40,6 @@ friend class SymbolTableListTraits; friend class SymbolTableListTraits; friend class SymbolTableListTraits; - friend class SymbolTableListTraits; /// @name Types /// @{ public: @@ -133,6 +133,7 @@ /// essentially a StringMap wrapper. class MDSymbolTable { + friend class SymbolTableListTraits; /// @name Types /// @{ private: Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=93247&r1=93246&r2=93247&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Tue Jan 12 12:34:06 2010 @@ -239,6 +239,26 @@ //===----------------------------------------------------------------------===// // NamedMDNode implementation. // + +namespace llvm { +// SymbolTableListTraits specialization for MDSymbolTable. +void ilist_traits +::addNodeToList(NamedMDNode *N) { + assert(N->getParent() == 0 && "Value already in a container!!"); + Module *Owner = getListOwner(); + N->setParent(Owner); + MDSymbolTable &ST = Owner->getMDSymbolTable(); + ST.insert(N->getName(), N); +} + +void ilist_traits::removeNodeFromList(NamedMDNode *N) { + N->setParent(0); + Module *Owner = getListOwner(); + MDSymbolTable &ST = Owner->getMDSymbolTable(); + ST.remove(N->getName()); +} +} + static SmallVector &getNMDOps(void *Operands) { return *(SmallVector*)Operands; } @@ -254,10 +274,8 @@ for (unsigned i = 0; i != NumMDs; ++i) Node.push_back(WeakVH(MDs[i])); - if (ParentModule) { + if (ParentModule) ParentModule->getNamedMDList().push_back(this); - ParentModule->addMDNodeName(N, this); - } } NamedMDNode *NamedMDNode::Create(const NamedMDNode *NMD, Module *M) { @@ -295,7 +313,6 @@ /// eraseFromParent - Drop all references and remove the node from parent /// module. void NamedMDNode::eraseFromParent() { - getParent()->getMDSymbolTable().remove(getName()); getParent()->getNamedMDList().erase(this); } @@ -306,8 +323,10 @@ /// setName - Set the name of this named metadata. void NamedMDNode::setName(StringRef N) { - if (!N.empty()) - Name = N.str(); + assert (!N.empty() && "Invalid named metadata name!"); + Name = N.str(); + if (Parent) + Parent->getMDSymbolTable().insert(N, this); } /// getName - Return a constant reference to this named metadata's name. Modified: llvm/trunk/lib/VMCore/Module.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=93247&r1=93246&r2=93247&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Module.cpp (original) +++ llvm/trunk/lib/VMCore/Module.cpp Tue Jan 12 12:34:06 2010 @@ -325,12 +325,6 @@ return NMD; } -/// addMDNodeName - Insert an entry in the NamedMDNode symbol table mapping -/// Name to NMD. -void Module::addMDNodeName(StringRef Name, NamedMDNode *NMD) { - NamedMDSymTab->insert(Name, NMD); -} - //===----------------------------------------------------------------------===// // Methods for easy access to the types in the module. // From dpatel at apple.com Tue Jan 12 12:57:57 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 12 Jan 2010 18:57:57 -0000 Subject: [llvm-commits] [llvm] r93249 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp Message-ID: <201001121857.o0CIvvpC011430@zion.cs.uiuc.edu> Author: dpatel Date: Tue Jan 12 12:57:56 2010 New Revision: 93249 URL: http://llvm.org/viewvc/llvm-project?rev=93249&view=rev Log: Use Twine, instead of StringRef, for consistency. Modified: llvm/trunk/include/llvm/Metadata.h llvm/trunk/lib/VMCore/Metadata.cpp Modified: llvm/trunk/include/llvm/Metadata.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=93249&r1=93248&r2=93249&view=diff ============================================================================== --- llvm/trunk/include/llvm/Metadata.h (original) +++ llvm/trunk/include/llvm/Metadata.h Tue Jan 12 12:57:56 2010 @@ -194,10 +194,10 @@ void setParent(Module *M) { Parent = M; } protected: - explicit NamedMDNode(LLVMContext &C, StringRef N, MDNode*const *Vals, + explicit NamedMDNode(LLVMContext &C, const Twine &N, MDNode*const *Vals, unsigned NumVals, Module *M = 0); public: - static NamedMDNode *Create(LLVMContext &C, StringRef N, + static NamedMDNode *Create(LLVMContext &C, const Twine &N, MDNode *const *MDs, unsigned NumMDs, Module *M = 0) { return new NamedMDNode(C, N, MDs, NumMDs, M); @@ -229,7 +229,7 @@ void addOperand(MDNode *M); /// setName - Set the name of this named metadata. - void setName(StringRef Name); + void setName(const Twine &NewName); /// getName - Return a constant reference to this named metadata's name. StringRef getName() const; Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=93249&r1=93248&r2=93249&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Tue Jan 12 12:57:56 2010 @@ -18,6 +18,7 @@ #include "llvm/Instruction.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/SmallString.h" #include "SymbolTableListTraitsImpl.h" #include "llvm/Support/ValueHandle.h" using namespace llvm; @@ -263,7 +264,7 @@ return *(SmallVector*)Operands; } -NamedMDNode::NamedMDNode(LLVMContext &C, StringRef N, +NamedMDNode::NamedMDNode(LLVMContext &C, const Twine &N, MDNode *const *MDs, unsigned NumMDs, Module *ParentModule) : Value(Type::getMetadataTy(C), Value::NamedMDNodeVal), Parent(0) { @@ -322,11 +323,23 @@ } /// setName - Set the name of this named metadata. -void NamedMDNode::setName(StringRef N) { - assert (!N.empty() && "Invalid named metadata name!"); - Name = N.str(); +void NamedMDNode::setName(const Twine &NewName) { + assert (!NewName.isTriviallyEmpty() && "Invalid named metadata name!"); + + SmallString<256> NameData; + NewName.toVector(NameData); + + const char *NameStr = NameData.data(); + unsigned NameLen = NameData.size(); + + StringRef NameRef = StringRef(NameStr, NameLen); + // Name isn't changing? + if (getName() == NameRef) + return; + + Name = NameRef.str(); if (Parent) - Parent->getMDSymbolTable().insert(N, this); + Parent->getMDSymbolTable().insert(NameRef, this); } /// getName - Return a constant reference to this named metadata's name. From dpatel at apple.com Tue Jan 12 13:03:02 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 12 Jan 2010 11:03:02 -0800 Subject: [llvm-commits] [llvm] r92931 - in /llvm/trunk: include/llvm/Metadata.h include/llvm/Module.h include/llvm/ValueSymbolTable.h lib/Bitcode/Writer/BitcodeWriter.cpp lib/Bitcode/Writer/ValueEnumerator.cpp lib/Bitcode/Writer/ValueEnumerator.h lib/VMCore/Metadata.cpp lib/VMCore/Module.cpp test/Feature/NamedMDNode.ll In-Reply-To: <1425FCCD-5C1F-4B73-8A79-C1128A5FD48D@apple.com> References: <201001071939.o07JdbMo002682@zion.cs.uiuc.edu> <1425FCCD-5C1F-4B73-8A79-C1128A5FD48D@apple.com> Message-ID: <160D8C72-BC95-4764-BFE7-571C4C39344F@apple.com> On Jan 8, 2010, at 1:39 PM, Chris Lattner wrote: > On Jan 7, 2010, at 11:39 AM, Devang Patel wrote: >> URL: http://llvm.org/viewvc/llvm-project?rev=92931&view=rev >> Log: >> Use separate namespace for named metadata. > > Great! > >> +++ llvm/trunk/include/llvm/Metadata.h Thu Jan 7 13:39:36 2010 > >> + /// setName - Set the name of this named metadata. >> + void setName(StringRef Name); > > If setName is part of the public API for this class then it should ensure that the module symtab is kept up to date. Right now, setName will change the NamedMDNode but not the symtab afaict. Done > >> +++ llvm/trunk/include/llvm/Module.h Thu Jan 7 13:39:36 2010 >> @@ -322,6 +324,10 @@ >> /// NamedMDNode with the specified name is not found. >> NamedMDNode *getOrInsertNamedMetadata(StringRef Name); >> >> + /// addMDNodeName - Insert an entry in the NamedMDNode symbol table mapping >> + /// Name to NMD. >> + void addMDNodeName(StringRef Name, NamedMDNode *NMD); > > This should not be public API. removed > >> +++ llvm/trunk/include/llvm/ValueSymbolTable.h Thu Jan 7 13:39:36 2010 >> @@ -129,6 +129,84 @@ >> /// @} >> }; >> >> +/// This class provides a symbol table of name/NamedMDNode pairs. It is >> +/// essentially a StringMap wrapper. >> + >> +class MDSymbolTable { >> +/// @name Types >> +/// @{ >> +public: >> + /// @brief A mapping of names to metadata >> + typedef StringMap MDMap; > > This typedef should not be public. Please also disable copy ctor and operator=. Done > >> +public: >> + /// insert - The method inserts a new entry into the stringmap. >> + void insert(StringRef Name, NamedMDNode *Node) { >> + (void) mmap.GetOrCreateValue(Name, Node); >> + } >> + >> + /// This method removes a NamedMDNode from the symbol table. >> + void remove(StringRef Name) { mmap.erase(Name); } > > Should these be private? Random classes should interact with the symbol table through Module and the NamedMDNode constructor. Still working on this. > >> +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Thu Jan 7 13:39:36 2010 >> @@ -528,10 +528,9 @@ >> } >> >> // Write name. >> - std::string Str = NMD->getNameStr(); >> - const char *StrBegin = Str.c_str(); >> - for (unsigned i = 0, e = Str.length(); i != e; ++i) >> - Record.push_back(StrBegin[i]); >> + StringRef Str = NMD->getName(); >> + for (unsigned i = 0, e = Str.size(); i != e; ++i) >> + Record.push_back(Str[i]); >> Stream.EmitRecord(bitc::METADATA_NAME, Record, 0/*TODO*/); >> Record.clear(); > > This is a fine change. However, coming back to the bitcode encoding of NamedMDNodes, why is this split into two records? hmm... no good reason to do only this way. > It seems that METADATA_NAME / METADATA_NAMED_NODE could be one record. > > The first element of the record would be the # MDNodes, then that # of mdnode id's would follow, then a length of the name, then the characters of the name. > >> +++ llvm/trunk/lib/VMCore/Metadata.cpp Thu Jan 7 13:39:36 2010 >> @@ -214,20 +214,21 @@ >> return *(SmallVector*)Operands; >> } >> >> -NamedMDNode::NamedMDNode(LLVMContext &C, const Twine &N, >> +NamedMDNode::NamedMDNode(LLVMContext &C, StringRef N, > > Shouldn't this take a Twine, not a StringRef for consistency with everything else? Done > >> MDNode *const *MDs, >> unsigned NumMDs, Module *ParentModule) >> : MetadataBase(Type::getMetadataTy(C), Value::NamedMDNodeVal), Parent(0) { >> setName(N); >> - >> Operands = new SmallVector(); >> >> SmallVector &Node = getNMDOps(Operands); >> for (unsigned i = 0; i != NumMDs; ++i) >> Node.push_back(WeakVH(MDs[i])); >> >> - if (ParentModule) >> + if (ParentModule) { >> ParentModule->getNamedMDList().push_back(this); >> + ParentModule->addMDNodeName(N, this); > > If you set up the ilist_traits right, you don't need to do this. The traits should autoinsert the NamedMDNode into the symbol table when it is added to a module, and autoremove it from the symtab when it is removed from the module. Done > >> @@ -265,6 +266,7 @@ >> /// eraseFromParent - Drop all references and remove the node from parent >> /// module. >> void NamedMDNode::eraseFromParent() { >> + getParent()->getMDSymbolTable().remove(getName()); >> getParent()->getNamedMDList().erase(this); > > Likewise. Done > >> } >> >> @@ -273,6 +275,16 @@ >> getNMDOps(Operands).clear(); >> } >> >> +/// setName - Set the name of this named metadata. >> +void NamedMDNode::setName(StringRef N) { >> + if (!N.empty()) >> + Name = N.str(); > > Should assert that N != empty. All NamedMDNodes must have non-empty names. Done > >> +++ llvm/trunk/lib/VMCore/Module.cpp Thu Jan 7 13:39:36 2010 >> @@ -59,6 +59,7 @@ >> : Context(C), ModuleID(MID), DataLayout("") { >> ValSymTab = new ValueSymbolTable(); >> TypeSymTab = new TypeSymbolTable(); >> + NamedMDSymTab = new MDSymbolTable(); > > You added a new, but not a delete to the destructor. Please don't leak this. Fixed leak. - Devang -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100112/60c75579/attachment.html From gohman at apple.com Tue Jan 12 13:04:34 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 12 Jan 2010 11:04:34 -0800 Subject: [llvm-commits] [llvm] r93202 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp In-Reply-To: <201001112249.o0BMnfKd016308@zion.cs.uiuc.edu> References: <201001112249.o0BMnfKd016308@zion.cs.uiuc.edu> Message-ID: On Jan 11, 2010, at 2:49 PM, Chris Lattner wrote: > Author: lattner > Date: Mon Jan 11 16:49:40 2010 > New Revision: 93202 > > URL: http://llvm.org/viewvc/llvm-project?rev=93202&view=rev > Log: > reenable the piece that turns trunc(zext(x)) -> x even if zext has multiple uses, > codegen has no apparent problem with the trunc version of this, because it turns > into a simple subreg idiom On targets where TargetLowering::isTruncateFree returns true, at least. Dan From clattner at apple.com Tue Jan 12 13:08:57 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 12 Jan 2010 11:08:57 -0800 Subject: [llvm-commits] [llvm] r93202 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp In-Reply-To: References: <201001112249.o0BMnfKd016308@zion.cs.uiuc.edu> Message-ID: <1B735D96-CF64-46E3-8828-A7322EC8BEBE@apple.com> On Jan 12, 2010, at 11:04 AM, Dan Gohman wrote: > > On Jan 11, 2010, at 2:49 PM, Chris Lattner wrote: > >> Author: lattner >> Date: Mon Jan 11 16:49:40 2010 >> New Revision: 93202 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=93202&view=rev >> Log: >> reenable the piece that turns trunc(zext(x)) -> x even if zext has >> multiple uses, >> codegen has no apparent problem with the trunc version of this, >> because it turns >> into a simple subreg idiom > > On targets where TargetLowering::isTruncateFree returns true, > at least. Are you concerned about a specific target? This xform in general only applies when the source and dest are both 'native' integer types. -Chris From stoklund at 2pi.dk Tue Jan 12 13:39:32 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 12 Jan 2010 11:39:32 -0800 Subject: [llvm-commits] [llvm] r93242 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel.ll In-Reply-To: <201001121746.o0CHkI4a008420@zion.cs.uiuc.edu> References: <201001121746.o0CHkI4a008420@zion.cs.uiuc.edu> Message-ID: On Jan 12, 2010, at 9:46 AM, Duncan Sands wrote: > Author: baldrick > Date: Tue Jan 12 11:46:16 2010 > New Revision: 93242 > > URL: http://llvm.org/viewvc/llvm-project?rev=93242&view=rev > Log: > Revert commit 93204, since it causes the assembler to barf > on x86-64 linux with messages like this: > Error: Incorrect register `%r14' used with `l' suffix > -bool X86FastISel::X86SelectOR(Instruction *I) { > - // FIXME: This is necessary because tablegen stopped generate fastisel > - // patterns after 93152 and 93191 (which turns OR to ADD if the set > - // bits in the source operands are known not to overlap). > - const TargetRegisterClass *RC = NULL; > - unsigned OpReg = 0, OpImm = 0; > - if (I->getType()->isInteger(16)) { > - RC = X86::GR16RegisterClass; > - OpReg = X86::OR16rr; OpImm = X86::OR16ri; > - } else if (I->getType()->isInteger(32)) { > - RC = X86::GR32RegisterClass; > - OpReg = X86::OR32rr; OpImm = X86::OR32ri; > - } else if (I->getType()->isInteger(64)) { > - RC = X86::GR64RegisterClass; > - OpReg = X86::OR32rr; OpImm = X86::OR32ri; Should this be OR64rr / OR64ri? That would explain the errors. /jakob From sabre at nondot.org Tue Jan 12 13:40:54 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 12 Jan 2010 19:40:54 -0000 Subject: [llvm-commits] [llvm] r93251 - in /llvm/trunk: include/llvm/Transforms/Utils/Local.h lib/Transforms/Utils/Local.cpp Message-ID: <201001121940.o0CJes6Y013204@zion.cs.uiuc.edu> Author: lattner Date: Tue Jan 12 13:40:54 2010 New Revision: 93251 URL: http://llvm.org/viewvc/llvm-project?rev=93251&view=rev Log: add a helper function. Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h llvm/trunk/lib/Transforms/Utils/Local.cpp Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=93251&r1=93250&r2=93251&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Tue Jan 12 13:40:54 2010 @@ -74,6 +74,14 @@ /// too, recursively. Return true if the PHI node is actually deleted. bool RecursivelyDeleteDeadPHINode(PHINode *PN); + +/// SimplifyInstructionsInBlock - Scan the specified basic block and try to +/// simplify any instructions in it and recursively delete dead instructions. +/// +/// This returns true if it changed the code, note that it can delete +/// instructions in other blocks as well in this block. +bool SimplifyInstructionsInBlock(BasicBlock *BB, const TargetData *TD = 0); + //===----------------------------------------------------------------------===// // Control Flow Graph Restructuring. // Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=93251&r1=93250&r2=93251&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Tue Jan 12 13:40:54 2010 @@ -335,6 +335,30 @@ return Changed; } +/// SimplifyInstructionsInBlock - Scan the specified basic block and try to +/// simplify any instructions in it and recursively delete dead instructions. +/// +/// This returns true if it changed the code, note that it can delete +/// instructions in other blocks as well in this block. +bool llvm::SimplifyInstructionsInBlock(BasicBlock *BB, const TargetData *TD) { + bool MadeChange = false; + for (BasicBlock::iterator BI = BB->begin(), E = BB->end(); BI != E; ) { + Instruction *Inst = BI++; + + if (Value *V = SimplifyInstruction(Inst, TD)) { + WeakVH BIHandle(BI); + ReplaceAndSimplifyAllUses(Inst, V, TD); + MadeChange = true; + if (BIHandle == 0) + BI = BB->begin(); + continue; + } + + MadeChange |= RecursivelyDeleteTriviallyDeadInstructions(Inst); + } + return MadeChange; +} + //===----------------------------------------------------------------------===// // Control Flow Graph Restructuring. // From mm.beck at gmx.net Tue Jan 12 14:28:49 2010 From: mm.beck at gmx.net (Michael Beck) Date: Tue, 12 Jan 2010 21:28:49 +0100 Subject: [llvm-commits] [Patch] Patch for llvm-config References: <13E01678D13D43229821E721E2F1C4A8@nvidia.com> Message-ID: Hi all, > Applying this patch breaks llvm-config for me. I don't know anything > about it, but maybe this will help: > > Bareword found where operator expected at /Users/sabre/llvm/Debug/bin/ > llvm-config line 133, near "--src Yep, this patch was broken. Attached is the correct one. best regards, -- Michael Beck -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-config.patch Type: application/octet-stream Size: 1698 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100112/bc8bfa34/attachment.obj From sabre at nondot.org Tue Jan 12 14:41:48 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 12 Jan 2010 20:41:48 -0000 Subject: [llvm-commits] [llvm] r93253 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/basic.ll Message-ID: <201001122041.o0CKfmnI015604@zion.cs.uiuc.edu> Author: lattner Date: Tue Jan 12 14:41:47 2010 New Revision: 93253 URL: http://llvm.org/viewvc/llvm-project?rev=93253&view=rev Log: 1) Use the new SimplifyInstructionsInBlock routine instead of the copy in JT. 2) When cloning blocks for PHI or xor conditions, use instsimplify to simplify the code as we go. This allows us to squish common cases early in JT which opens up opportunities for subsequent iterations, and allows it to completely simplify the testcase. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/test/Transforms/JumpThreading/basic.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=93253&r1=93252&r2=93253&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Tue Jan 12 14:41:47 2010 @@ -1341,20 +1341,7 @@ // At this point, the IR is fully up to date and consistent. Do a quick scan // over the new instructions and zap any that are constants or dead. This // frequently happens because of phi translation. - BI = NewBB->begin(); - for (BasicBlock::iterator E = NewBB->end(); BI != E; ) { - Instruction *Inst = BI++; - - if (Value *V = SimplifyInstruction(Inst, TD)) { - WeakVH BIHandle(BI); - ReplaceAndSimplifyAllUses(Inst, V, TD); - if (BIHandle == 0) - BI = NewBB->begin(); - continue; - } - - RecursivelyDeleteTriviallyDeadInstructions(Inst); - } + SimplifyInstructionsInBlock(NewBB, TD); // Threaded an edge! ++NumThreads; @@ -1425,9 +1412,6 @@ // mapping and using it to remap operands in the cloned instructions. for (; BI != BB->end(); ++BI) { Instruction *New = BI->clone(); - New->setName(BI->getName()); - PredBB->getInstList().insert(OldPredBranch, New); - ValueMapping[BI] = New; // Remap operands to patch up intra-block references. for (unsigned i = 0, e = New->getNumOperands(); i != e; ++i) @@ -1436,6 +1420,19 @@ if (I != ValueMapping.end()) New->setOperand(i, I->second); } + + // If this instruction can be simplified after the operands are updated, + // just use the simplified value instead. This frequently happens due to + // phi translation. + if (Value *IV = SimplifyInstruction(New, TD)) { + delete New; + ValueMapping[BI] = IV; + } else { + // Otherwise, insert the new instruction into the block. + New->setName(BI->getName()); + PredBB->getInstList().insert(OldPredBranch, New); + ValueMapping[BI] = New; + } } // Check to see if the targets of the branch had PHI nodes. If so, we need to Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=93253&r1=93252&r2=93253&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Tue Jan 12 14:41:47 2010 @@ -407,12 +407,7 @@ F2: ret i32 %v1 -;; FIXME: CONSTANT FOLD on clone and when phi gets eliminated. - -; CHECK: Entry.Merge_crit_edge: -; CHECK-NEXT: %M1 = icmp eq i32 192, 192 -; CHECK-NEXT: %N2 = xor i1 true, %M1 -; CHECK-NEXT: br i1 %N2, label %T2, label %F2 +; CHECK: br i1 %cond, label %F2, label %Merge ; CHECK: Merge: ; CHECK-NEXT: %M = icmp eq i32 %v1, 192 From anton at korobeynikov.info Tue Jan 12 02:31:26 2010 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 12 Jan 2010 11:31:26 +0300 Subject: [llvm-commits] [llvm] r93234 - /llvm/trunk/lib/Target/X86/X86Subtarget.h In-Reply-To: <201001120821.o0C8L8ZY003955@zion.cs.uiuc.edu> References: <201001120821.o0C8L8ZY003955@zion.cs.uiuc.edu> Message-ID: Hello, Duncan > - ? ?else if (isTargetCygMing() || isTargetWindows()) > + ? ?else if (isTargetMing() || isTargetWindows()) This won't compile (no such method) -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From evan.cheng at apple.com Tue Jan 12 12:23:11 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 12 Jan 2010 10:23:11 -0800 Subject: [llvm-commits] [llvm] r93204 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel.ll In-Reply-To: References: <201001112259.o0BMxRcR016736@zion.cs.uiuc.edu> Message-ID: <39A2428B-03B3-4358-8119-10770D83F1CE@apple.com> Yes, the hack should work fine. The only annoying part is getting the number just right so selecting to LEA is still preferred over ADD. Evan On Jan 12, 2010, at 10:03 AM, Dan Gohman wrote: > > > On Jan 11, 2010, at 2:59 PM, Evan Cheng wrote: > >> Author: evancheng >> Date: Mon Jan 11 16:59:27 2010 >> New Revision: 93204 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=93204&view=rev >> Log: >> Add manual ISD::OR fastisel selection routines. TableGen is no longer autogen them after 93152 and 93191. > > Hi Evan, > > Would it work to use AddedComplexity on the or_is_flag pattern, instead of having or_not_add? If so, we wouldn't need this code in fastisel. > > Dan > >> From evan.cheng at apple.com Tue Jan 12 14:56:59 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 12 Jan 2010 12:56:59 -0800 Subject: [llvm-commits] [llvm] r93242 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel.ll In-Reply-To: References: <201001121746.o0CHkI4a008420@zion.cs.uiuc.edu> Message-ID: <822BB7B6-F416-44A3-B9D3-7F0E2F58F315@apple.com> On Jan 12, 2010, at 11:39 AM, Jakob Stoklund Olesen wrote: > > On Jan 12, 2010, at 9:46 AM, Duncan Sands wrote: > >> Author: baldrick >> Date: Tue Jan 12 11:46:16 2010 >> New Revision: 93242 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=93242&view=rev >> Log: >> Revert commit 93204, since it causes the assembler to barf >> on x86-64 linux with messages like this: >> Error: Incorrect register `%r14' used with `l' suffix > > > >> -bool X86FastISel::X86SelectOR(Instruction *I) { >> - // FIXME: This is necessary because tablegen stopped generate fastisel >> - // patterns after 93152 and 93191 (which turns OR to ADD if the set >> - // bits in the source operands are known not to overlap). >> - const TargetRegisterClass *RC = NULL; >> - unsigned OpReg = 0, OpImm = 0; >> - if (I->getType()->isInteger(16)) { >> - RC = X86::GR16RegisterClass; >> - OpReg = X86::OR16rr; OpImm = X86::OR16ri; >> - } else if (I->getType()->isInteger(32)) { >> - RC = X86::GR32RegisterClass; >> - OpReg = X86::OR32rr; OpImm = X86::OR32ri; >> - } else if (I->getType()->isInteger(64)) { >> - RC = X86::GR64RegisterClass; >> - OpReg = X86::OR32rr; OpImm = X86::OR32ri; > > Should this be OR64rr / OR64ri? > > That would explain the errors. Yes. But I've since fixed it differently. Evan > > /jakob > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Tue Jan 12 16:00:04 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 12 Jan 2010 22:00:04 -0000 Subject: [llvm-commits] [llvm] r93259 - /llvm/trunk/include/llvm/Metadata.h Message-ID: <201001122200.o0CM04Sg018409@zion.cs.uiuc.edu> Author: lattner Date: Tue Jan 12 16:00:04 2010 New Revision: 93259 URL: http://llvm.org/viewvc/llvm-project?rev=93259&view=rev Log: use consistent tag kinds for ilist_traits Modified: llvm/trunk/include/llvm/Metadata.h Modified: llvm/trunk/include/llvm/Metadata.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=93259&r1=93258&r2=93259&view=diff ============================================================================== --- llvm/trunk/include/llvm/Metadata.h (original) +++ llvm/trunk/include/llvm/Metadata.h Tue Jan 12 16:00:04 2010 @@ -184,7 +184,7 @@ /// NamedMDNode is always named. All NamedMDNode operand has a type of metadata. class NamedMDNode : public Value, public ilist_node { friend class SymbolTableListTraits; - friend class ilist_traits; + friend struct ilist_traits; friend class LLVMContextImpl; NamedMDNode(const NamedMDNode &); // DO NOT IMPLEMENT From bob.wilson at apple.com Tue Jan 12 16:18:56 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 12 Jan 2010 22:18:56 -0000 Subject: [llvm-commits] [llvm] r93261 - /llvm/trunk/lib/CodeGen/LiveInterval.cpp Message-ID: <201001122218.o0CMIuBi019041@zion.cs.uiuc.edu> Author: bwilson Date: Tue Jan 12 16:18:56 2010 New Revision: 93261 URL: http://llvm.org/viewvc/llvm-project?rev=93261&view=rev Log: Fix a comment typo. 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=93261&r1=93260&r2=93261&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Jan 12 16:18:56 2010 @@ -10,7 +10,7 @@ // This file implements the LiveRange and LiveInterval classes. Given some // numbering of each the machine instructions an interval [i, j) is said to be a // live interval for register v if there is no instruction with number j' > j -// such that v is live at j' abd there is no instruction with number i' < i such +// such that v is live at j' and there is no instruction with number i' < i such // that v is live at i'. In this implementation intervals can have holes, // i.e. an interval might look like [1,20), [50,65), [1000,1001). Each // individual range is represented as an instance of LiveRange, and the whole From anton at korobeynikov.info Tue Jan 12 16:28:44 2010 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Wed, 13 Jan 2010 01:28:44 +0300 Subject: [llvm-commits] [llvm] r92864 - in /llvm/trunk/lib/CodeGen: CriticalAntiDepBreaker.cpp CriticalAntiDepBreaker.h In-Reply-To: <5F80963E-2A0C-4F70-AB78-6A4861090BC9@apple.com> References: <201001062221.o06MLP0B032188@zion.cs.uiuc.edu> <5F80963E-2A0C-4F70-AB78-6A4861090BC9@apple.com> Message-ID: Hello, Jim > Excellent news. Thanks for pointing this out. How close are we to a fully > working newlib with llvm at this point? Honestly speaking, I don't know. Will try to look for newlib's testsuite. > That would be greatly appreciated, yes. Thank you! Ok, will send. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From anon at cs.uiuc.edu Tue Jan 12 17:37:41 2010 From: anon at cs.uiuc.edu (anon at cs.uiuc.edu) Date: Tue, 12 Jan 2010 17:37:41 -0600 Subject: [llvm-commits] CVS: llvm-www/pubs/2010-04-ASPLOS-DeterministicCompiler.pdf Message-ID: <201001122337.o0CNbfMu022112@zion.cs.uiuc.edu> Changes in directory llvm-www/pubs: 2010-04-ASPLOS-DeterministicCompiler.pdf updated: 1.1 -> 1.2 --- Log message: Update to final *final* version. --- Diffs of the changes: (+0 -0) 2010-04-ASPLOS-DeterministicCompiler.pdf | 0 1 files changed Index: llvm-www/pubs/2010-04-ASPLOS-DeterministicCompiler.pdf From vhernandez at apple.com Tue Jan 12 17:37:59 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Tue, 12 Jan 2010 23:37:59 -0000 Subject: [llvm-commits] [llvm] r93270 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Message-ID: <201001122337.o0CNbxWd022341@zion.cs.uiuc.edu> Author: hernande Date: Tue Jan 12 17:37:59 2010 New Revision: 93270 URL: http://llvm.org/viewvc/llvm-project?rev=93270&view=rev Log: Make WriteConstants() more robust against stray values in ValueEnumerator's ValueList Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=93270&r1=93269&r2=93270&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Jan 12 17:37:59 2010 @@ -688,6 +688,11 @@ Record.clear(); continue; } + + // Ignore all values in ValueList except for Constants. + if (V && (isa(V) || isa(V))) + continue; + const Constant *C = cast(V); unsigned Code = -1U; unsigned AbbrevToUse = 0; From dalej at apple.com Tue Jan 12 18:00:24 2010 From: dalej at apple.com (Dale Johannesen) Date: Wed, 13 Jan 2010 00:00:24 -0000 Subject: [llvm-commits] [llvm] r93272 - in /llvm/trunk: include/llvm/CodeGen/MachineInstrBuilder.h include/llvm/CodeGen/MachineOperand.h lib/CodeGen/MachineInstr.cpp lib/VMCore/AsmWriter.cpp Message-ID: <201001130000.o0D00PoL023084@zion.cs.uiuc.edu> Author: johannes Date: Tue Jan 12 18:00:24 2010 New Revision: 93272 URL: http://llvm.org/viewvc/llvm-project?rev=93272&view=rev Log: Further progration of metadata operands. The dumper doesn't really do what I want yet, but at least it doesn't crash now. Modified: llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h llvm/trunk/include/llvm/CodeGen/MachineOperand.h llvm/trunk/lib/CodeGen/MachineInstr.cpp llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h?rev=93272&r1=93271&r2=93272&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h Tue Jan 12 18:00:24 2010 @@ -22,6 +22,7 @@ namespace llvm { class TargetInstrDesc; +class MDNode; namespace RegState { enum { @@ -123,6 +124,11 @@ MI->addOperand(MO); return *this; } + + const MachineInstrBuilder &addMetadata(MDNode *MD) const { + MI->addOperand(MachineOperand::CreateMetadata(MD)); + return *this; + } }; /// BuildMI - Builder interface. Specify how to create the initial instruction Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineOperand.h?rev=93272&r1=93271&r2=93272&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineOperand.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineOperand.h Tue Jan 12 18:00:24 2010 @@ -317,7 +317,7 @@ return Contents.OffsetedInfo.Val.SymbolName; } - MDNode *getMetadata() const { + const MDNode *getMetadata() const { assert(isMetadata() && "Wrong MachineOperand accessor"); return Contents.MD; } Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=93272&r1=93271&r2=93272&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Tue Jan 12 18:00:24 2010 @@ -34,6 +34,7 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/FoldingSet.h" +#include "llvm/Metadata.h" using namespace llvm; //===----------------------------------------------------------------------===// @@ -278,10 +279,15 @@ OS << '>'; break; case MachineOperand::MO_BlockAddress: - OS << "<"; + OS << '<'; WriteAsOperand(OS, getBlockAddress(), /*PrintType=*/false); OS << '>'; break; + case MachineOperand::MO_Metadata: + OS << '<'; + WriteAsOperand(OS, getMetadata(), /*PrintType=*/false); + OS << '>'; + break; default: llvm_unreachable("Unrecognized operand type"); } Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=93272&r1=93271&r2=93272&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Tue Jan 12 18:00:24 2010 @@ -564,6 +564,9 @@ if (const Function *Func = dyn_cast(V)) return new SlotTracker(Func); + if (isa(V)) + return new SlotTracker((Function *)0); + return 0; } @@ -1136,6 +1139,8 @@ return; } + if (!Machine) + Machine = createSlotTracker(V); Out << '!' << Machine->getMetadataSlot(N); return; } From evan.cheng at apple.com Tue Jan 12 18:30:23 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 13 Jan 2010 00:30:23 -0000 Subject: [llvm-commits] [llvm] r93278 - in /llvm/trunk: include/llvm/CodeGen/Passes.h include/llvm/Target/TargetInstrInfo.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/OptimizeExts.cpp lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.h test/CodeGen/X86/2008-08-05-SpillerBug.ll test/CodeGen/X86/sext-subreg.ll test/CodeGen/X86/stack-color-with-reg.ll Message-ID: <201001130030.o0D0UOAo024351@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jan 12 18:30:23 2010 New Revision: 93278 URL: http://llvm.org/viewvc/llvm-project?rev=93278&view=rev Log: Add a quick pass to optimize sign / zero extension instructions. For targets where the pre-extension values are available in the subreg of the result of the extension, replace the uses of the pre-extension value with the result + extract_subreg. For now, this pass is fairly conservative. It only perform the replacement when both the pre- and post- extension values are used in the block. It will miss cases where the post-extension values are live, but not used. Added: llvm/trunk/lib/CodeGen/OptimizeExts.cpp llvm/trunk/test/CodeGen/X86/sext-subreg.ll Modified: llvm/trunk/include/llvm/CodeGen/Passes.h llvm/trunk/include/llvm/Target/TargetInstrInfo.h llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.h llvm/trunk/test/CodeGen/X86/2008-08-05-SpillerBug.ll llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll Modified: llvm/trunk/include/llvm/CodeGen/Passes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=93278&r1=93277&r2=93278&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/Passes.h (original) +++ llvm/trunk/include/llvm/CodeGen/Passes.h Tue Jan 12 18:30:23 2010 @@ -170,6 +170,10 @@ /// instructions. FunctionPass *createMachineSinkingPass(); + /// createOptimizeExtsPass - This pass performs sign / zero extension + /// optimization by increasing uses of extended values. + FunctionPass *createOptimizeExtsPass(); + /// createStackSlotColoringPass - This pass performs stack slot coloring. FunctionPass *createStackSlotColoringPass(bool); Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=93278&r1=93277&r2=93278&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Tue Jan 12 18:30:23 2010 @@ -149,16 +149,15 @@ return false; } - /// isCoalescableInstr - Return true if the instruction is "coalescable". That - /// is, it's like a copy where it's legal for the source to overlap the - /// destination. e.g. X86::MOVSX64rr32. - virtual bool isCoalescableInstr(const MachineInstr &MI, bool &isCopy, - unsigned &SrcReg, unsigned &DstReg, - unsigned &SrcSubIdx, unsigned &DstSubIdx) const { - if (isMoveInstr(MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx)) { - isCopy = true; - return true; - } + /// isCoalescableExtInstr - Return true if the instruction is a "coalescable" + /// extension instruction. That is, it's like a copy where it's legal for the + /// source to overlap the destination. e.g. X86::MOVSX64rr32. If this returns + /// true, then it's expected the pre-extension value is available as a subreg + /// of the result register. This also returns the sub-register index in + /// SubIdx. + virtual bool isCoalescableExtInstr(const MachineInstr &MI, + unsigned &SrcReg, unsigned &DstReg, + unsigned &SubIdx) const { return false; } Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=93278&r1=93277&r2=93278&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Tue Jan 12 18:30:23 2010 @@ -62,6 +62,10 @@ cl::desc("Verify generated machine code"), cl::init(getenv("LLVM_VERIFY_MACHINEINSTRS")!=NULL)); +#if 1 +static cl::opt XX("xx", cl::Hidden); +#endif + // Enable or disable FastISel. Both options are needed, because // FastISel is enabled by default with -fast, and we wish to be // able to enable or disable fast-isel independently from -O0. @@ -324,6 +328,7 @@ /* allowDoubleDefs= */ true); if (OptLevel != CodeGenOpt::None) { + PM.add(createOptimizeExtsPass()); if (!DisableMachineLICM) PM.add(createMachineLICMPass()); if (!DisableMachineSink) Added: llvm/trunk/lib/CodeGen/OptimizeExts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/OptimizeExts.cpp?rev=93278&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/OptimizeExts.cpp (added) +++ llvm/trunk/lib/CodeGen/OptimizeExts.cpp Tue Jan 12 18:30:23 2010 @@ -0,0 +1,149 @@ +//===-- OptimizeExts.cpp - Optimize sign / zero extension instrs -----===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "ext-opt" +#include "llvm/CodeGen/Passes.h" +#include "llvm/CodeGen/MachineDominators.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/Target/TargetInstrInfo.h" +#include "llvm/Target/TargetRegisterInfo.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/Statistic.h" +using namespace llvm; + +static cl::opt Aggressive("aggressive-ext-opt", cl::Hidden, + cl::desc("Aggressive extension optimization")); + +STATISTIC(NumReuse, "Number of extension results reused"); + +namespace { + class OptimizeExts : public MachineFunctionPass { + const TargetMachine *TM; + const TargetInstrInfo *TII; + MachineRegisterInfo *MRI; + MachineDominatorTree *DT; // Machine dominator tree + + public: + static char ID; // Pass identification + OptimizeExts() : MachineFunctionPass(&ID) {} + + virtual bool runOnMachineFunction(MachineFunction &MF); + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesCFG(); + MachineFunctionPass::getAnalysisUsage(AU); + AU.addRequired(); + AU.addPreserved(); + } + }; +} + +char OptimizeExts::ID = 0; +static RegisterPass +X("opt-exts", "Optimize sign / zero extensions"); + +FunctionPass *llvm::createOptimizeExtsPass() { return new OptimizeExts(); } + +bool OptimizeExts::runOnMachineFunction(MachineFunction &MF) { + TM = &MF.getTarget(); + TII = TM->getInstrInfo(); + MRI = &MF.getRegInfo(); + DT = &getAnalysis(); + + bool Changed = false; + + SmallPtrSet LocalMIs; + for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { + MachineBasicBlock *MBB = &*I; + for (MachineBasicBlock::iterator MII = I->begin(), ME = I->end(); MII != ME; + ++MII) { + MachineInstr *MI = &*MII; + LocalMIs.insert(MI); + + unsigned SrcReg, DstReg, SubIdx; + if (TII->isCoalescableExtInstr(*MI, SrcReg, DstReg, SubIdx)) { + if (TargetRegisterInfo::isPhysicalRegister(DstReg) || + TargetRegisterInfo::isPhysicalRegister(SrcReg)) + continue; + + MachineRegisterInfo::use_iterator UI = MRI->use_begin(SrcReg); + if (++UI == MRI->use_end()) + // No other uses. + continue; + + // Ok, the source has other uses. See if we can replace the other uses + // with use of the result of the extension. + + SmallPtrSet ReachedBBs; + UI = MRI->use_begin(DstReg); + for (MachineRegisterInfo::use_iterator UE = MRI->use_end(); UI != UE; + ++UI) + ReachedBBs.insert(UI->getParent()); + + bool ExtendLife = true; + SmallVector Uses; + SmallVector ExtendedUses; + + UI = MRI->use_begin(SrcReg); + for (MachineRegisterInfo::use_iterator UE = MRI->use_end(); UI != UE; + ++UI) { + MachineOperand &UseMO = UI.getOperand(); + MachineInstr *UseMI = &*UI; + if (UseMI == MI) + continue; + MachineBasicBlock *UseMBB = UseMI->getParent(); + if (UseMBB == MBB) { + // Local uses that come after the extension. + if (!LocalMIs.count(UseMI)) + Uses.push_back(&UseMO); + } else if (ReachedBBs.count(UseMBB)) + // Non-local uses where the result of extension is used. Always + // replace these. + Uses.push_back(&UseMO); + else if (Aggressive && DT->dominates(MBB, UseMBB)) + // We may want to extend live range of the extension result in order + // to replace these uses. + ExtendedUses.push_back(&UseMO); + else { + // Both will be live out of the def MBB anyway. Don't extend live + // range of the extension result. + ExtendLife = false; + break; + } + } + + if (ExtendLife && !ExtendedUses.empty()) + // Ok, we'll extend the liveness of the extension result. + std::copy(ExtendedUses.begin(), ExtendedUses.end(), + std::back_inserter(Uses)); + + // Now replace all uses. + if (!Uses.empty()) { + const TargetRegisterClass *RC = MRI->getRegClass(SrcReg); + for (unsigned i = 0, e = Uses.size(); i != e; ++i) { + MachineOperand *UseMO = Uses[i]; + MachineInstr *UseMI = UseMO->getParent(); + MachineBasicBlock *UseMBB = UseMI->getParent(); + unsigned NewVR = MRI->createVirtualRegister(RC); + BuildMI(*UseMBB, UseMI, UseMI->getDebugLoc(), + TII->get(TargetInstrInfo::EXTRACT_SUBREG), NewVR) + .addReg(DstReg).addImm(SubIdx); + UseMO->setReg(NewVR); + ++NumReuse; + Changed = true; + } + } + } + } + } + + return Changed; +} Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=93278&r1=93277&r2=93278&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Tue Jan 12 18:30:23 2010 @@ -713,9 +713,9 @@ } bool -X86InstrInfo::isCoalescableInstr(const MachineInstr &MI, bool &isCopy, - unsigned &SrcReg, unsigned &DstReg, - unsigned &SrcSubIdx, unsigned &DstSubIdx) const { +X86InstrInfo::isCoalescableExtInstr(const MachineInstr &MI, + unsigned &SrcReg, unsigned &DstReg, + unsigned &SubIdx) const { switch (MI.getOpcode()) { default: break; case X86::MOVSX16rr8: @@ -733,10 +733,8 @@ if (MI.getOperand(0).getSubReg() || MI.getOperand(1).getSubReg()) // Be conservative. return false; - isCopy = false; SrcReg = MI.getOperand(1).getReg(); DstReg = MI.getOperand(0).getReg(); - DstSubIdx = 0; switch (MI.getOpcode()) { default: llvm_unreachable(0); @@ -747,22 +745,23 @@ case X86::MOVZX32rr8: case X86::MOVSX64rr8: case X86::MOVZX64rr8: - SrcSubIdx = 1; + SubIdx = 1; break; case X86::MOVSX32rr16: case X86::MOVZX32rr16: case X86::MOVSX64rr16: case X86::MOVZX64rr16: - SrcSubIdx = 3; + SubIdx = 3; break; case X86::MOVSX64rr32: case X86::MOVZX64rr32: - SrcSubIdx = 4; + SubIdx = 4; break; } + return true; } } - return isMoveInstr(MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx); + return false; } /// isFrameOperand - Return true and the FrameIndex if the specified Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=93278&r1=93277&r2=93278&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Tue Jan 12 18:30:23 2010 @@ -448,13 +448,15 @@ unsigned &SrcReg, unsigned &DstReg, unsigned &SrcSubIdx, unsigned &DstSubIdx) const; - /// isCoalescableInstr - Return true if the instruction is "coalescable". That - /// is, it's like a copy where it's legal for the source to overlap the - /// destination. e.g. X86::MOVSX64rr32. - virtual bool isCoalescableInstr(const MachineInstr &MI, bool &isCopy, - unsigned &SrcReg, unsigned &DstReg, - unsigned &SrcSubIdx, unsigned &DstSubIdx) const; - + /// isCoalescableExtInstr - Return true if the instruction is a "coalescable" + /// extension instruction. That is, it's like a copy where it's legal for the + /// source to overlap the destination. e.g. X86::MOVSX64rr32. If this returns + /// true, then it's expected the pre-extension value is available as a subreg + /// of the result register. This also returns the sub-register index in + /// SubIdx. + virtual bool isCoalescableExtInstr(const MachineInstr &MI, + unsigned &SrcReg, unsigned &DstReg, + unsigned &SubIdx) const; unsigned isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const; /// isLoadFromStackSlotPostFE - Check for post-frame ptr elimination Modified: llvm/trunk/test/CodeGen/X86/2008-08-05-SpillerBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-08-05-SpillerBug.ll?rev=93278&r1=93277&r2=93278&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-08-05-SpillerBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-08-05-SpillerBug.ll Tue Jan 12 18:30:23 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=i386-apple-darwin -disable-fp-elim -stats |& grep asm-printer | grep 58 +; RUN: llc < %s -mtriple=i386-apple-darwin -disable-fp-elim -stats |& grep asm-printer | grep 57 ; PR2568 @g_3 = external global i16 ; [#uses=1] Added: llvm/trunk/test/CodeGen/X86/sext-subreg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sext-subreg.ll?rev=93278&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/sext-subreg.ll (added) +++ llvm/trunk/test/CodeGen/X86/sext-subreg.ll Tue Jan 12 18:30:23 2010 @@ -0,0 +1,17 @@ +; RUN: llc < %s -march=x86-64 | FileCheck %s +; rdar://7529457 + +define i64 @t(i64 %A, i64 %B, i32* %P, i64 *%P2) nounwind { +; CHECK: t: +; CHECK: movslq %e{{.*}}, %rax +; CHECK: movq %rax +; CHECK: movl %eax + %C = add i64 %A, %B + %D = trunc i64 %C to i32 + volatile store i32 %D, i32* %P + %E = shl i64 %C, 32 + %F = ashr i64 %E, 32 + volatile store i64 %F, i64 *%P2 + volatile store i32 %D, i32* %P + ret i64 undef +} Modified: llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll?rev=93278&r1=93277&r2=93278&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll (original) +++ llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll Tue Jan 12 18:30:23 2010 @@ -1,5 +1,5 @@ ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -relocation-model=pic -disable-fp-elim -color-ss-with-regs -stats -info-output-file - > %t -; RUN: grep stackcoloring %t | grep "stack slot refs replaced with reg refs" | grep 6 +; RUN: grep stackcoloring %t | grep "stack slot refs replaced with reg refs" | grep 9 type { [62 x %struct.Bitvec*] } ; type %0 type { i8* } ; type %1 From jyasskin at google.com Tue Jan 12 18:31:43 2010 From: jyasskin at google.com (Jeffrey Yasskin) Date: Wed, 13 Jan 2010 00:31:43 -0000 Subject: [llvm-commits] [llvm] r93279 - /llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll Message-ID: <201001130031.o0D0Vin7024448@zion.cs.uiuc.edu> Author: jyasskin Date: Tue Jan 12 18:31:43 2010 New Revision: 93279 URL: http://llvm.org/viewvc/llvm-project?rev=93279&view=rev Log: Try to fix the ARM and PPC buildbots. The -mattr=vector-unaligned-mem flag doesn't exist there, and this is an x86 test. Modified: llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll Modified: llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll?rev=93279&r1=93278&r2=93279&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll Tue Jan 12 18:31:43 2010 @@ -1,4 +1,4 @@ -; RUN: llc -mattr=vector-unaligned-mem < %s | FileCheck %s +; RUN: llc -mattr=vector-unaligned-mem -march=x86 < %s | FileCheck %s ; CHECK: addps ( 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" From jyasskin at google.com Tue Jan 12 18:32:47 2010 From: jyasskin at google.com (Jeffrey Yasskin) Date: Tue, 12 Jan 2010 16:32:47 -0800 Subject: [llvm-commits] [llvm] r93189 - /llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll In-Reply-To: <201001112158.o0BLwJGM013869@zion.cs.uiuc.edu> References: <201001112158.o0BLwJGM013869@zion.cs.uiuc.edu> Message-ID: I just committed r93279 to fix this on ARM and PPC, which it crashed: http://google1.osuosl.org:8011/builders/llvm-arm-linux/builds/1427/steps/test-llvm/logs/2010-01-07-uamemfeature.ll and http://google1.osuosl.org:8011/builders/llvm-ppc-linux/builds/3820/steps/test-llvm/logs/2010-01-07-uamemfeature.ll Should an unsupported -mattr flag really cause llc to crash though? On Mon, Jan 11, 2010 at 1:58 PM, Chris Lattner wrote: > Author: lattner > Date: Mon Jan 11 15:58:19 2010 > New Revision: 93189 > > URL: http://llvm.org/viewvc/llvm-project?rev=93189&view=rev > Log: > reduce this to a sensible testcase. > > Modified: > ? ?llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll > > Modified: llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll?rev=93189&r1=93188&r2=93189&view=diff > > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll (original) > +++ llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll Mon Jan 11 15:58:19 2010 > @@ -1,24 +1,11 @@ > ?; RUN: llc -mattr=vector-unaligned-mem < %s | FileCheck %s > -; CHECK: addps{{[ \t]+}}( > +; CHECK: addps ( > > ?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 i32 @foo(i32 %n1, float* %A2, float* %B3, float* %C4) { > -"file loop.c, line 1, bb1": ? ?; srcLine 1 > - ? ? ? %"$LCS_4" = alloca i64, align 8 ? ? ? ? ; [#uses=5] ? ? ?; [oox.86 : sln.1] > - ? ? ? %"$LCS_5" = alloca i64, align 8 ? ? ? ? ; [#uses=5] ? ? ?; [oox.87 : sln.1] > - ? ? ? %"$LCS_6" = alloca i64, align 8 ? ? ? ? ; [#uses=5] ? ? ?; [oox.88 : sln.1] > - > - ? ? ? %r128 = load i64* %"$LCS_4", align 8 ? ? ? ? ? ?; [#uses=1] ? ? ? ; [oox.192 : sln.6] > - ? ? ? %r129 = inttoptr i64 %r128 to <4 x float>* ? ? ? ? ? ? ?; <<4 x float>*> [#uses=1] ? ? ?; [oox.192 : sln.6] > - ? ? ? %r130 = load <4 x float>* %r129, align 4 ? ? ? ? ? ? ? ?; <<4 x float>> [#uses=1] ? ? ? ; [oox.192 : sln.6] > - ? ? ? %r131 = load i64* %"$LCS_5", align 8 ? ? ? ? ? ?; [#uses=1] ? ? ? ; [oox.192 : sln.6] > - ? ? ? %r132 = inttoptr i64 %r131 to <4 x float>* ? ? ? ? ? ? ?; <<4 x float>*> [#uses=1] ? ? ?; [oox.192 : sln.6] > - ? ? ? %r133 = load <4 x float>* %r132, align 4 ? ? ? ? ? ? ? ?; <<4 x float>> [#uses=1] ? ? ? ; [oox.192 : sln.6] > - ? ? ? %r134 = add <4 x float> %r130, %r133 ? ? ? ? ? ?; <<4 x float>> [#uses=1] ? ? ? ; [oox.192 : sln.6] > - ? ? ? %r135 = load i64* %"$LCS_6", align 8 ? ? ? ? ? ?; [#uses=1] ? ? ? ; [oox.192 : sln.6] > - ? ? ? %r136 = inttoptr i64 %r135 to <4 x float>* ? ? ? ? ? ? ?; <<4 x float>*> [#uses=1] ? ? ?; [oox.192 : sln.6] > - ? ? ? store <4 x float> %r134, <4 x float>* %r136, align 4 ? ?; [oox.192 : sln.6] > - ? ? ? ret i32 0 ? ? ? ; [oox.189 : sln.10] > +define <4 x float> @foo(<4 x float>* %P, <4 x float> %In) nounwind { > + ? ? ? %A = load <4 x float>* %P, align 4 > + ? ? ? %B = add <4 x float> %A, %In > + ? ? ? ret <4 x float> %B > ?} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From stoklund at 2pi.dk Tue Jan 12 18:43:06 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 13 Jan 2010 00:43:06 -0000 Subject: [llvm-commits] [llvm] r93280 - in /llvm/trunk/lib/Target/ARM: ARMInstrThumb.td ARMRegisterInfo.td Message-ID: <201001130043.o0D0h6xA025039@zion.cs.uiuc.edu> Author: stoklund Date: Tue Jan 12 18:43:06 2010 New Revision: 93280 URL: http://llvm.org/viewvc/llvm-project?rev=93280&view=rev Log: Remove the JustSP single-register regclass. It was only being used by instructions with the t_addrmode_sp addressing mode, and that is pattern matched in a way that guarantees SP is used. There is never any register allocation done from this class. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=93280&r1=93279&r2=93280&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Jan 12 18:43:06 2010 @@ -113,7 +113,7 @@ def t_addrmode_sp : Operand, ComplexPattern { let PrintMethod = "printThumbAddrModeSPOperand"; - let MIOperandInfo = (ops JustSP:$base, i32imm:$offsimm); + let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm); } //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td?rev=93280&r1=93279&r2=93280&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td Tue Jan 12 18:43:06 2010 @@ -367,19 +367,6 @@ // Condition code registers. def CCR : RegisterClass<"ARM", [i32], 32, [CPSR]>; -// Just the stack pointer (for tSTRspi and friends). -def JustSP : RegisterClass<"ARM", [i32], 32, [SP]> { - let MethodProtos = [{ - iterator allocation_order_end(const MachineFunction &MF) const; - }]; - let MethodBodies = [{ - JustSPClass::iterator - JustSPClass::allocation_order_end(const MachineFunction &MF) const { - return allocation_order_begin(MF); - } - }]; -} - //===----------------------------------------------------------------------===// // Subregister Set Definitions... now that we have all of the pieces, define the // sub registers for each register. From dpatel at apple.com Tue Jan 12 18:53:13 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 12 Jan 2010 16:53:13 -0800 Subject: [llvm-commits] [llvm] r93270 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp In-Reply-To: <201001122337.o0CNbxWd022341@zion.cs.uiuc.edu> References: <201001122337.o0CNbxWd022341@zion.cs.uiuc.edu> Message-ID: On Jan 12, 2010, at 3:37 PM, Victor Hernandez wrote: > Author: hernande > Date: Tue Jan 12 17:37:59 2010 > New Revision: 93270 > > URL: http://llvm.org/viewvc/llvm-project?rev=93270&view=rev > Log: > Make WriteConstants() more robust against stray values in ValueEnumerator's ValueList Isn't this covering a bug if there are stray values in ValueList ? - Devang > > Modified: > llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp > > Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=93270&r1=93269&r2=93270&view=diff > > ============================================================================== > --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) > +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Jan 12 17:37:59 2010 > @@ -688,6 +688,11 @@ > Record.clear(); > continue; > } > + > + // Ignore all values in ValueList except for Constants. > + if (V && (isa(V) || isa(V))) > + continue; > + > const Constant *C = cast(V); > unsigned Code = -1U; > unsigned AbbrevToUse = 0; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From kremenek at apple.com Tue Jan 12 19:02:47 2010 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 13 Jan 2010 01:02:47 -0000 Subject: [llvm-commits] [llvm] r93283 - /llvm/trunk/lib/CodeGen/CMakeLists.txt Message-ID: <201001130102.o0D12mHZ025693@zion.cs.uiuc.edu> Author: kremenek Date: Tue Jan 12 19:02:47 2010 New Revision: 93283 URL: http://llvm.org/viewvc/llvm-project?rev=93283&view=rev Log: Update CMake file. Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=93283&r1=93282&r2=93283&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/CMakeLists.txt Tue Jan 12 19:02:47 2010 @@ -35,12 +35,13 @@ MachineModuleInfoImpls.cpp MachinePassRegistry.cpp MachineRegisterInfo.cpp - MachineSink.cpp MachineSSAUpdater.cpp + MachineSink.cpp MachineVerifier.cpp MaxStackAlignment.cpp ObjectCodeEmitter.cpp OcamlGC.cpp + OptimizeExts.cpp PHIElimination.cpp Passes.cpp PostRASchedulerList.cpp From dalej at apple.com Tue Jan 12 19:39:39 2010 From: dalej at apple.com (Dale Johannesen) Date: Wed, 13 Jan 2010 01:39:39 -0000 Subject: [llvm-commits] [llvm] r93284 - /llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Message-ID: <201001130139.o0D1ddFV026900@zion.cs.uiuc.edu> Author: johannes Date: Tue Jan 12 19:39:38 2010 New Revision: 93284 URL: http://llvm.org/viewvc/llvm-project?rev=93284&view=rev Log: Fix a comment. Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=93284&r1=93283&r2=93284&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Tue Jan 12 19:39:38 2010 @@ -664,7 +664,7 @@ /// frame indices from instructions which may use them. The instruction /// referenced by the iterator contains an MO_FrameIndex operand which must be /// eliminated by this method. This method may modify or replace the - /// specified instruction, as long as it keeps the iterator pointing the the + /// specified instruction, as long as it keeps the iterator pointing at the /// finished product. SPAdj is the SP adjustment due to call frame setup /// instruction. /// From evan.cheng at apple.com Tue Jan 12 19:43:20 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 13 Jan 2010 01:43:20 -0000 Subject: [llvm-commits] [llvm] r93285 - /llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Message-ID: <201001130143.o0D1hKgK027088@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jan 12 19:43:20 2010 New Revision: 93285 URL: http://llvm.org/viewvc/llvm-project?rev=93285&view=rev Log: Remove debug option I accidentally left in. Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=93285&r1=93284&r2=93285&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Tue Jan 12 19:43:20 2010 @@ -62,9 +62,6 @@ cl::desc("Verify generated machine code"), cl::init(getenv("LLVM_VERIFY_MACHINEINSTRS")!=NULL)); -#if 1 -static cl::opt XX("xx", cl::Hidden); -#endif // Enable or disable FastISel. Both options are needed, because // FastISel is enabled by default with -fast, and we wish to be From evan.cheng at apple.com Tue Jan 12 19:51:43 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 13 Jan 2010 01:51:43 -0000 Subject: [llvm-commits] [llvm] r93286 - in /llvm/trunk: lib/CodeGen/LLVMTargetMachine.cpp test/CodeGen/X86/2008-08-05-SpillerBug.ll test/CodeGen/X86/sext-subreg.ll test/CodeGen/X86/stack-color-with-reg.ll Message-ID: <201001130151.o0D1phTS027386@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jan 12 19:51:43 2010 New Revision: 93286 URL: http://llvm.org/viewvc/llvm-project?rev=93286&view=rev Log: Disable opt-ext pass to unbreak the build for now. Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp llvm/trunk/test/CodeGen/X86/2008-08-05-SpillerBug.ll llvm/trunk/test/CodeGen/X86/sext-subreg.ll llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=93286&r1=93285&r2=93286&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Tue Jan 12 19:51:43 2010 @@ -325,7 +325,6 @@ /* allowDoubleDefs= */ true); if (OptLevel != CodeGenOpt::None) { - PM.add(createOptimizeExtsPass()); if (!DisableMachineLICM) PM.add(createMachineLICMPass()); if (!DisableMachineSink) Modified: llvm/trunk/test/CodeGen/X86/2008-08-05-SpillerBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-08-05-SpillerBug.ll?rev=93286&r1=93285&r2=93286&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-08-05-SpillerBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-08-05-SpillerBug.ll Tue Jan 12 19:51:43 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=i386-apple-darwin -disable-fp-elim -stats |& grep asm-printer | grep 57 +; RUN: llc < %s -mtriple=i386-apple-darwin -disable-fp-elim -stats |& grep asm-printer | grep 58 ; PR2568 @g_3 = external global i16 ; [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/sext-subreg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sext-subreg.ll?rev=93286&r1=93285&r2=93286&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/sext-subreg.ll (original) +++ llvm/trunk/test/CodeGen/X86/sext-subreg.ll Tue Jan 12 19:51:43 2010 @@ -1,5 +1,6 @@ ; RUN: llc < %s -march=x86-64 | FileCheck %s ; rdar://7529457 +; XFAIL: * define i64 @t(i64 %A, i64 %B, i32* %P, i64 *%P2) nounwind { ; CHECK: t: Modified: llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll?rev=93286&r1=93285&r2=93286&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll (original) +++ llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll Tue Jan 12 19:51:43 2010 @@ -1,5 +1,5 @@ ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -relocation-model=pic -disable-fp-elim -color-ss-with-regs -stats -info-output-file - > %t -; RUN: grep stackcoloring %t | grep "stack slot refs replaced with reg refs" | grep 9 +; RUN: grep stackcoloring %t | grep "stack slot refs replaced with reg refs" | grep 6 type { [62 x %struct.Bitvec*] } ; type %0 type { i8* } ; type %1 From vhernandez at apple.com Tue Jan 12 20:07:13 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Tue, 12 Jan 2010 18:07:13 -0800 Subject: [llvm-commits] [llvm] r93270 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp In-Reply-To: References: <201001122337.o0CNbxWd022341@zion.cs.uiuc.edu> Message-ID: <0783565B-F057-461B-86D8-72A3F9D9BA14@apple.com> On Jan 12, 2010, at 4:53 PM, Devang Patel wrote: > > On Jan 12, 2010, at 3:37 PM, Victor Hernandez wrote: > >> Author: hernande >> Date: Tue Jan 12 17:37:59 2010 >> New Revision: 93270 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=93270&view=rev >> Log: >> Make WriteConstants() more robust against stray values in ValueEnumerator's ValueList > > Isn't this covering a bug if there are stray values in ValueList ? It very well could turn out to be just that. Currently I am seeing stray function-local values in the ValueList when the global constants are getting written. I am working on getting them to not exist until incorporateFunction time, but even then, I don't know if there will be stray values while function-local constants are being written. I'll update you after some more investigation. Victor > - > Devang >> >> Modified: >> llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp >> >> Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=93270&r1=93269&r2=93270&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) >> +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Jan 12 17:37:59 2010 >> @@ -688,6 +688,11 @@ >> Record.clear(); >> continue; >> } >> + >> + // Ignore all values in ValueList except for Constants. >> + if (V && (isa(V) || isa(V))) >> + continue; >> + >> const Constant *C = cast(V); >> unsigned Code = -1U; >> unsigned AbbrevToUse = 0; >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From clattner at apple.com Tue Jan 12 20:22:33 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 12 Jan 2010 18:22:33 -0800 Subject: [llvm-commits] [llvm] r93280 - in /llvm/trunk/lib/Target/ARM: ARMInstrThumb.td ARMRegisterInfo.td In-Reply-To: <201001130043.o0D0h6xA025039@zion.cs.uiuc.edu> References: <201001130043.o0D0h6xA025039@zion.cs.uiuc.edu> Message-ID: <066B11E1-AF73-457D-9384-46919B1A212F@apple.com> On Jan 12, 2010, at 4:43 PM, Jakob Stoklund Olesen wrote: > Author: stoklund > Date: Tue Jan 12 18:43:06 2010 > New Revision: 93280 > > URL: http://llvm.org/viewvc/llvm-project?rev=93280&view=rev > Log: > Remove the JustSP single-register regclass. > > It was only being used by instructions with the t_addrmode_sp addressing mode, > and that is pattern matched in a way that guarantees SP is used. There is > never any register allocation done from this class. Thanks Jakob! -Chris From sabre at nondot.org Tue Jan 12 20:24:17 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 12 Jan 2010 18:24:17 -0800 Subject: [llvm-commits] [llvm] r93189 - /llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll In-Reply-To: References: <201001112158.o0BLwJGM013869@zion.cs.uiuc.edu> Message-ID: <349BC534-5BFA-45F3-9C0A-C314C2353E2F@nondot.org> On Jan 12, 2010, at 4:32 PM, Jeffrey Yasskin wrote: > I just committed r93279 to fix this on ARM and PPC, which it crashed: > http://google1.osuosl.org:8011/builders/llvm-arm-linux/builds/1427/steps/test-llvm/logs/2010-01-07-uamemfeature.ll > and http://google1.osuosl.org:8011/builders/llvm-ppc-linux/builds/3820/steps/test-llvm/logs/2010-01-07-uamemfeature.ll Thanks, that's the right fix for the test, since the grep will fail even if llc doesn't crash. > Should an unsupported -mattr flag really cause llc to crash though? No, that's apparently a bug in the ppc/arm backends. :( -Chris From dpatel at apple.com Tue Jan 12 20:28:23 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 12 Jan 2010 18:28:23 -0800 Subject: [llvm-commits] [llvm] r93270 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp In-Reply-To: <0783565B-F057-461B-86D8-72A3F9D9BA14@apple.com> References: <201001122337.o0CNbxWd022341@zion.cs.uiuc.edu> <0783565B-F057-461B-86D8-72A3F9D9BA14@apple.com> Message-ID: On Jan 12, 2010, at 6:07 PM, Victor Hernandez wrote: > > On Jan 12, 2010, at 4:53 PM, Devang Patel wrote: > >> >> On Jan 12, 2010, at 3:37 PM, Victor Hernandez wrote: >> >>> Author: hernande >>> Date: Tue Jan 12 17:37:59 2010 >>> New Revision: 93270 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=93270&view=rev >>> Log: >>> Make WriteConstants() more robust against stray values in ValueEnumerator's ValueList >> >> Isn't this covering a bug if there are stray values in ValueList ? > > It very well could turn out to be just that. Currently I am seeing stray function-local values in the ValueList when the global constants are getting written. I am working on getting them to not exist until incorporateFunction time, but even then, I don't know if there will be stray values while function-local constants are being written. hmm.. stray values are not good, we should flag these values. > I'll update you after some more investigation. You may want to keep this patch in your local tree while you sort out function-local values patch. - Devang > > Victor > >> - >> Devang >>> >>> Modified: >>> llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp >>> >>> Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=93270&r1=93269&r2=93270&view=diff >>> >>> ============================================================================== >>> --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) >>> +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Jan 12 17:37:59 2010 >>> @@ -688,6 +688,11 @@ >>> Record.clear(); >>> continue; >>> } >>> + >>> + // Ignore all values in ValueList except for Constants. >>> + if (V && (isa(V) || isa(V))) >>> + continue; >>> + >>> const Constant *C = cast(V); >>> unsigned Code = -1U; >>> unsigned AbbrevToUse = 0; >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > From clattner at apple.com Tue Jan 12 20:55:10 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 12 Jan 2010 18:55:10 -0800 Subject: [llvm-commits] [llvm] r93270 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp In-Reply-To: References: <201001122337.o0CNbxWd022341@zion.cs.uiuc.edu> <0783565B-F057-461B-86D8-72A3F9D9BA14@apple.com> Message-ID: On Jan 12, 2010, at 6:28 PM, Devang Patel wrote: >> It very well could turn out to be just that. Currently I am seeing stray function-local values in the ValueList when the global constants are getting written. I am working on getting them to not exist until incorporateFunction time, but even then, I don't know if there will be stray values while function-local constants are being written. > > hmm.. stray values are not good, we should flag these values. > >> I'll update you after some more investigation. > > You may want to keep this patch in your local tree while you sort out function-local values patch. Yes, this shouldn't go into mainline, please revert it Victor. -Chris From vhernandez at apple.com Tue Jan 12 21:18:31 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Wed, 13 Jan 2010 03:18:31 -0000 Subject: [llvm-commits] [llvm] r93289 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Message-ID: <201001130318.o0D3IVaM030689@zion.cs.uiuc.edu> Author: hernande Date: Tue Jan 12 21:18:30 2010 New Revision: 93289 URL: http://llvm.org/viewvc/llvm-project?rev=93289&view=rev Log: Revert 93270 pending investigation of how stray non-constant values end up in ValueEnumerator's ValueList during WriteConstants() Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=93289&r1=93288&r2=93289&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Jan 12 21:18:30 2010 @@ -688,11 +688,6 @@ Record.clear(); continue; } - - // Ignore all values in ValueList except for Constants. - if (V && (isa(V) || isa(V))) - continue; - const Constant *C = cast(V); unsigned Code = -1U; unsigned AbbrevToUse = 0; From vhernandez at apple.com Tue Jan 12 21:19:23 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Tue, 12 Jan 2010 19:19:23 -0800 Subject: [llvm-commits] [llvm] r93270 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp In-Reply-To: References: <201001122337.o0CNbxWd022341@zion.cs.uiuc.edu> <0783565B-F057-461B-86D8-72A3F9D9BA14@apple.com> Message-ID: <306BC1BC-D6D9-4031-9ADD-D39512DFB319@apple.com> On Jan 12, 2010, at 6:55 PM, Chris Lattner wrote: > On Jan 12, 2010, at 6:28 PM, Devang Patel wrote: >>> It very well could turn out to be just that. Currently I am seeing stray function-local values in the ValueList when the global constants are getting written. I am working on getting them to not exist until incorporateFunction time, but even then, I don't know if there will be stray values while function-local constants are being written. >> >> hmm.. stray values are not good, we should flag these values. >> >>> I'll update you after some more investigation. >> >> You may want to keep this patch in your local tree while you sort out function-local values patch. > > Yes, this shouldn't go into mainline, please revert it Victor. Ok, just reverted it. It does look like I can avoid adding those stray values to the ValueEnumerator. > > -Chris From clattner at apple.com Tue Jan 12 22:21:21 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 12 Jan 2010 20:21:21 -0800 Subject: [llvm-commits] [llvm] r93270 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp In-Reply-To: <306BC1BC-D6D9-4031-9ADD-D39512DFB319@apple.com> References: <201001122337.o0CNbxWd022341@zion.cs.uiuc.edu> <0783565B-F057-461B-86D8-72A3F9D9BA14@apple.com> <306BC1BC-D6D9-4031-9ADD-D39512DFB319@apple.com> Message-ID: <11419A59-70CA-424B-8D01-620E16970CDA@apple.com> On Jan 12, 2010, at 7:19 PM, Victor Hernandez wrote: > > On Jan 12, 2010, at 6:55 PM, Chris Lattner wrote: > >> On Jan 12, 2010, at 6:28 PM, Devang Patel wrote: >>>> It very well could turn out to be just that. Currently I am seeing stray function-local values in the ValueList when the global constants are getting written. I am working on getting them to not exist until incorporateFunction time, but even then, I don't know if there will be stray values while function-local constants are being written. >>> >>> hmm.. stray values are not good, we should flag these values. >>> >>>> I'll update you after some more investigation. >>> >>> You may want to keep this patch in your local tree while you sort out function-local values patch. >> >> Yes, this shouldn't go into mainline, please revert it Victor. > > Ok, just reverted it. It does look like I can avoid adding those stray values to the ValueEnumerator. Thanks! From sabre at nondot.org Tue Jan 12 22:29:22 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 04:29:22 -0000 Subject: [llvm-commits] [llvm] r93290 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <201001130429.o0D4TOD8000495@zion.cs.uiuc.edu> Author: lattner Date: Tue Jan 12 22:29:19 2010 New Revision: 93290 URL: http://llvm.org/viewvc/llvm-project?rev=93290&view=rev Log: reduce indentation and use early exits in AsmPrinter::EmitConstantValueOnly Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93290&r1=93289&r2=93290&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Jan 12 22:29:19 2010 @@ -807,130 +807,145 @@ // Print out the specified constant, without a storage class. Only the // constants valid in constant expressions can occur here. void AsmPrinter::EmitConstantValueOnly(const Constant *CV) { - if (CV->isNullValue() || isa(CV)) + if (CV->isNullValue() || isa(CV)) { O << '0'; - else if (const ConstantInt *CI = dyn_cast(CV)) { + return; + } + + if (const ConstantInt *CI = dyn_cast(CV)) { O << CI->getZExtValue(); - } else if (const GlobalValue *GV = dyn_cast(CV)) { + return; + } + + if (const GlobalValue *GV = dyn_cast(CV)) { // This is a constant address for a global variable or function. Use the // name of the variable or function as the address value. O << Mang->getMangledName(GV); - } else if (const ConstantExpr *CE = dyn_cast(CV)) { + return; + } + + if (const BlockAddress *BA = dyn_cast(CV)) { + GetBlockAddressSymbol(BA)->print(O, MAI); + return; + } + + const ConstantExpr *CE = dyn_cast(CV); + if (CE == 0) { + llvm_unreachable("Unknown constant value!"); + O << '0'; + return; + } + + switch (CE->getOpcode()) { + case Instruction::ZExt: + case Instruction::SExt: + case Instruction::FPTrunc: + case Instruction::FPExt: + case Instruction::UIToFP: + case Instruction::SIToFP: + case Instruction::FPToUI: + case Instruction::FPToSI: + default: + llvm_unreachable("FIXME: Don't support this constant cast expr"); + case Instruction::GetElementPtr: { + // generate a symbolic expression for the byte address const TargetData *TD = TM.getTargetData(); - unsigned Opcode = CE->getOpcode(); - switch (Opcode) { - case Instruction::ZExt: - case Instruction::SExt: - case Instruction::FPTrunc: - case Instruction::FPExt: - case Instruction::UIToFP: - case Instruction::SIToFP: - case Instruction::FPToUI: - case Instruction::FPToSI: - llvm_unreachable("FIXME: Don't support this constant cast expr"); - case Instruction::GetElementPtr: { - // generate a symbolic expression for the byte address - const Constant *ptrVal = CE->getOperand(0); - SmallVector idxVec(CE->op_begin()+1, CE->op_end()); - if (int64_t Offset = TD->getIndexedOffset(ptrVal->getType(), &idxVec[0], - idxVec.size())) { - // Truncate/sext the offset to the pointer size. - if (TD->getPointerSizeInBits() != 64) { - int SExtAmount = 64-TD->getPointerSizeInBits(); - Offset = (Offset << SExtAmount) >> SExtAmount; - } - - if (Offset) - O << '('; - EmitConstantValueOnly(ptrVal); - if (Offset > 0) - O << ") + " << Offset; - else if (Offset < 0) - O << ") - " << -Offset; - } else { - EmitConstantValueOnly(ptrVal); - } - break; + const Constant *ptrVal = CE->getOperand(0); + SmallVector idxVec(CE->op_begin()+1, CE->op_end()); + int64_t Offset = TD->getIndexedOffset(ptrVal->getType(), &idxVec[0], + idxVec.size()); + if (Offset == 0) + return EmitConstantValueOnly(ptrVal); + + // Truncate/sext the offset to the pointer size. + if (TD->getPointerSizeInBits() != 64) { + int SExtAmount = 64-TD->getPointerSizeInBits(); + Offset = (Offset << SExtAmount) >> SExtAmount; } - case Instruction::BitCast: - return EmitConstantValueOnly(CE->getOperand(0)); + + if (Offset) + O << '('; + EmitConstantValueOnly(ptrVal); + if (Offset > 0) + O << ") + " << Offset; + else + O << ") - " << -Offset; + return; + } + case Instruction::BitCast: + return EmitConstantValueOnly(CE->getOperand(0)); - case Instruction::IntToPtr: { - // Handle casts to pointers by changing them into casts to the appropriate - // integer type. This promotes constant folding and simplifies this code. - Constant *Op = CE->getOperand(0); - Op = ConstantExpr::getIntegerCast(Op, TD->getIntPtrType(CV->getContext()), - false/*ZExt*/); + case Instruction::IntToPtr: { + // Handle casts to pointers by changing them into casts to the appropriate + // integer type. This promotes constant folding and simplifies this code. + const TargetData *TD = TM.getTargetData(); + Constant *Op = CE->getOperand(0); + Op = ConstantExpr::getIntegerCast(Op, TD->getIntPtrType(CV->getContext()), + false/*ZExt*/); + return EmitConstantValueOnly(Op); + } + + case Instruction::PtrToInt: { + // Support only foldable casts to/from pointers that can be eliminated by + // changing the pointer to the appropriately sized integer type. + Constant *Op = CE->getOperand(0); + const Type *Ty = CE->getType(); + const TargetData *TD = TM.getTargetData(); + + // We can emit the pointer value into this slot if the slot is an + // integer slot greater or equal to the size of the pointer. + if (TD->getTypeAllocSize(Ty) == TD->getTypeAllocSize(Op->getType())) return EmitConstantValueOnly(Op); - } + + O << "(("; + EmitConstantValueOnly(Op); + APInt ptrMask = + APInt::getAllOnesValue(TD->getTypeAllocSizeInBits(Op->getType())); + + SmallString<40> S; + ptrMask.toStringUnsigned(S); + O << ") & " << S.str() << ')'; + return; + } - case Instruction::PtrToInt: { - // Support only foldable casts to/from pointers that can be eliminated by - // changing the pointer to the appropriately sized integer type. - Constant *Op = CE->getOperand(0); - const Type *Ty = CE->getType(); - - // We can emit the pointer value into this slot if the slot is an - // integer slot greater or equal to the size of the pointer. - if (TD->getTypeAllocSize(Ty) == TD->getTypeAllocSize(Op->getType())) - return EmitConstantValueOnly(Op); - - O << "(("; - EmitConstantValueOnly(Op); - APInt ptrMask = - APInt::getAllOnesValue(TD->getTypeAllocSizeInBits(Op->getType())); + case Instruction::Trunc: + // We emit the value and depend on the assembler to truncate the generated + // expression properly. This is important for differences between + // blockaddress labels. Since the two labels are in the same function, it + // is reasonable to treat their delta as a 32-bit value. + return EmitConstantValueOnly(CE->getOperand(0)); - SmallString<40> S; - ptrMask.toStringUnsigned(S); - O << ") & " << S.str() << ')'; - break; - } - - case Instruction::Trunc: - // We emit the value and depend on the assembler to truncate the generated - // expression properly. This is important for differences between - // blockaddress labels. Since the two labels are in the same function, it - // is reasonable to treat their delta as a 32-bit value. - return EmitConstantValueOnly(CE->getOperand(0)); - + case Instruction::Add: + case Instruction::Sub: + case Instruction::And: + case Instruction::Or: + case Instruction::Xor: + O << '('; + EmitConstantValueOnly(CE->getOperand(0)); + O << ')'; + switch (CE->getOpcode()) { case Instruction::Add: + O << " + "; + break; case Instruction::Sub: + O << " - "; + break; case Instruction::And: + O << " & "; + break; case Instruction::Or: + O << " | "; + break; case Instruction::Xor: - O << '('; - EmitConstantValueOnly(CE->getOperand(0)); - O << ')'; - switch (Opcode) { - case Instruction::Add: - O << " + "; - break; - case Instruction::Sub: - O << " - "; - break; - case Instruction::And: - O << " & "; - break; - case Instruction::Or: - O << " | "; - break; - case Instruction::Xor: - O << " ^ "; - break; - default: - break; - } - O << '('; - EmitConstantValueOnly(CE->getOperand(1)); - O << ')'; - break; + O << " ^ "; + break; default: - llvm_unreachable("Unsupported operator!"); + break; } - } else if (const BlockAddress *BA = dyn_cast(CV)) { - GetBlockAddressSymbol(BA)->print(O, MAI); - } else { - llvm_unreachable("Unknown constant value!"); + O << '('; + EmitConstantValueOnly(CE->getOperand(1)); + O << ')'; + break; } } From sabre at nondot.org Tue Jan 12 22:34:19 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 04:34:19 -0000 Subject: [llvm-commits] [llvm] r93291 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <201001130434.o0D4YJhq000635@zion.cs.uiuc.edu> Author: lattner Date: Tue Jan 12 22:34:19 2010 New Revision: 93291 URL: http://llvm.org/viewvc/llvm-project?rev=93291&view=rev Log: reduce indentation and add a fast-path to EmitGlobalConstant for 8-byte integers on 64-bit systems. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93291&r1=93290&r2=93291&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Jan 12 22:34:19 2010 @@ -1305,22 +1305,39 @@ if (CV->isNullValue() || isa(CV)) { EmitZeros(Size, AddrSpace); return; - } else if (const ConstantArray *CVA = dyn_cast(CV)) { + } + + if (const ConstantArray *CVA = dyn_cast(CV)) { EmitGlobalConstantArray(CVA , AddrSpace); return; - } else if (const ConstantStruct *CVS = dyn_cast(CV)) { + } + + if (const ConstantStruct *CVS = dyn_cast(CV)) { EmitGlobalConstantStruct(CVS, AddrSpace); return; - } else if (const ConstantFP *CFP = dyn_cast(CV)) { + } + + if (const ConstantFP *CFP = dyn_cast(CV)) { EmitGlobalConstantFP(CFP, AddrSpace); return; - } else if (const ConstantInt *CI = dyn_cast(CV)) { + } + + if (const ConstantInt *CI = dyn_cast(CV)) { + // If we can directly emit an 8-byte constant, do it. + if (Size == 8) + if (const char *Data64Dir = MAI->getData64bitsDirective(AddrSpace)) { + O << Data64Dir << CI->getZExtValue() << '\n'; + return; + } + // Small integers are handled below; large integers are handled here. if (Size > 4) { EmitGlobalConstantLargeInt(CI, AddrSpace); return; } - } else if (const ConstantVector *CP = dyn_cast(CV)) { + } + + if (const ConstantVector *CP = dyn_cast(CV)) { EmitGlobalConstantVector(CP); return; } From sabre at nondot.org Tue Jan 12 22:38:16 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 04:38:16 -0000 Subject: [llvm-commits] [llvm] r93292 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <201001130438.o0D4cG7F000781@zion.cs.uiuc.edu> Author: lattner Date: Tue Jan 12 22:38:16 2010 New Revision: 93292 URL: http://llvm.org/viewvc/llvm-project?rev=93292&view=rev Log: reduce nesting and code duplication in AsmPrinter::EmitGlobalConstantLargeInt. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93292&r1=93291&r2=93292&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Jan 12 22:38:16 2010 @@ -1260,39 +1260,34 @@ else Val = RawData[i]; - if (MAI->getData64bitsDirective(AddrSpace)) + if (MAI->getData64bitsDirective(AddrSpace)) { O << MAI->getData64bitsDirective(AddrSpace) << Val << '\n'; - else if (TD->isBigEndian()) { - O << MAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32); - if (VerboseAsm) { - O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() - << " most significant half of i64 " << Val; - } - O << '\n'; - O << MAI->getData32bitsDirective(AddrSpace) << unsigned(Val); - if (VerboseAsm) { - O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() - << " least significant half of i64 " << Val; - } - O << '\n'; - } else { - O << MAI->getData32bitsDirective(AddrSpace) << unsigned(Val); - if (VerboseAsm) { - O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() - << " least significant half of i64 " << Val; - } - O << '\n'; - O << MAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32); - if (VerboseAsm) { - O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() - << " most significant half of i64 " << Val; - } - O << '\n'; + continue; } + + // Emit two 32-bit chunks, order depends on endianness. + unsigned FirstChunk = unsigned(Val), SecondChunk = unsigned(Val >> 32); + const char *FirstName = " least", *SecondName = " most"; + if (TD->isBigEndian()) { + std::swap(FirstChunk, SecondChunk); + std::swap(FirstName, SecondName); + } + + O << MAI->getData32bitsDirective(AddrSpace) << FirstChunk; + if (VerboseAsm) { + O.PadToColumn(MAI->getCommentColumn()); + O << MAI->getCommentString() + << FirstName << " significant half of i64 " << Val; + } + O << '\n'; + + O << MAI->getData32bitsDirective(AddrSpace) << SecondChunk; + if (VerboseAsm) { + O.PadToColumn(MAI->getCommentColumn()); + O << MAI->getCommentString() + << SecondName << " significant half of i64 " << Val; + } + O << '\n'; } } From sabre at nondot.org Tue Jan 12 22:39:47 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 04:39:47 -0000 Subject: [llvm-commits] [llvm] r93293 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <201001130439.o0D4dlNU000847@zion.cs.uiuc.edu> Author: lattner Date: Tue Jan 12 22:39:46 2010 New Revision: 93293 URL: http://llvm.org/viewvc/llvm-project?rev=93293&view=rev Log: fix assert in AsmPrinter::EmitGlobalConstantLargeInt to match reality. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93293&r1=93292&r2=93293&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Jan 12 22:39:46 2010 @@ -1246,8 +1246,7 @@ unsigned AddrSpace) { const TargetData *TD = TM.getTargetData(); unsigned BitWidth = CI->getBitWidth(); - assert(isPowerOf2_32(BitWidth) && - "Non-power-of-2-sized integers not handled!"); + assert((BitWidth & 63) == 0 && "only support multiples of 64-bits"); // We don't expect assemblers to support integer data directives // for more than 64 bits, so we emit the data in at most 64-bit From sabre at nondot.org Tue Jan 12 22:50:21 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 04:50:21 -0000 Subject: [llvm-commits] [llvm] r93294 - /llvm/trunk/include/llvm/ADT/StringRef.h Message-ID: <201001130450.o0D4oLY3001182@zion.cs.uiuc.edu> Author: lattner Date: Tue Jan 12 22:50:20 2010 New Revision: 93294 URL: http://llvm.org/viewvc/llvm-project?rev=93294&view=rev Log: give StringRef a const_iterator member. Modified: llvm/trunk/include/llvm/ADT/StringRef.h Modified: llvm/trunk/include/llvm/ADT/StringRef.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=93294&r1=93293&r2=93294&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringRef.h (original) +++ llvm/trunk/include/llvm/ADT/StringRef.h Tue Jan 12 22:50:20 2010 @@ -29,6 +29,7 @@ class StringRef { public: typedef const char *iterator; + typedef const char *const_iterator; static const size_t npos = ~size_t(0); typedef size_t size_type; @@ -42,15 +43,8 @@ // Workaround PR5482: nearly all gcc 4.x miscompile StringRef and std::min() // Changing the arg of min to be an integer, instead of a reference to an // integer works around this bug. - size_t min(size_t a, size_t b) const - { - return a < b ? a : b; - } - - size_t max(size_t a, size_t b) const - { - return a > b ? a : b; - } + size_t min(size_t a, size_t b) const { return a < b ? a : b; } + size_t max(size_t a, size_t b) const { return a > b ? a : b; } public: /// @name Constructors From sabre at nondot.org Tue Jan 12 22:55:33 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 04:55:33 -0000 Subject: [llvm-commits] [llvm] r93295 - in /llvm/trunk: include/llvm/Support/Mangler.h lib/VMCore/Mangler.cpp Message-ID: <201001130455.o0D4tXUT001440@zion.cs.uiuc.edu> Author: lattner Date: Tue Jan 12 22:55:33 2010 New Revision: 93295 URL: http://llvm.org/viewvc/llvm-project?rev=93295&view=rev Log: change makeNameProper to take a stringref instead of std::string. Modified: llvm/trunk/include/llvm/Support/Mangler.h llvm/trunk/lib/VMCore/Mangler.cpp Modified: llvm/trunk/include/llvm/Support/Mangler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=93295&r1=93294&r2=93295&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Mangler.h (original) +++ llvm/trunk/include/llvm/Support/Mangler.h Tue Jan 12 22:55:33 2010 @@ -19,6 +19,7 @@ #include namespace llvm { +class StringRef; class Type; class Module; class Value; @@ -111,7 +112,7 @@ /// does this for you, so there's no point calling it on the result /// from getValueName. /// - std::string makeNameProper(const std::string &x, + std::string makeNameProper(StringRef x, ManglerPrefixTy PrefixTy = Mangler::Default); /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix Modified: llvm/trunk/lib/VMCore/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=93295&r1=93294&r2=93295&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Mangler.cpp (original) +++ llvm/trunk/lib/VMCore/Mangler.cpp Tue Jan 12 22:55:33 2010 @@ -32,7 +32,7 @@ /// makeNameProper - We don't want identifier names non-C-identifier characters /// in them, so mangle them as appropriate. /// -std::string Mangler::makeNameProper(const std::string &X, +std::string Mangler::makeNameProper(StringRef X, ManglerPrefixTy PrefixTy) { assert(!X.empty() && "Cannot mangle empty strings"); @@ -41,7 +41,7 @@ // If X does not start with (char)1, add the prefix. bool NeedPrefix = true; - std::string::const_iterator I = X.begin(); + StringRef::iterator I = X.begin(); if (*I == 1) { NeedPrefix = false; ++I; // Skip over the marker. @@ -52,7 +52,7 @@ if (!SymbolsCanStartWithDigit && *I >= '0' && *I <= '9') Result += MangleLetter(*I++); - for (std::string::const_iterator E = X.end(); I != E; ++I) { + for (StringRef::iterator E = X.end(); I != E; ++I) { if (!isCharAcceptable(*I)) Result += MangleLetter(*I); else @@ -74,7 +74,7 @@ bool NeedPrefix = true; bool NeedQuotes = false; std::string Result; - std::string::const_iterator I = X.begin(); + StringRef::iterator I = X.begin(); if (*I == 1) { NeedPrefix = false; ++I; // Skip over the marker. @@ -87,7 +87,7 @@ // Do an initial scan of the string, checking to see if we need quotes or // to escape a '"' or not. if (!NeedQuotes) - for (std::string::const_iterator E = X.end(); I != E; ++I) + for (StringRef::iterator E = X.end(); I != E; ++I) if (!isCharAcceptable(*I)) { NeedQuotes = true; break; @@ -98,7 +98,7 @@ if (!NeedPrefix) return X.substr(1); // Strip off the \001. - Result = Prefix + X; + Result = Prefix + X.str(); if (PrefixTy == Mangler::Private) Result = PrivatePrefix + Result; @@ -109,10 +109,10 @@ } if (NeedPrefix) - Result = X.substr(0, I-X.begin()); + Result = X.substr(0, I-X.begin()).str(); // Otherwise, construct the string the expensive way. - for (std::string::const_iterator E = X.end(); I != E; ++I) { + for (StringRef::iterator E = X.end(); I != E; ++I) { if (*I == '"') Result += "_QQ_"; else if (*I == '\n') From sabre at nondot.org Tue Jan 12 23:02:57 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 05:02:57 -0000 Subject: [llvm-commits] [llvm] r93296 - in /llvm/trunk: include/llvm/Support/Mangler.h lib/VMCore/Mangler.cpp Message-ID: <201001130502.o0D52veK001679@zion.cs.uiuc.edu> Author: lattner Date: Tue Jan 12 23:02:57 2010 New Revision: 93296 URL: http://llvm.org/viewvc/llvm-project?rev=93296&view=rev Log: my mistake, Mangler::makeNameProper wants to take a twine, not a stringref! Modified: llvm/trunk/include/llvm/Support/Mangler.h llvm/trunk/lib/VMCore/Mangler.cpp Modified: llvm/trunk/include/llvm/Support/Mangler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=93296&r1=93295&r2=93296&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Mangler.h (original) +++ llvm/trunk/include/llvm/Support/Mangler.h Tue Jan 12 23:02:57 2010 @@ -19,7 +19,7 @@ #include namespace llvm { -class StringRef; +class Twine; class Type; class Module; class Value; @@ -112,7 +112,7 @@ /// does this for you, so there's no point calling it on the result /// from getValueName. /// - std::string makeNameProper(StringRef x, + std::string makeNameProper(const Twine &Name, ManglerPrefixTy PrefixTy = Mangler::Default); /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix Modified: llvm/trunk/lib/VMCore/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=93296&r1=93295&r2=93296&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Mangler.cpp (original) +++ llvm/trunk/lib/VMCore/Mangler.cpp Tue Jan 12 23:02:57 2010 @@ -16,7 +16,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringMap.h" -#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/SmallString.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -32,8 +32,11 @@ /// makeNameProper - We don't want identifier names non-C-identifier characters /// in them, so mangle them as appropriate. /// -std::string Mangler::makeNameProper(StringRef X, +std::string Mangler::makeNameProper(const Twine &TheName, ManglerPrefixTy PrefixTy) { + SmallString<256> TmpData; + TheName.toVector(TmpData); + StringRef X = TmpData.str(); assert(!X.empty() && "Cannot mangle empty strings"); if (!UseQuotes) { From kledzik at apple.com Tue Jan 12 23:30:33 2010 From: kledzik at apple.com (Nick Kledzik) Date: Wed, 13 Jan 2010 05:30:33 -0000 Subject: [llvm-commits] [compiler-rt] r93297 - /compiler-rt/trunk/lib/ppc/restFP.S Message-ID: <201001130530.o0D5Uaxv002521@zion.cs.uiuc.edu> Author: kledzik Date: Tue Jan 12 23:30:28 2010 New Revision: 93297 URL: http://llvm.org/viewvc/llvm-project?rev=93297&view=rev Log: Fix copy/paste error. http://llvm.org/bugs/show_bug.cgi?id=572 Modified: compiler-rt/trunk/lib/ppc/restFP.S Modified: compiler-rt/trunk/lib/ppc/restFP.S URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ppc/restFP.S?rev=93297&r1=93296&r2=93297&view=diff ============================================================================== --- compiler-rt/trunk/lib/ppc/restFP.S (original) +++ compiler-rt/trunk/lib/ppc/restFP.S Tue Jan 12 23:30:28 2010 @@ -20,24 +20,24 @@ // unit carries its own copy of this function. // DEFINE_COMPILERRT_PRIVATE_FUNCTION(restFP) - stfd f14,-144(r1) - stfd f15,-136(r1) - stfd f16,-128(r1) - stfd f17,-120(r1) - stfd f18,-112(r1) - stfd f19,-104(r1) - stfd f20,-96(r1) - stfd f21,-88(r1) - stfd f22,-80(r1) - stfd f23,-72(r1) - stfd f24,-64(r1) - stfd f25,-56(r1) - stfd f26,-48(r1) - stfd f27,-40(r1) - stfd f28,-32(r1) - stfd f29,-24(r1) - stfd f30,-16(r1) - stfd f31,-8(r1) + lfd f14,-144(r1) + lfd f15,-136(r1) + lfd f16,-128(r1) + lfd f17,-120(r1) + lfd f18,-112(r1) + lfd f19,-104(r1) + lfd f20,-96(r1) + lfd f21,-88(r1) + lfd f22,-80(r1) + lfd f23,-72(r1) + lfd f24,-64(r1) + lfd f25,-56(r1) + lfd f26,-48(r1) + lfd f27,-40(r1) + lfd f28,-32(r1) + lfd f29,-24(r1) + lfd f30,-16(r1) + lfd f31,-8(r1) lwz r0,8(r1) mtlr r0 blr From sabre at nondot.org Wed Jan 13 00:38:19 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 06:38:19 -0000 Subject: [llvm-commits] [llvm] r93298 - in /llvm/trunk: include/llvm/Support/Mangler.h include/llvm/Target/TargetLoweringObjectFile.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp lib/Target/CBackend/CBackend.cpp lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp lib/Target/TargetLoweringObjectFile.cpp lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp lib/VMCore/Mangler.cpp Message-ID: <201001130638.o0D6cKim004751@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 00:38:18 2010 New Revision: 93298 URL: http://llvm.org/viewvc/llvm-project?rev=93298&view=rev Log: change Mangler::makeNameProper to return its result in a SmallVector instead of returning it in an std::string. Based on this change: 1. Change TargetLoweringObjectFileCOFF::getCOFFSection to take a StringRef 2. Change a bunch of targets to call makeNameProper with a smallstring, making several of them *much* more efficient. 3. Rewrite Mangler::makeNameProper to not build names and then prepend prefixes, not use temporary std::strings, and to avoid other crimes. Modified: llvm/trunk/include/llvm/Support/Mangler.h llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp llvm/trunk/lib/Target/CBackend/CBackend.cpp llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp llvm/trunk/lib/VMCore/Mangler.cpp Modified: llvm/trunk/include/llvm/Support/Mangler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=93298&r1=93297&r2=93298&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Mangler.h (original) +++ llvm/trunk/include/llvm/Support/Mangler.h Wed Jan 13 00:38:18 2010 @@ -112,8 +112,9 @@ /// does this for you, so there's no point calling it on the result /// from getValueName. /// - std::string makeNameProper(const Twine &Name, - ManglerPrefixTy PrefixTy = Mangler::Default); + void makeNameProper(SmallVectorImpl &OutName, + const Twine &Name, + ManglerPrefixTy PrefixTy = Mangler::Default); /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix /// and the specified global variable's name. If the global variable doesn't Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=93298&r1=93297&r2=93298&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original) +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Wed Jan 13 00:38:18 2010 @@ -352,7 +352,7 @@ /// getCOFFSection - Return the MCSection for the specified COFF section. /// FIXME: Switch this to a semantic view eventually. - const MCSection *getCOFFSection(const char *Name, bool isDirective, + const MCSection *getCOFFSection(StringRef Name, bool isDirective, SectionKind K) const; }; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93298&r1=93297&r2=93298&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Jan 13 00:38:18 2010 @@ -1679,13 +1679,14 @@ // functions. std::string FuncName = Mang->getMangledName(F); - SmallString<60> Name; - raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "BA" - << FuncName.size() << '_' << FuncName << '_' - << Mang->makeNameProper(BB->getName()) - << Suffix; + SmallString<60> NameResult; + raw_svector_ostream(NameResult) << MAI->getPrivateGlobalPrefix() << "BA" + << FuncName.size() << '_' << FuncName << '_'; + Mang->makeNameProper(NameResult, BB->getName()); + if (Suffix[0]) + NameResult += Suffix; - return OutContext.GetOrCreateSymbol(Name.str()); + return OutContext.GetOrCreateSymbol(NameResult.str()); } MCSymbol *AsmPrinter::GetMBBSymbol(unsigned MBBID) const { Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=93298&r1=93297&r2=93298&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Wed Jan 13 00:38:18 2010 @@ -175,16 +175,16 @@ printDataDirective(MCPV->getType()); ARMConstantPoolValue *ACPV = static_cast(MCPV); - std::string Name; + SmallString<128> TmpNameStr; if (ACPV->isLSDA()) { - SmallString<16> LSDAName; - raw_svector_ostream(LSDAName) << MAI->getPrivateGlobalPrefix() << + raw_svector_ostream(TmpNameStr) << MAI->getPrivateGlobalPrefix() << "_LSDA_" << getFunctionNumber(); - Name = LSDAName.str(); + O << TmpNameStr.str(); } else if (ACPV->isBlockAddress()) { - Name = GetBlockAddressSymbol(ACPV->getBlockAddress())->getName(); + O << GetBlockAddressSymbol(ACPV->getBlockAddress())->getName(); } else if (ACPV->isGlobalValue()) { + std::string Name; GlobalValue *GV = ACPV->getGV(); bool isIndirect = Subtarget->isTargetDarwin() && Subtarget->GVIsIndirectSymbol(GV, TM.getRelocationModel()); @@ -201,16 +201,16 @@ GV->hasHiddenVisibility() ? MMIMachO.getHiddenGVStubEntry(Sym) : MMIMachO.getGVStubEntry(Sym); if (StubSym == 0) { - SmallString<128> NameStr; - Mang->getNameWithPrefix(NameStr, GV, false); - StubSym = OutContext.GetOrCreateSymbol(NameStr.str()); + Mang->getNameWithPrefix(TmpNameStr, GV, false); + StubSym = OutContext.GetOrCreateSymbol(TmpNameStr.str()); } } + O << Name; } else { assert(ACPV->isExtSymbol() && "unrecognized constant pool value"); - Name = Mang->makeNameProper(ACPV->getSymbol()); + Mang->makeNameProper(TmpNameStr, ACPV->getSymbol()); + O << TmpNameStr.str(); } - O << Name; if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")"; if (ACPV->getPCAdjustment() != 0) { @@ -392,9 +392,10 @@ } case MachineOperand::MO_ExternalSymbol: { bool isCallOp = Modifier && !strcmp(Modifier, "call"); - std::string Name = Mang->makeNameProper(MO.getSymbolName()); + SmallString<128> NameStr; + Mang->makeNameProper(NameStr, MO.getSymbolName()); - O << Name; + O << NameStr.str(); if (isCallOp && Subtarget->isTargetELF() && TM.getRelocationModel() == Reloc::PIC_) O << "(PLT)"; Modified: llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp?rev=93298&r1=93297&r2=93298&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp Wed Jan 13 00:38:18 2010 @@ -31,6 +31,7 @@ #include "llvm/Target/TargetRegistry.h" #include "llvm/Support/Mangler.h" #include "llvm/ADT/Statistic.h" +#include "llvm/ADT/SmallString.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" using namespace llvm; @@ -179,9 +180,12 @@ O << Mang->getMangledName(MO.getGlobal()); printOffset(MO.getOffset()); break; - case MachineOperand::MO_ExternalSymbol: - O << Mang->makeNameProper(MO.getSymbolName()); + case MachineOperand::MO_ExternalSymbol: { + SmallString<60> NameStr; + Mang->makeNameProper(NameStr, MO.getSymbolName()); + O << NameStr.str(); break; + } case MachineOperand::MO_ConstantPoolIndex: O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_" << MO.getIndex(); Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=93298&r1=93297&r2=93298&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Wed Jan 13 00:38:18 2010 @@ -25,6 +25,7 @@ #include "llvm/IntrinsicInst.h" #include "llvm/InlineAsm.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Analysis/ConstantsScanner.h" #include "llvm/Analysis/FindUsedTypes.h" @@ -2207,12 +2208,17 @@ // If there are no type names, exit early. if (I == End) return; + SmallString<128> TempName; + // Print out forward declarations for structure types before anything else! Out << "/* Structure forward decls */\n"; for (; I != End; ++I) { - std::string Name = "struct l_" + Mang->makeNameProper(I->first); - Out << Name << ";\n"; - TypeNames.insert(std::make_pair(I->second, Name)); + const char *Prefix = "struct l_"; + TempName.append(Prefix, Prefix+strlen(Prefix)); + Mang->makeNameProper(TempName, I->first); + Out << TempName.str() << ";\n"; + TypeNames.insert(std::make_pair(I->second, TempName.str())); + TempName.clear(); } Out << '\n'; @@ -2221,10 +2227,14 @@ // for struct or opaque types. Out << "/* Typedefs */\n"; for (I = TST.begin(); I != End; ++I) { - std::string Name = "l_" + Mang->makeNameProper(I->first); + const char *Prefix = "l_"; + TempName.append(Prefix, Prefix+strlen(Prefix)); + Mang->makeNameProper(TempName, I->first); + Out << "typedef "; - printType(Out, I->second, false, Name); + printType(Out, I->second, false, TempName.str()); Out << ";\n"; + TempName.clear(); } Out << '\n'; Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=93298&r1=93297&r2=93298&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Wed Jan 13 00:38:18 2010 @@ -49,6 +49,7 @@ #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSet.h" +#include "llvm/ADT/SmallString.h" using namespace llvm; STATISTIC(EmittedInsts, "Number of machine instrs printed"); @@ -69,15 +70,20 @@ AnonSymbol = Mang->getMangledName(GV, "$stub$tmp", true); } - void Init(const std::string &GV, Mangler *Mang) { + void Init(StringRef GVName, Mangler *Mang) { // Already initialized. if (!Stub.empty()) return; - Stub = Mang->makeNameProper(GV + "$stub", - Mangler::Private); - LazyPtr = Mang->makeNameProper(GV + "$lazy_ptr", - Mangler::Private); - AnonSymbol = Mang->makeNameProper(GV + "$stub$tmp", - Mangler::Private); + SmallString<128> TmpStr; + Mang->makeNameProper(TmpStr, GVName + "$stub", Mangler::Private); + Stub = TmpStr.str(); + TmpStr.clear(); + + Mang->makeNameProper(TmpStr, GVName + "$lazy_ptr", Mangler::Private); + LazyPtr = TmpStr.str(); + TmpStr.clear(); + + Mang->makeNameProper(TmpStr, GVName + "$stub$tmp", Mangler::Private); + AnonSymbol = TmpStr.str(); } }; @@ -230,7 +236,9 @@ } } if (MO.getType() == MachineOperand::MO_ExternalSymbol) { - FnStubInfo &FnInfo =FnStubs[Mang->makeNameProper(MO.getSymbolName())]; + SmallString<128> MangledName; + Mang->makeNameProper(MangledName, MO.getSymbolName()); + FnStubInfo &FnInfo = FnStubs[MangledName.str()]; FnInfo.Init(MO.getSymbolName(), Mang); O << FnInfo.Stub; return; Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=93298&r1=93297&r2=93298&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Wed Jan 13 00:38:18 2010 @@ -492,16 +492,15 @@ } -static unsigned -getELFSectionType(const char *Name, SectionKind K) { +static unsigned getELFSectionType(StringRef Name, SectionKind K) { - if (strcmp(Name, ".init_array") == 0) + if (Name == ".init_array") return MCSectionELF::SHT_INIT_ARRAY; - if (strcmp(Name, ".fini_array") == 0) + if (Name == ".fini_array") return MCSectionELF::SHT_FINI_ARRAY; - if (strcmp(Name, ".preinit_array") == 0) + if (Name == ".preinit_array") return MCSectionELF::SHT_PREINIT_ARRAY; if (K.isBSS() || K.isThreadBSS()) @@ -577,10 +576,12 @@ // into a 'uniqued' section name, create and return the section now. if (GV->isWeakForLinker()) { const char *Prefix = getSectionPrefixForUniqueGlobal(Kind); - std::string Name = Mang->makeNameProper(GV->getNameStr()); + SmallString<128> Name; + Name.append(Prefix, Prefix+strlen(Prefix)); + Mang->makeNameProper(Name, GV->getName()); - return getELFSection((Prefix+Name).c_str(), - getELFSectionType((Prefix+Name).c_str(), Kind), + return getELFSection(Name.str(), + getELFSectionType(Name.str(), Kind), getELFSectionFlags(Kind), Kind); } @@ -983,7 +984,7 @@ const MCSection *TargetLoweringObjectFileCOFF:: -getCOFFSection(const char *Name, bool isDirective, SectionKind Kind) const { +getCOFFSection(StringRef Name, bool isDirective, SectionKind Kind) const { // Create the map if it doesn't already exist. if (UniquingMap == 0) UniquingMap = new MachOUniqueMapTy(); @@ -1078,8 +1079,9 @@ // into a 'uniqued' section name, create and return the section now. if (GV->isWeakForLinker()) { const char *Prefix = getCOFFSectionPrefixForUniqueGlobal(Kind); - std::string Name = Mang->makeNameProper(GV->getNameStr()); - return getCOFFSection((Prefix+Name).c_str(), false, Kind); + SmallString<128> Name(Prefix, Prefix+strlen(Prefix)); + Mang->makeNameProper(Name, GV->getNameStr()); + return getCOFFSection(Name.str(), false, Kind); } if (Kind.isText()) Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=93298&r1=93297&r2=93298&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Wed Jan 13 00:38:18 2010 @@ -201,6 +201,7 @@ /// jump tables, constant pools, global address and external symbols, all of /// which print to a label with various suffixes for relocation types etc. void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) { + SmallString<128> TempNameStr; switch (MO.getType()) { default: llvm_unreachable("unknown symbol type!"); case MachineOperand::MO_JumpTableIndex: @@ -236,41 +237,38 @@ if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY || MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) { - SmallString<128> NameStr; - Mang->getNameWithPrefix(NameStr, GV, true); - NameStr += "$non_lazy_ptr"; - MCSymbol *Sym = OutContext.GetOrCreateSymbol(NameStr.str()); + Mang->getNameWithPrefix(TempNameStr, GV, true); + TempNameStr += "$non_lazy_ptr"; + MCSymbol *Sym = OutContext.GetOrCreateSymbol(TempNameStr.str()); const MCSymbol *&StubSym = MMI->getObjFileInfo().getGVStubEntry(Sym); if (StubSym == 0) { - NameStr.clear(); - Mang->getNameWithPrefix(NameStr, GV, false); - StubSym = OutContext.GetOrCreateSymbol(NameStr.str()); + TempNameStr.clear(); + Mang->getNameWithPrefix(TempNameStr, GV, false); + StubSym = OutContext.GetOrCreateSymbol(TempNameStr.str()); } } else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){ - SmallString<128> NameStr; - Mang->getNameWithPrefix(NameStr, GV, true); - NameStr += "$non_lazy_ptr"; - MCSymbol *Sym = OutContext.GetOrCreateSymbol(NameStr.str()); + Mang->getNameWithPrefix(TempNameStr, GV, true); + TempNameStr += "$non_lazy_ptr"; + MCSymbol *Sym = OutContext.GetOrCreateSymbol(TempNameStr.str()); const MCSymbol *&StubSym = MMI->getObjFileInfo().getHiddenGVStubEntry(Sym); if (StubSym == 0) { - NameStr.clear(); - Mang->getNameWithPrefix(NameStr, GV, false); - StubSym = OutContext.GetOrCreateSymbol(NameStr.str()); + TempNameStr.clear(); + Mang->getNameWithPrefix(TempNameStr, GV, false); + StubSym = OutContext.GetOrCreateSymbol(TempNameStr.str()); } } else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) { - SmallString<128> NameStr; - Mang->getNameWithPrefix(NameStr, GV, true); - NameStr += "$stub"; - MCSymbol *Sym = OutContext.GetOrCreateSymbol(NameStr.str()); + Mang->getNameWithPrefix(TempNameStr, GV, true); + TempNameStr += "$stub"; + MCSymbol *Sym = OutContext.GetOrCreateSymbol(TempNameStr.str()); const MCSymbol *&StubSym = MMI->getObjFileInfo().getFnStubEntry(Sym); if (StubSym == 0) { - NameStr.clear(); - Mang->getNameWithPrefix(NameStr, GV, false); - StubSym = OutContext.GetOrCreateSymbol(NameStr.str()); + TempNameStr.clear(); + Mang->getNameWithPrefix(TempNameStr, GV, false); + StubSym = OutContext.GetOrCreateSymbol(TempNameStr.str()); } } @@ -285,24 +283,24 @@ break; } case MachineOperand::MO_ExternalSymbol: { - std::string Name = Mang->makeNameProper(MO.getSymbolName()); + Mang->makeNameProper(TempNameStr, MO.getSymbolName()); if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) { - Name += "$stub"; - MCSymbol *Sym = OutContext.GetOrCreateSymbol(StringRef(Name)); + TempNameStr += "$stub"; + MCSymbol *Sym = OutContext.GetOrCreateSymbol(TempNameStr.str()); const MCSymbol *&StubSym = MMI->getObjFileInfo().getFnStubEntry(Sym); if (StubSym == 0) { - Name.erase(Name.end()-5, Name.end()); - StubSym = OutContext.GetOrCreateSymbol(StringRef(Name)); + TempNameStr.erase(TempNameStr.end()-5, TempNameStr.end()); + StubSym = OutContext.GetOrCreateSymbol(TempNameStr.str()); } } // If the name begins with a dollar-sign, enclose it in parens. We do this // to avoid having it look like an integer immediate to the assembler. - if (Name[0] == '$') - O << '(' << Name << ')'; + if (TempNameStr[0] == '$') + O << '(' << TempNameStr << ')'; else - O << Name; + O << TempNameStr; break; } } Modified: llvm/trunk/lib/VMCore/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=93298&r1=93297&r2=93298&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Mangler.cpp (original) +++ llvm/trunk/lib/VMCore/Mangler.cpp Wed Jan 13 00:38:18 2010 @@ -24,59 +24,54 @@ return V < 10 ? V+'0' : V+'A'-10; } -static std::string MangleLetter(unsigned char C) { - char Result[] = { '_', HexDigit(C >> 4), HexDigit(C & 15), '_', 0 }; - return Result; +static void MangleLetter(SmallVectorImpl &OutName, unsigned char C) { + OutName.push_back('_'); + OutName.push_back(HexDigit(C >> 4)); + OutName.push_back(HexDigit(C & 15)); + OutName.push_back('_'); } /// makeNameProper - We don't want identifier names non-C-identifier characters /// in them, so mangle them as appropriate. /// -std::string Mangler::makeNameProper(const Twine &TheName, - ManglerPrefixTy PrefixTy) { +void Mangler::makeNameProper(SmallVectorImpl &OutName, + const Twine &TheName, + ManglerPrefixTy PrefixTy) { SmallString<256> TmpData; TheName.toVector(TmpData); StringRef X = TmpData.str(); assert(!X.empty() && "Cannot mangle empty strings"); if (!UseQuotes) { - std::string Result; - // If X does not start with (char)1, add the prefix. - bool NeedPrefix = true; StringRef::iterator I = X.begin(); if (*I == 1) { - NeedPrefix = false; - ++I; // Skip over the marker. + ++I; // Skip over the no-prefix marker. + } else { + if (PrefixTy == Mangler::Private) + OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); + else if (PrefixTy == Mangler::LinkerPrivate) + OutName.append(LinkerPrivatePrefix, + LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); + OutName.append(Prefix, Prefix+strlen(Prefix)); } // Mangle the first letter specially, don't allow numbers unless the target // explicitly allows them. if (!SymbolsCanStartWithDigit && *I >= '0' && *I <= '9') - Result += MangleLetter(*I++); + MangleLetter(OutName, *I++); for (StringRef::iterator E = X.end(); I != E; ++I) { if (!isCharAcceptable(*I)) - Result += MangleLetter(*I); + MangleLetter(OutName, *I); else - Result += *I; - } - - if (NeedPrefix) { - Result = Prefix + Result; - - if (PrefixTy == Mangler::Private) - Result = PrivatePrefix + Result; - else if (PrefixTy == Mangler::LinkerPrivate) - Result = LinkerPrivatePrefix + Result; + OutName.push_back(*I); } - - return Result; + return; } bool NeedPrefix = true; bool NeedQuotes = false; - std::string Result; StringRef::iterator I = X.begin(); if (*I == 1) { NeedPrefix = false; @@ -98,43 +93,57 @@ // In the common case, we don't need quotes. Handle this quickly. if (!NeedQuotes) { - if (!NeedPrefix) - return X.substr(1); // Strip off the \001. - - Result = Prefix + X.str(); + if (!NeedPrefix) { + OutName.append(X.begin()+1, X.end()); // Strip off the \001. + return; + } if (PrefixTy == Mangler::Private) - Result = PrivatePrefix + Result; + OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); else if (PrefixTy == Mangler::LinkerPrivate) - Result = LinkerPrivatePrefix + Result; - - return Result; - } - - if (NeedPrefix) - Result = X.substr(0, I-X.begin()).str(); + OutName.append(LinkerPrivatePrefix, + LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); - // Otherwise, construct the string the expensive way. - for (StringRef::iterator E = X.end(); I != E; ++I) { - if (*I == '"') - Result += "_QQ_"; - else if (*I == '\n') - Result += "_NL_"; + if (Prefix[0] == 0) + ; // Common noop, no prefix. + else if (Prefix[1] == 0) + OutName.push_back(Prefix[0]); // Common, one character prefix. else - Result += *I; + OutName.append(Prefix, Prefix+strlen(Prefix)); // Arbitrary prefix. + OutName.append(X.begin(), X.end()); + return; } + // Add leading quote. + OutName.push_back('"'); + + // Add prefixes unless disabled. if (NeedPrefix) { - Result = Prefix + Result; - if (PrefixTy == Mangler::Private) - Result = PrivatePrefix + Result; + OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); else if (PrefixTy == Mangler::LinkerPrivate) - Result = LinkerPrivatePrefix + Result; + OutName.append(LinkerPrivatePrefix, + LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); + OutName.append(Prefix, Prefix+strlen(Prefix)); + } + + // Add the piece that we already scanned through. + OutName.append(X.begin(), I); + + // Otherwise, construct the string the expensive way. + for (StringRef::iterator E = X.end(); I != E; ++I) { + if (*I == '"') { + const char *Quote = "_QQ_"; + OutName.append(Quote, Quote+4); + } else if (*I == '\n') { + const char *Newline = "_NL_"; + OutName.append(Newline, Newline+4); + } else + OutName.push_back(*I); } - Result = '"' + Result + '"'; - return Result; + // Add trailing quote. + OutName.push_back('"'); } /// getMangledName - Returns the mangled name of V, an LLVM Value, @@ -151,8 +160,11 @@ (GV->hasPrivateLinkage() || ForcePrivate) ? Mangler::Private : GV->hasLinkerPrivateLinkage() ? Mangler::LinkerPrivate : Mangler::Default; - if (GV->hasName()) - return makeNameProper(GV->getNameStr() + Suffix, PrefixTy); + SmallString<128> Result; + if (GV->hasName()) { + makeNameProper(Result, GV->getNameStr() + Suffix, PrefixTy); + return Result.str().str(); + } // Get the ID for the global, assigning a new one if we haven't got one // already. @@ -160,7 +172,8 @@ if (ID == 0) ID = NextAnonGlobalID++; // Must mangle the global into a unique ID. - return makeNameProper("__unnamed_" + utostr(ID) + Suffix, PrefixTy); + makeNameProper(Result, "__unnamed_" + utostr(ID) + Suffix, PrefixTy); + return Result.str().str(); } From sabre at nondot.org Wed Jan 13 01:01:09 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 07:01:09 -0000 Subject: [llvm-commits] [llvm] r93300 - in /llvm/trunk: include/llvm/Support/Mangler.h lib/VMCore/Mangler.cpp Message-ID: <201001130701.o0D71ANN005662@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 01:01:09 2010 New Revision: 93300 URL: http://llvm.org/viewvc/llvm-project?rev=93300&view=rev Log: ugh, my last patch just sped up a method and changed all the clients that I want to completely eliminate. Add fixme's so I remember this in the future, and add the missing helper that they should be upgraded to use instead. Modified: llvm/trunk/include/llvm/Support/Mangler.h llvm/trunk/lib/VMCore/Mangler.cpp Modified: llvm/trunk/include/llvm/Support/Mangler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=93300&r1=93299&r2=93300&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Mangler.h (original) +++ llvm/trunk/include/llvm/Support/Mangler.h Wed Jan 13 01:01:09 2010 @@ -102,6 +102,9 @@ /// specified suffix. If 'ForcePrivate' is specified, the label is specified /// to have a private label prefix. /// + /// FIXME: This is deprecated, new code should use getNameWithPrefix and use + /// MCSymbol printing to handle quotes or not etc. + /// std::string getMangledName(const GlobalValue *V, const char *Suffix = "", bool ForcePrivate = false); @@ -112,6 +115,9 @@ /// does this for you, so there's no point calling it on the result /// from getValueName. /// + /// FIXME: This is deprecated, new code should use getNameWithPrefix and use + /// MCSymbol printing to handle quotes or not etc. + /// void makeNameProper(SmallVectorImpl &OutName, const Twine &Name, ManglerPrefixTy PrefixTy = Mangler::Default); @@ -121,6 +127,12 @@ /// have a name, this fills in a unique name for the global. void getNameWithPrefix(SmallVectorImpl &OutName, const GlobalValue *GV, bool isImplicitlyPrivate); + + /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix + /// and the specified name as the global variable name. GVName must not be + /// empty. + void getNameWithPrefix(SmallVectorImpl &OutName, const Twine &GVName, + ManglerPrefixTy PrefixTy = Mangler::Default); }; } // End llvm namespace Modified: llvm/trunk/lib/VMCore/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=93300&r1=93299&r2=93300&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Mangler.cpp (original) +++ llvm/trunk/lib/VMCore/Mangler.cpp Wed Jan 13 01:01:09 2010 @@ -34,6 +34,9 @@ /// makeNameProper - We don't want identifier names non-C-identifier characters /// in them, so mangle them as appropriate. /// +/// FIXME: This is deprecated, new code should use getNameWithPrefix and use +/// MCSymbol printing to handle quotes or not etc. +/// void Mangler::makeNameProper(SmallVectorImpl &OutName, const Twine &TheName, ManglerPrefixTy PrefixTy) { @@ -151,6 +154,9 @@ /// specified suffix. If 'ForcePrivate' is specified, the label is specified /// to have a private label prefix. /// +/// FIXME: This is deprecated, new code should use getNameWithPrefix and use +/// MCSymbol printing to handle quotes or not etc. +/// std::string Mangler::getMangledName(const GlobalValue *GV, const char *Suffix, bool ForcePrivate) { assert((!isa(GV) || !cast(GV)->isIntrinsic()) && @@ -176,6 +182,37 @@ return Result.str().str(); } +/// getNameWithPrefix - Fill OutName with the name of the appropriate prefix +/// and the specified name as the global variable name. GVName must not be +/// empty. +void Mangler::getNameWithPrefix(SmallVectorImpl &OutName, + const Twine &GVName, ManglerPrefixTy PrefixTy) { + SmallString<256> TmpData; + GVName.toVector(TmpData); + StringRef Name = TmpData.str(); + assert(!Name.empty() && "getNameWithPrefix requires non-empty name"); + + // If the global name is not led with \1, add the appropriate prefixes. + if (Name[0] != '\1') { + if (PrefixTy == Mangler::Private) + OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); + else if (PrefixTy == Mangler::LinkerPrivate) + OutName.append(LinkerPrivatePrefix, + LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); + + if (Prefix[0] == 0) + ; // Common noop, no prefix. + else if (Prefix[1] == 0) + OutName.push_back(Prefix[0]); // Common, one character prefix. + else + OutName.append(Prefix, Prefix+strlen(Prefix)); // Arbitrary prefix. + } else { + Name = Name.substr(1); + } + + OutName.append(Name.begin(), Name.end()); +} + /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix /// and the specified global variable's name. If the global variable doesn't @@ -183,33 +220,28 @@ void Mangler::getNameWithPrefix(SmallVectorImpl &OutName, const GlobalValue *GV, bool isImplicitlyPrivate) { - - // If the global is anonymous or not led with \1, then add the appropriate - // prefix. - if (!GV->hasName() || GV->getName()[0] != '\1') { + // If this global has a name, handle it simply. + if (GV->hasName()) { + ManglerPrefixTy PrefixTy = Mangler::Default; if (GV->hasPrivateLinkage() || isImplicitlyPrivate) - OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); + PrefixTy = Mangler::Private; else if (GV->hasLinkerPrivateLinkage()) - OutName.append(LinkerPrivatePrefix, - LinkerPrivatePrefix+strlen(LinkerPrivatePrefix));; - OutName.append(Prefix, Prefix+strlen(Prefix)); - } - - // If the global has a name, just append it now. - if (GV->hasName()) { - StringRef Name = GV->getName(); + PrefixTy = Mangler::LinkerPrivate; - // Strip off the prefix marker if present. - if (Name[0] != '\1') - OutName.append(Name.begin(), Name.end()); - else - OutName.append(Name.begin()+1, Name.end()); - return; + return getNameWithPrefix(OutName, GV->getName(), PrefixTy); } // If the global variable doesn't have a name, return a unique name for the // global based on a numbering. + // Anonymous names always get prefixes. + if (GV->hasPrivateLinkage() || isImplicitlyPrivate) + OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); + else if (GV->hasLinkerPrivateLinkage()) + OutName.append(LinkerPrivatePrefix, + LinkerPrivatePrefix+strlen(LinkerPrivatePrefix));; + OutName.append(Prefix, Prefix+strlen(Prefix)); + // Get the ID for the global, assigning a new one if we haven't got one // already. unsigned &ID = AnonGlobalIDs[GV]; From sabre at nondot.org Wed Jan 13 01:12:07 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 07:12:07 -0000 Subject: [llvm-commits] [llvm] r93301 - in /llvm/trunk: include/llvm/ADT/Twine.h lib/VMCore/Mangler.cpp Message-ID: <201001130712.o0D7C725005990@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 01:12:06 2010 New Revision: 93301 URL: http://llvm.org/viewvc/llvm-project?rev=93301&view=rev Log: add new isSingleStringRef()/getSingleStringRef() methods to twine, and use them to avoid a copy of a string in getNameWithPrefix in the common case. It seems like Value::setName and other places should use this as well? Modified: llvm/trunk/include/llvm/ADT/Twine.h llvm/trunk/lib/VMCore/Mangler.cpp Modified: llvm/trunk/include/llvm/ADT/Twine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Twine.h?rev=93301&r1=93300&r2=93301&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Twine.h (original) +++ llvm/trunk/include/llvm/ADT/Twine.h Wed Jan 13 01:12:06 2010 @@ -329,6 +329,22 @@ bool isTriviallyEmpty() const { return isNullary(); } + + /// isSingleStringRef - Return true if this twine can be dynamically + /// accessed as a single StringRef value with getSingleStringRef(). + bool isSingleStringRef() const { + if (getRHSKind() != EmptyKind) return false; + + switch (getLHSKind()) { + case EmptyKind: + case CStringKind: + case StdStringKind: + case StringRefKind: + return true; + default: + return false; + } + } /// @} /// @name String Operations @@ -347,6 +363,20 @@ /// SmallVector. void toVector(SmallVectorImpl &Out) const; + /// getSingleStringRef - This returns the twine as a single StringRef. This + /// method is only valid if isSingleStringRef() is true. + StringRef getSingleStringRef() const { + assert(isSingleStringRef() &&"This cannot be had as a single stringref!"); + switch (getLHSKind()) { + default: assert(0 && "Out of sync with isSingleStringRef"); + case EmptyKind: return StringRef(); + case CStringKind: return StringRef((const char*)LHS); + case StdStringKind: return StringRef(*(const std::string*)LHS); + case StringRefKind: return *(const StringRef*)LHS; + } + } + + /// print - Write the concatenated string represented by this twine to the /// stream \arg OS. void print(raw_ostream &OS) const; Modified: llvm/trunk/lib/VMCore/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=93301&r1=93300&r2=93301&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Mangler.cpp (original) +++ llvm/trunk/lib/VMCore/Mangler.cpp Wed Jan 13 01:12:06 2010 @@ -188,8 +188,13 @@ void Mangler::getNameWithPrefix(SmallVectorImpl &OutName, const Twine &GVName, ManglerPrefixTy PrefixTy) { SmallString<256> TmpData; - GVName.toVector(TmpData); - StringRef Name = TmpData.str(); + StringRef Name; + if (GVName.isSingleStringRef()) + Name = GVName.getSingleStringRef(); + else { + GVName.toVector(TmpData); + Name = TmpData.str(); + } assert(!Name.empty() && "getNameWithPrefix requires non-empty name"); // If the global name is not led with \1, add the appropriate prefixes. From sabre at nondot.org Wed Jan 13 01:16:53 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 07:16:53 -0000 Subject: [llvm-commits] [llvm] r93302 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <201001130716.o0D7Gr8b006214@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 01:16:53 2010 New Revision: 93302 URL: http://llvm.org/viewvc/llvm-project?rev=93302&view=rev Log: use the new form of getNameWithPrefix, not makeNameProper. Among other things, this would do very weird things if the basic block name had (e.g.) a space in it on darwin: makeNameProper would add quotes, then the mcsymbol would escape the quotes. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93302&r1=93301&r2=93302&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Jan 13 01:16:53 2010 @@ -1682,7 +1682,7 @@ SmallString<60> NameResult; raw_svector_ostream(NameResult) << MAI->getPrivateGlobalPrefix() << "BA" << FuncName.size() << '_' << FuncName << '_'; - Mang->makeNameProper(NameResult, BB->getName()); + Mang->getNameWithPrefix(NameResult, BB->getName()); if (Suffix[0]) NameResult += Suffix; From sabre at nondot.org Wed Jan 13 01:30:50 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 07:30:50 -0000 Subject: [llvm-commits] [llvm] r93303 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/CodeGen/ARM/indirectbr.ll test/CodeGen/PowerPC/indirectbr.ll Message-ID: <201001130730.o0D7UoNg006677@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 01:30:49 2010 New Revision: 93303 URL: http://llvm.org/viewvc/llvm-project?rev=93303&view=rev Log: remove uses of deprecated functions, this generates slightly different BlockAddress labels, but nothing semantically important. Add a FIXME that BlockAddress codegen is broken if the LLVM BB has an empty name (e.g. strip was run). Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/test/CodeGen/ARM/indirectbr.ll llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93303&r1=93302&r2=93303&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Jan 13 01:30:49 2010 @@ -1677,14 +1677,15 @@ // This code must use the function name itself, and not the function number, // since it must be possible to generate the label name from within other // functions. - std::string FuncName = Mang->getMangledName(F); + SmallString<60> FnName; + Mang->getNameWithPrefix(FnName, F, false); + // FIXME: THIS IS BROKEN IF THE LLVM BASIC BLOCK DOESN'T HAVE A NAME! SmallString<60> NameResult; - raw_svector_ostream(NameResult) << MAI->getPrivateGlobalPrefix() << "BA" - << FuncName.size() << '_' << FuncName << '_'; - Mang->getNameWithPrefix(NameResult, BB->getName()); - if (Suffix[0]) - NameResult += Suffix; + Mang->getNameWithPrefix(NameResult, + StringRef("BA") + Twine((unsigned)FnName.size()) + + "_" + FnName.str() + "_" + BB->getName() + Suffix, + Mangler::Private); return OutContext.GetOrCreateSymbol(NameResult.str()); } Modified: llvm/trunk/test/CodeGen/ARM/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/indirectbr.ll?rev=93303&r1=93302&r2=93303&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/indirectbr.ll (original) +++ llvm/trunk/test/CodeGen/ARM/indirectbr.ll Wed Jan 13 01:30:49 2010 @@ -55,6 +55,6 @@ store i8* blockaddress(@foo, %L5), i8** @nextaddr, align 4 ret i32 %res.3 } -; ARM: .long LBA4__foo__L5-(LPC{{.*}}+8) -; THUMB: .long LBA4__foo__L5-(LPC{{.*}}+4) -; THUMB2: .long LBA4__foo__L5 +; ARM: .long L_BA4__foo_L5-(LPC{{.*}}+8) +; THUMB: .long L_BA4__foo_L5-(LPC{{.*}}+4) +; THUMB2: .long L_BA4__foo_L5 Modified: llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll?rev=93303&r1=93302&r2=93303&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll Wed Jan 13 01:30:49 2010 @@ -43,12 +43,12 @@ L1: ; preds = %L2, %bb2 %res.3 = phi i32 [ %phitmp, %L2 ], [ 2, %bb2 ] ; [#uses=1] -; PIC: addis r4, r2, ha16(LBA4__foo__L5-"L1$pb") -; PIC: li r5, lo16(LBA4__foo__L5-"L1$pb") +; PIC: addis r4, r2, ha16(L_BA4__foo_L5-"L1$pb") +; PIC: li r5, lo16(L_BA4__foo_L5-"L1$pb") ; PIC: add r4, r4, r5 ; PIC: stw r4 -; STATIC: li r2, lo16(LBA4__foo__L5) -; STATIC: addis r2, r2, ha16(LBA4__foo__L5) +; STATIC: li r2, lo16(L_BA4__foo_L5) +; STATIC: addis r2, r2, ha16(L_BA4__foo_L5) ; STATIC: stw r2 store i8* blockaddress(@foo, %L5), i8** @nextaddr, align 4 ret i32 %res.3 From sabre at nondot.org Wed Jan 13 01:50:21 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 07:50:21 -0000 Subject: [llvm-commits] [llvm] r93304 - /llvm/trunk/lib/VMCore/Mangler.cpp Message-ID: <201001130750.o0D7oLNu007394@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 01:50:21 2010 New Revision: 93304 URL: http://llvm.org/viewvc/llvm-project?rev=93304&view=rev Log: don't add the \1 to the name. Modified: llvm/trunk/lib/VMCore/Mangler.cpp Modified: llvm/trunk/lib/VMCore/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=93304&r1=93303&r2=93304&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Mangler.cpp (original) +++ llvm/trunk/lib/VMCore/Mangler.cpp Wed Jan 13 01:50:21 2010 @@ -131,7 +131,7 @@ } // Add the piece that we already scanned through. - OutName.append(X.begin(), I); + OutName.append(X.begin()+!NeedPrefix, I); // Otherwise, construct the string the expensive way. for (StringRef::iterator E = X.end(); I != E; ++I) { From sabre at nondot.org Wed Jan 13 01:57:00 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 07:57:00 -0000 Subject: [llvm-commits] [llvm] r93305 - in /llvm/trunk/lib/Target: PowerPC/AsmPrinter/PPCAsmPrinter.cpp TargetLoweringObjectFile.cpp X86/AsmPrinter/X86AsmPrinter.cpp Message-ID: <201001130757.o0D7v0mt007608@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 01:56:59 2010 New Revision: 93305 URL: http://llvm.org/viewvc/llvm-project?rev=93305&view=rev Log: eliminate some uses of Mangler::makeNameProper. Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=93305&r1=93304&r2=93305&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Wed Jan 13 01:56:59 2010 @@ -71,18 +71,19 @@ } void Init(StringRef GVName, Mangler *Mang) { - // Already initialized. - if (!Stub.empty()) return; + assert(!GVName.empty()); + if (!Stub.empty()) return; // Already initialized. + // Get the names for the external symbol name. SmallString<128> TmpStr; - Mang->makeNameProper(TmpStr, GVName + "$stub", Mangler::Private); + Mang->getNameWithPrefix(TmpStr, GVName + "$stub", Mangler::Private); Stub = TmpStr.str(); TmpStr.clear(); - Mang->makeNameProper(TmpStr, GVName + "$lazy_ptr", Mangler::Private); + Mang->getNameWithPrefix(TmpStr, GVName + "$lazy_ptr", Mangler::Private); LazyPtr = TmpStr.str(); TmpStr.clear(); - Mang->makeNameProper(TmpStr, GVName + "$stub$tmp", Mangler::Private); + Mang->getNameWithPrefix(TmpStr, GVName + "$stub$tmp", Mangler::Private); AnonSymbol = TmpStr.str(); } }; @@ -237,7 +238,7 @@ } if (MO.getType() == MachineOperand::MO_ExternalSymbol) { SmallString<128> MangledName; - Mang->makeNameProper(MangledName, MO.getSymbolName()); + Mang->getNameWithPrefix(MangledName, MO.getSymbolName()); FnStubInfo &FnInfo = FnStubs[MangledName.str()]; FnInfo.Init(MO.getSymbolName(), Mang); O << FnInfo.Stub; Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=93305&r1=93304&r2=93305&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Wed Jan 13 01:56:59 2010 @@ -1080,7 +1080,7 @@ if (GV->isWeakForLinker()) { const char *Prefix = getCOFFSectionPrefixForUniqueGlobal(Kind); SmallString<128> Name(Prefix, Prefix+strlen(Prefix)); - Mang->makeNameProper(Name, GV->getNameStr()); + Mang->getNameWithPrefix(Name, GV->getName()); return getCOFFSection(Name.str(), false, Kind); } Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=93305&r1=93304&r2=93305&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Wed Jan 13 01:56:59 2010 @@ -283,24 +283,32 @@ break; } case MachineOperand::MO_ExternalSymbol: { - Mang->makeNameProper(TempNameStr, MO.getSymbolName()); + const MCSymbol *SymToPrint; if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) { - TempNameStr += "$stub"; - MCSymbol *Sym = OutContext.GetOrCreateSymbol(TempNameStr.str()); + Mang->getNameWithPrefix(TempNameStr, + StringRef(MO.getSymbolName())+"$stub"); + const MCSymbol *Sym = OutContext.GetOrCreateSymbol(TempNameStr.str()); const MCSymbol *&StubSym = MMI->getObjFileInfo().getFnStubEntry(Sym); if (StubSym == 0) { TempNameStr.erase(TempNameStr.end()-5, TempNameStr.end()); StubSym = OutContext.GetOrCreateSymbol(TempNameStr.str()); } + SymToPrint = StubSym; + } else { + Mang->getNameWithPrefix(TempNameStr, MO.getSymbolName()); + SymToPrint = OutContext.GetOrCreateSymbol(TempNameStr.str()); } // If the name begins with a dollar-sign, enclose it in parens. We do this // to avoid having it look like an integer immediate to the assembler. - if (TempNameStr[0] == '$') - O << '(' << TempNameStr << ')'; - else - O << TempNameStr; + if (SymToPrint->getName()[0] != '$') + SymToPrint->print(O, MAI); + else { + O << '('; + SymToPrint->print(O, MAI); + O << '('; + } break; } } From evan.cheng at apple.com Wed Jan 13 01:59:14 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 13 Jan 2010 07:59:14 -0000 Subject: [llvm-commits] [llvm] r93306 - /llvm/trunk/lib/CodeGen/OptimizeExts.cpp Message-ID: <201001130759.o0D7xEeS007690@zion.cs.uiuc.edu> Author: evancheng Date: Wed Jan 13 01:59:13 2010 New Revision: 93306 URL: http://llvm.org/viewvc/llvm-project?rev=93306&view=rev Log: Add comment; refactor; avoid pulling in DT if it's not used. Modified: llvm/trunk/lib/CodeGen/OptimizeExts.cpp Modified: llvm/trunk/lib/CodeGen/OptimizeExts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/OptimizeExts.cpp?rev=93306&r1=93305&r2=93306&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/OptimizeExts.cpp (original) +++ llvm/trunk/lib/CodeGen/OptimizeExts.cpp Wed Jan 13 01:59:13 2010 @@ -6,6 +6,16 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// +// This pass performs optimization of sign / zero extension instructions. It +// may be extended to handle other instructions of similar property. +// +// On some targets, some instructions, e.g. X86 sign / zero extension, may +// leave the source value in the lower part of the result. This pass will +// replace (some) uses of the pre-extension value with uses of the sub-register +// of the results. +// +//===----------------------------------------------------------------------===// #define DEBUG_TYPE "ext-opt" #include "llvm/CodeGen/Passes.h" @@ -40,9 +50,15 @@ virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); MachineFunctionPass::getAnalysisUsage(AU); - AU.addRequired(); - AU.addPreserved(); + if (Aggressive) { + AU.addRequired(); + AU.addPreserved(); + } } + + private: + bool OptimizeInstr(MachineInstr *MI, MachineBasicBlock *MBB, + SmallPtrSet &LocalMIs); }; } @@ -52,96 +68,111 @@ FunctionPass *llvm::createOptimizeExtsPass() { return new OptimizeExts(); } +/// OptimizeInstr - If instruction is a copy-like instruction, i.e. it reads +/// a single register and writes a single register and it does not modify +/// the source, and if the source value is preserved as a sub-register of +/// the result, then replace all reachable uses of the source with the subreg +/// of the result. +bool OptimizeExts::OptimizeInstr(MachineInstr *MI, MachineBasicBlock *MBB, + SmallPtrSet &LocalMIs) { + bool Changed = false; + LocalMIs.insert(MI); + + unsigned SrcReg, DstReg, SubIdx; + if (TII->isCoalescableExtInstr(*MI, SrcReg, DstReg, SubIdx)) { + if (TargetRegisterInfo::isPhysicalRegister(DstReg) || + TargetRegisterInfo::isPhysicalRegister(SrcReg)) + return false; + + MachineRegisterInfo::use_iterator UI = MRI->use_begin(SrcReg); + if (++UI == MRI->use_end()) + // No other uses. + return false; + + // Ok, the source has other uses. See if we can replace the other uses + // with use of the result of the extension. + SmallPtrSet ReachedBBs; + UI = MRI->use_begin(DstReg); + for (MachineRegisterInfo::use_iterator UE = MRI->use_end(); UI != UE; + ++UI) + ReachedBBs.insert(UI->getParent()); + + bool ExtendLife = true; + // Uses that are in the same BB of uses of the result of the instruction. + SmallVector Uses; + // Uses that the result of the instruction can reach. + SmallVector ExtendedUses; + + UI = MRI->use_begin(SrcReg); + for (MachineRegisterInfo::use_iterator UE = MRI->use_end(); UI != UE; + ++UI) { + MachineOperand &UseMO = UI.getOperand(); + MachineInstr *UseMI = &*UI; + if (UseMI == MI) + continue; + MachineBasicBlock *UseMBB = UseMI->getParent(); + if (UseMBB == MBB) { + // Local uses that come after the extension. + if (!LocalMIs.count(UseMI)) + Uses.push_back(&UseMO); + } else if (ReachedBBs.count(UseMBB)) + // Non-local uses where the result of extension is used. Always + // replace these. + Uses.push_back(&UseMO); + else if (Aggressive && DT->dominates(MBB, UseMBB)) + // We may want to extend live range of the extension result in order + // to replace these uses. + ExtendedUses.push_back(&UseMO); + else { + // Both will be live out of the def MBB anyway. Don't extend live + // range of the extension result. + ExtendLife = false; + break; + } + } + + if (ExtendLife && !ExtendedUses.empty()) + // Ok, we'll extend the liveness of the extension result. + std::copy(ExtendedUses.begin(), ExtendedUses.end(), + std::back_inserter(Uses)); + + // Now replace all uses. + if (!Uses.empty()) { + const TargetRegisterClass *RC = MRI->getRegClass(SrcReg); + for (unsigned i = 0, e = Uses.size(); i != e; ++i) { + MachineOperand *UseMO = Uses[i]; + MachineInstr *UseMI = UseMO->getParent(); + MachineBasicBlock *UseMBB = UseMI->getParent(); + unsigned NewVR = MRI->createVirtualRegister(RC); + BuildMI(*UseMBB, UseMI, UseMI->getDebugLoc(), + TII->get(TargetInstrInfo::EXTRACT_SUBREG), NewVR) + .addReg(DstReg).addImm(SubIdx); + UseMO->setReg(NewVR); + ++NumReuse; + Changed = true; + } + } + } + + return Changed; +} + bool OptimizeExts::runOnMachineFunction(MachineFunction &MF) { TM = &MF.getTarget(); TII = TM->getInstrInfo(); MRI = &MF.getRegInfo(); - DT = &getAnalysis(); + DT = Aggressive ? &getAnalysis() : 0; bool Changed = false; SmallPtrSet LocalMIs; for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { MachineBasicBlock *MBB = &*I; + LocalMIs.clear(); for (MachineBasicBlock::iterator MII = I->begin(), ME = I->end(); MII != ME; ++MII) { MachineInstr *MI = &*MII; - LocalMIs.insert(MI); - - unsigned SrcReg, DstReg, SubIdx; - if (TII->isCoalescableExtInstr(*MI, SrcReg, DstReg, SubIdx)) { - if (TargetRegisterInfo::isPhysicalRegister(DstReg) || - TargetRegisterInfo::isPhysicalRegister(SrcReg)) - continue; - - MachineRegisterInfo::use_iterator UI = MRI->use_begin(SrcReg); - if (++UI == MRI->use_end()) - // No other uses. - continue; - - // Ok, the source has other uses. See if we can replace the other uses - // with use of the result of the extension. - - SmallPtrSet ReachedBBs; - UI = MRI->use_begin(DstReg); - for (MachineRegisterInfo::use_iterator UE = MRI->use_end(); UI != UE; - ++UI) - ReachedBBs.insert(UI->getParent()); - - bool ExtendLife = true; - SmallVector Uses; - SmallVector ExtendedUses; - - UI = MRI->use_begin(SrcReg); - for (MachineRegisterInfo::use_iterator UE = MRI->use_end(); UI != UE; - ++UI) { - MachineOperand &UseMO = UI.getOperand(); - MachineInstr *UseMI = &*UI; - if (UseMI == MI) - continue; - MachineBasicBlock *UseMBB = UseMI->getParent(); - if (UseMBB == MBB) { - // Local uses that come after the extension. - if (!LocalMIs.count(UseMI)) - Uses.push_back(&UseMO); - } else if (ReachedBBs.count(UseMBB)) - // Non-local uses where the result of extension is used. Always - // replace these. - Uses.push_back(&UseMO); - else if (Aggressive && DT->dominates(MBB, UseMBB)) - // We may want to extend live range of the extension result in order - // to replace these uses. - ExtendedUses.push_back(&UseMO); - else { - // Both will be live out of the def MBB anyway. Don't extend live - // range of the extension result. - ExtendLife = false; - break; - } - } - - if (ExtendLife && !ExtendedUses.empty()) - // Ok, we'll extend the liveness of the extension result. - std::copy(ExtendedUses.begin(), ExtendedUses.end(), - std::back_inserter(Uses)); - - // Now replace all uses. - if (!Uses.empty()) { - const TargetRegisterClass *RC = MRI->getRegClass(SrcReg); - for (unsigned i = 0, e = Uses.size(); i != e; ++i) { - MachineOperand *UseMO = Uses[i]; - MachineInstr *UseMI = UseMO->getParent(); - MachineBasicBlock *UseMBB = UseMI->getParent(); - unsigned NewVR = MRI->createVirtualRegister(RC); - BuildMI(*UseMBB, UseMI, UseMI->getDebugLoc(), - TII->get(TargetInstrInfo::EXTRACT_SUBREG), NewVR) - .addReg(DstReg).addImm(SubIdx); - UseMO->setReg(NewVR); - ++NumReuse; - Changed = true; - } - } - } + Changed |= OptimizeInstr(MI, MBB, LocalMIs); } } From evan.cheng at apple.com Wed Jan 13 02:01:33 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 13 Jan 2010 08:01:33 -0000 Subject: [llvm-commits] [llvm] r93307 - /llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Message-ID: <201001130801.o0D81XlO007801@zion.cs.uiuc.edu> Author: evancheng Date: Wed Jan 13 02:01:32 2010 New Revision: 93307 URL: http://llvm.org/viewvc/llvm-project?rev=93307&view=rev Log: For now, avoid issuing extract_subreg to reuse lower 8-bit, it's not safe in 32-bit. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=93307&r1=93306&r2=93307&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Wed Jan 13 02:01:32 2010 @@ -724,6 +724,10 @@ case X86::MOVZX32rr8: case X86::MOVSX64rr8: case X86::MOVZX64rr8: + if (!TM.getSubtarget().is64Bit()) + // It's not always legal to reference the low 8-bit of the larger + // register in 32-bit mode. + return false; case X86::MOVSX32rr16: case X86::MOVZX32rr16: case X86::MOVSX64rr16: From sabre at nondot.org Wed Jan 13 02:02:14 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 08:02:14 -0000 Subject: [llvm-commits] [llvm] r93308 - /llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Message-ID: <201001130802.o0D82FhE007849@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 02:02:14 2010 New Revision: 93308 URL: http://llvm.org/viewvc/llvm-project?rev=93308&view=rev Log: add a fixme, ELF MCSection isn't quite right and weak unnamed globals are broken on linux (even though they are pointless, they shouldn't ICE). Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=93308&r1=93307&r2=93308&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Wed Jan 13 02:02:14 2010 @@ -578,6 +578,10 @@ const char *Prefix = getSectionPrefixForUniqueGlobal(Kind); SmallString<128> Name; Name.append(Prefix, Prefix+strlen(Prefix)); + // FIXME: This will fail for weak globals with no names, this also depends + // on the mangling behavior of makeNameProper to mangle the section name + // before construction. Instead, this should use getNameWithPrefix on the + // global variable and the MCSection printing code should do the mangling. Mang->makeNameProper(Name, GV->getName()); return getELFSection(Name.str(), From sabre at nondot.org Wed Jan 13 02:04:25 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 08:04:25 -0000 Subject: [llvm-commits] [llvm] r93309 - /llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp Message-ID: <201001130804.o0D84Pqt007928@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 02:04:24 2010 New Revision: 93309 URL: http://llvm.org/viewvc/llvm-project?rev=93309&view=rev Log: MC'ize this a bit and upgrade APIs Modified: llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp Modified: llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp?rev=93309&r1=93308&r2=93309&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp Wed Jan 13 02:04:24 2010 @@ -25,6 +25,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCContext.h" #include "llvm/MC/MCSymbol.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetLoweringObjectFile.h" @@ -182,8 +183,8 @@ break; case MachineOperand::MO_ExternalSymbol: { SmallString<60> NameStr; - Mang->makeNameProper(NameStr, MO.getSymbolName()); - O << NameStr.str(); + Mang->getNameWithPrefix(NameStr, MO.getSymbolName()); + OutContext.GetOrCreateSymbol(NameStr.str())->print(O, MAI); break; } case MachineOperand::MO_ConstantPoolIndex: From sabre at nondot.org Wed Jan 13 02:08:33 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 08:08:33 -0000 Subject: [llvm-commits] [llvm] r93310 - /llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Message-ID: <201001130808.o0D88Xnd008071@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 02:08:33 2010 New Revision: 93310 URL: http://llvm.org/viewvc/llvm-project?rev=93310&view=rev Log: upgrade and MC'ize a few uses of makeNameProper. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=93310&r1=93309&r2=93310&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Wed Jan 13 02:08:33 2010 @@ -208,8 +208,8 @@ O << Name; } else { assert(ACPV->isExtSymbol() && "unrecognized constant pool value"); - Mang->makeNameProper(TmpNameStr, ACPV->getSymbol()); - O << TmpNameStr.str(); + Mang->getNameWithPrefix(TmpNameStr, ACPV->getSymbol()); + OutContext.GetOrCreateSymbol(TmpNameStr.str())->print(O, MAI); } if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")"; @@ -393,9 +393,9 @@ case MachineOperand::MO_ExternalSymbol: { bool isCallOp = Modifier && !strcmp(Modifier, "call"); SmallString<128> NameStr; - Mang->makeNameProper(NameStr, MO.getSymbolName()); - - O << NameStr.str(); + Mang->getNameWithPrefix(NameStr, MO.getSymbolName()); + OutContext.GetOrCreateSymbol(NameStr.str())->print(O, MAI); + if (isCallOp && Subtarget->isTargetELF() && TM.getRelocationModel() == Reloc::PIC_) O << "(PLT)"; From evan.cheng at apple.com Wed Jan 13 02:45:41 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 13 Jan 2010 08:45:41 -0000 Subject: [llvm-commits] [llvm] r93313 - in /llvm/trunk: lib/CodeGen/LLVMTargetMachine.cpp test/CodeGen/X86/sext-subreg.ll test/CodeGen/X86/stack-color-with-reg.ll Message-ID: <201001130845.o0D8jgAG010488@zion.cs.uiuc.edu> Author: evancheng Date: Wed Jan 13 02:45:40 2010 New Revision: 93313 URL: http://llvm.org/viewvc/llvm-project?rev=93313&view=rev Log: Re-enable extension optimization pass. Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp llvm/trunk/test/CodeGen/X86/sext-subreg.ll llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=93313&r1=93312&r2=93313&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Wed Jan 13 02:45:40 2010 @@ -325,6 +325,7 @@ /* allowDoubleDefs= */ true); if (OptLevel != CodeGenOpt::None) { + PM.add(createOptimizeExtsPass()); if (!DisableMachineLICM) PM.add(createMachineLICMPass()); if (!DisableMachineSink) Modified: llvm/trunk/test/CodeGen/X86/sext-subreg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sext-subreg.ll?rev=93313&r1=93312&r2=93313&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/sext-subreg.ll (original) +++ llvm/trunk/test/CodeGen/X86/sext-subreg.ll Wed Jan 13 02:45:40 2010 @@ -1,6 +1,5 @@ ; RUN: llc < %s -march=x86-64 | FileCheck %s ; rdar://7529457 -; XFAIL: * define i64 @t(i64 %A, i64 %B, i32* %P, i64 *%P2) nounwind { ; CHECK: t: Modified: llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll?rev=93313&r1=93312&r2=93313&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll (original) +++ llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll Wed Jan 13 02:45:40 2010 @@ -1,5 +1,5 @@ ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -relocation-model=pic -disable-fp-elim -color-ss-with-regs -stats -info-output-file - > %t -; RUN: grep stackcoloring %t | grep "stack slot refs replaced with reg refs" | grep 6 +; RUN: grep stackcoloring %t | grep "stack slot refs replaced with reg refs" | grep 9 type { [62 x %struct.Bitvec*] } ; type %0 type { i8* } ; type %1 From benny.kra at googlemail.com Wed Jan 13 06:45:24 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Wed, 13 Jan 2010 12:45:24 -0000 Subject: [llvm-commits] [llvm] r93317 - in /llvm/trunk: include/llvm/ADT/Twine.h lib/Support/Twine.cpp lib/VMCore/Mangler.cpp lib/VMCore/Metadata.cpp lib/VMCore/Value.cpp Message-ID: <201001131245.o0DCjPbv001185@zion.cs.uiuc.edu> Author: d0k Date: Wed Jan 13 06:45:23 2010 New Revision: 93317 URL: http://llvm.org/viewvc/llvm-project?rev=93317&view=rev Log: Introduce Twine::toStringRef, a variant of toVector which avoids the copy if the twine can be represented as a single StringRef. Use the new methode to simplify some twine users. Modified: llvm/trunk/include/llvm/ADT/Twine.h llvm/trunk/lib/Support/Twine.cpp llvm/trunk/lib/VMCore/Mangler.cpp llvm/trunk/lib/VMCore/Metadata.cpp llvm/trunk/lib/VMCore/Value.cpp Modified: llvm/trunk/include/llvm/ADT/Twine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Twine.h?rev=93317&r1=93316&r2=93317&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Twine.h (original) +++ llvm/trunk/include/llvm/ADT/Twine.h Wed Jan 13 06:45:23 2010 @@ -375,8 +375,12 @@ case StringRefKind: return *(const StringRef*)LHS; } } - - + + /// toStringRef - This returns the twine as a single StringRef if it can be + /// represented as such. Otherwise the twine is written into the given + /// SmallVector and a StringRef to the SmallVector's data is returned. + StringRef toStringRef(SmallVectorImpl &Out) const; + /// print - Write the concatenated string represented by this twine to the /// stream \arg OS. void print(raw_ostream &OS) const; Modified: llvm/trunk/lib/Support/Twine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Twine.cpp?rev=93317&r1=93316&r2=93317&view=diff ============================================================================== --- llvm/trunk/lib/Support/Twine.cpp (original) +++ llvm/trunk/lib/Support/Twine.cpp Wed Jan 13 06:45:23 2010 @@ -15,8 +15,7 @@ std::string Twine::str() const { SmallString<256> Vec; - toVector(Vec); - return std::string(Vec.begin(), Vec.end()); + return toStringRef(Vec).str(); } void Twine::toVector(SmallVectorImpl &Out) const { @@ -24,6 +23,13 @@ print(OS); } +StringRef Twine::toStringRef(SmallVectorImpl &Out) const { + if (isSingleStringRef()) + return getSingleStringRef(); + toVector(Out); + return StringRef(Out.data(), Out.size()); +} + void Twine::printOneChild(raw_ostream &OS, const void *Ptr, NodeKind Kind) const { switch (Kind) { Modified: llvm/trunk/lib/VMCore/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=93317&r1=93316&r2=93317&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Mangler.cpp (original) +++ llvm/trunk/lib/VMCore/Mangler.cpp Wed Jan 13 06:45:23 2010 @@ -41,8 +41,7 @@ const Twine &TheName, ManglerPrefixTy PrefixTy) { SmallString<256> TmpData; - TheName.toVector(TmpData); - StringRef X = TmpData.str(); + StringRef X = TheName.toStringRef(TmpData); assert(!X.empty() && "Cannot mangle empty strings"); if (!UseQuotes) { @@ -188,13 +187,7 @@ void Mangler::getNameWithPrefix(SmallVectorImpl &OutName, const Twine &GVName, ManglerPrefixTy PrefixTy) { SmallString<256> TmpData; - StringRef Name; - if (GVName.isSingleStringRef()) - Name = GVName.getSingleStringRef(); - else { - GVName.toVector(TmpData); - Name = TmpData.str(); - } + StringRef Name = GVName.toStringRef(TmpData); assert(!Name.empty() && "getNameWithPrefix requires non-empty name"); // If the global name is not led with \1, add the appropriate prefixes. Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=93317&r1=93316&r2=93317&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Wed Jan 13 06:45:23 2010 @@ -327,12 +327,8 @@ assert (!NewName.isTriviallyEmpty() && "Invalid named metadata name!"); SmallString<256> NameData; - NewName.toVector(NameData); + StringRef NameRef = NewName.toStringRef(NameData); - const char *NameStr = NameData.data(); - unsigned NameLen = NameData.size(); - - StringRef NameRef = StringRef(NameStr, NameLen); // Name isn't changing? if (getName() == NameRef) return; Modified: llvm/trunk/lib/VMCore/Value.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=93317&r1=93316&r2=93317&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Value.cpp (original) +++ llvm/trunk/lib/VMCore/Value.cpp Wed Jan 13 06:45:23 2010 @@ -170,13 +170,10 @@ return; SmallString<256> NameData; - NewName.toVector(NameData); - - const char *NameStr = NameData.data(); - unsigned NameLen = NameData.size(); + StringRef NameRef = NewName.toStringRef(NameData); // Name isn't changing? - if (getName() == StringRef(NameStr, NameLen)) + if (getName() == NameRef) return; assert(!getType()->isVoidTy() && "Cannot assign a name to void values!"); @@ -187,7 +184,7 @@ return; // Cannot set a name on this value (e.g. constant). if (!ST) { // No symbol table to update? Just do the change. - if (NameLen == 0) { + if (NameRef.empty()) { // Free the name for this value. Name->Destroy(); Name = 0; @@ -201,7 +198,7 @@ // then reallocated. // Create the new name. - Name = ValueName::Create(NameStr, NameStr+NameLen); + Name = ValueName::Create(NameRef.begin(), NameRef.end()); Name->setValue(this); return; } @@ -214,12 +211,12 @@ Name->Destroy(); Name = 0; - if (NameLen == 0) + if (NameRef.empty()) return; } // Name is changing to something new. - Name = ST->createValueName(StringRef(NameStr, NameLen), this); + Name = ST->createValueName(NameRef, this); } From daniel at zuster.org Wed Jan 13 10:12:50 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 13 Jan 2010 16:12:50 -0000 Subject: [llvm-commits] [compiler-rt] r93318 - in /compiler-rt/trunk: CMakeLists.txt ConfigureChecks.cmake cmake/ConfigureChecks.cmake cmake/config.h.cmake config.h.cmake Message-ID: <201001131612.o0DGCp3H008871@zion.cs.uiuc.edu> Author: ddunbar Date: Wed Jan 13 10:12:49 2010 New Revision: 93318 URL: http://llvm.org/viewvc/llvm-project?rev=93318&view=rev Log: Sink {config.h,ConfigureChecks}.cmake into cmake directory. Added: compiler-rt/trunk/cmake/ConfigureChecks.cmake - copied, changed from r86542, compiler-rt/trunk/ConfigureChecks.cmake compiler-rt/trunk/cmake/config.h.cmake - copied, changed from r86542, compiler-rt/trunk/config.h.cmake Removed: compiler-rt/trunk/ConfigureChecks.cmake compiler-rt/trunk/config.h.cmake Modified: compiler-rt/trunk/CMakeLists.txt Modified: compiler-rt/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=93318&r1=93317&r2=93318&view=diff ============================================================================== --- compiler-rt/trunk/CMakeLists.txt (original) +++ compiler-rt/trunk/CMakeLists.txt Wed Jan 13 10:12:49 2010 @@ -19,8 +19,9 @@ "${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." ) -INCLUDE( ConfigureChecks.cmake ) -CONFIGURE_FILE( config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ) +INCLUDE( ${CMAKE_SOURCE_DIR}/cmake/ConfigureChecks.cmake ) +CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/cmake/config.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/config.h ) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} @@ -46,7 +47,7 @@ ELSE( BUILD_BLOCKS_RUNTIME ) MESSAGE(STATUS "No suitable atomic operation routines detected, skipping Blocks Runtime") ENDIF( BUILD_BLOCKS_RUNTIME ) - + ADD_SUBDIRECTORY( lib ) # Enable Test Suit: Removed: compiler-rt/trunk/ConfigureChecks.cmake URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/ConfigureChecks.cmake?rev=93317&view=auto ============================================================================== --- compiler-rt/trunk/ConfigureChecks.cmake (original) +++ compiler-rt/trunk/ConfigureChecks.cmake (removed) @@ -1,38 +0,0 @@ -INCLUDE( CheckIncludeFile ) -INCLUDE( CheckFunctionExists ) -INCLUDE( CheckSymbolExists ) -INCLUDE( CheckCSourceCompiles ) - -SET( PACKAGE ${PACKAGE_NAME} ) -SET( VERSION ${PACKAGE_VERSION} ) - -SET( BINARYDIR ${CMAKE_BINARY_DIR} ) -SET( SOURCEDIR ${CMAKE_SOURCE_DIR} ) - -# HEADER FILES -CHECK_INCLUDE_FILE( sys/byteorder.h HAVE_SYS_BYTEORDER_H ) -CHECK_INCLUDE_FILE( AvailabilityMacros.h HAVE_AVAILABILITY_MACROS_H ) -CHECK_INCLUDE_FILE( TargetConditionals.h HAVE_TARGET_CONDITIONALS_H ) -CHECK_INCLUDE_FILE( libkern/OSAtomic.h HAVE_LIBKERN_OSATOMIC_H ) - -# FUNCTIONS -CHECK_FUNCTION_EXISTS( sysconf HAVE_SYSCONF ) -CHECK_SYMBOL_EXISTS( OSAtomicCompareAndSwapInt libkern/OSAtomic.h HAVE_OSATOMIC_COMPARE_AND_SWAP_INT ) -CHECK_SYMBOL_EXISTS( OSAtomicCompareAndSwapLong libkern/OSAtomic.h HAVE_OSATOMIC_COMPARE_AND_SWAP_LONG ) - -# BUILTIN -CHECK_C_SOURCE_COMPILES( " -volatile int a; -int main(int argc, char *argv[]) { - (void)__sync_bool_compare_and_swap(&a, 1, 2); - return 0; -} -" HAVE_SYNC_BOOL_COMPARE_AND_SWAP_INT ) - -CHECK_C_SOURCE_COMPILES( " -volatile long a; -int main(int argc, char *argv[]) { - (void)__sync_bool_compare_and_swap(&a, 1, 2); - return 0; -} -" HAVE_SYNC_BOOL_COMPARE_AND_SWAP_LONG ) Copied: compiler-rt/trunk/cmake/ConfigureChecks.cmake (from r86542, compiler-rt/trunk/ConfigureChecks.cmake) URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/ConfigureChecks.cmake?p2=compiler-rt/trunk/cmake/ConfigureChecks.cmake&p1=compiler-rt/trunk/ConfigureChecks.cmake&r1=86542&r2=93318&rev=93318&view=diff ============================================================================== (empty) Copied: compiler-rt/trunk/cmake/config.h.cmake (from r86542, compiler-rt/trunk/config.h.cmake) URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config.h.cmake?p2=compiler-rt/trunk/cmake/config.h.cmake&p1=compiler-rt/trunk/config.h.cmake&r1=86542&r2=93318&rev=93318&view=diff ============================================================================== (empty) Removed: compiler-rt/trunk/config.h.cmake URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/config.h.cmake?rev=93317&view=auto ============================================================================== --- compiler-rt/trunk/config.h.cmake (original) +++ compiler-rt/trunk/config.h.cmake (removed) @@ -1,12 +0,0 @@ -#cmakedefine HAVE_SYS_BYTEORDER_H ${HAVE_SYS_BYTEORDER} -#cmakedefine HAVE_AVAILABILITY_MACROS_H ${HAVE_AVAILABILITY_MACROS_H} -#cmakedefine HAVE_TARGET_CONDITIONALS_H ${HAVE_TARGET_CONDITIONALS_H} -#cmakedefine HAVE_LIBKERN_OSATOMIC_H ${HAVE_LIBKERN_OSATOMIC_H} - -#cmakedefine HAVE_SYSCONF ${HAVE_SYSCONF} - -#cmakedefine HAVE_OSATOMIC_COMPARE_AND_SWAP_INT ${HAVE_OSATOMIC_COMPARE_AND_SWAP_INT} -#cmakedefine HAVE_OSATOMIC_COMPARE_AND_SWAP_LONG ${HAVE_OSATOMIC_COMPARE_AND_SWAP_LONG} - -#cmakedefine HAVE_SYNC_BOOL_COMPARE_AND_SWAP_INT ${HAVE_SYNC_BOOL_COMPARE_AND_SWAP_INT} -#cmakedefine HAVE_SYNC_BOOL_COMPARE_AND_SWAP_LONG ${HAVE_SYNC_BOOL_COMPARE_AND_SWAP_LONG} From daniel at zuster.org Wed Jan 13 10:13:01 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 13 Jan 2010 16:13:01 -0000 Subject: [llvm-commits] [compiler-rt] r93319 - in /compiler-rt/trunk: Makefile make/AppleBI.mk make/config.mk make/subdir.mk make/util.mk Message-ID: <201001131613.o0DGD1Qs008892@zion.cs.uiuc.edu> Author: ddunbar Date: Wed Jan 13 10:13:01 2010 New Revision: 93319 URL: http://llvm.org/viewvc/llvm-project?rev=93319&view=rev Log: Tidy up comments, remove whitespace, and rename 'print-%' make debugging target to 'make-print-%' to match LLVM. Modified: compiler-rt/trunk/Makefile compiler-rt/trunk/make/AppleBI.mk compiler-rt/trunk/make/config.mk compiler-rt/trunk/make/subdir.mk compiler-rt/trunk/make/util.mk Modified: compiler-rt/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/Makefile?rev=93319&r1=93318&r2=93319&view=diff ============================================================================== --- compiler-rt/trunk/Makefile (original) +++ compiler-rt/trunk/Makefile Wed Jan 13 10:13:01 2010 @@ -5,9 +5,8 @@ include make/config.mk include make/util.mk -# If SRCROOT is defined, assume we are doing an Apple style build. We -# should be able to use RC_XBS for this but that is unused during -# "make installsrc". +# If SRCROOT is defined, assume we are doing an Apple style build. We should be +# able to use RC_XBS for this but that is unused during "make installsrc". ifdef SRCROOT include make/AppleBI.mk endif @@ -75,7 +74,7 @@ endef # Template: CNA_template Config Arch -# +# # This template is used once per Config/Arch at the top-level. define CNA_template $(call Set,ActiveConfig,$1) @@ -84,10 +83,9 @@ $(call Set,ActiveLibGen,$(ActiveObjPath)/libcompiler_rt.Generic.a) $(call Set,ActiveLibOpt,$(ActiveObjPath)/libcompiler_rt.Optimized.a) -# Initialize inputs lists. This are extended by the CNA_subdir -# template. The one tricky bit is that we need to use these quoted, -# because they are not complete until the entire makefile has been -# processed. +# Initialize inputs lists. This are extended by the CNA_subdir template. The one +# tricky bit is that we need to use these quoted, because they are not complete +# until the entire makefile has been processed. $(call Set,GenericInputs.$(ActiveConfig).$(ActiveArch),) $(call Set,OptimizedInputs.$(ActiveConfig).$(ActiveArch),) # Final.Inputs is created once we have loaded all the subdirectories @@ -124,10 +122,10 @@ ### # How to build things. -# Define rules for building on each configuration & architecture. This -# is not exactly obvious, but variables inside the template are being -# expanded during the make processing, so automatic variables must be -# quoted and normal assignment cannot be used. +# Define rules for building on each configuration & architecture. This is not +# exactly obvious, but variables inside the template are being expanded during +# the make processing, so automatic variables must be quoted and normal +# assignment cannot be used. # Template: CNA_template Config Arch Dir # Uses: GetArgs, Dependencies, ObjNames @@ -143,8 +141,7 @@ $(call Set,ActiveFlags,$(call GetArgs,$(ActiveConfig),$(ActiveArch))) $(call Set,ActiveObjects,$(ObjNames:%=$(ActiveObjPath)/%)) -# Add to the input list for the appropriate library and update the -# dependency. +# Add to the input list for the appropriate library and update the dependency. $(call Append,$(Target).Inputs.$(ActiveConfig).$(ActiveArch),$(ActiveObjects)) $(ProjObjRoot)/$(ActiveConfig)/$(ActiveArch)/libcompiler_rt.$(Target).a: $(ActiveObjects) Modified: compiler-rt/trunk/make/AppleBI.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/AppleBI.mk?rev=93319&r1=93318&r2=93319&view=diff ============================================================================== --- compiler-rt/trunk/make/AppleBI.mk (original) +++ compiler-rt/trunk/make/AppleBI.mk Wed Jan 13 10:13:01 2010 @@ -12,17 +12,16 @@ ProjObjRoot := $(ProjSrcRoot) endif -# We override this with RC_ARCHS because B&I may want to build on an -# ARCH we haven't explicitly defined support for. If all goes well, -# this will just work and the resulting lib will just have generic -# versions for anything unknown. +# We override this with RC_ARCHS because B&I may want to build on an ARCH we +# haven't explicitly defined support for. If all goes well, this will just work +# and the resulting lib will just have generic versions for anything unknown. Archs := $(RC_ARCHS) -# log full compile lines in B&I logs and omit summary lines -Verb := +# Log full compile lines in B&I logs and omit summary lines. +Verb := Summary := @true -# list of functions needed for each architecture +# List of functions needed for each architecture. Funcs_all = absvdi2.o absvsi2.o addvdi3.o addvsi3.o ashldi3.o ashrdi3.o \ clzdi2.o clzsi2.o cmpdi2.o ctzdi2.o ctzsi2.o \ divdc3.o divdi3.o divsc3.o ffsdi2.o \ @@ -32,14 +31,14 @@ mulsc3.o mulvdi3.o mulvsi3.o negdi2.o negvdi2.o negvsi2.o \ paritydi2.o paritysi2.o popcountdi2.o popcountsi2.o powidf2.o \ powisf2.o subvdi3.o subvsi3.o ucmpdi2.o udivdi3.o \ - udivmoddi4.o umoddi3.o apple_versioning.o eprintf.o + udivmoddi4.o umoddi3.o apple_versioning.o eprintf.o Funcs_i386 = divxc3.o fixunsxfdi.o fixunsxfsi.o fixxfdi.o floatdixf.o \ floatundixf.o mulxc3.o powixf2.o clear_cache.o \ - enable_execute_stack.o + enable_execute_stack.o Funcs_ppc = divtc3.o fixtfdi.o fixunstfdi.o floatditf.o floatunditf.o \ gcc_qadd.o gcc_qdiv.o gcc_qmul.o gcc_qsub.o multc3.o \ powitf2.o restFP.o saveFP.o trampoline_setup.o \ - clear_cache.o enable_execute_stack.o + clear_cache.o enable_execute_stack.o Funcs_x86_64 = absvti2.o addvti3.o ashlti3.o ashrti3.o clzti2.o cmpti2.o \ ctzti2.o divti3.o divxc3.o ffsti2.o fixdfti.o fixsfti.o \ fixunsdfti.o fixunssfti.o fixunsxfdi.o fixunsxfsi.o \ @@ -49,50 +48,49 @@ mulvti3.o mulxc3.o negti2.o negvti2.o parityti2.o \ popcountti2.o powixf2.o subvti3.o ucmpti2.o udivmodti4.o \ udivti3.o umodti3.o clear_cache.o enable_execute_stack.o -Funcs_armv6 = adddf3vfp.o addsf3vfp.o bswapdi2.o bswapsi2.o divdf3vfp.o \ - divsf3vfp.o eqdf2vfp.o eqsf2vfp.o extendsfdf2vfp.o \ - fixdfsivfp.o fixsfsivfp.o fixunsdfsivfp.o fixunssfsivfp.o \ - floatsidfvfp.o floatsisfvfp.o floatunssidfvfp.o floatunssisfvfp.o \ - gedf2vfp.o gesf2vfp.o gtdf2vfp.o gtsf2vfp.o \ - ledf2vfp.o lesf2vfp.o ltdf2vfp.o ltsf2vfp.o \ - muldf3vfp.o mulsf3vfp.o \ - nedf2vfp.o negdf2vfp.o negsf2vfp.o nesf2vfp.o \ - subdf3vfp.o subsf3vfp.o truncdfsf2vfp.o unorddf2vfp.o unordsf2vfp.o \ - modsi3.o umodsi3.o udivsi3.o divsi3.o switch.o save_restore_d8_d15.o +Funcs_armv6 = adddf3vfp.o addsf3vfp.o bswapdi2.o bswapsi2.o divdf3vfp.o \ + divsf3vfp.o eqdf2vfp.o eqsf2vfp.o extendsfdf2vfp.o \ + fixdfsivfp.o fixsfsivfp.o fixunsdfsivfp.o fixunssfsivfp.o \ + floatsidfvfp.o floatsisfvfp.o floatunssidfvfp.o floatunssisfvfp.o \ + gedf2vfp.o gesf2vfp.o gtdf2vfp.o gtsf2vfp.o \ + ledf2vfp.o lesf2vfp.o ltdf2vfp.o ltsf2vfp.o \ + muldf3vfp.o mulsf3vfp.o \ + nedf2vfp.o negdf2vfp.o negsf2vfp.o nesf2vfp.o \ + subdf3vfp.o subsf3vfp.o truncdfsf2vfp.o unorddf2vfp.o unordsf2vfp.o \ + modsi3.o umodsi3.o udivsi3.o divsi3.o switch.o save_restore_d8_d15.o -# copies any public headers to DSTROOT +# Copies any public headers to DSTROOT. installhdrs: -# copies source code to SRCROOT +# Copies source code to SRCROOT. installsrc: - cp -r . $(SRCROOT) + cp -r . $(SRCROOT) -# copy results to DSTROOT +# Copy results to DSTROOT. install: $(SYMROOT)/usr/local/lib/system/libcompiler_rt.a - mkdir -p $(DSTROOT)/usr/local/lib/system - cp $(SYMROOT)/usr/local/lib/system/libcompiler_rt.a \ - $(DSTROOT)/usr/local/lib/system/libcompiler_rt.a - cd $(DSTROOT)/usr/local/lib/system; \ - ln -s libcompiler_rt.a libcompiler_rt_profile.a; \ - ln -s libcompiler_rt.a libcompiler_rt_debug.a + mkdir -p $(DSTROOT)/usr/local/lib/system + cp $(SYMROOT)/usr/local/lib/system/libcompiler_rt.a \ + $(DSTROOT)/usr/local/lib/system/libcompiler_rt.a + cd $(DSTROOT)/usr/local/lib/system; \ + ln -s libcompiler_rt.a libcompiler_rt_profile.a; \ + ln -s libcompiler_rt.a libcompiler_rt_debug.a -# rule to make fat libcompiler_rt.a +# Rule to make fat libcompiler_rt.a. $(SYMROOT)/usr/local/lib/system/libcompiler_rt.a : $(foreach arch,$(Archs), \ $(OBJROOT)/$(arch)-pruned.a) - mkdir -p $(SYMROOT)/usr/local/lib/system - lipo -create $^ -o $@ + mkdir -p $(SYMROOT)/usr/local/lib/system + lipo -create $^ -o $@ -# rule to make filter each architecture of libcompiler_rt.a -# adds project info so that "what /usr/lib/libSystem.B.dylib" will work +# Rule to add project info so that "what /usr/lib/libSystem.B.dylib" will work. $(OBJROOT)/%-pruned.a : $(OBJROOT)/Release/%/libcompiler_rt.Optimized.a - mkdir -p $(OBJROOT)/$*.tmp - cd $(OBJROOT)/$*.tmp; \ - /Developer/Makefiles/bin/version.pl $(RC_ProjectName) > $(OBJROOT)/version.c; \ - gcc -arch $* -c ${OBJROOT}/version.c -o version.o; \ - ar -x $< $(Funcs_all) $(Funcs_$*); \ - libtool -static *.o -o $@ + mkdir -p $(OBJROOT)/$*.tmp + cd $(OBJROOT)/$*.tmp; \ + /Developer/Makefiles/bin/version.pl $(RC_ProjectName) > $(OBJROOT)/version.c; \ + gcc -arch $* -c ${OBJROOT}/version.c -o version.o; \ + ar -x $< $(Funcs_all) $(Funcs_$*); \ + libtool -static *.o -o $@ Modified: compiler-rt/trunk/make/config.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/config.mk?rev=93319&r1=93318&r2=93319&view=diff ============================================================================== --- compiler-rt/trunk/make/config.mk (original) +++ compiler-rt/trunk/make/config.mk Wed Jan 13 10:13:01 2010 @@ -3,9 +3,8 @@ OS := $(shell uname) -# Assume make is always run from top-level of source directory. Note -# than an Apple style build overrides these variables later in the -# makefile. +# Assume make is always run from top-level of source directory. Note than an +# Apple style build overrides these variables later in the makefile. ProjSrcRoot := $(shell pwd) ProjObjRoot := $(ProjSrcRoot) @@ -73,7 +72,7 @@ ifndef VERBOSE Verb := @ else - Verb := + Verb := endif Echo := @echo Modified: compiler-rt/trunk/make/subdir.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/subdir.mk?rev=93319&r1=93318&r2=93319&view=diff ============================================================================== --- compiler-rt/trunk/make/subdir.mk (original) +++ compiler-rt/trunk/make/subdir.mk Wed Jan 13 10:13:01 2010 @@ -1,5 +1,4 @@ -# This file is intended to be included from each subdirectory -# makefile. +# This file is intended to be included from each subdirectory makefile. ifeq ($(Dir),) $(error "No Dir variable defined.") @@ -10,6 +9,7 @@ endif # Expand template for each configuration and architecture. +# # FIXME: This level of logic should be in primary Makefile? ifeq ($(OnlyConfigs),) ConfigsToTraverse := $(Configs) @@ -35,8 +35,7 @@ ### # Include child makefile fragments -# Evaluate this now so we do not have to worry about order of -# evaluation. +# Evaluate this now so we do not have to worry about order of evaluation. SubDirsList := $(SubDirs:%=$(Dir)/%) ifeq ($(SubDirsList),) else Modified: compiler-rt/trunk/make/util.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/util.mk?rev=93319&r1=93318&r2=93319&view=diff ============================================================================== --- compiler-rt/trunk/make/util.mk (original) +++ compiler-rt/trunk/make/util.mk Wed Jan 13 10:13:01 2010 @@ -22,8 +22,8 @@ ### # Debugging -# General debugging rule, use 'make print-XXX' to print the -# definition, value and origin of XXX. -print-%: +# General debugging rule, use 'make print-XXX' to print the definition, value +# and origin of XXX. +make-print-%: $(error PRINT: $(value $*) = "$($*)" (from $(origin $*))) From aaronngray.lists at googlemail.com Wed Jan 13 10:34:42 2010 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Wed, 13 Jan 2010 16:34:42 +0000 Subject: [llvm-commits] [Cygwin] No runtime lib profile patch Message-ID: <9719867c1001130834h6ec68c3fldb62470f37262f4e@mail.gmail.com> Hi, I am getting the following build error on doing a full build on LLVM on Cygwin :- make[2]: Entering directory `/home/ang/build/llvm/runtime/libprofile' llvm[2]: Linking Debug Loadable Module profile_rt.dll /usr/bin/ld: warning: cannot find entry symbol __cygwin_dll_entry at 12; defaulting to 67941000 /home/ang/build/llvm/runtime/libprofile/Debug/BasicBlockTracing.o: In function ` BBTraceAtExitHandler': /home/ang/svn/llvm-93000/runtime/libprofile/BasicBlockTracing.c:35: undefined re ference to `_free' /home/ang/build/llvm/runtime/libprofile/Debug/BasicBlockTracing.o: In function ` llvm_start_basic_block_tracing': /home/ang/svn/llvm-93000/runtime/libprofile/BasicBlockTracing.c:59: undefined re ference to `_malloc' /home/ang/svn/llvm-93000/runtime/libprofile/BasicBlockTracing.c:64: undefined re ference to `_atexit' /home/ang/build/llvm/runtime/libprofile/Debug/CommonProfiling.o: In function `sa ve_arguments': /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:44: undefined refe rence to `_memmove' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:47: undefined refe rence to `_strcmp' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:49: undefined refe rence to `_puts' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:51: undefined refe rence to `_strdup' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:52: undefined refe rence to `_memmove' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:56: undefined refe rence to `_printf' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:39: undefined refe rence to `_strncmp' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:61: undefined refe rence to `_strlen' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:63: undefined refe rence to `_malloc' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:65: undefined refe rence to `_strlen' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:66: undefined refe rence to `_memcpy' /home/ang/build/llvm/runtime/libprofile/Debug/CommonProfiling.o: In function `wr ite_profiling_data': /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:91: undefined refe rence to `_open' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:93: undefined refe rence to `_fprintf' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:95: undefined refe rence to `_perror' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:103: undefined ref erence to `_write' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:104: undefined ref erence to `_write' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:105: undefined ref erence to `_write' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:108: undefined ref erence to `_write' /home/ang/svn/llvm-93000/runtime/libprofile/CommonProfiling.c:114: undefined ref erence to `_write' /home/ang/build/llvm/runtime/libprofile/Debug/CommonProfiling.o:/home/ang/svn/ll vm-93000/runtime/libprofile/CommonProfiling.c:115: more undefined references to `_write' follow /home/ang/build/llvm/runtime/libprofile/Debug/EdgeProfiling.o: In function `llvm _start_edge_profiling': /home/ang/svn/llvm-93000/runtime/libprofile/EdgeProfiling.c:43: undefined refere nce to `_atexit' /home/ang/build/llvm/runtime/libprofile/Debug/OptimalEdgeProfiling.o: In functio n `llvm_start_opt_edge_profiling': /home/ang/svn/llvm-93000/runtime/libprofile/OptimalEdgeProfiling.c:43: undefined reference to `_atexit' /usr/lib/libpthread.a(t-d000053.o):(.text+0x2): undefined reference to `__imp___ _getreent' collect2: ld returned 1 exit status make[2]: *** [/home/ang/build/llvm/Debug/lib/profile_rt.dll] Error 1 make[2]: Leaving directory `/home/ang/build/llvm/runtime/libprofile' make[1]: *** [libprofile/.makeall] Error 2 make[1]: Leaving directory `/home/ang/build/llvm/runtime' make: *** [all] Error 1 I have done a quick patch to omit building of this library for Cygwin as I am not sure if or how to solve this build on Cygwin. Index: runtime/Makefile =================================================================== --- runtime/Makefile (revision 93262) +++ runtime/Makefile (working copy) @@ -20,8 +20,12 @@ PARALLEL_DIRS := $(filter-out libprofile, $(PARALLEL_DIRS)) endif +ifeq ($(OS), Cygwin) +PARALLEL_DIRS := $(filter-out libprofile, $(PARALLEL_DIRS)) +endif + endif include $(LEVEL)/Makefile.common install:: Hoping someone more experienced can take a look at this. Many thanks, Aaron -------------- next part -------------- A non-text attachment was scrubbed... Name: CygwinNoLibProfile.patch Type: application/octet-stream Size: 403 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100113/db85b94b/attachment.obj From clattner at apple.com Wed Jan 13 12:39:02 2010 From: clattner at apple.com (Chris Lattner) Date: Wed, 13 Jan 2010 10:39:02 -0800 Subject: [llvm-commits] [llvm] r93317 - in /llvm/trunk: include/llvm/ADT/Twine.h lib/Support/Twine.cpp lib/VMCore/Mangler.cpp lib/VMCore/Metadata.cpp lib/VMCore/Value.cpp In-Reply-To: <201001131245.o0DCjPbv001185@zion.cs.uiuc.edu> References: <201001131245.o0DCjPbv001185@zion.cs.uiuc.edu> Message-ID: <5AC1662F-4813-4A28-A671-7F407E943CC2@apple.com> On Jan 13, 2010, at 4:45 AM, Benjamin Kramer wrote: > Author: d0k > Date: Wed Jan 13 06:45:23 2010 > New Revision: 93317 > > URL: http://llvm.org/viewvc/llvm-project?rev=93317&view=rev > Log: > Introduce Twine::toStringRef, a variant of toVector which avoids the copy if the > twine can be represented as a single StringRef. Use the new methode to simplify > some twine users. Nice, that is much more elegant! -Chris From sabre at nondot.org Wed Jan 13 13:00:58 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 19:00:58 -0000 Subject: [llvm-commits] [llvm] r93332 - /llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Message-ID: <201001131900.o0DJ0wRg015877@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 13:00:57 2010 New Revision: 93332 URL: http://llvm.org/viewvc/llvm-project?rev=93332&view=rev Log: properly use MCSymbol to print the strings aquired from getNameWithPrefix. Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=93332&r1=93331&r2=93332&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Wed Jan 13 13:00:57 2010 @@ -32,6 +32,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCContext.h" #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" @@ -58,33 +59,55 @@ class PPCAsmPrinter : public AsmPrinter { protected: struct FnStubInfo { - std::string Stub, LazyPtr, AnonSymbol; + std::string StubName, LazyPtrName, AnonSymbolName; + MCSymbol *StubSym, *LazyPtrSym, *AnonSymbolSym; - FnStubInfo() {} + FnStubInfo() { + StubSym = LazyPtrSym = AnonSymbolSym = 0; + } void Init(const GlobalValue *GV, Mangler *Mang) { // Already initialized. - if (!Stub.empty()) return; - Stub = Mang->getMangledName(GV, "$stub", true); - LazyPtr = Mang->getMangledName(GV, "$lazy_ptr", true); - AnonSymbol = Mang->getMangledName(GV, "$stub$tmp", true); + if (!StubName.empty()) return; + StubName = Mang->getMangledName(GV, "$stub", true); + LazyPtrName = Mang->getMangledName(GV, "$lazy_ptr", true); + AnonSymbolName = Mang->getMangledName(GV, "$stub$tmp", true); } - void Init(StringRef GVName, Mangler *Mang) { + void Init(StringRef GVName, Mangler *Mang, MCContext &Ctx) { assert(!GVName.empty()); - if (!Stub.empty()) return; // Already initialized. + if (StubSym != 0) return; // Already initialized. // Get the names for the external symbol name. SmallString<128> TmpStr; Mang->getNameWithPrefix(TmpStr, GVName + "$stub", Mangler::Private); - Stub = TmpStr.str(); + StubSym = Ctx.GetOrCreateSymbol(TmpStr.str()); TmpStr.clear(); Mang->getNameWithPrefix(TmpStr, GVName + "$lazy_ptr", Mangler::Private); - LazyPtr = TmpStr.str(); + LazyPtrSym = Ctx.GetOrCreateSymbol(TmpStr.str()); TmpStr.clear(); Mang->getNameWithPrefix(TmpStr, GVName + "$stub$tmp", Mangler::Private); - AnonSymbol = TmpStr.str(); + AnonSymbolSym = Ctx.GetOrCreateSymbol(TmpStr.str()); + } + + void printStub(raw_ostream &OS, const MCAsmInfo *MAI) const { + if (StubSym) + StubSym->print(OS, MAI); + else + OS << StubName; + } + void printLazyPtr(raw_ostream &OS, const MCAsmInfo *MAI) const { + if (LazyPtrSym) + LazyPtrSym->print(OS, MAI); + else + OS << LazyPtrName; + } + void printAnonSymbol(raw_ostream &OS, const MCAsmInfo *MAI) const { + if (AnonSymbolSym) + AnonSymbolSym->print(OS, MAI); + else + OS << AnonSymbolName; } }; @@ -232,7 +255,7 @@ // Dynamically-resolved functions need a stub for the function. FnStubInfo &FnInfo = FnStubs[Mang->getMangledName(GV)]; FnInfo.Init(GV, Mang); - O << FnInfo.Stub; + FnInfo.printStub(O, MAI); return; } } @@ -240,8 +263,8 @@ SmallString<128> MangledName; Mang->getNameWithPrefix(MangledName, MO.getSymbolName()); FnStubInfo &FnInfo = FnStubs[MangledName.str()]; - FnInfo.Init(MO.getSymbolName(), Mang); - O << FnInfo.Stub; + FnInfo.Init(MO.getSymbolName(), Mang, OutContext); + FnInfo.printStub(O, MAI); return; } } @@ -1046,27 +1069,38 @@ MCSectionMachO::S_SYMBOL_STUBS | MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, 32, SectionKind::getText()); - for (StringMap::iterator I = FnStubs.begin(), E = FnStubs.end(); + for (StringMap::iterator I = FnStubs.begin(), E = FnStubs.end(); I != E; ++I) { OutStreamer.SwitchSection(StubSection); EmitAlignment(4); const FnStubInfo &Info = I->second; - O << Info.Stub << ":\n"; + Info.printStub(O, MAI); + O << ":\n"; O << "\t.indirect_symbol " << I->getKeyData() << '\n'; O << "\tmflr r0\n"; - O << "\tbcl 20,31," << Info.AnonSymbol << '\n'; - O << Info.AnonSymbol << ":\n"; + O << "\tbcl 20,31,"; + Info.printAnonSymbol(O, MAI); + O << '\n'; + Info.printAnonSymbol(O, MAI); + O << ":\n"; O << "\tmflr r11\n"; - O << "\taddis r11,r11,ha16(" << Info.LazyPtr << "-" << Info.AnonSymbol; + O << "\taddis r11,r11,ha16("; + Info.printLazyPtr(O, MAI); + O << '-'; + Info.printAnonSymbol(O, MAI); O << ")\n"; O << "\tmtlr r0\n"; O << (isPPC64 ? "\tldu" : "\tlwzu") << " r12,lo16("; - O << Info.LazyPtr << "-" << Info.AnonSymbol << ")(r11)\n"; + Info.printLazyPtr(O, MAI); + O << '-'; + Info.printAnonSymbol(O, MAI); + O << ")(r11)\n"; O << "\tmtctr r12\n"; O << "\tbctr\n"; OutStreamer.SwitchSection(LSPSection); - O << Info.LazyPtr << ":\n"; + Info.printLazyPtr(O, MAI); + O << ":\n"; O << "\t.indirect_symbol " << I->getKeyData() << '\n'; O << (isPPC64 ? "\t.quad" : "\t.long") << " dyld_stub_binding_helper\n"; } @@ -1082,15 +1116,20 @@ OutStreamer.SwitchSection(StubSection); EmitAlignment(4); const FnStubInfo &Info = I->second; - O << Info.Stub << ":\n"; + Info.printStub(O, MAI); + O << ":\n"; O << "\t.indirect_symbol " << I->getKeyData() << '\n'; - O << "\tlis r11,ha16(" << Info.LazyPtr << ")\n"; + O << "\tlis r11,ha16("; + Info.printLazyPtr(O, MAI); + O << ")\n"; O << (isPPC64 ? "\tldu" : "\tlwzu") << " r12,lo16("; - O << Info.LazyPtr << ")(r11)\n"; + Info.printLazyPtr(O, MAI); + O << ")(r11)\n"; O << "\tmtctr r12\n"; O << "\tbctr\n"; OutStreamer.SwitchSection(LSPSection); - O << Info.LazyPtr << ":\n"; + Info.printLazyPtr(O, MAI); + O << ":\n"; O << "\t.indirect_symbol " << I->getKeyData() << '\n'; O << (isPPC64 ? "\t.quad" : "\t.long") << " dyld_stub_binding_helper\n"; } From sabre at nondot.org Wed Jan 13 13:05:37 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 19:05:37 -0000 Subject: [llvm-commits] [llvm] r93333 - /llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Message-ID: <201001131905.o0DJ5bFH016092@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 13:05:36 2010 New Revision: 93333 URL: http://llvm.org/viewvc/llvm-project?rev=93333&view=rev Log: don't call getNameWithPrefix repeatedly and unnecesarily. Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=93333&r1=93332&r2=93333&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Wed Jan 13 13:05:36 2010 @@ -69,6 +69,8 @@ void Init(const GlobalValue *GV, Mangler *Mang) { // Already initialized. if (!StubName.empty()) return; + + // Get the names. StubName = Mang->getMangledName(GV, "$stub", true); LazyPtrName = Mang->getMangledName(GV, "$lazy_ptr", true); AnonSymbolName = Mang->getMangledName(GV, "$stub$tmp", true); @@ -81,13 +83,13 @@ SmallString<128> TmpStr; Mang->getNameWithPrefix(TmpStr, GVName + "$stub", Mangler::Private); StubSym = Ctx.GetOrCreateSymbol(TmpStr.str()); - TmpStr.clear(); - - Mang->getNameWithPrefix(TmpStr, GVName + "$lazy_ptr", Mangler::Private); + TmpStr.erase(TmpStr.end()-5, TmpStr.end()); // Remove $stub + + TmpStr += "$lazy_ptr"; LazyPtrSym = Ctx.GetOrCreateSymbol(TmpStr.str()); - TmpStr.clear(); + TmpStr.erase(TmpStr.end()-9, TmpStr.end()); // Remove $lazy_ptr - Mang->getNameWithPrefix(TmpStr, GVName + "$stub$tmp", Mangler::Private); + TmpStr += "$stub$tmp"; AnonSymbolSym = Ctx.GetOrCreateSymbol(TmpStr.str()); } From sabre at nondot.org Wed Jan 13 13:13:16 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 19:13:16 -0000 Subject: [llvm-commits] [llvm] r93334 - /llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Message-ID: <201001131913.o0DJDGDc016430@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 13:13:16 2010 New Revision: 93334 URL: http://llvm.org/viewvc/llvm-project?rev=93334&view=rev Log: just finish MCizing FnStubInfo which cleans it up and simplifies it. Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=93334&r1=93333&r2=93334&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Wed Jan 13 13:13:16 2010 @@ -59,57 +59,42 @@ class PPCAsmPrinter : public AsmPrinter { protected: struct FnStubInfo { - std::string StubName, LazyPtrName, AnonSymbolName; - MCSymbol *StubSym, *LazyPtrSym, *AnonSymbolSym; + MCSymbol *Stub, *LazyPtr, *AnonSymbol; FnStubInfo() { - StubSym = LazyPtrSym = AnonSymbolSym = 0; + Stub = LazyPtr = AnonSymbol = 0; } - void Init(const GlobalValue *GV, Mangler *Mang) { + void Init(const GlobalValue *GV, Mangler *Mang, MCContext &Ctx) { // Already initialized. - if (!StubName.empty()) return; + if (Stub != 0) return; // Get the names. - StubName = Mang->getMangledName(GV, "$stub", true); - LazyPtrName = Mang->getMangledName(GV, "$lazy_ptr", true); - AnonSymbolName = Mang->getMangledName(GV, "$stub$tmp", true); + SmallString<128> TmpStr; + Mang->getNameWithPrefix(TmpStr, GV, true); + MakeSymbols(TmpStr, Ctx); } void Init(StringRef GVName, Mangler *Mang, MCContext &Ctx) { - assert(!GVName.empty()); - if (StubSym != 0) return; // Already initialized. + assert(!GVName.empty() && "external symbol name shouldn't be empty"); + if (Stub != 0) return; // Already initialized. // Get the names for the external symbol name. SmallString<128> TmpStr; - Mang->getNameWithPrefix(TmpStr, GVName + "$stub", Mangler::Private); - StubSym = Ctx.GetOrCreateSymbol(TmpStr.str()); + Mang->getNameWithPrefix(TmpStr, GVName, Mangler::Private); + MakeSymbols(TmpStr, Ctx); + } + + void MakeSymbols(SmallString<128> &TmpStr, MCContext &Ctx) { + TmpStr += "$stub"; + Stub = Ctx.GetOrCreateSymbol(TmpStr.str()); TmpStr.erase(TmpStr.end()-5, TmpStr.end()); // Remove $stub TmpStr += "$lazy_ptr"; - LazyPtrSym = Ctx.GetOrCreateSymbol(TmpStr.str()); + LazyPtr = Ctx.GetOrCreateSymbol(TmpStr.str()); TmpStr.erase(TmpStr.end()-9, TmpStr.end()); // Remove $lazy_ptr TmpStr += "$stub$tmp"; - AnonSymbolSym = Ctx.GetOrCreateSymbol(TmpStr.str()); - } - - void printStub(raw_ostream &OS, const MCAsmInfo *MAI) const { - if (StubSym) - StubSym->print(OS, MAI); - else - OS << StubName; - } - void printLazyPtr(raw_ostream &OS, const MCAsmInfo *MAI) const { - if (LazyPtrSym) - LazyPtrSym->print(OS, MAI); - else - OS << LazyPtrName; - } - void printAnonSymbol(raw_ostream &OS, const MCAsmInfo *MAI) const { - if (AnonSymbolSym) - AnonSymbolSym->print(OS, MAI); - else - OS << AnonSymbolName; + AnonSymbol = Ctx.GetOrCreateSymbol(TmpStr.str()); } }; @@ -256,8 +241,8 @@ if (GV->isDeclaration() || GV->isWeakForLinker()) { // Dynamically-resolved functions need a stub for the function. FnStubInfo &FnInfo = FnStubs[Mang->getMangledName(GV)]; - FnInfo.Init(GV, Mang); - FnInfo.printStub(O, MAI); + FnInfo.Init(GV, Mang, OutContext); + FnInfo.Stub->print(O, MAI); return; } } @@ -266,7 +251,7 @@ Mang->getNameWithPrefix(MangledName, MO.getSymbolName()); FnStubInfo &FnInfo = FnStubs[MangledName.str()]; FnInfo.Init(MO.getSymbolName(), Mang, OutContext); - FnInfo.printStub(O, MAI); + FnInfo.Stub->print(O, MAI); return; } } @@ -1076,32 +1061,32 @@ OutStreamer.SwitchSection(StubSection); EmitAlignment(4); const FnStubInfo &Info = I->second; - Info.printStub(O, MAI); + Info.Stub->print(O, MAI); O << ":\n"; O << "\t.indirect_symbol " << I->getKeyData() << '\n'; O << "\tmflr r0\n"; O << "\tbcl 20,31,"; - Info.printAnonSymbol(O, MAI); + Info.AnonSymbol->print(O, MAI); O << '\n'; - Info.printAnonSymbol(O, MAI); + Info.AnonSymbol->print(O, MAI); O << ":\n"; O << "\tmflr r11\n"; O << "\taddis r11,r11,ha16("; - Info.printLazyPtr(O, MAI); + Info.LazyPtr->print(O, MAI); O << '-'; - Info.printAnonSymbol(O, MAI); + Info.AnonSymbol->print(O, MAI); O << ")\n"; O << "\tmtlr r0\n"; O << (isPPC64 ? "\tldu" : "\tlwzu") << " r12,lo16("; - Info.printLazyPtr(O, MAI); + Info.LazyPtr->print(O, MAI); O << '-'; - Info.printAnonSymbol(O, MAI); + Info.AnonSymbol->print(O, MAI); O << ")(r11)\n"; O << "\tmtctr r12\n"; O << "\tbctr\n"; OutStreamer.SwitchSection(LSPSection); - Info.printLazyPtr(O, MAI); + Info.LazyPtr->print(O, MAI); O << ":\n"; O << "\t.indirect_symbol " << I->getKeyData() << '\n'; O << (isPPC64 ? "\t.quad" : "\t.long") << " dyld_stub_binding_helper\n"; @@ -1118,19 +1103,19 @@ OutStreamer.SwitchSection(StubSection); EmitAlignment(4); const FnStubInfo &Info = I->second; - Info.printStub(O, MAI); + Info.Stub->print(O, MAI); O << ":\n"; O << "\t.indirect_symbol " << I->getKeyData() << '\n'; O << "\tlis r11,ha16("; - Info.printLazyPtr(O, MAI); + Info.LazyPtr->print(O, MAI); O << ")\n"; O << (isPPC64 ? "\tldu" : "\tlwzu") << " r12,lo16("; - Info.printLazyPtr(O, MAI); + Info.LazyPtr->print(O, MAI); O << ")(r11)\n"; O << "\tmtctr r12\n"; O << "\tbctr\n"; OutStreamer.SwitchSection(LSPSection); - Info.printLazyPtr(O, MAI); + Info.LazyPtr->print(O, MAI); O << ":\n"; O << "\t.indirect_symbol " << I->getKeyData() << '\n'; O << (isPPC64 ? "\t.quad" : "\t.long") << " dyld_stub_binding_helper\n"; From evan.cheng at apple.com Wed Jan 13 13:16:39 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 13 Jan 2010 19:16:39 -0000 Subject: [llvm-commits] [llvm] r93335 - in /llvm/trunk: lib/CodeGen/OptimizeExts.cpp test/CodeGen/X86/2010-01-13-OptExtBug.ll test/CodeGen/X86/stack-color-with-reg.ll Message-ID: <201001131916.o0DJGde5016562@zion.cs.uiuc.edu> Author: evancheng Date: Wed Jan 13 13:16:39 2010 New Revision: 93335 URL: http://llvm.org/viewvc/llvm-project?rev=93335&view=rev Log: Commit some changes I had managed to lose last night while refactoring the code. Avoid change use of PHI instructions because it's not legal to insert any instructions before them. This fixes PR6027. Added: llvm/trunk/test/CodeGen/X86/2010-01-13-OptExtBug.ll Modified: llvm/trunk/lib/CodeGen/OptimizeExts.cpp llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll Modified: llvm/trunk/lib/CodeGen/OptimizeExts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/OptimizeExts.cpp?rev=93335&r1=93334&r2=93335&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/OptimizeExts.cpp (original) +++ llvm/trunk/lib/CodeGen/OptimizeExts.cpp Wed Jan 13 13:16:39 2010 @@ -110,6 +110,11 @@ MachineInstr *UseMI = &*UI; if (UseMI == MI) continue; + if (UseMI->getOpcode() == TargetInstrInfo::PHI) { + ExtendLife = false; + continue; + } + MachineBasicBlock *UseMBB = UseMI->getParent(); if (UseMBB == MBB) { // Local uses that come after the extension. @@ -117,7 +122,7 @@ Uses.push_back(&UseMO); } else if (ReachedBBs.count(UseMBB)) // Non-local uses where the result of extension is used. Always - // replace these. + // replace these unless it's a PHI. Uses.push_back(&UseMO); else if (Aggressive && DT->dominates(MBB, UseMBB)) // We may want to extend live range of the extension result in order Added: llvm/trunk/test/CodeGen/X86/2010-01-13-OptExtBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-01-13-OptExtBug.ll?rev=93335&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-01-13-OptExtBug.ll (added) +++ llvm/trunk/test/CodeGen/X86/2010-01-13-OptExtBug.ll Wed Jan 13 13:16:39 2010 @@ -0,0 +1,46 @@ +; RUN: llc < %s -mtriple=i386-pc-linux-gnu +; PR6027 + +%class.OlsonTimeZone = type { i16, i32*, i8*, i16 } + +define void @XX(%class.OlsonTimeZone* %this) align 2 { +entry: + %call = tail call i8* @_Z15uprv_malloc_4_2v() + %0 = bitcast i8* %call to double* + %tmp = getelementptr inbounds %class.OlsonTimeZone* %this, i32 0, i32 3 + %tmp2 = load i16* %tmp + %tmp525 = getelementptr inbounds %class.OlsonTimeZone* %this, i32 0, i32 0 + %tmp626 = load i16* %tmp525 + %cmp27 = icmp slt i16 %tmp2, %tmp626 + br i1 %cmp27, label %bb.nph, label %for.end + +for.cond: + %tmp6 = load i16* %tmp5 + %cmp = icmp slt i16 %inc, %tmp6 + %indvar.next = add i32 %indvar, 1 + br i1 %cmp, label %for.body, label %for.end + +bb.nph: + %tmp10 = getelementptr inbounds %class.OlsonTimeZone* %this, i32 0, i32 2 + %tmp17 = getelementptr inbounds %class.OlsonTimeZone* %this, i32 0, i32 1 + %tmp5 = getelementptr inbounds %class.OlsonTimeZone* %this, i32 0, i32 0 + %tmp29 = sext i16 %tmp2 to i32 + %tmp31 = add i16 %tmp2, 1 + %tmp32 = zext i16 %tmp31 to i32 + br label %for.body + +for.body: + %indvar = phi i32 [ 0, %bb.nph ], [ %indvar.next, %for.cond ] + %tmp30 = add i32 %indvar, %tmp29 + %tmp33 = add i32 %indvar, %tmp32 + %inc = trunc i32 %tmp33 to i16 + %tmp11 = load i8** %tmp10 + %arrayidx = getelementptr i8* %tmp11, i32 %tmp30 + %tmp12 = load i8* %arrayidx + br label %for.cond + +for.end: + ret void +} + +declare i8* @_Z15uprv_malloc_4_2v() Modified: llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll?rev=93335&r1=93334&r2=93335&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll (original) +++ llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll Wed Jan 13 13:16:39 2010 @@ -1,5 +1,5 @@ ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -relocation-model=pic -disable-fp-elim -color-ss-with-regs -stats -info-output-file - > %t -; RUN: grep stackcoloring %t | grep "stack slot refs replaced with reg refs" | grep 9 +; RUN: grep stackcoloring %t | grep "stack slot refs replaced with reg refs" | grep 14 type { [62 x %struct.Bitvec*] } ; type %0 type { i8* } ; type %1 From sabre at nondot.org Wed Jan 13 13:19:18 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 19:19:18 -0000 Subject: [llvm-commits] [llvm] r93336 - /llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Message-ID: <201001131919.o0DJJIva016738@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 13:19:17 2010 New Revision: 93336 URL: http://llvm.org/viewvc/llvm-project?rev=93336&view=rev Log: Use the GV version of getNameWithPrefix in TargetLoweringObjectFileCOFF:: SelectSectionForGlobal, unbreaking weak globals with no-name. Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=93336&r1=93335&r2=93336&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Wed Jan 13 13:19:17 2010 @@ -1084,7 +1084,7 @@ if (GV->isWeakForLinker()) { const char *Prefix = getCOFFSectionPrefixForUniqueGlobal(Kind); SmallString<128> Name(Prefix, Prefix+strlen(Prefix)); - Mang->getNameWithPrefix(Name, GV->getName()); + Mang->getNameWithPrefix(Name, GV, false); return getCOFFSection(Name.str(), false, Kind); } From vhernandez at apple.com Wed Jan 13 13:34:09 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Wed, 13 Jan 2010 19:34:09 -0000 Subject: [llvm-commits] [llvm] r93337 - /llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Message-ID: <201001131934.o0DJYAEj017397@zion.cs.uiuc.edu> Author: hernande Date: Wed Jan 13 13:34:08 2010 New Revision: 93337 URL: http://llvm.org/viewvc/llvm-project?rev=93337&view=rev Log: Parse function-local metadata inside function blocks Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=93337&r1=93336&r2=93337&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Wed Jan 13 13:34:08 2010 @@ -1657,6 +1657,9 @@ case bitc::METADATA_ATTACHMENT_ID: if (ParseMetadataAttachment()) return true; break; + case bitc::METADATA_BLOCK_ID: + if (ParseMetadata()) return true; + break; } continue; } From vhernandez at apple.com Wed Jan 13 13:36:16 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Wed, 13 Jan 2010 19:36:16 -0000 Subject: [llvm-commits] [llvm] r93338 - in /llvm/trunk/lib/Bitcode/Writer: ValueEnumerator.cpp ValueEnumerator.h Message-ID: <201001131936.o0DJaGrj017512@zion.cs.uiuc.edu> Author: hernande Date: Wed Jan 13 13:36:16 2010 New Revision: 93338 URL: http://llvm.org/viewvc/llvm-project?rev=93338&view=rev Log: Enumerate function-local metadata (and its types and operands) only during function-incorporation, global metadata continues to be enumerated during creation of ValueEnumerator Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=93338&r1=93337&r2=93338&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Wed Jan 13 13:36:16 2010 @@ -92,7 +92,7 @@ for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E;++I){ for (User::const_op_iterator OI = I->op_begin(), E = I->op_end(); OI != E; ++OI) - EnumerateOperandType(*OI); + EnumerateOperandType(*OI, true); EnumerateType(I->getType()); if (const CallInst *CI = dyn_cast(I)) EnumerateAttributes(CI->getAttributes()); @@ -103,7 +103,7 @@ MDs.clear(); I->getAllMetadata(MDs); for (unsigned i = 0, e = MDs.size(); i != e; ++i) - EnumerateMetadata(MDs[i].second); + EnumerateMetadata(MDs[i].second, true); } } @@ -224,7 +224,7 @@ MDValueMap[MD] = Values.size(); } -void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD) { +void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD, bool isGlobal) { // Check to see if it's already in! unsigned &MDValueID = MDValueMap[MD]; if (MDValueID) { @@ -237,14 +237,18 @@ EnumerateType(MD->getType()); if (const MDNode *N = dyn_cast(MD)) { - MDValues.push_back(std::make_pair(MD, 1U)); - MDValueMap[MD] = MDValues.size(); - MDValueID = MDValues.size(); - for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { - if (Value *V = N->getOperand(i)) - EnumerateValue(V); - else - EnumerateType(Type::getVoidTy(MD->getContext())); + if ((isGlobal && !N->isFunctionLocal()) || + (!isGlobal && N->isFunctionLocal())) { + MDValues.push_back(std::make_pair(MD, 1U)); + MDValueMap[MD] = MDValues.size(); + MDValueID = MDValues.size(); + for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { + if (Value *V = N->getOperand(i)) + EnumerateValue(V); + else + EnumerateType(Type::getVoidTy(MD->getContext())); + } + return; } return; } @@ -255,10 +259,10 @@ MDValueID = MDValues.size(); } -void ValueEnumerator::EnumerateValue(const Value *V) { +void ValueEnumerator::EnumerateValue(const Value *V, bool isGlobal) { assert(!V->getType()->isVoidTy() && "Can't insert void values!"); if (const MetadataBase *MB = dyn_cast(V)) - return EnumerateMetadata(MB); + return EnumerateMetadata(MB, isGlobal); else if (const NamedMDNode *NMD = dyn_cast(V)) return EnumerateNamedMDNode(NMD); @@ -292,7 +296,7 @@ for (User::const_op_iterator I = C->op_begin(), E = C->op_end(); I != E; ++I) if (!isa(*I)) // Don't enumerate BB operand to BlockAddress. - EnumerateValue(*I); + EnumerateValue(*I, isGlobal); // Finally, add the value. Doing this could make the ValueID reference be // dangling, don't reuse it. @@ -329,8 +333,14 @@ // Enumerate the types for the specified value. If the value is a constant, // walk through it, enumerating the types of the constant. -void ValueEnumerator::EnumerateOperandType(const Value *V) { +void ValueEnumerator::EnumerateOperandType(const Value *V, bool isGlobal) { EnumerateType(V->getType()); + + // During function-incorporation, only enumerate metadata operands. + if (!isGlobal) + if (const MetadataBase *MB = dyn_cast(V)) + return EnumerateMetadata(MB, isGlobal); + if (const Constant *C = dyn_cast(V)) { // If this constant is already enumerated, ignore it, we know its type must // be enumerated. @@ -345,13 +355,13 @@ // blockaddress. if (isa(Op)) continue; - EnumerateOperandType(cast(Op)); + EnumerateOperandType(cast(Op), isGlobal); } if (const MDNode *N = dyn_cast(V)) { for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) if (Value *Elem = N->getOperand(i)) - EnumerateOperandType(Elem); + EnumerateOperandType(Elem, isGlobal); } } else if (isa(V) || isa(V)) EnumerateValue(V); @@ -404,6 +414,10 @@ // Add all of the instructions. for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) { + for (User::const_op_iterator OI = I->op_begin(), E = I->op_end(); + OI != E; ++OI) { + EnumerateOperandType(*OI, false); + } if (!I->getType()->isVoidTy()) EnumerateValue(I); } Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h?rev=93338&r1=93337&r2=93338&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h (original) +++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h Wed Jan 13 13:36:16 2010 @@ -105,6 +105,7 @@ const ValueList &getValues() const { return Values; } const ValueList &getMDValues() const { return MDValues; } + ValueList getMDValues() { return MDValues; } const TypeList &getTypes() const { return Types; } const std::vector &getBasicBlocks() const { return BasicBlocks; @@ -127,11 +128,11 @@ private: void OptimizeConstants(unsigned CstStart, unsigned CstEnd); - void EnumerateMetadata(const MetadataBase *MD); + void EnumerateMetadata(const MetadataBase *MD, bool isGlobal); void EnumerateNamedMDNode(const NamedMDNode *NMD); - void EnumerateValue(const Value *V); + void EnumerateValue(const Value *V, bool isGlobal = true); void EnumerateType(const Type *T); - void EnumerateOperandType(const Value *V); + void EnumerateOperandType(const Value *V, bool isGlobal); void EnumerateAttributes(const AttrListPtr &PAL); void EnumerateTypeSymbolTable(const TypeSymbolTable &ST); From vhernandez at apple.com Wed Jan 13 13:37:33 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Wed, 13 Jan 2010 19:37:33 -0000 Subject: [llvm-commits] [llvm] r93339 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Message-ID: <201001131937.o0DJbXO9017579@zion.cs.uiuc.edu> Author: hernande Date: Wed Jan 13 13:37:33 2010 New Revision: 93339 URL: http://llvm.org/viewvc/llvm-project?rev=93339&view=rev Log: Write function-local metadata as a metadata subblock of a funciton block Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=93339&r1=93338&r2=93339&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Wed Jan 13 13:37:33 2010 @@ -499,11 +499,13 @@ for (unsigned i = 0, e = Vals.size(); i != e; ++i) { if (const MDNode *N = dyn_cast(Vals[i].first)) { - if (!StartedMetadataBlock) { - Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); - StartedMetadataBlock = true; + if (!N->isFunctionLocal()) { + if (!StartedMetadataBlock) { + Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); + StartedMetadataBlock = true; + } + WriteMDNode(N, VE, Stream, Record); } - WriteMDNode(N, VE, Stream, Record); } else if (const MDString *MDS = dyn_cast(Vals[i].first)) { if (!StartedMetadataBlock) { Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); @@ -552,6 +554,35 @@ Stream.ExitBlock(); } +static void WriteFunctionLocalMetadata(const ValueEnumerator &VE, + BitstreamWriter &Stream) { + bool StartedMetadataBlock = false; + SmallVector Record; + ValueEnumerator::ValueList Vals = VE.getMDValues(); + ValueEnumerator::ValueList::iterator it = Vals.begin(); + ValueEnumerator::ValueList::iterator end = Vals.end(); + + while (it != end) { + if (const MDNode *N = dyn_cast((*it).first)) { + if (N->isFunctionLocal()) { + if (!StartedMetadataBlock) { + Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); + StartedMetadataBlock = true; + } + WriteMDNode(N, VE, Stream, Record); + // Remove function-local MD, since it is used outside of function. + it = Vals.erase(it); + end = Vals.end(); + continue; + } + } + ++it; + } + + if (StartedMetadataBlock) + Stream.ExitBlock(); +} + static void WriteMetadataAttachment(const Function &F, const ValueEnumerator &VE, BitstreamWriter &Stream) { @@ -1210,6 +1241,7 @@ // Emit names for all the instructions etc. WriteValueSymbolTable(F.getValueSymbolTable(), VE, Stream); + WriteFunctionLocalMetadata(VE, Stream); WriteMetadataAttachment(F, VE, Stream); VE.purgeFunction(); Stream.ExitBlock(); From sabre at nondot.org Wed Jan 13 13:54:08 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 19:54:08 -0000 Subject: [llvm-commits] [llvm] r93341 - /llvm/trunk/lib/Target/CBackend/CBackend.cpp Message-ID: <201001131954.o0DJs8uD018726@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 13:54:07 2010 New Revision: 93341 URL: http://llvm.org/viewvc/llvm-project?rev=93341&view=rev Log: stop the CBE from using deprecated Mangler stuff. Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=93341&r1=93340&r2=93341&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Wed Jan 13 13:54:07 2010 @@ -342,6 +342,35 @@ char CWriter::ID = 0; + +static bool isAcceptableChar(char C) { + if ((C < 'a' || C > 'z') && (C < 'A' || C > 'Z') && + (C < '0' || C > '9') && C != '_' && C != '$' && C != '@') + return false; + return true; +} + +static char HexDigit(int V) { + return V < 10 ? V+'0' : V+'A'-10; +} + +static std::string Mangle(const std::string &S) { + std::string Result; + + for (unsigned i = 0, e = S.size(); i != e; ++i) + if (isAcceptableChar(S[i])) + Result += S[i]; + else { + Result += '_'; + Result += HexDigit((S[i] >> 4) & 15); + Result += HexDigit(S[i] & 15); + Result += '_'; + } + + return Result; +} + + /// This method inserts names for any unnamed structure types that are used by /// the program, and removes names from structure types that are not used by the /// program. @@ -1432,8 +1461,11 @@ std::string CWriter::GetValueName(const Value *Operand) { // Mangle globals with the standard mangler interface for LLC compatibility. - if (const GlobalValue *GV = dyn_cast(Operand)) - return Mang->getMangledName(GV); + if (const GlobalValue *GV = dyn_cast(Operand)) { + SmallString<128> Str; + Mang->getNameWithPrefix(Str, GV, false); + return Mangle(Str.str().str()); + } std::string Name = Operand->getName(); @@ -1858,7 +1890,6 @@ // Ensure that all structure types have names... Mang = new Mangler(M); - Mang->markCharUnacceptable('.'); // Keep track of which functions are static ctors/dtors so they can have // an attribute added to their prototypes. @@ -2208,17 +2239,12 @@ // If there are no type names, exit early. if (I == End) return; - SmallString<128> TempName; - // Print out forward declarations for structure types before anything else! Out << "/* Structure forward decls */\n"; for (; I != End; ++I) { - const char *Prefix = "struct l_"; - TempName.append(Prefix, Prefix+strlen(Prefix)); - Mang->makeNameProper(TempName, I->first); - Out << TempName.str() << ";\n"; - TypeNames.insert(std::make_pair(I->second, TempName.str())); - TempName.clear(); + std::string Name = "struct " + Mangle("l_"+I->first); + Out << Name << ";\n"; + TypeNames.insert(std::make_pair(I->second, Name)); } Out << '\n'; @@ -2227,14 +2253,10 @@ // for struct or opaque types. Out << "/* Typedefs */\n"; for (I = TST.begin(); I != End; ++I) { - const char *Prefix = "l_"; - TempName.append(Prefix, Prefix+strlen(Prefix)); - Mang->makeNameProper(TempName, I->first); - + std::string Name = Mangle("l_"+I->first); Out << "typedef "; - printType(Out, I->second, false, TempName.str()); + printType(Out, I->second, false, Name); Out << ";\n"; - TempName.clear(); } Out << '\n'; From stoklund at 2pi.dk Wed Jan 13 13:54:39 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 13 Jan 2010 19:54:39 -0000 Subject: [llvm-commits] [llvm] r93342 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <201001131954.o0DJse4Y018775@zion.cs.uiuc.edu> Author: stoklund Date: Wed Jan 13 13:54:39 2010 New Revision: 93342 URL: http://llvm.org/viewvc/llvm-project?rev=93342&view=rev Log: Fix pasto Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=93342&r1=93341&r2=93342&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Jan 13 13:54:39 2010 @@ -3155,7 +3155,7 @@ default: llvm_unreachable("unsupported size for AtomicCmpSwap!"); case 1: ldrOpc = isThumb2 ? ARM::t2LDREXB : ARM::LDREXB; - strOpc = isThumb2 ? ARM::t2LDREXB : ARM::STREXB; + strOpc = isThumb2 ? ARM::t2STREXB : ARM::STREXB; break; case 2: ldrOpc = isThumb2 ? ARM::t2LDREXH : ARM::LDREXH; From devang.patel at gmail.com Wed Jan 13 15:00:16 2010 From: devang.patel at gmail.com (Devang Patel) Date: Wed, 13 Jan 2010 13:00:16 -0800 Subject: [llvm-commits] [llvm] r93338 - in /llvm/trunk/lib/Bitcode/Writer: ValueEnumerator.cpp ValueEnumerator.h In-Reply-To: <201001131936.o0DJaGrj017512@zion.cs.uiuc.edu> References: <201001131936.o0DJaGrj017512@zion.cs.uiuc.edu> Message-ID: <352a1fb21001131300q21c970c1r4ad677849aa3fc20@mail.gmail.com> On Wed, Jan 13, 2010 at 11:36 AM, Victor Hernandez wrote: > -void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD) { > +void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD, bool isGlobal) { > ? // Check to see if it's already in! > ? unsigned &MDValueID = MDValueMap[MD]; > ? if (MDValueID) { > @@ -237,14 +237,18 @@ > ? EnumerateType(MD->getType()); > > ? if (const MDNode *N = dyn_cast(MD)) { > - ? ?MDValues.push_back(std::make_pair(MD, 1U)); > - ? ?MDValueMap[MD] = MDValues.size(); > - ? ?MDValueID = MDValues.size(); > - ? ?for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { > - ? ? ?if (Value *V = N->getOperand(i)) > - ? ? ? ?EnumerateValue(V); > - ? ? ?else > - ? ? ? ?EnumerateType(Type::getVoidTy(MD->getContext())); > + ? ?if ((isGlobal && !N->isFunctionLocal()) || > + ? ? ? ?(!isGlobal && N->isFunctionLocal())) { What are the cases where isGlobal does not match N->isFunctionLocal() ? - Devang From johnny.chen at apple.com Wed Jan 13 15:00:27 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 13 Jan 2010 21:00:27 -0000 Subject: [llvm-commits] [llvm] r93349 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Message-ID: <201001132100.o0DL0RI4021270@zion.cs.uiuc.edu> Author: johnny Date: Wed Jan 13 15:00:26 2010 New Revision: 93349 URL: http://llvm.org/viewvc/llvm-project?rev=93349&view=rev Log: Fixed a couple of places for Thumb MOV where encoding bits are underspecified. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=93349&r1=93348&r2=93349&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Wed Jan 13 15:00:26 2010 @@ -208,9 +208,8 @@ let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in { def tBRIND : TI<(outs), (ins GPR:$dst), IIC_Br, "mov\tpc, $dst", [(brind GPR:$dst)]>, - T1Special<{1,0,?,?}> { - // = pc - let Inst{7} = 1; + T1Special<{1,0,1,1}> { + // = Inst{7:2-0} = pc let Inst{2-0} = 0b111; } } @@ -748,7 +747,7 @@ // 16-bit movcc in IT blocks for Thumb2. def tMOVCCr : T1pIt<(outs GPR:$dst), (ins GPR:$lhs, GPR:$rhs), IIC_iCMOVr, "mov", "\t$dst, $rhs", []>, - T1Special<{1,0,?,?}>; + T1Special<{1,0,1,1}>; def tMOVCCi : T1pIt<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs), IIC_iCMOVi, "mov", "\t$dst, $rhs", []>, From devang.patel at gmail.com Wed Jan 13 15:05:24 2010 From: devang.patel at gmail.com (Devang Patel) Date: Wed, 13 Jan 2010 13:05:24 -0800 Subject: [llvm-commits] [llvm] r93339 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp In-Reply-To: <201001131937.o0DJbXO9017579@zion.cs.uiuc.edu> References: <201001131937.o0DJbXO9017579@zion.cs.uiuc.edu> Message-ID: <352a1fb21001131305i49e7e817nda9f224ecb4d6537@mail.gmail.com> On Wed, Jan 13, 2010 at 11:37 AM, Victor Hernandez wrote: > > +static void WriteFunctionLocalMetadata(const ValueEnumerator &VE, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BitstreamWriter &Stream) { > + ?bool StartedMetadataBlock = false; > + ?SmallVector Record; > + ?ValueEnumerator::ValueList Vals = VE.getMDValues(); > + ?ValueEnumerator::ValueList::iterator it = Vals.begin(); > + ?ValueEnumerator::ValueList::iterator end = Vals.end(); > + > + ?while (it != end) { > + ? ?if (const MDNode *N = dyn_cast((*it).first)) { > + ? ? ?if (N->isFunctionLocal()) { > + ? ? ? ?if (!StartedMetadataBlock) { > + ? ? ? ? ?Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); > + ? ? ? ? ?StartedMetadataBlock = true; > + ? ? ? ?} > + ? ? ? ?WriteMDNode(N, VE, Stream, Record); > + ? ? ? ?// Remove function-local MD, since it is used outside of function. how ? > + ? ? ? ?it = Vals.erase(it); > + ? ? ? ?end = Vals.end(); > + ? ? ? ?continue; > + ? ? ?} > + ? ?} > + ? ?++it; > + ?} > + > + ?if (StartedMetadataBlock) > + ? ?Stream.ExitBlock(); > +} > + > ?static void WriteMetadataAttachment(const Function &F, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const ValueEnumerator &VE, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BitstreamWriter &Stream) { > @@ -1210,6 +1241,7 @@ > ? // Emit names for all the instructions etc. > ? WriteValueSymbolTable(F.getValueSymbolTable(), VE, Stream); > > + ?WriteFunctionLocalMetadata(VE, Stream); This does not check function so will it write function local metadata from one function into another function's block ? > ? WriteMetadataAttachment(F, VE, Stream); > ? VE.purgeFunction(); > ? Stream.ExitBlock(); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > - Devang From vhernandez at apple.com Wed Jan 13 15:07:20 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Wed, 13 Jan 2010 13:07:20 -0800 Subject: [llvm-commits] [llvm] r93339 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp In-Reply-To: <352a1fb21001131305i49e7e817nda9f224ecb4d6537@mail.gmail.com> References: <201001131937.o0DJbXO9017579@zion.cs.uiuc.edu> <352a1fb21001131305i49e7e817nda9f224ecb4d6537@mail.gmail.com> Message-ID: On Jan 13, 2010, at 1:05 PM, Devang Patel wrote: > On Wed, Jan 13, 2010 at 11:37 AM, Victor Hernandez wrote: > >> >> +static void WriteFunctionLocalMetadata(const ValueEnumerator &VE, >> + BitstreamWriter &Stream) { >> + bool StartedMetadataBlock = false; >> + SmallVector Record; >> + ValueEnumerator::ValueList Vals = VE.getMDValues(); >> + ValueEnumerator::ValueList::iterator it = Vals.begin(); >> + ValueEnumerator::ValueList::iterator end = Vals.end(); >> + >> + while (it != end) { >> + if (const MDNode *N = dyn_cast((*it).first)) { >> + if (N->isFunctionLocal()) { >> + if (!StartedMetadataBlock) { >> + Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); >> + StartedMetadataBlock = true; >> + } >> + WriteMDNode(N, VE, Stream, Record); >> + // Remove function-local MD, since it is used outside of function. > > how ? Sorry that is a typo. Meant to say "is not used". > >> + it = Vals.erase(it); >> + end = Vals.end(); >> + continue; >> + } >> + } >> + ++it; >> + } >> + >> + if (StartedMetadataBlock) >> + Stream.ExitBlock(); >> +} >> + >> static void WriteMetadataAttachment(const Function &F, >> const ValueEnumerator &VE, >> BitstreamWriter &Stream) { >> @@ -1210,6 +1241,7 @@ >> // Emit names for all the instructions etc. >> WriteValueSymbolTable(F.getValueSymbolTable(), VE, Stream); >> >> + WriteFunctionLocalMetadata(VE, Stream); > > This does not check function so will it write function local metadata > from one function into another function's block ? That check is done by the Verifier. Do you think I need to do it here also? > >> WriteMetadataAttachment(F, VE, Stream); >> VE.purgeFunction(); >> Stream.ExitBlock(); >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > > - > Devang From sabre at nondot.org Wed Jan 13 15:09:59 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 21:09:59 -0000 Subject: [llvm-commits] [llvm] r93350 - in /llvm/trunk: include/llvm/MC/MCSymbol.h lib/MC/MCSymbol.cpp Message-ID: <201001132109.o0DL9xxM021657@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 15:09:59 2010 New Revision: 93350 URL: http://llvm.org/viewvc/llvm-project?rev=93350&view=rev Log: expose a static function as a static method on the MCSymbol class. Modified: llvm/trunk/include/llvm/MC/MCSymbol.h llvm/trunk/lib/MC/MCSymbol.cpp Modified: llvm/trunk/include/llvm/MC/MCSymbol.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSymbol.h?rev=93350&r1=93349&r2=93350&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCSymbol.h (original) +++ llvm/trunk/include/llvm/MC/MCSymbol.h Wed Jan 13 15:09:59 2010 @@ -136,6 +136,11 @@ /// dump - Print the value to stderr. void dump() const; + + /// printMangledName - Print the specified string in mangled form if it uses + /// any unusual characters. + static void printMangledName(StringRef Str, raw_ostream &OS, + const MCAsmInfo *MAI); }; } // end namespace llvm Modified: llvm/trunk/lib/MC/MCSymbol.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSymbol.cpp?rev=93350&r1=93349&r2=93350&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCSymbol.cpp (original) +++ llvm/trunk/lib/MC/MCSymbol.cpp Wed Jan 13 15:09:59 2010 @@ -52,11 +52,14 @@ return false; } -static void PrintMangledName(raw_ostream &OS, StringRef Str, - const MCAsmInfo &MAI) { +/// printMangledName - Print the specified string in mangled form if it uses +/// any unusual characters. +void MCSymbol::printMangledName(StringRef Str, raw_ostream &OS, + const MCAsmInfo *MAI) { // The first character is not allowed to be a number unless the target // explicitly allows it. - if (!MAI.doesAllowNameToStartWithDigit() && Str[0] >= '0' && Str[0] <= '9') { + if ((MAI == 0 || !MAI->doesAllowNameToStartWithDigit()) && + Str[0] >= '0' && Str[0] <= '9') { MangleLetter(OS, Str[0]); Str = Str.substr(1); } @@ -95,7 +98,7 @@ // On systems that do not allow quoted names, print with mangling. if (!MAI->doesAllowQuotesInName()) - return PrintMangledName(OS, getName(), *MAI); + return printMangledName(getName(), OS, MAI); // If the string contains a double quote or newline, we still have to mangle // it. From sabre at nondot.org Wed Jan 13 15:12:35 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 21:12:35 -0000 Subject: [llvm-commits] [llvm] r93351 - /llvm/trunk/lib/Target/CBackend/CBackend.cpp Message-ID: <201001132112.o0DLCZQn021761@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 15:12:34 2010 New Revision: 93351 URL: http://llvm.org/viewvc/llvm-project?rev=93351&view=rev Log: reduce duplicate mangling logic by using MCSymbol::printMangledName. Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=93351&r1=93350&r2=93351&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Wed Jan 13 15:12:34 2010 @@ -35,6 +35,7 @@ #include "llvm/CodeGen/IntrinsicLowering.h" #include "llvm/Transforms/Scalar.h" #include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCSymbol.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/Support/CallSite.h" @@ -343,31 +344,11 @@ char CWriter::ID = 0; -static bool isAcceptableChar(char C) { - if ((C < 'a' || C > 'z') && (C < 'A' || C > 'Z') && - (C < '0' || C > '9') && C != '_' && C != '$' && C != '@') - return false; - return true; -} - -static char HexDigit(int V) { - return V < 10 ? V+'0' : V+'A'-10; -} - static std::string Mangle(const std::string &S) { std::string Result; - - for (unsigned i = 0, e = S.size(); i != e; ++i) - if (isAcceptableChar(S[i])) - Result += S[i]; - else { - Result += '_'; - Result += HexDigit((S[i] >> 4) & 15); - Result += HexDigit(S[i] & 15); - Result += '_'; - } - - return Result; + raw_string_ostream OS(Result); + MCSymbol::printMangledName(S, OS, 0); + return OS.str(); } From devang.patel at gmail.com Wed Jan 13 15:15:52 2010 From: devang.patel at gmail.com (Devang Patel) Date: Wed, 13 Jan 2010 13:15:52 -0800 Subject: [llvm-commits] [llvm] r93339 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp In-Reply-To: References: <201001131937.o0DJbXO9017579@zion.cs.uiuc.edu> <352a1fb21001131305i49e7e817nda9f224ecb4d6537@mail.gmail.com> Message-ID: <352a1fb21001131315l2fd18436s84afa0767db3215c@mail.gmail.com> On Wed, Jan 13, 2010 at 1:07 PM, Victor Hernandez wrote: > > On Jan 13, 2010, at 1:05 PM, Devang Patel wrote: > >> On Wed, Jan 13, 2010 at 11:37 AM, Victor Hernandez wrote: >> >>> >>> +static void WriteFunctionLocalMetadata(const ValueEnumerator &VE, >>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BitstreamWriter &Stream) { >>> + ?bool StartedMetadataBlock = false; >>> + ?SmallVector Record; >>> + ?ValueEnumerator::ValueList Vals = VE.getMDValues(); >>> + ?ValueEnumerator::ValueList::iterator it = Vals.begin(); >>> + ?ValueEnumerator::ValueList::iterator end = Vals.end(); >>> + >>> + ?while (it != end) { >>> + ? ?if (const MDNode *N = dyn_cast((*it).first)) { >>> + ? ? ?if (N->isFunctionLocal()) { >>> + ? ? ? ?if (!StartedMetadataBlock) { >>> + ? ? ? ? ?Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); >>> + ? ? ? ? ?StartedMetadataBlock = true; >>> + ? ? ? ?} >>> + ? ? ? ?WriteMDNode(N, VE, Stream, Record); >>> + ? ? ? ?// Remove function-local MD, since it is used outside of function. >> >> how ? > > Sorry that is a typo. ?Meant to say "is not used". but why remove from value list ? > >> >>> + ? ? ? ?it = Vals.erase(it); >>> + ? ? ? ?end = Vals.end(); >>> + ? ? ? ?continue; >>> + ? ? ?} >>> + ? ?} >>> + ? ?++it; >>> + ?} >>> + >>> + ?if (StartedMetadataBlock) >>> + ? ?Stream.ExitBlock(); >>> +} >>> + >>> ?static void WriteMetadataAttachment(const Function &F, >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const ValueEnumerator &VE, >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BitstreamWriter &Stream) { >>> @@ -1210,6 +1241,7 @@ >>> ? // Emit names for all the instructions etc. >>> ? WriteValueSymbolTable(F.getValueSymbolTable(), VE, Stream); >>> >>> + ?WriteFunctionLocalMetadata(VE, Stream); >> >> This does not check function so will it write function local metadata >> from one function into another function's block ? > > That check is done by the Verifier. ?Do you think I need to do it here also? Are you sure that incoming VE will not have function local metadata for another function at this point? > >> >>> ? WriteMetadataAttachment(F, VE, Stream); >>> ? VE.purgeFunction(); >>> ? Stream.ExitBlock(); >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> >> >> >> - >> Devang > > -- - Devang From vhernandez at apple.com Wed Jan 13 15:19:59 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Wed, 13 Jan 2010 13:19:59 -0800 Subject: [llvm-commits] [llvm] r93339 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp In-Reply-To: <352a1fb21001131315l2fd18436s84afa0767db3215c@mail.gmail.com> References: <201001131937.o0DJbXO9017579@zion.cs.uiuc.edu> <352a1fb21001131305i49e7e817nda9f224ecb4d6537@mail.gmail.com> <352a1fb21001131315l2fd18436s84afa0767db3215c@mail.gmail.com> Message-ID: <80A05DBF-E67B-4B67-B55E-E5B33A8F95FE@apple.com> On Jan 13, 2010, at 1:15 PM, Devang Patel wrote: > On Wed, Jan 13, 2010 at 1:07 PM, Victor Hernandez wrote: >> >> On Jan 13, 2010, at 1:05 PM, Devang Patel wrote: >> >>> On Wed, Jan 13, 2010 at 11:37 AM, Victor Hernandez wrote: >>> >>>> >>>> +static void WriteFunctionLocalMetadata(const ValueEnumerator &VE, >>>> + BitstreamWriter &Stream) { >>>> + bool StartedMetadataBlock = false; >>>> + SmallVector Record; >>>> + ValueEnumerator::ValueList Vals = VE.getMDValues(); >>>> + ValueEnumerator::ValueList::iterator it = Vals.begin(); >>>> + ValueEnumerator::ValueList::iterator end = Vals.end(); >>>> + >>>> + while (it != end) { >>>> + if (const MDNode *N = dyn_cast((*it).first)) { >>>> + if (N->isFunctionLocal()) { >>>> + if (!StartedMetadataBlock) { >>>> + Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); >>>> + StartedMetadataBlock = true; >>>> + } >>>> + WriteMDNode(N, VE, Stream, Record); >>>> + // Remove function-local MD, since it is used outside of function. >>> >>> how ? >> >> Sorry that is a typo. Meant to say "is not used". > > but why remove from value list ? Because the same ValueList (via VE.getMDValues()) is used during all of the bitcode-writing. Function-local metadata needs to exist in the ValueList only during the writing of the function it is local to (from its lazy enumeration during incorporateFunction until WriteFunctionLocalMetadata() is called). If it does not get removed here, then it will still be in VE.getMDValues() when we go to write the next function. > >> >>> >>>> + it = Vals.erase(it); >>>> + end = Vals.end(); >>>> + continue; >>>> + } >>>> + } >>>> + ++it; >>>> + } >>>> + >>>> + if (StartedMetadataBlock) >>>> + Stream.ExitBlock(); >>>> +} >>>> + >>>> static void WriteMetadataAttachment(const Function &F, >>>> const ValueEnumerator &VE, >>>> BitstreamWriter &Stream) { >>>> @@ -1210,6 +1241,7 @@ >>>> // Emit names for all the instructions etc. >>>> WriteValueSymbolTable(F.getValueSymbolTable(), VE, Stream); >>>> >>>> + WriteFunctionLocalMetadata(VE, Stream); >>> >>> This does not check function so will it write function local metadata >>> from one function into another function's block ? >> >> That check is done by the Verifier. Do you think I need to do it here also? > > Are you sure that incoming VE will not have function local metadata > for another function at this point? Yes, that is guaranteed by removing function-local metadata as soon as they get written. > >> >>> >>>> WriteMetadataAttachment(F, VE, Stream); >>>> VE.purgeFunction(); >>>> Stream.ExitBlock(); >>>> >>>> >>>> _______________________________________________ >>>> llvm-commits mailing list >>>> llvm-commits at cs.uiuc.edu >>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>>> >>> >>> >>> - >>> Devang >> >> > > > > -- > - > Devang -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100113/42a94716/attachment.html From sabre at nondot.org Wed Jan 13 15:21:29 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 21:21:29 -0000 Subject: [llvm-commits] [llvm] r93352 - /llvm/trunk/lib/MC/MCSectionELF.cpp Message-ID: <201001132121.o0DLLTa0022100@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 15:21:29 2010 New Revision: 93352 URL: http://llvm.org/viewvc/llvm-project?rev=93352&view=rev Log: tidy Modified: llvm/trunk/lib/MC/MCSectionELF.cpp Modified: llvm/trunk/lib/MC/MCSectionELF.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSectionELF.cpp?rev=93352&r1=93351&r2=93352&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCSectionELF.cpp (original) +++ llvm/trunk/lib/MC/MCSectionELF.cpp Wed Jan 13 15:21:29 2010 @@ -8,10 +8,10 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCSectionELF.h" +#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" +#include "llvm/MC/MCSymbol.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/MC/MCAsmInfo.h" - using namespace llvm; MCSectionELF *MCSectionELF:: @@ -23,7 +23,7 @@ // ShouldOmitSectionDirective - Decides whether a '.section' directive // should be printed before the section name bool MCSectionELF::ShouldOmitSectionDirective(const char *Name, - const MCAsmInfo &MAI) const { + const MCAsmInfo &MAI) const { // FIXME: Does .section .bss/.data/.text work everywhere?? if (strcmp(Name, ".text") == 0 || @@ -37,7 +37,6 @@ // ShouldPrintSectionType - Only prints the section type if supported bool MCSectionELF::ShouldPrintSectionType(unsigned Ty) const { - if (IsExplicit && !(Ty == SHT_NOBITS || Ty == SHT_PROGBITS)) return false; From vhernandez at apple.com Wed Jan 13 15:23:25 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Wed, 13 Jan 2010 13:23:25 -0800 Subject: [llvm-commits] [llvm] r93338 - in /llvm/trunk/lib/Bitcode/Writer: ValueEnumerator.cpp ValueEnumerator.h In-Reply-To: <352a1fb21001131300q21c970c1r4ad677849aa3fc20@mail.gmail.com> References: <201001131936.o0DJaGrj017512@zion.cs.uiuc.edu> <352a1fb21001131300q21c970c1r4ad677849aa3fc20@mail.gmail.com> Message-ID: <10AD2E2C-7D7A-4B5F-847A-EE228B900962@apple.com> On Jan 13, 2010, at 1:00 PM, Devang Patel wrote: > On Wed, Jan 13, 2010 at 11:36 AM, Victor Hernandez wrote: > >> -void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD) { >> +void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD, bool isGlobal) { >> // Check to see if it's already in! >> unsigned &MDValueID = MDValueMap[MD]; >> if (MDValueID) { >> @@ -237,14 +237,18 @@ >> EnumerateType(MD->getType()); >> >> if (const MDNode *N = dyn_cast(MD)) { >> - MDValues.push_back(std::make_pair(MD, 1U)); >> - MDValueMap[MD] = MDValues.size(); >> - MDValueID = MDValues.size(); >> - for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { >> - if (Value *V = N->getOperand(i)) >> - EnumerateValue(V); >> - else >> - EnumerateType(Type::getVoidTy(MD->getContext())); >> + if ((isGlobal && !N->isFunctionLocal()) || >> + (!isGlobal && N->isFunctionLocal())) { > > What are the cases where isGlobal does not match N->isFunctionLocal() ? Prehaps isGlobal is not the best name, it means not-during-function-incorporation. I think I should improve that variable name. The case I have encountered is: 1. During ValueEnumerator creation (isGlobal = true), all metadata is iterated over, including those inside of functions, and the isFunctionLocal() metadata needs to be ignored until lazy function incorporation is done. The other case should be when incorporateFunction (isGlobal = false) comes across a non-function-local metadata. But in that case the lookup of it in MDValueMap should have succeeded and we will not reach here. > - > Devang From vhernandez at apple.com Wed Jan 13 15:25:05 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Wed, 13 Jan 2010 21:25:05 -0000 Subject: [llvm-commits] [llvm] r93355 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Message-ID: <201001132125.o0DLP5Mk022263@zion.cs.uiuc.edu> Author: hernande Date: Wed Jan 13 15:25:04 2010 New Revision: 93355 URL: http://llvm.org/viewvc/llvm-project?rev=93355&view=rev Log: Fix comment typo Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=93355&r1=93354&r2=93355&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Wed Jan 13 15:25:04 2010 @@ -570,7 +570,7 @@ StartedMetadataBlock = true; } WriteMDNode(N, VE, Stream, Record); - // Remove function-local MD, since it is used outside of function. + // Remove function-local MD, since it is not used outside of function. it = Vals.erase(it); end = Vals.end(); continue; From sabre at nondot.org Wed Jan 13 15:29:21 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 21:29:21 -0000 Subject: [llvm-commits] [llvm] r93356 - /llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Message-ID: <201001132129.o0DLTLuA022483@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 15:29:21 2010 New Revision: 93356 URL: http://llvm.org/viewvc/llvm-project?rev=93356&view=rev Log: fix ELF section mangling stuff for weak symbols to not use obsolete Mangler interfaces. Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=93356&r1=93355&r2=93356&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Wed Jan 13 15:29:21 2010 @@ -21,11 +21,13 @@ #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionELF.h" +#include "llvm/MC/MCSymbol.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Mangler.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" using namespace llvm; @@ -576,16 +578,16 @@ // into a 'uniqued' section name, create and return the section now. if (GV->isWeakForLinker()) { const char *Prefix = getSectionPrefixForUniqueGlobal(Kind); - SmallString<128> Name; + SmallString<128> Name, MangledName; Name.append(Prefix, Prefix+strlen(Prefix)); - // FIXME: This will fail for weak globals with no names, this also depends - // on the mangling behavior of makeNameProper to mangle the section name - // before construction. Instead, this should use getNameWithPrefix on the - // global variable and the MCSection printing code should do the mangling. - Mang->makeNameProper(Name, GV->getName()); - - return getELFSection(Name.str(), - getELFSectionType(Name.str(), Kind), + Mang->getNameWithPrefix(Name, GV, false); + + raw_svector_ostream OS(MangledName); + MCSymbol::printMangledName(Name, OS, 0); + OS.flush(); + + return getELFSection(MangledName.str(), + getELFSectionType(MangledName.str(), Kind), getELFSectionFlags(Kind), Kind); } From sabre at nondot.org Wed Jan 13 15:31:39 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 21:31:39 -0000 Subject: [llvm-commits] [llvm] r93357 - /llvm/trunk/include/llvm/Support/Mangler.h Message-ID: <201001132131.o0DLVd2O022611@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 15:31:39 2010 New Revision: 93357 URL: http://llvm.org/viewvc/llvm-project?rev=93357&view=rev Log: makeNameProper is now private! Modified: llvm/trunk/include/llvm/Support/Mangler.h Modified: llvm/trunk/include/llvm/Support/Mangler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=93357&r1=93356&r2=93357&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Mangler.h (original) +++ llvm/trunk/include/llvm/Support/Mangler.h Wed Jan 13 15:31:39 2010 @@ -108,6 +108,19 @@ std::string getMangledName(const GlobalValue *V, const char *Suffix = "", bool ForcePrivate = false); + /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix + /// and the specified global variable's name. If the global variable doesn't + /// have a name, this fills in a unique name for the global. + void getNameWithPrefix(SmallVectorImpl &OutName, const GlobalValue *GV, + bool isImplicitlyPrivate); + + /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix + /// and the specified name as the global variable name. GVName must not be + /// empty. + void getNameWithPrefix(SmallVectorImpl &OutName, const Twine &GVName, + ManglerPrefixTy PrefixTy = Mangler::Default); + +private: /// makeNameProper - We don't want identifier names with ., space, or /// - in them, so we mangle these characters into the strings "d_", /// "s_", and "D_", respectively. This is a very simple mangling that @@ -122,17 +135,6 @@ const Twine &Name, ManglerPrefixTy PrefixTy = Mangler::Default); - /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix - /// and the specified global variable's name. If the global variable doesn't - /// have a name, this fills in a unique name for the global. - void getNameWithPrefix(SmallVectorImpl &OutName, const GlobalValue *GV, - bool isImplicitlyPrivate); - - /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix - /// and the specified name as the global variable name. GVName must not be - /// empty. - void getNameWithPrefix(SmallVectorImpl &OutName, const Twine &GVName, - ManglerPrefixTy PrefixTy = Mangler::Default); }; } // End llvm namespace From clattner at apple.com Wed Jan 13 15:34:44 2010 From: clattner at apple.com (Chris Lattner) Date: Wed, 13 Jan 2010 13:34:44 -0800 Subject: [llvm-commits] [PATCH 1/2] Extend SuccIterator In-Reply-To: <696c556ec1eb9711328c99fcc3cdce51b7546e09.1263252928.git.grosser@fim.uni-passau.de> References: <696c556ec1eb9711328c99fcc3cdce51b7546e09.1263252928.git.grosser@fim.uni-passau.de> Message-ID: On Jan 11, 2010, at 3:36 PM, Tobias Grosser wrote: > > Implement most of the missing methods to make SuccIterator random > access. > operator[] is still missing. LGTM, please commit. -Chris > --- > include/llvm/Support/CFG.h | 63 +++++++++++++++++++++++++++++++++++ > ++++++++- > 1 files changed, 62 insertions(+), 1 deletions(-) > > <0001-Extend- > SuccIterator.patch>_______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Wed Jan 13 15:35:15 2010 From: clattner at apple.com (Chris Lattner) Date: Wed, 13 Jan 2010 13:35:15 -0800 Subject: [llvm-commits] [PATCH 2/2] Add getSource() to SuccIterator In-Reply-To: <1c4b0b493785abc788bae2af36045f02bcdf85ad.1263252928.git.grosser@fim.uni-passau.de> References: <1c4b0b493785abc788bae2af36045f02bcdf85ad.1263252928.git.grosser@fim.uni-passau.de> Message-ID: <6FB0B10A-C408-4C46-910C-83434FE23D75@apple.com> On Jan 11, 2010, at 3:36 PM, Tobias Grosser wrote: > > Get the source BB of an iterator. Sure, seems fine. Please make it a doxygen comment with 3 ///'s From devang.patel at gmail.com Wed Jan 13 15:46:27 2010 From: devang.patel at gmail.com (Devang Patel) Date: Wed, 13 Jan 2010 13:46:27 -0800 Subject: [llvm-commits] [llvm] r93339 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp In-Reply-To: <80A05DBF-E67B-4B67-B55E-E5B33A8F95FE@apple.com> References: <201001131937.o0DJbXO9017579@zion.cs.uiuc.edu> <352a1fb21001131305i49e7e817nda9f224ecb4d6537@mail.gmail.com> <352a1fb21001131315l2fd18436s84afa0767db3215c@mail.gmail.com> <80A05DBF-E67B-4B67-B55E-E5B33A8F95FE@apple.com> Message-ID: <352a1fb21001131346w5b765debraa3159e87d1cbd0d@mail.gmail.com> On Wed, Jan 13, 2010 at 1:19 PM, Victor Hernandez wrote: > > On Jan 13, 2010, at 1:15 PM, Devang Patel wrote: > > On Wed, Jan 13, 2010 at 1:07 PM, Victor Hernandez > wrote: > > On Jan 13, 2010, at 1:05 PM, Devang Patel wrote: > > On Wed, Jan 13, 2010 at 11:37 AM, Victor Hernandez > wrote: > > > +static void WriteFunctionLocalMetadata(const ValueEnumerator &VE, > > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BitstreamWriter &Stream) { > > + ?bool StartedMetadataBlock = false; > > + ?SmallVector Record; > > + ?ValueEnumerator::ValueList Vals = VE.getMDValues(); > > + ?ValueEnumerator::ValueList::iterator it = Vals.begin(); > > + ?ValueEnumerator::ValueList::iterator end = Vals.end(); > > + > > + ?while (it != end) { > > + ? ?if (const MDNode *N = dyn_cast((*it).first)) { > > + ? ? ?if (N->isFunctionLocal()) { > > + ? ? ? ?if (!StartedMetadataBlock) { > > + ? ? ? ? ?Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); > > + ? ? ? ? ?StartedMetadataBlock = true; > > + ? ? ? ?} > > + ? ? ? ?WriteMDNode(N, VE, Stream, Record); > > + ? ? ? ?// Remove function-local MD, since it is used outside of function. > > how ? > > Sorry that is a typo. ?Meant to say "is not used". > > but why remove from value list ? > > Because the same ValueList (via?VE.getMDValues()) is used during all of the > bitcode-writing. ?Function-local metadata needs to exist in the ValueList > only during the writing of the function it is local to (from its lazy > enumeration during incorporateFunction until?WriteFunctionLocalMetadata() is > called). ?If it does not get removed here, then it will still be > in?VE.getMDValues() when we go to write the next function. > > > > + ? ? ? ?it = Vals.erase(it); > > + ? ? ? ?end = Vals.end(); > > + ? ? ? ?continue; > > + ? ? ?} > > + ? ?} > > + ? ?++it; > > + ?} > > + > > + ?if (StartedMetadataBlock) > > + ? ?Stream.ExitBlock(); > > +} > > + > > ?static void WriteMetadataAttachment(const Function &F, > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const ValueEnumerator &VE, > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BitstreamWriter &Stream) { > > @@ -1210,6 +1241,7 @@ > > ? // Emit names for all the instructions etc. > > ? WriteValueSymbolTable(F.getValueSymbolTable(), VE, Stream); > > + ?WriteFunctionLocalMetadata(VE, Stream); > > This does not check function so will it write function local metadata > > from one function into another function's block ? > > That check is done by the Verifier. ?Do you think I need to do it here also? > > Are you sure that incoming VE will not have function local metadata > for another function at this point? > > Yes, that is guaranteed by removing function-local metadata as soon as they > get written. > ValueList is not manipulated like this in BitCode Writer. Erasing element one by one from ValueList may have performance impact. Instead, it is better to keep ValueList intact and check function in WriteFunctionLocalMetadata() and update isFunctionLocal() to return Function *. - Devang From sabre at nondot.org Wed Jan 13 15:51:41 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 21:51:41 -0000 Subject: [llvm-commits] [llvm] r93360 - /llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll Message-ID: <201001132151.o0DLpfIK023395@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 15:51:41 2010 New Revision: 93360 URL: http://llvm.org/viewvc/llvm-project?rev=93360&view=rev Log: this test requires SSE, thanks to jyasskin for pointing this out. Modified: llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll Modified: llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll?rev=93360&r1=93359&r2=93360&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-01-07-UAMemFeature.ll Wed Jan 13 15:51:41 2010 @@ -1,4 +1,4 @@ -; RUN: llc -mattr=vector-unaligned-mem -march=x86 < %s | FileCheck %s +; RUN: llc -mcpu=yonah -mattr=vector-unaligned-mem -march=x86 < %s | FileCheck %s ; CHECK: addps ( 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" From devang.patel at gmail.com Wed Jan 13 16:01:30 2010 From: devang.patel at gmail.com (Devang Patel) Date: Wed, 13 Jan 2010 14:01:30 -0800 Subject: [llvm-commits] [llvm] r93338 - in /llvm/trunk/lib/Bitcode/Writer: ValueEnumerator.cpp ValueEnumerator.h In-Reply-To: <10AD2E2C-7D7A-4B5F-847A-EE228B900962@apple.com> References: <201001131936.o0DJaGrj017512@zion.cs.uiuc.edu> <352a1fb21001131300q21c970c1r4ad677849aa3fc20@mail.gmail.com> <10AD2E2C-7D7A-4B5F-847A-EE228B900962@apple.com> Message-ID: <352a1fb21001131401i4c612f5fj2f26f0ee9982c2c1@mail.gmail.com> On Wed, Jan 13, 2010 at 1:23 PM, Victor Hernandez wrote: > > On Jan 13, 2010, at 1:00 PM, Devang Patel wrote: > >> On Wed, Jan 13, 2010 at 11:36 AM, Victor Hernandez wrote: >> >>> -void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD) { >>> +void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD, bool isGlobal) { >>> ? // Check to see if it's already in! >>> ? unsigned &MDValueID = MDValueMap[MD]; >>> ? if (MDValueID) { >>> @@ -237,14 +237,18 @@ >>> ? EnumerateType(MD->getType()); >>> >>> ? if (const MDNode *N = dyn_cast(MD)) { >>> - ? ?MDValues.push_back(std::make_pair(MD, 1U)); >>> - ? ?MDValueMap[MD] = MDValues.size(); >>> - ? ?MDValueID = MDValues.size(); >>> - ? ?for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { >>> - ? ? ?if (Value *V = N->getOperand(i)) >>> - ? ? ? ?EnumerateValue(V); >>> - ? ? ?else >>> - ? ? ? ?EnumerateType(Type::getVoidTy(MD->getContext())); >>> + ? ?if ((isGlobal && !N->isFunctionLocal()) || >>> + ? ? ? ?(!isGlobal && N->isFunctionLocal())) { >> >> What are the cases where isGlobal does not match N->isFunctionLocal() ?? > > Prehaps isGlobal is not the best name, it means not-during-function-incorporation. ?I think I should improve that variable name. > > The case I have encountered is: > 1. During ValueEnumerator creation (isGlobal = true), all metadata is iterated over, including those inside of functions, and the isFunctionLocal() metadata needs to be ignored until lazy function incorporation is done. > > The other case should be when incorporateFunction (isGlobal = false) comes across a non-function-local metadata. ?But in that case the lookup of it in MDValueMap should have succeeded and we will not reach here. > This looks like a very complex approach! I do not like adding extra parameter to EnumerateOperandType() just for this purpose. Is there a alternative ? What if you - ignore function local metadata while processing function args in ValueEnumerator construction - ignore non function local metadata while processing function args in ValueEnumerator::incorporateFunction() ? This way you do not need to modify any interface. ? - Devang From grosser at fim.uni-passau.de Wed Jan 13 16:21:28 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Wed, 13 Jan 2010 22:21:28 -0000 Subject: [llvm-commits] [llvm] r93363 - /llvm/trunk/include/llvm/Support/CFG.h Message-ID: <201001132221.o0DMLT9J024497@zion.cs.uiuc.edu> Author: grosser Date: Wed Jan 13 16:21:28 2010 New Revision: 93363 URL: http://llvm.org/viewvc/llvm-project?rev=93363&view=rev Log: Extend SuccIterator Implement most of the missing methods to make SuccIterator random access. operator[] is still missing. 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=93363&r1=93362&r2=93363&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CFG.h (original) +++ llvm/trunk/include/llvm/Support/CFG.h Wed Jan 13 16:21:28 2010 @@ -93,7 +93,7 @@ public: typedef SuccIterator _Self; typedef typename super::pointer pointer; - // TODO: This can be random access iterator, need operator+ and stuff tho + // TODO: This can be random access iterator, only operator[] missing. inline SuccIterator(Term_ T) : Term(T), idx(0) { // begin iterator assert(T && "getTerminator returned null!"); @@ -109,6 +109,10 @@ return *this; } + inline bool index_is_valid (int idx) { + return idx >= 0 && (unsigned) idx < Term->getNumSuccessors(); + } + /// getSuccessorIndex - This is used to interface between code that wants to /// operate on terminator instructions directly. unsigned getSuccessorIndex() const { return idx; } @@ -120,6 +124,7 @@ inline pointer operator->() const { return operator*(); } inline _Self& operator++() { ++idx; return *this; } // Preincrement + inline _Self operator++(int) { // Postincrement _Self tmp = *this; ++*this; return tmp; } @@ -128,6 +133,62 @@ inline _Self operator--(int) { // Postdecrement _Self tmp = *this; --*this; return tmp; } + + inline bool operator<(const _Self& x) const { + assert(Term == x.Term && "Cannot compare iterators of different blocks!"); + return idx < x.idx; + } + + inline bool operator<=(const _Self& x) const { + assert(Term == x.Term && "Cannot compare iterators of different blocks!"); + return idx <= x.idx; + } + inline bool operator>=(const _Self& x) const { + assert(Term == x.Term && "Cannot compare iterators of different blocks!"); + return idx >= x.idx; + } + + inline bool operator>(const _Self& x) const { + return idx > x.idx; + assert(Term == x.Term && "Cannot compare iterators of different blocks!"); + } + + inline _Self& operator+=(int Right) { + unsigned new_idx = idx + Right; + assert(index_is_valid(new_idx) && "Iterator index out of bound"); + idx = new_idx; + return *this; + } + + inline _Self operator+(int Right) { + _Self tmp = *this; + tmp += Right; + return tmp; + } + + inline _Self& operator-=(int Right) { + return operator+=(-Right); + } + + inline _Self operator-(int Right) { + return operator+(-Right); + } + + inline int operator-(const _Self& x) { + assert(Term == x.Term && "Cannot work on iterators of different blocks!"); + int distance = idx - x.idx; + return distance; + } + + // This works for read access, however write access is difficult as changes + // to Term are only possible with Term->setSuccessor(idx). Pointers that can + // be modified are not available. + // + // inline pointer operator[](int offset) { + // _Self tmp = *this; + // tmp += offset; + // return tmp.operator*(); + // } }; typedef SuccIterator succ_iterator; From grosser at fim.uni-passau.de Wed Jan 13 16:21:43 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Wed, 13 Jan 2010 22:21:43 -0000 Subject: [llvm-commits] [llvm] r93364 - /llvm/trunk/include/llvm/Support/CFG.h Message-ID: <201001132221.o0DMLhe5024514@zion.cs.uiuc.edu> Author: grosser Date: Wed Jan 13 16:21:43 2010 New Revision: 93364 URL: http://llvm.org/viewvc/llvm-project?rev=93364&view=rev Log: Add getSource() to SuccIterator Get the source BB of an iterator. 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=93364&r1=93363&r2=93364&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CFG.h (original) +++ llvm/trunk/include/llvm/Support/CFG.h Wed Jan 13 16:21:43 2010 @@ -189,6 +189,11 @@ // tmp += offset; // return tmp.operator*(); // } + + /// Get the source BB of this iterator. + inline BB_ *getSource() { + return Term->getParent(); + } }; typedef SuccIterator succ_iterator; From grosbach at apple.com Wed Jan 13 16:37:43 2010 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 13 Jan 2010 22:37:43 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93366 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <201001132237.o0DMbhI7025147@zion.cs.uiuc.edu> Author: grosbach Date: Wed Jan 13 16:37:43 2010 New Revision: 93366 URL: http://llvm.org/viewvc/llvm-project?rev=93366&view=rev Log: No fetch-and-add for Thumb1. Copy/Paste-o error. 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=93366&r1=93365&r2=93366&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Jan 13 16:37:43 2010 @@ -5294,6 +5294,10 @@ case BUILT_IN_FETCH_AND_ADD_1: case BUILT_IN_FETCH_AND_ADD_2: case BUILT_IN_FETCH_AND_ADD_4: { +#if defined(TARGET_ARM) + if (TARGET_THUMB1 || !arm_arch6) + return false; +#endif Result = BuildBinaryAtomicBuiltin(exp, Intrinsic::atomic_load_add); return true; } From espindola at google.com Wed Jan 13 16:42:59 2010 From: espindola at google.com (Rafael Espindola) Date: Wed, 13 Jan 2010 17:42:59 -0500 Subject: [llvm-commits] [patch] Add support for emulators in RunSafely.sh Message-ID: <38a0d8451001131442q334aaacftfc638aee8671f456@mail.gmail.com> The attached patch adds support for running the llvm testsuite with an emulator. This is handy when a real device is not available and a patch needs more testing then just a "make check". Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: emulator.patch Type: text/x-diff Size: 1671 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100113/6af4b7d7/attachment.bin From nlewycky at google.com Wed Jan 13 16:51:26 2010 From: nlewycky at google.com (Nick Lewycky) Date: Wed, 13 Jan 2010 14:51:26 -0800 Subject: [llvm-commits] [patch] Add support for emulators in RunSafely.sh In-Reply-To: <38a0d8451001131442q334aaacftfc638aee8671f456@mail.gmail.com> References: <38a0d8451001131442q334aaacftfc638aee8671f456@mail.gmail.com> Message-ID: This could be used for a valgrind as well, for example. Maybe the flag should be named "run_under" instead of emulator? I'm on the fence on that because valgrind really is an emulator under the hood. This isn't compatible GET_STABLE_NUMBERS, nor remote execution. Instead of modifying just one RUNSAFELY line to add $(EMULATOR_OPT), you should put: ifdef EMULATOR RUNSAFELY := $(RUNSAFELY) $(EMULATOR_OPT) endif at line 109. Nick On 13 January 2010 14:42, Rafael Espindola wrote: > The attached patch adds support for running the llvm testsuite with an > emulator. This is handy when a real device is not available and a > patch needs more testing then just a "make check". > > Cheers, > -- > Rafael ?vila de Esp?ndola > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100113/7bb23be0/attachment.html From espindola at google.com Wed Jan 13 17:18:00 2010 From: espindola at google.com (Rafael Espindola) Date: Wed, 13 Jan 2010 18:18:00 -0500 Subject: [llvm-commits] [patch] Add support for emulators in RunSafely.sh In-Reply-To: References: <38a0d8451001131442q334aaacftfc638aee8671f456@mail.gmail.com> Message-ID: <38a0d8451001131518i721591d1vea33e6d7efa7f097@mail.gmail.com> 2010/1/13 Nick Lewycky : > This could be used for a valgrind as well, for example. Maybe the flag > should be named "run_under" instead of emulator? I'm on the fence on that > because valgrind really is an emulator under the hood. It could be something else, so it is a good point. > This isn't compatible GET_STABLE_NUMBERS, nor remote execution. Instead of > modifying just one RUNSAFELY line to add $(EMULATOR_OPT), you should put: > > ? ifdef EMULATOR > ??? RUNSAFELY := $(RUNSAFELY) $(EMULATOR_OPT) > ? endif > > at line 109. Updated patch attached. I am testing it. > Nick Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: run-under.patch Type: text/x-diff Size: 1477 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100113/9c49b542/attachment.bin From nlewycky at google.com Wed Jan 13 17:19:04 2010 From: nlewycky at google.com (Nick Lewycky) Date: Wed, 13 Jan 2010 15:19:04 -0800 Subject: [llvm-commits] [patch] Add support for emulators in RunSafely.sh In-Reply-To: <38a0d8451001131518i721591d1vea33e6d7efa7f097@mail.gmail.com> References: <38a0d8451001131442q334aaacftfc638aee8671f456@mail.gmail.com> <38a0d8451001131518i721591d1vea33e6d7efa7f097@mail.gmail.com> Message-ID: On 13 January 2010 15:18, Rafael Espindola wrote: > 2010/1/13 Nick Lewycky : > > This could be used for a valgrind as well, for example. Maybe the flag > > should be named "run_under" instead of emulator? I'm on the fence on that > > because valgrind really is an emulator under the hood. > > It could be something else, so it is a good point. > Looks good to me. Thanks Rafael! Nick > > This isn't compatible GET_STABLE_NUMBERS, nor remote execution. Instead > of > > modifying just one RUNSAFELY line to add $(EMULATOR_OPT), you should put: > > > > ifdef EMULATOR > > RUNSAFELY := $(RUNSAFELY) $(EMULATOR_OPT) > > endif > > > > at line 109. > > Updated patch attached. I am testing it. > > > Nick > > Cheers, > -- > Rafael ?vila de Esp?ndola > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100113/8ea07ac0/attachment.html From bob.wilson at apple.com Wed Jan 13 17:21:51 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 13 Jan 2010 23:21:51 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93368 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h Message-ID: <201001132321.o0DNLpWe026805@zion.cs.uiuc.edu> Author: bwilson Date: Wed Jan 13 17:21:50 2010 New Revision: 93368 URL: http://llvm.org/viewvc/llvm-project?rev=93368&view=rev Log: Fix problems passing aggregates for ARM. There are several components of this: * The PassInIntegerRegisters method needs to divide the aggregate into 32-bit units and not use 64-bit integers for ARM. The patch adds a check to see if the target supports 64-bit integers as a legal type. If not, it will use 32-bit integers. It is possible that some target might want to do something different, but this seems like a much more reasonable default behavior. Every 32-bit target that I've worked with divides arguments into 32-bit units like this. * If there are any "leftover" bytes that do not fit into the array of 32- or 64-bit integers, they need to be passed as a single integer that is big enough to hold them (possibly bigger). The previous code that split those bytes into multiple integers was wrong for any target ABI where each of those integers will be passed in a separate register. * For the last "leftover" value, the HandleScalarArgument method needs to have its "RealSize" argument set. This is to handle cases where the "leftover" integer type is bigger than than actual data (e.g., using an i32 to pass 3 bytes). This is already done by the PassInMixedRegisters code. There was some discussion on the mailing list, following previous attempts to fix this, about using "byval" to pass aggregates for ARM. I looked into that and decided that it would be more work than I have time for right now. This patch makes the default behavior much more reasonable. It also correctly handles the ARM AAPCS ABI for both big- and little-endian targets and the APCS ABI for little-endian targets. The big-endian APCS ABI pads small aggregates (smaller than 32-bits) differently, and "byval" might still be the best way to handle that, if anyone even cares about big-endian APCS. I've run the GCC "compat" testsuite for x86-32, x86-64, powerpc and ARM (all on Darwin) to verify that this does not break anything. For ARM (little-endian APCS), it fixes almost all of the previous failures: Running ....testsuite/gcc.dg/compat/compat.exp ... WARNING: program timed out. FAIL: gcc.dg/compat/struct-by-value-15 c_compat_x_tst.o compile WARNING: program timed out. FAIL: gcc.dg/compat/struct-by-value-17 c_compat_x_tst.o compile WARNING: program timed out. FAIL: gcc.dg/compat/struct-by-value-18 c_compat_x_tst.o compile FAIL: gcc.dg/compat/struct-by-value-9 c_compat_x_tst.o-c_compat_y_tst.o execute FAIL: gcc.dg/compat/struct-by-value-9 c_compat_x_tst.o-c_compat_y_alt.o execute FAIL: gcc.dg/compat/vector-1 c_compat_x_tst.o-c_compat_y_alt.o execute FAIL: gcc.dg/compat/vector-1 c_compat_x_alt.o-c_compat_y_tst.o execute (I was testing a debug build, so hopefully those timeouts would not occur with an optimized build.) The other targets were unaffected by this change. This fixes pr5406 and Apple radars 7226213 and 7226380. Many thanks to Rafael ?vila de Esp?ndola for his help with this! Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=93368&r1=93367&r2=93368&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Wed Jan 13 17:21:50 2010 @@ -610,8 +610,9 @@ // from Int64 alignment. ARM backend needs this. unsigned Align = TYPE_ALIGN(type)/8; unsigned Int64Align = - getTargetData().getABITypeAlignment(Type::getInt64Ty(getGlobalContext())); - bool UseInt64 = DontCheckAlignment ? true : (Align >= Int64Align); + getTargetData().getABITypeAlignment(Type::getInt64Ty(getGlobalContext())); + bool UseInt64 = (getTargetData().isLegalInteger(64) && + (DontCheckAlignment || Align >= Int64Align)); // FIXME: In cases where we can, we should use the original struct. // Consider cases like { int, int } and {int, short} for example! This will @@ -621,29 +622,36 @@ unsigned ElementSize = UseInt64 ? 8:4; unsigned ArraySize = Size / ElementSize; + // Put as much of the aggregate as possible into an array. const Type *ATy = NULL; const Type *ArrayElementType = NULL; if (ArraySize) { Size = Size % ElementSize; - ArrayElementType = (UseInt64) ? - Type::getInt64Ty(getGlobalContext()) : Type::getInt32Ty(getGlobalContext()); + ArrayElementType = (UseInt64 ? + Type::getInt64Ty(getGlobalContext()) : + Type::getInt32Ty(getGlobalContext())); ATy = ArrayType::get(ArrayElementType, ArraySize); Elts.push_back(ATy); } - if (Size >= 4) { - Elts.push_back(Type::getInt32Ty(getGlobalContext())); - Size -= 4; - } - if (Size >= 2) { - Elts.push_back(Type::getInt16Ty(getGlobalContext())); - Size -= 2; - } - if (Size >= 1) { - Elts.push_back(Type::getInt8Ty(getGlobalContext())); - Size -= 1; + // Pass any leftover bytes as a separate element following the array. + unsigned LastEltRealSize = 0; + const llvm::Type *LastEltTy = 0; + if (Size > 4) { + LastEltTy = Type::getInt64Ty(getGlobalContext()); + } else if (Size > 2) { + LastEltTy = Type::getInt32Ty(getGlobalContext()); + } else if (Size > 1) { + LastEltTy = Type::getInt16Ty(getGlobalContext()); + } else if (Size > 0) { + LastEltTy = Type::getInt8Ty(getGlobalContext()); + } + if (LastEltTy) { + Elts.push_back(LastEltTy); + if (Size != getTargetData().getTypeAllocSize(LastEltTy)) + LastEltRealSize = Size; } - assert(Size == 0 && "Didn't cover value?"); + const StructType *STy = StructType::get(getGlobalContext(), Elts, false); unsigned i = 0; @@ -658,10 +666,10 @@ C.ExitField(); ++i; } - for (unsigned e = Elts.size(); i != e; ++i) { + if (LastEltTy) { C.EnterField(i, STy); - C.HandleScalarArgument(Elts[i], 0); - ScalarElts.push_back(Elts[i]); + C.HandleScalarArgument(LastEltTy, 0, LastEltRealSize); + ScalarElts.push_back(LastEltTy); C.ExitField(); } } From isanbard at gmail.com Wed Jan 13 17:23:17 2010 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 13 Jan 2010 23:23:17 -0000 Subject: [llvm-commits] [llvm] r93369 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineAddSub.cpp test/Transforms/InstCombine/fsub-fadd.ll Message-ID: <201001132323.o0DNNIpO026876@zion.cs.uiuc.edu> Author: void Date: Wed Jan 13 17:23:17 2010 New Revision: 93369 URL: http://llvm.org/viewvc/llvm-project?rev=93369&view=rev Log: When the visitSub method was split into visitSub and visitFSub, this xform was added to the FSub version. However, the original version of this xform guarded against doing this for floating point (!Op0->getType()->isFPOrFPVector()). This is causing LLVM to perform incorrect xforms for code like: void func(double *rhi, double *rlo, double xh, double xl, double yh, double yl){ double mh, ml; double c = 134217729.0; double up, u1, u2, vp, v1, v2; up = xh*c; u1 = (xh - up) + up; u2 = xh - u1; vp = yh*c; v1 = (yh - vp) + vp; v2 = yh - v1; mh = xh*yh; ml = (((u1*v1 - mh) + (u1*v2)) + (u2*v1)) + (u2*v2); ml += xh*yl + xl*yh; *rhi = mh + ml; *rlo = (mh - (*rhi)) + ml; } The last line was optimized away, but rl is intended to be the difference between the infinitely precise result of mh + ml and after it has been rounded to double precision. Added: llvm/trunk/test/Transforms/InstCombine/fsub-fadd.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp?rev=93369&r1=93368&r2=93369&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp Wed Jan 13 17:23:17 2010 @@ -736,16 +736,5 @@ if (Value *V = dyn_castFNegVal(Op1)) return BinaryOperator::CreateFAdd(Op0, V); - if (BinaryOperator *Op1I = dyn_cast(Op1)) { - if (Op1I->getOpcode() == Instruction::FAdd) { - if (Op1I->getOperand(0) == Op0) // X-(X+Y) == -Y - return BinaryOperator::CreateFNeg(Op1I->getOperand(1), - I.getName()); - else if (Op1I->getOperand(1) == Op0) // X-(Y+X) == -Y - return BinaryOperator::CreateFNeg(Op1I->getOperand(0), - I.getName()); - } - } - return 0; } Added: llvm/trunk/test/Transforms/InstCombine/fsub-fadd.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fsub-fadd.ll?rev=93369&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/fsub-fadd.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/fsub-fadd.ll Wed Jan 13 17:23:17 2010 @@ -0,0 +1,39 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s +; + +define void @func(double* %rhi, double* %rlo, double %xh, double %xl, double %yh, double %yl) nounwind ssp { +entry: + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + %tmp = fmul double %xh, 0x41A0000002000000 ; [#uses=2] + %tmp1 = fsub double %xh, %tmp ; [#uses=1] + %tmp2 = fadd double %tmp1, %tmp ; [#uses=3] + %tmp3 = fsub double %xh, %tmp2 ; [#uses=2] + %tmp4 = fmul double %yh, 0x41A0000002000000 ; [#uses=2] + %tmp5 = fsub double %yh, %tmp4 ; [#uses=1] + %tmp6 = fadd double %tmp5, %tmp4 ; [#uses=3] + %tmp7 = fsub double %yh, %tmp6 ; [#uses=2] + %tmp8 = fmul double %xh, %yh ; [#uses=3] + %tmp9 = fmul double %tmp2, %tmp6 ; [#uses=1] + %tmp10 = fsub double %tmp9, %tmp8 ; [#uses=1] + %tmp11 = fmul double %tmp2, %tmp7 ; [#uses=1] + %tmp12 = fadd double %tmp10, %tmp11 ; [#uses=1] + %tmp13 = fmul double %tmp3, %tmp6 ; [#uses=1] + %tmp14 = fadd double %tmp12, %tmp13 ; [#uses=1] + %tmp15 = fmul double %tmp3, %tmp7 ; [#uses=1] + %tmp16 = fadd double %tmp14, %tmp15 ; [#uses=1] + %tmp17 = fmul double %xh, %yl ; [#uses=1] + %tmp18 = fmul double %xl, %yh ; [#uses=1] + %tmp19 = fadd double %tmp17, %tmp18 ; [#uses=1] + %tmp20 = fadd double %tmp19, %tmp16 ; [#uses=2] + %tmp21 = fadd double %tmp8, %tmp20 ; [#uses=1] + store double %tmp21, double* %rhi, align 8 + %tmp22 = load double* %rhi, align 8 ; [#uses=1] + %tmp23 = fsub double %tmp8, %tmp22 ; [#uses=1] + %tmp24 = fadd double %tmp23, %tmp20 ; [#uses=1] + +; CHECK: %tmp23 = fsub double %tmp8, %tmp21 +; CHECK: %tmp24 = fadd double %tmp23, %tmp20 + + store double %tmp24, double* %rlo, align 8 + ret void +} From sabre at nondot.org Wed Jan 13 17:28:40 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 23:28:40 -0000 Subject: [llvm-commits] [llvm] r93372 - /llvm/trunk/lib/Target/X86/README.txt Message-ID: <201001132328.o0DNSevM027126@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 17:28:40 2010 New Revision: 93372 URL: http://llvm.org/viewvc/llvm-project?rev=93372&view=rev Log: X86 if conversion + tail merging issues from PR6032. Modified: llvm/trunk/lib/Target/X86/README.txt Modified: llvm/trunk/lib/Target/X86/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README.txt?rev=93372&r1=93371&r2=93372&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/README.txt (original) +++ llvm/trunk/lib/Target/X86/README.txt Wed Jan 13 17:28:40 2010 @@ -1868,3 +1868,23 @@ information to add the "lock" prefix. //===---------------------------------------------------------------------===// + +The X86 backend should be able to if-convert SSE comparisons like "ucomisd" to +"cmpsd". For example, this code: + +double d1(double x) { return x == x ? x : x + x; } + +Compiles into: + +_d1: + ucomisd %xmm0, %xmm0 + jnp LBB1_2 + addsd %xmm0, %xmm0 + ret +LBB1_2: + ret + +Also, the 'ret's should be shared. This is PR6032. + +//===---------------------------------------------------------------------===// + From sabre at nondot.org Wed Jan 13 17:29:12 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 23:29:12 -0000 Subject: [llvm-commits] [llvm] r93373 - in /llvm/trunk/lib/Target/X86: README-SSE.txt README.txt Message-ID: <201001132329.o0DNTCgm027160@zion.cs.uiuc.edu> Author: lattner Date: Wed Jan 13 17:29:11 2010 New Revision: 93373 URL: http://llvm.org/viewvc/llvm-project?rev=93373&view=rev Log: this is an SSE-specific issue. Modified: llvm/trunk/lib/Target/X86/README-SSE.txt llvm/trunk/lib/Target/X86/README.txt Modified: llvm/trunk/lib/Target/X86/README-SSE.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README-SSE.txt?rev=93373&r1=93372&r2=93373&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/README-SSE.txt (original) +++ llvm/trunk/lib/Target/X86/README-SSE.txt Wed Jan 13 17:29:11 2010 @@ -916,3 +916,23 @@ "load, add 1.0, store" is better done in the fp stack, etc. //===---------------------------------------------------------------------===// + +The X86 backend should be able to if-convert SSE comparisons like "ucomisd" to +"cmpsd". For example, this code: + +double d1(double x) { return x == x ? x : x + x; } + +Compiles into: + +_d1: + ucomisd %xmm0, %xmm0 + jnp LBB1_2 + addsd %xmm0, %xmm0 + ret +LBB1_2: + ret + +Also, the 'ret's should be shared. This is PR6032. + +//===---------------------------------------------------------------------===// + Modified: llvm/trunk/lib/Target/X86/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README.txt?rev=93373&r1=93372&r2=93373&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/README.txt (original) +++ llvm/trunk/lib/Target/X86/README.txt Wed Jan 13 17:29:11 2010 @@ -1868,23 +1868,3 @@ information to add the "lock" prefix. //===---------------------------------------------------------------------===// - -The X86 backend should be able to if-convert SSE comparisons like "ucomisd" to -"cmpsd". For example, this code: - -double d1(double x) { return x == x ? x : x + x; } - -Compiles into: - -_d1: - ucomisd %xmm0, %xmm0 - jnp LBB1_2 - addsd %xmm0, %xmm0 - ret -LBB1_2: - ret - -Also, the 'ret's should be shared. This is PR6032. - -//===---------------------------------------------------------------------===// - From bob.wilson at apple.com Wed Jan 13 17:34:16 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 13 Jan 2010 23:34:16 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93374 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h Message-ID: <201001132334.o0DNYGlA027416@zion.cs.uiuc.edu> Author: bwilson Date: Wed Jan 13 17:34:16 2010 New Revision: 93374 URL: http://llvm.org/viewvc/llvm-project?rev=93374&view=rev Log: Fix some trailing whitespace in my previous change, and make the same fixes to the SVR4ABI version of PassInIntegerRegisters. Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=93374&r1=93373&r2=93374&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Wed Jan 13 17:34:16 2010 @@ -622,7 +622,7 @@ unsigned ElementSize = UseInt64 ? 8:4; unsigned ArraySize = Size / ElementSize; - // Put as much of the aggregate as possible into an array. + // Put as much of the aggregate as possible into an array. const Type *ATy = NULL; const Type *ArrayElementType = NULL; if (ArraySize) { @@ -651,7 +651,7 @@ if (Size != getTargetData().getTypeAllocSize(LastEltTy)) LastEltRealSize = Size; } - + const StructType *STy = StructType::get(getGlobalContext(), Elts, false); unsigned i = 0; @@ -1058,8 +1058,9 @@ // from Int64 alignment. ARM backend needs this. unsigned Align = TYPE_ALIGN(type)/8; unsigned Int64Align = - getTargetData().getABITypeAlignment(Type::getInt64Ty(getGlobalContext())); - bool UseInt64 = DontCheckAlignment ? true : (Align >= Int64Align); + getTargetData().getABITypeAlignment(Type::getInt64Ty(getGlobalContext())); + bool UseInt64 = (getTargetData().isLegalInteger(64) && + (DontCheckAlignment || Align >= Int64Align)); // FIXME: In cases where we can, we should use the original struct. // Consider cases like { int, int } and {int, short} for example! This will @@ -1069,29 +1070,36 @@ unsigned ElementSize = UseInt64 ? 8:4; unsigned ArraySize = Size / ElementSize; + // Put as much of the aggregate as possible into an array. const Type *ATy = NULL; const Type *ArrayElementType = NULL; if (ArraySize) { Size = Size % ElementSize; - ArrayElementType = (UseInt64) ? - Type::getInt64Ty(getGlobalContext()) : Type::getInt32Ty(getGlobalContext()); + ArrayElementType = (UseInt64 ? + Type::getInt64Ty(getGlobalContext()) : + Type::getInt32Ty(getGlobalContext())); ATy = ArrayType::get(ArrayElementType, ArraySize); Elts.push_back(ATy); } - if (Size >= 4) { - Elts.push_back(Type::getInt32Ty(getGlobalContext())); - Size -= 4; - } - if (Size >= 2) { - Elts.push_back(Type::getInt16Ty(getGlobalContext())); - Size -= 2; - } - if (Size >= 1) { - Elts.push_back(Type::getInt8Ty(getGlobalContext())); - Size -= 1; + // Pass any leftover bytes as a separate element following the array. + unsigned LastEltRealSize = 0; + const llvm::Type *LastEltTy = 0; + if (Size > 4) { + LastEltTy = Type::getInt64Ty(getGlobalContext()); + } else if (Size > 2) { + LastEltTy = Type::getInt32Ty(getGlobalContext()); + } else if (Size > 1) { + LastEltTy = Type::getInt16Ty(getGlobalContext()); + } else if (Size > 0) { + LastEltTy = Type::getInt8Ty(getGlobalContext()); + } + if (LastEltTy) { + Elts.push_back(LastEltTy); + if (Size != getTargetData().getTypeAllocSize(LastEltTy)) + LastEltRealSize = Size; } - assert(Size == 0 && "Didn't cover value?"); + const StructType *STy = StructType::get(getGlobalContext(), Elts, false); unsigned i = 0; @@ -1106,10 +1114,10 @@ C.ExitField(); ++i; } - for (unsigned e = Elts.size(); i != e; ++i) { + if (LastEltTy) { C.EnterField(i, STy); - C.HandleScalarArgument(Elts[i], 0); - ScalarElts.push_back(Elts[i]); + C.HandleScalarArgument(LastEltTy, 0, LastEltRealSize); + ScalarElts.push_back(LastEltTy); C.ExitField(); } } From gohman at apple.com Wed Jan 13 17:45:38 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 13 Jan 2010 15:45:38 -0800 Subject: [llvm-commits] [llvm] r93202 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp In-Reply-To: <1B735D96-CF64-46E3-8828-A7322EC8BEBE@apple.com> References: <201001112249.o0BMnfKd016308@zion.cs.uiuc.edu> <1B735D96-CF64-46E3-8828-A7322EC8BEBE@apple.com> Message-ID: <26E60AAA-0038-44C7-8AC5-F289A58D9F37@apple.com> On Jan 12, 2010, at 11:08 AM, Chris Lattner wrote: > > On Jan 12, 2010, at 11:04 AM, Dan Gohman wrote: > >> >> On Jan 11, 2010, at 2:49 PM, Chris Lattner wrote: >>> >>> reenable the piece that turns trunc(zext(x)) -> x even if zext has multiple uses, >>> codegen has no apparent problem with the trunc version of this, because it turns >>> into a simple subreg idiom >> >> On targets where TargetLowering::isTruncateFree returns true, >> at least. > > Are you concerned about a specific target? This xform in general only applies when the source and dest are both 'native' integer types. No, just theoretical targets I guess, so it's probably close enough. Dan From gohman at apple.com Wed Jan 13 17:45:44 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 13 Jan 2010 15:45:44 -0800 Subject: [llvm-commits] [llvm] r93372 - /llvm/trunk/lib/Target/X86/README.txt In-Reply-To: <201001132328.o0DNSevM027126@zion.cs.uiuc.edu> References: <201001132328.o0DNSevM027126@zion.cs.uiuc.edu> Message-ID: <355E067F-D5EA-457B-8363-3C27D12D62C1@apple.com> On Jan 13, 2010, at 3:28 PM, Chris Lattner wrote: > Author: lattner > Date: Wed Jan 13 17:28:40 2010 > New Revision: 93372 > > URL: http://llvm.org/viewvc/llvm-project?rev=93372&view=rev > Log: > X86 if conversion + tail merging issues from PR6032. > > Modified: > llvm/trunk/lib/Target/X86/README.txt > > Modified: llvm/trunk/lib/Target/X86/README.txt > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README.txt?rev=93372&r1=93371&r2=93372&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/README.txt (original) > +++ llvm/trunk/lib/Target/X86/README.txt Wed Jan 13 17:28:40 2010 > @@ -1868,3 +1868,23 @@ > information to add the "lock" prefix. > > //===---------------------------------------------------------------------===// > + > +The X86 backend should be able to if-convert SSE comparisons like "ucomisd" to > +"cmpsd". For example, this code: > + > +double d1(double x) { return x == x ? x : x + x; } > + > +Compiles into: > + > +_d1: > + ucomisd %xmm0, %xmm0 > + jnp LBB1_2 > + addsd %xmm0, %xmm0 Is cmpsd actually faster? With the cmpsd approach, the addsd must be executed unconditionally. Dan From espindola at google.com Wed Jan 13 18:20:16 2010 From: espindola at google.com (Rafael Espindola) Date: Wed, 13 Jan 2010 19:20:16 -0500 Subject: [llvm-commits] [patch] Add support for emulators in RunSafely.sh In-Reply-To: References: <38a0d8451001131442q334aaacftfc638aee8671f456@mail.gmail.com> <38a0d8451001131518i721591d1vea33e6d7efa7f097@mail.gmail.com> Message-ID: <38a0d8451001131620t73911635o7e3cdbfa72f0670c@mail.gmail.com> > Looks good to me. Thanks Rafael! OK, it was not so simple because of the strict argument order. Fixed. I also fixed the very long lines is Makefile.programs. Note that RunSafelyAndStable.sh cannot take options. > Nick Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: run-under.patch Type: text/x-diff Size: 2813 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100113/e04d13d4/attachment.bin From stuart at apple.com Wed Jan 13 18:22:05 2010 From: stuart at apple.com (Stuart Hastings) Date: Thu, 14 Jan 2010 00:22:05 -0000 Subject: [llvm-commits] [llvm] r93380 - /llvm/trunk/utils/buildit/GNUmakefile Message-ID: <201001140022.o0E0M5Vg029187@zion.cs.uiuc.edu> Author: stuart Date: Wed Jan 13 18:22:05 2010 New Revision: 93380 URL: http://llvm.org/viewvc/llvm-project?rev=93380&view=rev Log: Enable assertions by default for Apple-style builds. Modified: llvm/trunk/utils/buildit/GNUmakefile Modified: llvm/trunk/utils/buildit/GNUmakefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/buildit/GNUmakefile?rev=93380&r1=93379&r2=93380&view=diff ============================================================================== --- llvm/trunk/utils/buildit/GNUmakefile (original) +++ llvm/trunk/utils/buildit/GNUmakefile Wed Jan 13 18:22:05 2010 @@ -34,8 +34,8 @@ PREFIX = /usr/local -# Unless assertions are forced on in the GMAKE command line, disable them. -ifdef ENABLE_ASSERTIONS +# Unless assertions are forced on in the GMAKE command line, enable them. +ifndef ENABLE_ASSERTIONS LLVM_ASSERTIONS := yes else LLVM_ASSERTIONS := no From grosser at fim.uni-passau.de Wed Jan 13 18:21:58 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Thu, 14 Jan 2010 01:21:58 +0100 Subject: [llvm-commits] [PATCH] Create Generic DOTGraphTraits Printer/Viewer Message-ID: Move the DOTGraphTraits dotty printer/viewer templates, that were developed for the dominance tree into their own header file. This will allow reuse in future passes. --- include/llvm/Support/DOTGraphTraitsPass.h | 79 +++++++++++++++++++++++++++++ lib/Analysis/DomPrinter.cpp | 70 ++++++------------------- 2 files changed, 96 insertions(+), 53 deletions(-) create mode 100644 include/llvm/Support/DOTGraphTraitsPass.h -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Create-Generic-DOTGraphTraits-Printer-Viewer.patch Type: text/x-patch Size: 6920 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100114/b50a7f79/attachment.bin From stuart at apple.com Wed Jan 13 18:34:53 2010 From: stuart at apple.com (Stuart Hastings) Date: Thu, 14 Jan 2010 00:34:53 -0000 Subject: [llvm-commits] [llvm] r93381 - /llvm/trunk/utils/buildit/GNUmakefile Message-ID: <201001140034.o0E0Yrpx029684@zion.cs.uiuc.edu> Author: stuart Date: Wed Jan 13 18:34:53 2010 New Revision: 93381 URL: http://llvm.org/viewvc/llvm-project?rev=93381&view=rev Log: Erm, previous patch was wrong; Thanks Bill\! Modified: llvm/trunk/utils/buildit/GNUmakefile Modified: llvm/trunk/utils/buildit/GNUmakefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/buildit/GNUmakefile?rev=93381&r1=93380&r2=93381&view=diff ============================================================================== --- llvm/trunk/utils/buildit/GNUmakefile (original) +++ llvm/trunk/utils/buildit/GNUmakefile Wed Jan 13 18:34:53 2010 @@ -37,8 +37,6 @@ # Unless assertions are forced on in the GMAKE command line, enable them. ifndef ENABLE_ASSERTIONS LLVM_ASSERTIONS := yes -else -LLVM_ASSERTIONS := no endif # Default is optimized build. From stuart at apple.com Wed Jan 13 18:44:09 2010 From: stuart at apple.com (Stuart Hastings) Date: Thu, 14 Jan 2010 00:44:09 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93387 - /llvm-gcc-4.2/trunk/gcc/omp-low.c Message-ID: <201001140044.o0E0i9ER030047@zion.cs.uiuc.edu> Author: stuart Date: Wed Jan 13 18:44:08 2010 New Revision: 93387 URL: http://llvm.org/viewvc/llvm-project?rev=93387&view=rev Log: Decorate an OMP-specific MODIFY with correct lexical block. Modified: llvm-gcc-4.2/trunk/gcc/omp-low.c Modified: llvm-gcc-4.2/trunk/gcc/omp-low.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/omp-low.c?rev=93387&r1=93386&r2=93387&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/omp-low.c (original) +++ llvm-gcc-4.2/trunk/gcc/omp-low.c Wed Jan 13 18:44:08 2010 @@ -2870,6 +2870,15 @@ t = build2 (MULT_EXPR, type, t, fd->step); t = build2 (PLUS_EXPR, type, t, fd->n1); t = build2 (MODIFY_EXPR, void_type_node, fd->v, t); + /* LLVM LOCAL begin 7387470 */ + /* Decorate this MODIFY_EXPR with the correct lexical block. */ + { + extern tree debug_find_var_in_block_tree (tree, tree); + TREE_BLOCK(t) = + debug_find_var_in_block_tree(fd->v, + DECL_INITIAL(current_function_decl)); + } + /* LLVM LOCAL end 7387470 */ gimplify_and_add (t, &list); t = fold_convert (type, e0); From stuart at apple.com Wed Jan 13 18:46:16 2010 From: stuart at apple.com (Stuart Hastings) Date: Thu, 14 Jan 2010 00:46:16 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93388 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg: ssp-1.c ssp-2.c Message-ID: <201001140046.o0E0kGBl030123@zion.cs.uiuc.edu> Author: stuart Date: Wed Jan 13 18:46:15 2010 New Revision: 93388 URL: http://llvm.org/viewvc/llvm-project?rev=93388&view=rev Log: Move loop index out of stack in stack-clobbering testcases. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c?rev=93388&r1=93387&r2=93388&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c Wed Jan 13 18:46:15 2010 @@ -11,7 +11,7 @@ int main () { - int i; + static int i; /* Can't allocate this on the stack. */ char foo[255]; // smash stack Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c?rev=93388&r1=93387&r2=93388&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c Wed Jan 13 18:46:15 2010 @@ -12,7 +12,7 @@ void overflow() { - int i = 0; + static int i = 0; /* Can't allocate this on the stack. */ char foo[30]; /* Overflow buffer. */ From wendling at apple.com Wed Jan 13 18:47:48 2010 From: wendling at apple.com (Bill Wendling) Date: Wed, 13 Jan 2010 16:47:48 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r93388 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg: ssp-1.c ssp-2.c In-Reply-To: <201001140046.o0E0kGBl030123@zion.cs.uiuc.edu> References: <201001140046.o0E0kGBl030123@zion.cs.uiuc.edu> Message-ID: Would using "memset" be good here instead of the iterator? -bw On Jan 13, 2010, at 4:46 PM, Stuart Hastings wrote: > Author: stuart > Date: Wed Jan 13 18:46:15 2010 > New Revision: 93388 > > URL: http://llvm.org/viewvc/llvm-project?rev=93388&view=rev > Log: > Move loop index out of stack in stack-clobbering testcases. > > Modified: > llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c > llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c > > Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c?rev=93388&r1=93387&r2=93388&view=diff > > ============================================================================== > --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c (original) > +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c Wed Jan 13 18:46:15 2010 > @@ -11,7 +11,7 @@ > > int main () > { > - int i; > + static int i; /* Can't allocate this on the stack. */ > char foo[255]; > > // smash stack > > Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c?rev=93388&r1=93387&r2=93388&view=diff > > ============================================================================== > --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c (original) > +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c Wed Jan 13 18:46:15 2010 > @@ -12,7 +12,7 @@ > void > overflow() > { > - int i = 0; > + static int i = 0; /* Can't allocate this on the stack. */ > char foo[30]; > > /* Overflow buffer. */ > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From stuart at apple.com Wed Jan 13 18:51:09 2010 From: stuart at apple.com (Stuart Hastings) Date: Wed, 13 Jan 2010 16:51:09 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r93388 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg: ssp-1.c ssp-2.c In-Reply-To: References: <201001140046.o0E0kGBl030123@zion.cs.uiuc.edu> Message-ID: <582707D3-2463-4210-8BAF-E9A21A2ADCAE@apple.com> On Jan 13, 2010, at 4:47 PM, Bill Wendling wrote: > Would using "memset" be good here instead of the iterator? Hm. memset() couldn't be any worse. Can you think of a target or situation where memset() would be better? stuart > -bw > > On Jan 13, 2010, at 4:46 PM, Stuart Hastings wrote: > >> Author: stuart >> Date: Wed Jan 13 18:46:15 2010 >> New Revision: 93388 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=93388&view=rev >> Log: >> Move loop index out of stack in stack-clobbering testcases. >> >> Modified: >> llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c >> llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c >> >> Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c >> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c?rev=93388&r1=93387&r2=93388&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c (original) >> +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c Wed Jan 13 >> 18:46:15 2010 >> @@ -11,7 +11,7 @@ >> >> int main () >> { >> - int i; >> + static int i; /* Can't allocate this on the stack. */ >> char foo[255]; >> >> // smash stack >> >> Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c >> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c?rev=93388&r1=93387&r2=93388&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c (original) >> +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c Wed Jan 13 >> 18:46:15 2010 >> @@ -12,7 +12,7 @@ >> void >> overflow() >> { >> - int i = 0; >> + static int i = 0; /* Can't allocate this on the stack. */ >> char foo[30]; >> >> /* Overflow buffer. */ >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From stuart at apple.com Wed Jan 13 18:51:43 2010 From: stuart at apple.com (Stuart Hastings) Date: Thu, 14 Jan 2010 00:51:43 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93391 - /llvm-gcc-4.2/trunk/gcc/cp/parser.c Message-ID: <201001140051.o0E0phSG030306@zion.cs.uiuc.edu> Author: stuart Date: Wed Jan 13 18:51:42 2010 New Revision: 93391 URL: http://llvm.org/viewvc/llvm-project?rev=93391&view=rev Log: Declare block/closure byref variable at function scope. Modified: llvm-gcc-4.2/trunk/gcc/cp/parser.c Modified: llvm-gcc-4.2/trunk/gcc/cp/parser.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/parser.c?rev=93391&r1=93390&r2=93391&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/cp/parser.c (original) +++ llvm-gcc-4.2/trunk/gcc/cp/parser.c Wed Jan 13 18:51:42 2010 @@ -21724,7 +21724,17 @@ /* Current scope must be that of the main function body. */ /* FIXME gcc_assert (current_scope->function_body);*/ - pushdecl (byref_decl); + /* LLVM LOCAL begin 7387470 */ + /* Find the scope for function body (outer-most scope) and insert + this variable in that scope. This is to avoid duplicate + declaration of the save variable. */ + { + struct cp_binding_level *b = current_binding_level; + while (b->level_chain->kind != sk_function_parms) + b = b->level_chain; + pushdecl_with_scope (byref_decl, b, /*is_friend=*/false); + } + /* LLVM LOCAL end 7387470 */ mark_used (byref_decl); /* APPLE LOCAL begin radar 6083129 - byref escapes (cp) */ /* FIXME: finish this off, ensure the decl is scoped appropriately @@ -22039,7 +22049,7 @@ */ static void declare_block_prologue_local_byref_vars (tree self_parm, tree component, - tree stmt) + tree stmt) { tree decl, block_component; tree_stmt_iterator i; From stuart at apple.com Wed Jan 13 18:52:40 2010 From: stuart at apple.com (Stuart Hastings) Date: Thu, 14 Jan 2010 00:52:40 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93392 - /llvm-gcc-4.2/trunk/gcc/gimple-low.c Message-ID: <201001140052.o0E0qeU6030341@zion.cs.uiuc.edu> Author: stuart Date: Wed Jan 13 18:52:40 2010 New Revision: 93392 URL: http://llvm.org/viewvc/llvm-project?rev=93392&view=rev Log: Decorate OMP_FOR MODIFY statement with lexical block. Modified: llvm-gcc-4.2/trunk/gcc/gimple-low.c Modified: llvm-gcc-4.2/trunk/gcc/gimple-low.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/gimple-low.c?rev=93392&r1=93391&r2=93392&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/gimple-low.c (original) +++ llvm-gcc-4.2/trunk/gcc/gimple-low.c Wed Jan 13 18:52:40 2010 @@ -246,7 +246,9 @@ case GOTO_EXPR: case LABEL_EXPR: case SWITCH_EXPR: - case OMP_FOR: + /* LLVM LOCAL begin 7387470 */ + /* LLVM LOCAL deletion; OMP_FOR case moved below. */ + /* LLVM LOCAL end 7387470 */ case OMP_SECTIONS: case OMP_SECTION: case OMP_SINGLE: @@ -257,6 +259,16 @@ case OMP_CONTINUE: break; + /* LLVM LOCAL begin 7387470 */ + case OMP_FOR: + { + tree init = OMP_FOR_INIT(stmt); + gcc_assert(TREE_CODE(init) == MODIFY_EXPR && "expected simple assignment"); + TREE_BLOCK(init) = data->block; + } + break; + /* LLVM LOCAL end 7387470 */ + case MODIFY_EXPR: if (TREE_CODE (TREE_OPERAND (stmt, 1)) == CALL_EXPR) stmt = TREE_OPERAND (stmt, 1); From stoklund at 2pi.dk Wed Jan 13 18:54:11 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 14 Jan 2010 00:54:11 -0000 Subject: [llvm-commits] [llvm] r93393 - /llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Message-ID: <201001140054.o0E0sBGg030394@zion.cs.uiuc.edu> Author: stoklund Date: Wed Jan 13 18:54:10 2010 New Revision: 93393 URL: http://llvm.org/viewvc/llvm-project?rev=93393&view=rev Log: Don't fold insufficiently aligned ldr/str into ldm/stm instructions. An unaligned ldr causes a trap, and is then emulated by the kernel with awesome performance. The darwin kernel does not emulate unaligned ldm/stm Thumb2 instructions, so don't generate them. This fixes the miscompilation of Multisource/Applications/JM/lencod for Thumb2. Generating unaligned ldr/str pairs from a 16-bit aligned memcpy is probably also a bad idea, but that is beyond the scope of this patch. Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=93393&r1=93392&r2=93393&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Wed Jan 13 18:54:10 2010 @@ -740,6 +740,18 @@ /// isMemoryOp - Returns true if instruction is a memory operations (that this /// pass is capable of operating on). static bool isMemoryOp(const MachineInstr *MI) { + if (MI->hasOneMemOperand()) { + const MachineMemOperand *MMO = *MI->memoperands_begin(); + + // Don't touch volatile memory accesses - we may be changing their order. + if (MMO->isVolatile()) + return false; + + // Unaligned ldr/str is emulated by some kernels, but unaligned ldm/stm is not. + if (MMO->getAlignment() < 4) + return false; + } + int Opcode = MI->getOpcode(); switch (Opcode) { default: break; From stuart at apple.com Wed Jan 13 18:54:44 2010 From: stuart at apple.com (Stuart Hastings) Date: Thu, 14 Jan 2010 00:54:44 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93394 - /llvm-gcc-4.2/trunk/gcc/tree-cfg.c Message-ID: <201001140054.o0E0siXa030425@zion.cs.uiuc.edu> Author: stuart Date: Wed Jan 13 18:54:44 2010 New Revision: 93394 URL: http://llvm.org/viewvc/llvm-project?rev=93394&view=rev Log: Decorate computed-GOTO variable assignment with lexical block. Modified: llvm-gcc-4.2/trunk/gcc/tree-cfg.c Modified: llvm-gcc-4.2/trunk/gcc/tree-cfg.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/tree-cfg.c?rev=93394&r1=93393&r2=93394&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/tree-cfg.c (original) +++ llvm-gcc-4.2/trunk/gcc/tree-cfg.c Wed Jan 13 18:54:44 2010 @@ -316,6 +316,19 @@ /* Copy the original computed goto's destination into VAR. */ assignment = build2 (MODIFY_EXPR, ptr_type_node, var, GOTO_DESTINATION (last)); + /* LLVM LOCAL begin 7387470 */ + if (TREE_CODE_CLASS(TREE_CODE(GOTO_DESTINATION(last))) == + tcc_declaration) + { + extern tree debug_find_var_in_block_tree (tree, tree); + tree block = + debug_find_var_in_block_tree(GOTO_DESTINATION(last), + DECL_INITIAL(current_function_decl)); + /* This could be a compiler-created temporary variable + where block == NULL_TREE. That's O.K. */ + TREE_BLOCK(assignment) = block; + } + /* LLVM LOCAL end 7387470 */ bsi_insert_before (&bsi, assignment, BSI_SAME_STMT); /* And re-vector the computed goto to the new destination. */ From wendling at apple.com Wed Jan 13 19:01:47 2010 From: wendling at apple.com (Bill Wendling) Date: Wed, 13 Jan 2010 17:01:47 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r93388 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg: ssp-1.c ssp-2.c In-Reply-To: <582707D3-2463-4210-8BAF-E9A21A2ADCAE@apple.com> References: <201001140046.o0E0kGBl030123@zion.cs.uiuc.edu> <582707D3-2463-4210-8BAF-E9A21A2ADCAE@apple.com> Message-ID: My thinking was to avoid having to modify the variables in this test to avoid smashing them. Using memset would test only what the test is meant to test instead of having to worry if a local on the stack is also going to be trashed... -bw On Jan 13, 2010, at 4:51 PM, Stuart Hastings wrote: > > On Jan 13, 2010, at 4:47 PM, Bill Wendling wrote: > >> Would using "memset" be good here instead of the iterator? > > Hm. memset() couldn't be any worse. > > Can you think of a target or situation where memset() would be better? > > stuart > >> -bw >> >> On Jan 13, 2010, at 4:46 PM, Stuart Hastings wrote: >> >>> Author: stuart >>> Date: Wed Jan 13 18:46:15 2010 >>> New Revision: 93388 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=93388&view=rev >>> Log: >>> Move loop index out of stack in stack-clobbering testcases. >>> >>> Modified: >>> llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c >>> llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c >>> >>> Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c >>> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c?rev=93388&r1=93387&r2=93388&view=diff >>> >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ===================================================================== >>> --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c (original) >>> +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-1.c Wed Jan 13 18:46:15 2010 >>> @@ -11,7 +11,7 @@ >>> >>> int main () >>> { >>> - int i; >>> + static int i; /* Can't allocate this on the stack. */ >>> char foo[255]; >>> >>> // smash stack >>> >>> Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c >>> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c?rev=93388&r1=93387&r2=93388&view=diff >>> >>> ============================================================================== >>> --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c (original) >>> +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/ssp-2.c Wed Jan 13 18:46:15 2010 >>> @@ -12,7 +12,7 @@ >>> void >>> overflow() >>> { >>> - int i = 0; >>> + static int i = 0; /* Can't allocate this on the stack. */ >>> char foo[30]; >>> >>> /* Overflow buffer. */ >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > From echristo at apple.com Wed Jan 13 19:08:22 2010 From: echristo at apple.com (Eric Christopher) Date: Wed, 13 Jan 2010 17:08:22 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r93388 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg: ssp-1.c ssp-2.c In-Reply-To: <201001140046.o0E0kGBl030123@zion.cs.uiuc.edu> References: <201001140046.o0E0kGBl030123@zion.cs.uiuc.edu> Message-ID: On Jan 13, 2010, at 4:46 PM, Stuart Hastings wrote: > Author: stuart > Date: Wed Jan 13 18:46:15 2010 > New Revision: 93388 > > URL: http://llvm.org/viewvc/llvm-project?rev=93388&view=rev > Log: > Move loop index out of stack in stack-clobbering testcases. ? -eric From stuart at apple.com Wed Jan 13 19:14:11 2010 From: stuart at apple.com (Stuart Hastings) Date: Wed, 13 Jan 2010 17:14:11 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r93388 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg: ssp-1.c ssp-2.c In-Reply-To: References: <201001140046.o0E0kGBl030123@zion.cs.uiuc.edu> Message-ID: <7686EEB2-6D40-4F68-BAAB-BE56E2D700F9@apple.com> On Jan 13, 2010, at 5:08 PM, Eric Christopher wrote: > > On Jan 13, 2010, at 4:46 PM, Stuart Hastings wrote: > >> Author: stuart >> Date: Wed Jan 13 18:46:15 2010 >> New Revision: 93388 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=93388&view=rev >> Log: >> Move loop index out of stack in stack-clobbering testcases. > > ? > > -eric It's testing the stack-protector by clobbering its own stackframe. I'm about to commit some lexical-block debug stuff, and I had to change the order of declaration of variables. That's not supposed to break anything, but... lots of breakage. For these two tiny test cases, GCC allocated the loop index in a register, even at -O0. At -O0, LLVM put that variable on the stack. When I disturbed the order of declaration, the loop index moved *above* the array-to-clobber, the loop clobbered its own index, and then it looped indefinitely. (Note: my patch to change the order of declaration hasn't been committed yet.) Making the loop index static moves it far away from the clobbering. Bill says we can replace the loop and its index variable with a call to memset(). Do you have a strong opinion on this? stuart From nlewycky at google.com Wed Jan 13 19:18:36 2010 From: nlewycky at google.com (Nick Lewycky) Date: Wed, 13 Jan 2010 17:18:36 -0800 Subject: [llvm-commits] [patch] Add support for emulators in RunSafely.sh In-Reply-To: <38a0d8451001131620t73911635o7e3cdbfa72f0670c@mail.gmail.com> References: <38a0d8451001131442q334aaacftfc638aee8671f456@mail.gmail.com> <38a0d8451001131518i721591d1vea33e6d7efa7f097@mail.gmail.com> <38a0d8451001131620t73911635o7e3cdbfa72f0670c@mail.gmail.com> Message-ID: On 13 January 2010 16:20, Rafael Espindola wrote: > > Looks good to me. Thanks Rafael! > > OK, it was not so simple because of the strict argument order. Fixed. > I also fixed the very long lines is Makefile.programs. > Yuck. Without proper flags processing, this whole script should probably just use environment variables instead. Anyways, thanks for the refactoring, this looks much better. Note that RunSafelyAndStable.sh cannot take options. > No, but I'm not sure it needs to. It takes which means that "prog foo" could become "wrapper prog foo" with no difference in behaviour. But after taking another look, I don't see any of the makefiles in llvm-test actually using GET_STABLE_NUMBERS. I guess you don't really need to support that. :) So with that said, this patch *once again* looks fine, but then, so did all the others ;) Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100113/dd081646/attachment.html From echristo at apple.com Wed Jan 13 19:24:33 2010 From: echristo at apple.com (Eric Christopher) Date: Wed, 13 Jan 2010 17:24:33 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r93388 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg: ssp-1.c ssp-2.c In-Reply-To: <7686EEB2-6D40-4F68-BAAB-BE56E2D700F9@apple.com> References: <201001140046.o0E0kGBl030123@zion.cs.uiuc.edu> <7686EEB2-6D40-4F68-BAAB-BE56E2D700F9@apple.com> Message-ID: >> > > It's testing the stack-protector by clobbering its own stackframe. > Yep. > I'm about to commit some lexical-block debug stuff, and I had to change the order of declaration of variables. That's not supposed to break anything, but... lots of breakage. > Why did you have to change the order of declaration of variables? I'd be surprised if someone wasn't relying on this behavior, even if they're not supposed to. > For these two tiny test cases, GCC allocated the loop index in a register, even at -O0. At -O0, LLVM put that variable on the stack. > > When I disturbed the order of declaration, the loop index moved *above* the array-to-clobber, the loop clobbered its own index, and then it looped indefinitely. > > (Note: my patch to change the order of declaration hasn't been committed yet.) > > Making the loop index static moves it far away from the clobbering. Bill says we can replace the loop and its index variable with a call to memset(). > > Do you have a strong opinion on this? I'd say static and haul it out of the function, but I'm still concerned about the other. -eric From stuart at apple.com Wed Jan 13 19:41:33 2010 From: stuart at apple.com (Stuart Hastings) Date: Wed, 13 Jan 2010 17:41:33 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r93388 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg: ssp-1.c ssp-2.c In-Reply-To: References: <201001140046.o0E0kGBl030123@zion.cs.uiuc.edu> <7686EEB2-6D40-4F68-BAAB-BE56E2D700F9@apple.com> Message-ID: On Jan 13, 2010, at 5:24 PM, Eric Christopher wrote: >>> >> >> It's testing the stack-protector by clobbering its own stackframe. >> > > Yep. > >> I'm about to commit some lexical-block debug stuff, and I had to >> change the order of declaration of variables. That's not supposed >> to break anything, but... lots of breakage. >> > > Why did you have to change the order of declaration of variables? I'm adding debug support for lexical blocks. The LLVM interface I use has no "back-patching" ability; if the user wrote { int a; blah(); ... { int b; blah(); ... { int c; blah(); ... } { int d; ... then I'm obliged to defer the declarations of b, c, and d until IR generation reaches those points in the code. I cannot declare them all when I enter the function, as we do now. If the user turns off debug info, we're supposed to generate the same code; accordingly, I must declare the variables in LLVM in the same order. > I'd be surprised if someone wasn't relying on this behavior, even if > they're not supposed to. My favorite test cases concerns a 96-bit struct composed of three floats; on x86_64, this is passed in two SSE registers. If the callee has variable arguments :-) , the GCC x86_64 ABI stuff in i386.c generates a 128-bit store into a 96-bit local variable. When I changed the order of declaration, some local int was clobbered. This is a latent bug inside GCC; I'm confident a testcase could be created to demonstrate it. The particular test case passes with our current GCC because that local int variable gets allocated in a register at - O0. :-) Note that my fix for the test case referenced above hasn't been committed yet. The x86_64 ABI is somewhat complex, and the code is fragile. stuart >> For these two tiny test cases, GCC allocated the loop index in a >> register, even at -O0. At -O0, LLVM put that variable on the stack. >> >> When I disturbed the order of declaration, the loop index moved >> *above* the array-to-clobber, the loop clobbered its own index, and >> then it looped indefinitely. >> >> (Note: my patch to change the order of declaration hasn't been >> committed yet.) >> >> Making the loop index static moves it far away from the >> clobbering. Bill says we can replace the loop and its index >> variable with a call to memset(). >> >> Do you have a strong opinion on this? > > > I'd say static and haul it out of the function, but I'm still > concerned about the other. > > -eric From vhernandez at apple.com Wed Jan 13 19:45:14 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 14 Jan 2010 01:45:14 -0000 Subject: [llvm-commits] [llvm] r93400 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp Message-ID: <201001140145.o0E1jEDi032182@zion.cs.uiuc.edu> Author: hernande Date: Wed Jan 13 19:45:14 2010 New Revision: 93400 URL: http://llvm.org/viewvc/llvm-project?rev=93400&view=rev Log: Add MDNode::getFunction(), which figures out the metadata's function, if it has function that it is local to. Modified: llvm/trunk/include/llvm/Metadata.h llvm/trunk/lib/VMCore/Metadata.cpp Modified: llvm/trunk/include/llvm/Metadata.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=93400&r1=93399&r2=93400&view=diff ============================================================================== --- llvm/trunk/include/llvm/Metadata.h (original) +++ llvm/trunk/include/llvm/Metadata.h Wed Jan 13 19:45:14 2010 @@ -151,6 +151,11 @@ bool isFunctionLocal() const { return (getSubclassDataFromValue() & FunctionLocalBit) != 0; } + + // getFunction - If this metadata is function-local and recursively has a + // function-local operand, return the first such operand's parent function. + // Otherwise, return null. + Function *getFunction() const; // destroy - Delete this node. Only when there are no uses. void destroy(); Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=93400&r1=93399&r2=93400&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Wed Jan 13 19:45:14 2010 @@ -121,6 +121,40 @@ Op->~MDNodeOperand(); } +static Function *getFunctionHelper(const MDNode *N, + SmallPtrSet &Visited) { + assert(N->isFunctionLocal() && "Should only be called on function-local MD"); + Function *F = NULL; + // Only visit each MDNode once. + if (!Visited.insert(N)) return F; + + for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { + Value *V = N->getOperand(i); + if (!V) continue; + if (Instruction *I = dyn_cast(V)) + F = I->getParent()->getParent(); + else if (BasicBlock *BB = dyn_cast(V)) + F = BB->getParent(); + else if (Argument *A = dyn_cast(V)) + F = A->getParent(); + else if (MDNode *MD = dyn_cast(V)) + if (MD->isFunctionLocal()) + F = getFunctionHelper(MD, Visited); + if (F) break; + } + + return F; +} + +// getFunction - If this metadata is function-local and recursively has a +// function-local operand, return the first such operand's parent function. +// Otherwise, return null. +Function *MDNode::getFunction() const { + if (!isFunctionLocal()) return NULL; + SmallPtrSet Visited; + return getFunctionHelper(this, Visited); +} + // destroy - Delete this node. Only when there are no uses. void MDNode::destroy() { setValueSubclassData(getSubclassDataFromValue() | DestroyFlag); From vhernandez at apple.com Wed Jan 13 19:46:03 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 14 Jan 2010 01:46:03 -0000 Subject: [llvm-commits] [llvm] r93401 - /llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Message-ID: <201001140146.o0E1k3Ae032225@zion.cs.uiuc.edu> Author: hernande Date: Wed Jan 13 19:46:02 2010 New Revision: 93401 URL: http://llvm.org/viewvc/llvm-project?rev=93401&view=rev Log: Clean up unnecessary return and brackets Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=93401&r1=93400&r2=93401&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Wed Jan 13 19:46:02 2010 @@ -242,13 +242,11 @@ MDValues.push_back(std::make_pair(MD, 1U)); MDValueMap[MD] = MDValues.size(); MDValueID = MDValues.size(); - for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { + for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) if (Value *V = N->getOperand(i)) EnumerateValue(V); else EnumerateType(Type::getVoidTy(MD->getContext())); - } - return; } return; } From vhernandez at apple.com Wed Jan 13 19:47:37 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 14 Jan 2010 01:47:37 -0000 Subject: [llvm-commits] [llvm] r93402 - /llvm/trunk/lib/VMCore/AsmWriter.cpp Message-ID: <201001140147.o0E1lbIC032335@zion.cs.uiuc.edu> Author: hernande Date: Wed Jan 13 19:47:37 2010 New Revision: 93402 URL: http://llvm.org/viewvc/llvm-project?rev=93402&view=rev Log: Fix printing of function-local metadata in AsmWriter Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=93402&r1=93401&r2=93402&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Wed Jan 13 19:47:37 2010 @@ -2062,8 +2062,9 @@ else W.printAlias(cast(GV)); } else if (const MDNode *N = dyn_cast(this)) { - SlotTracker SlotTable((Function*)0); - AssemblyWriter W(OS, SlotTable, 0, AAW); + Function *F = N->getFunction(); + SlotTracker SlotTable(F); + AssemblyWriter W(OS, SlotTable, getModuleFromVal(F), AAW); W.printMDNodeBody(N); } else if (const NamedMDNode *N = dyn_cast(this)) { SlotTracker SlotTable(N->getParent()); From vhernandez at apple.com Wed Jan 13 19:50:09 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 14 Jan 2010 01:50:09 -0000 Subject: [llvm-commits] [llvm] r93403 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Message-ID: <201001140150.o0E1o9NK032426@zion.cs.uiuc.edu> Author: hernande Date: Wed Jan 13 19:50:08 2010 New Revision: 93403 URL: http://llvm.org/viewvc/llvm-project?rev=93403&view=rev Log: In WriteFunction(), write function-local metadata before we write the instructions, so instruction's references to metadata are fully resolved by the time they get written. Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=93403&r1=93402&r2=93403&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Wed Jan 13 19:50:08 2010 @@ -1226,6 +1226,9 @@ VE.getFunctionConstantRange(CstStart, CstEnd); WriteConstants(CstStart, CstEnd, VE, Stream, false); + // If there is function-local metadata, emit it now. + WriteFunctionLocalMetadata(VE, Stream); + // Keep a running idea of what the instruction ID is. unsigned InstID = CstEnd; @@ -1241,7 +1244,6 @@ // Emit names for all the instructions etc. WriteValueSymbolTable(F.getValueSymbolTable(), VE, Stream); - WriteFunctionLocalMetadata(VE, Stream); WriteMetadataAttachment(F, VE, Stream); VE.purgeFunction(); Stream.ExitBlock(); From vhernandez at apple.com Wed Jan 13 19:51:29 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 14 Jan 2010 01:51:29 -0000 Subject: [llvm-commits] [llvm] r93406 - /llvm/trunk/test/Assembler/functionlocal-metadata.ll Message-ID: <201001140151.o0E1pTZR032495@zion.cs.uiuc.edu> Author: hernande Date: Wed Jan 13 19:51:28 2010 New Revision: 93406 URL: http://llvm.org/viewvc/llvm-project?rev=93406&view=rev Log: Now that LLParser, AsmWriter, BitcodeReader, and BitcodeWriter all correctly support function-local metadata, test it. Modified: llvm/trunk/test/Assembler/functionlocal-metadata.ll Modified: llvm/trunk/test/Assembler/functionlocal-metadata.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/functionlocal-metadata.ll?rev=93406&r1=93405&r2=93406&view=diff ============================================================================== --- llvm/trunk/test/Assembler/functionlocal-metadata.ll (original) +++ llvm/trunk/test/Assembler/functionlocal-metadata.ll Wed Jan 13 19:51:28 2010 @@ -1,22 +1,30 @@ -; RUN: llvm-as < %s | llvm-dis | grep {ret void, !foo !0, !bar !1} +; RUN: llvm-as < %s | llvm-dis | FileCheck %s define void @Foo(i32 %a, i32 %b) { entry: - %0 = add i32 %a, 1 ; [#uses=1] - %two = add i32 %b, 2 ; [#uses=2] - - call void @llvm.dbg.func.start(metadata !{i32 %0}) - call void @llvm.dbg.func.start(metadata !{i32 %b, i32 %0}) - call void @llvm.dbg.func.start(metadata !{i32 %a, metadata !"foo"}) - call void @llvm.dbg.func.start(metadata !{metadata !0, i32 %two}) + %0 = add i32 %a, 1 ; [#uses=1] + %two = add i32 %b, %0 ; [#uses=0] + %1 = alloca i32 ; [#uses=1] + %three = bitcast i32* %1 to { }* ; <{ }*> [#uses=6] + + call void @llvm.dbg.declare({ }* %three, metadata !{i32* %1}) +; CHECK: metadata !{i32* %1} + call void @llvm.dbg.declare({ }* %three, metadata !{{ }* %three}) + call void @llvm.dbg.declare({ }* %three, metadata !{i32 %0}) + call void @llvm.dbg.declare({ }* %three, metadata !{{ }* %three, i32 %0}) + call void @llvm.dbg.declare({ }* %three, metadata !{i32 %b, i32 %0}) + call void @llvm.dbg.declare({ }* %three, metadata !{i32 %a, metadata !"foo"}) +; CHECK: metadata !{i32 %a, metadata !"foo"} + call void @llvm.dbg.declare({ }* %three, metadata !{metadata !0, i32 %two}) ret void, !foo !0, !bar !1 +; CHECK: ret void, !foo !0, !bar !1 } !0 = metadata !{i32 662302, i32 26, metadata !1, null} !1 = metadata !{i32 4, metadata !"foo"} -declare void @llvm.dbg.func.start(metadata) nounwind readnone +declare void @llvm.dbg.declare({ }*, metadata) nounwind readnone !foo = !{ !0 } !bar = !{ !1 } From rafael.espindola at gmail.com Wed Jan 13 20:10:24 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Thu, 14 Jan 2010 02:10:24 -0000 Subject: [llvm-commits] [test-suite] r93407 - in /test-suite/trunk: Makefile.programs RunSafely.sh Message-ID: <201001140210.o0E2AOvn000849@zion.cs.uiuc.edu> Author: rafael Date: Wed Jan 13 20:10:24 2010 New Revision: 93407 URL: http://llvm.org/viewvc/llvm-project?rev=93407&view=rev Log: Add the -u (run under) option to RunSafely.sh Update Makefile to pass RUNUNDER to RunSafely.sh Modified: test-suite/trunk/Makefile.programs test-suite/trunk/RunSafely.sh Modified: test-suite/trunk/Makefile.programs URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.programs?rev=93407&r1=93406&r2=93407&view=diff ============================================================================== --- test-suite/trunk/Makefile.programs (original) +++ test-suite/trunk/Makefile.programs Wed Jan 13 20:10:24 2010 @@ -82,29 +82,36 @@ else EXIT_OK := 0 endif + ifdef GET_STABLE_NUMBERS RUNSAFELY := $(PROGDIR)/RunSafelyAndStable.sh $(RUNTIMELIMIT) $(EXIT_OK) else +RUNSAFELY := $(PROGDIR)/RunSafely.sh + ifdef REMOTE_HOST +RUNSAFELY := $(RUNSAFELY) -r $(REMOTE_HOST) ifndef REMOTE_CLIENT REMOTE_CLIENT := rsh endif +endif + ifdef REMOTE_USER -ifdef REMOTE_PORT -RUNSAFELY := $(PROGDIR)/RunSafely.sh -r $(REMOTE_HOST) -l $(REMOTE_USER) -rc $(REMOTE_CLIENT) -rp "$(REMOTE_PORT)" $(RUNTIMELIMIT) $(EXIT_OK) -else -RUNSAFELY := $(PROGDIR)/RunSafely.sh -r $(REMOTE_HOST) -l $(REMOTE_USER) -rc $(REMOTE_CLIENT) $(RUNTIMELIMIT) $(EXIT_OK) +RUNSAFELY := $(RUNSAFELY) -l $(REMOTE_USER) endif -else -ifdef REMOTE_PORT -RUNSAFELY := $(PROGDIR)/RunSafely.sh -r $(REMOTE_HOST) -rc $(REMOTE_CLIENT) -rp "$(REMOTE_PORT)" $(RUNTIMELIMIT) $(EXIT_OK) -else -RUNSAFELY := $(PROGDIR)/RunSafely.sh -r $(REMOTE_HOST) -rc $(REMOTE_CLIENT) $(RUNTIMELIMIT) $(EXIT_OK) + +ifdef REMOTE_CLIENT +RUNSAFELY := $(RUNSAFELY) -rc $(REMOTE_CLIENT) endif + +ifdef REMOTE_PORT +RUNSAFELY := $(RUNSAFELY) -rp "$(REMOTE_PORT)" endif -else -RUNSAFELY := $(PROGDIR)/RunSafely.sh $(RUNTIMELIMIT) $(EXIT_OK) + +ifdef RUNUNDER +RUNSAFELY := $(RUNSAFELY) -u $(RUNUNDER) endif + +RUNSAFELY := $(RUNSAFELY) $(RUNTIMELIMIT) $(EXIT_OK) endif RUNTOOLSAFELY := $(PROGDIR)/RunToolSafely.sh $(RUNTIMELIMIT) Modified: test-suite/trunk/RunSafely.sh URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/RunSafely.sh?rev=93407&r1=93406&r2=93407&view=diff ============================================================================== --- test-suite/trunk/RunSafely.sh (original) +++ test-suite/trunk/RunSafely.sh Wed Jan 13 20:10:24 2010 @@ -25,6 +25,7 @@ # Syntax: # # RunSafely.sh [-r ] [-l ] [-rc ] [-rp ] +# [-u ] # # # where: @@ -32,6 +33,7 @@ # is the username on the remote host # is the remote client used to execute the program # is the port used by the remote client +# is a wrapper that the program is run under # is the maximum number of seconds to let the run # is 1 if the program must exit with 0 return code # is a file from which standard input is directed @@ -54,6 +56,7 @@ RUSER=`id -un` RCLIENT=rsh RPORT= +RUN_UNDER= if [ $1 = "-r" ]; then RHOST=$2 shift 2 @@ -70,6 +73,10 @@ RPORT="-p $2" shift 2 fi +if [ $1 = "-u" ]; then + RUN_UNDER=$2 + shift 2 +fi ULIMIT=$1 EXITOK=$2 @@ -121,7 +128,7 @@ # necessary I/O redirection. # PWD=`pwd` -COMMAND="$PROGRAM $*" +COMMAND="$RUN_UNDER $PROGRAM $*" if [ "$SYSTEM" = "Darwin" ]; then COMMAND="${DIR}TimedExec.sh $ULIMIT $PWD $COMMAND" fi From vhernandez at apple.com Wed Jan 13 20:12:41 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 14 Jan 2010 02:12:41 -0000 Subject: [llvm-commits] [llvm] r93408 - /llvm/trunk/test/Assembler/functionlocal-metadata.ll Message-ID: <201001140212.o0E2CfmP000952@zion.cs.uiuc.edu> Author: hernande Date: Wed Jan 13 20:12:41 2010 New Revision: 93408 URL: http://llvm.org/viewvc/llvm-project?rev=93408&view=rev Log: Extend testcase to also test llvm.dbg.value intrinsic Modified: llvm/trunk/test/Assembler/functionlocal-metadata.ll Modified: llvm/trunk/test/Assembler/functionlocal-metadata.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/functionlocal-metadata.ll?rev=93408&r1=93407&r2=93408&view=diff ============================================================================== --- llvm/trunk/test/Assembler/functionlocal-metadata.ll (original) +++ llvm/trunk/test/Assembler/functionlocal-metadata.ll Wed Jan 13 20:12:41 2010 @@ -17,6 +17,12 @@ ; CHECK: metadata !{i32 %a, metadata !"foo"} call void @llvm.dbg.declare({ }* %three, metadata !{metadata !0, i32 %two}) + call void @llvm.dbg.value(metadata !{ i32 %a }, i64 0, metadata !1) + call void @llvm.dbg.value(metadata !{ i32 %0 }, i64 25, metadata !0) + call void @llvm.dbg.value(metadata !{ i32* %1 }, i64 16, metadata !"foo") +; CHECK: call void @llvm.dbg.value(metadata !{i32* %1}, i64 16, metadata !"foo") + call void @llvm.dbg.value(metadata !{ { }* %three }, i64 12, metadata !"bar") + ret void, !foo !0, !bar !1 ; CHECK: ret void, !foo !0, !bar !1 } @@ -25,6 +31,7 @@ !1 = metadata !{i32 4, metadata !"foo"} declare void @llvm.dbg.declare({ }*, metadata) nounwind readnone +declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone !foo = !{ !0 } !bar = !{ !1 } From evan.cheng at apple.com Wed Jan 13 20:24:07 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 14 Jan 2010 02:24:07 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93409 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <201001140224.o0E2O7Rl001369@zion.cs.uiuc.edu> Author: evancheng Date: Wed Jan 13 20:24:07 2010 New Revision: 93409 URL: http://llvm.org/viewvc/llvm-project?rev=93409&view=rev Log: Add missing memory barrier after binary atomic builtin. r74403 apparently left this out by mistake. x86 target will optimize it away but it's looking for the barrier after the operation. 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=93409&r1=93408&r2=93409&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Jan 13 20:24:07 2010 @@ -4812,10 +4812,20 @@ #else EmitMemoryBarrier(true, true, true, true, true); #endif + Value *Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, id, Ty, 2), C, C + 2); + + // The gcc builtins are also full memory barriers. + // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. +#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) + EmitMemoryBarrier(true, true, true, true, false); +#else + EmitMemoryBarrier(true, true, true, true, true); +#endif + Result = Builder.CreateIntToPtr(Result, ResultTy); return Result; } From evan.cheng at apple.com Wed Jan 13 20:24:50 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 14 Jan 2010 02:24:50 -0000 Subject: [llvm-commits] [llvm] r93410 - /llvm/trunk/test/FrontendC/2010-01-13-MemBarrier.c Message-ID: <201001140224.o0E2OoQO001398@zion.cs.uiuc.edu> Author: evancheng Date: Wed Jan 13 20:24:50 2010 New Revision: 93410 URL: http://llvm.org/viewvc/llvm-project?rev=93410&view=rev Log: Test for r93409. Added: llvm/trunk/test/FrontendC/2010-01-13-MemBarrier.c Added: llvm/trunk/test/FrontendC/2010-01-13-MemBarrier.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2010-01-13-MemBarrier.c?rev=93410&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/2010-01-13-MemBarrier.c (added) +++ llvm/trunk/test/FrontendC/2010-01-13-MemBarrier.c Wed Jan 13 20:24:50 2010 @@ -0,0 +1,11 @@ +// RUN: %llvmgcc %s -S -emit-llvm -o - | FileCheck %s +// XFAIL: sparc,powerpc +// rdar://7536390 + +unsigned t(unsigned *ptr, unsigned val) { + // CHECK: @t + // CHECK: call void @llvm.memory.barrier + // CHECK-NEXT: call i32 @llvm.atomic.swap.i32 + // CHECK-NEXT: call void @llvm.memory.barrier + return __sync_lock_test_and_set(ptr, val); +} From espindola at google.com Wed Jan 13 20:34:25 2010 From: espindola at google.com (Rafael Espindola) Date: Wed, 13 Jan 2010 21:34:25 -0500 Subject: [llvm-commits] [patch] Add support for emulators in RunSafely.sh In-Reply-To: References: <38a0d8451001131442q334aaacftfc638aee8671f456@mail.gmail.com> <38a0d8451001131518i721591d1vea33e6d7efa7f097@mail.gmail.com> <38a0d8451001131620t73911635o7e3cdbfa72f0670c@mail.gmail.com> Message-ID: <38a0d8451001131834u6682a921ged1d2113ab775b95@mail.gmail.com> > No, but I'm not sure it needs to. It takes which means > that "prog foo" could become "wrapper prog foo" with no difference in > behaviour. But after taking another look, I don't see any of the makefiles > in llvm-test actually using GET_STABLE_NUMBERS. I guess you don't really > need to support that. :) The problem is that it calls RunSafely.sh and the argument end up in the wrong order. > So with that said, this patch once again looks fine, but then, so did all > the others ;) Committed. > Nick > Thanks, -- Rafael ?vila de Esp?ndola From gohman at apple.com Wed Jan 13 21:08:49 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 14 Jan 2010 03:08:49 -0000 Subject: [llvm-commits] [llvm] r93417 - in /llvm/trunk: lib/CodeGen/SelectionDAG/DAGCombiner.cpp test/CodeGen/X86/br-fold.ll Message-ID: <201001140308.o0E38nWW003034@zion.cs.uiuc.edu> Author: djg Date: Wed Jan 13 21:08:49 2010 New Revision: 93417 URL: http://llvm.org/viewvc/llvm-project?rev=93417&view=rev Log: Fix a codegen abort seen in 483.xalancbmk. Added: llvm/trunk/test/CodeGen/X86/br-fold.ll 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=93417&r1=93416&r2=93417&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed Jan 13 21:08:49 2010 @@ -1684,6 +1684,9 @@ EVT VT = N0.getValueType(); assert(N0.getOpcode() == N1.getOpcode() && "Bad input!"); + // Bail early if none of these transforms apply. + if (N0.getNode()->getNumOperands() == 0) return SDValue(); + // For each of OP in AND/OR/XOR: // fold (OP (zext x), (zext y)) -> (zext (OP x, y)) // fold (OP (sext x), (sext y)) -> (sext (OP x, y)) Added: llvm/trunk/test/CodeGen/X86/br-fold.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/br-fold.ll?rev=93417&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/br-fold.ll (added) +++ llvm/trunk/test/CodeGen/X86/br-fold.ll Wed Jan 13 21:08:49 2010 @@ -0,0 +1,20 @@ +; RUN: llc -march=x86-64 < %s | FileCheck %s + +; CHECK: orq +; CHECK-NEXT: jne + + at _ZN11xercesc_2_513SchemaSymbols21fgURI_SCHEMAFORSCHEMAE = external constant [33 x i16], align 32 ; <[33 x i16]*> [#uses=1] + at _ZN11xercesc_2_56XMLUni16fgNotationStringE = external constant [9 x i16], align 16 ; <[9 x i16]*> [#uses=1] + +define fastcc void @foo() { +entry: + br i1 icmp eq (i64 or (i64 ptrtoint ([33 x i16]* @_ZN11xercesc_2_513SchemaSymbols21fgURI_SCHEMAFORSCHEMAE to i64), + i64 ptrtoint ([9 x i16]* @_ZN11xercesc_2_56XMLUni16fgNotationStringE to i64)), i64 0), + label %bb8.i329, label %bb4.i.i318.preheader + +bb4.i.i318.preheader: ; preds = %bb6 + unreachable + +bb8.i329: ; preds = %bb6 + unreachable +} From nicholas at mxc.ca Wed Jan 13 23:30:30 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 13 Jan 2010 21:30:30 -0800 Subject: [llvm-commits] [llvm] r93373 - in /llvm/trunk/lib/Target/X86: README-SSE.txt README.txt In-Reply-To: <201001132329.o0DNTCgm027160@zion.cs.uiuc.edu> References: <201001132329.o0DNTCgm027160@zion.cs.uiuc.edu> Message-ID: <4B4EABF6.2070505@mxc.ca> Chris Lattner wrote: > Author: lattner > Date: Wed Jan 13 17:29:11 2010 > New Revision: 93373 > > URL: http://llvm.org/viewvc/llvm-project?rev=93373&view=rev > Log: > this is an SSE-specific issue. It is? We don't want to convert the branch into a switch in the IR? Nick > > Modified: > llvm/trunk/lib/Target/X86/README-SSE.txt > llvm/trunk/lib/Target/X86/README.txt > > Modified: llvm/trunk/lib/Target/X86/README-SSE.txt > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README-SSE.txt?rev=93373&r1=93372&r2=93373&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/README-SSE.txt (original) > +++ llvm/trunk/lib/Target/X86/README-SSE.txt Wed Jan 13 17:29:11 2010 > @@ -916,3 +916,23 @@ > "load, add 1.0, store" is better done in the fp stack, etc. > > //===---------------------------------------------------------------------===// > + > +The X86 backend should be able to if-convert SSE comparisons like "ucomisd" to > +"cmpsd". For example, this code: > + > +double d1(double x) { return x == x ? x : x + x; } > + > +Compiles into: > + > +_d1: > + ucomisd %xmm0, %xmm0 > + jnp LBB1_2 > + addsd %xmm0, %xmm0 > + ret > +LBB1_2: > + ret > + > +Also, the 'ret's should be shared. This is PR6032. > + > +//===---------------------------------------------------------------------===// > + > > Modified: llvm/trunk/lib/Target/X86/README.txt > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README.txt?rev=93373&r1=93372&r2=93373&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/README.txt (original) > +++ llvm/trunk/lib/Target/X86/README.txt Wed Jan 13 17:29:11 2010 > @@ -1868,23 +1868,3 @@ > information to add the "lock" prefix. > > //===---------------------------------------------------------------------===// > - > -The X86 backend should be able to if-convert SSE comparisons like "ucomisd" to > -"cmpsd". For example, this code: > - > -double d1(double x) { return x == x ? x : x + x; } > - > -Compiles into: > - > -_d1: > - ucomisd %xmm0, %xmm0 > - jnp LBB1_2 > - addsd %xmm0, %xmm0 > - ret > -LBB1_2: > - ret > - > -Also, the 'ret's should be shared. This is PR6032. > - > -//===---------------------------------------------------------------------===// > - > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From clattner at apple.com Thu Jan 14 00:53:10 2010 From: clattner at apple.com (Chris Lattner) Date: Wed, 13 Jan 2010 22:53:10 -0800 Subject: [llvm-commits] [llvm] r93372 - /llvm/trunk/lib/Target/X86/README.txt In-Reply-To: <355E067F-D5EA-457B-8363-3C27D12D62C1@apple.com> References: <201001132328.o0DNSevM027126@zion.cs.uiuc.edu> <355E067F-D5EA-457B-8363-3C27D12D62C1@apple.com> Message-ID: <82584920-9DEA-4B93-AF61-10C11F6FD9A7@apple.com> On Jan 13, 2010, at 3:45 PM, Dan Gohman wrote: >> >> //===---------------------------------------------------------------------===// >> + >> +The X86 backend should be able to if-convert SSE comparisons like "ucomisd" to >> +"cmpsd". For example, this code: >> + >> +double d1(double x) { return x == x ? x : x + x; } >> + >> +Compiles into: >> + >> +_d1: >> + ucomisd %xmm0, %xmm0 >> + jnp LBB1_2 >> + addsd %xmm0, %xmm0 > > Is cmpsd actually faster? With the cmpsd approach, the > addsd must be executed unconditionally. Right, no idea! I suppose it would depend on how predictable the branch is, and the cost of moving the condition bits from the sse unit. -Chris From sabre at nondot.org Thu Jan 14 00:54:09 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 13 Jan 2010 22:54:09 -0800 Subject: [llvm-commits] [llvm] r93373 - in /llvm/trunk/lib/Target/X86: README-SSE.txt README.txt In-Reply-To: <4B4EABF6.2070505@mxc.ca> References: <201001132329.o0DNTCgm027160@zion.cs.uiuc.edu> <4B4EABF6.2070505@mxc.ca> Message-ID: On Jan 13, 2010, at 9:30 PM, Nick Lewycky wrote: > Chris Lattner wrote: >> Author: lattner >> Date: Wed Jan 13 17:29:11 2010 >> New Revision: 93373 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=93373&view=rev >> Log: >> this is an SSE-specific issue. > > It is? Yes, > We don't want to convert the branch into a switch in the IR? No, that would require unconditionally executing the add, which the mid-level IR has no idea about how profitable this is. ucomisd -> cmppd is a very SSE-specific case. -Chris From baldrick at free.fr Thu Jan 14 03:55:22 2010 From: baldrick at free.fr (Duncan Sands) Date: Thu, 14 Jan 2010 10:55:22 +0100 Subject: [llvm-commits] [llvm-gcc-4.2] r93387 - /llvm-gcc-4.2/trunk/gcc/omp-low.c In-Reply-To: <201001140044.o0E0i9ER030047@zion.cs.uiuc.edu> References: <201001140044.o0E0i9ER030047@zion.cs.uiuc.edu> Message-ID: <4B4EEA0A.8070007@free.fr> Hi Stuart, > Decorate an OMP-specific MODIFY with correct lexical block. why? Where are you going with these patches? Ciao, Duncan. From baldrick at free.fr Thu Jan 14 04:03:46 2010 From: baldrick at free.fr (Duncan Sands) Date: Thu, 14 Jan 2010 11:03:46 +0100 Subject: [llvm-commits] [llvm-gcc-4.2] r93409 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <201001140224.o0E2O7Rl001369@zion.cs.uiuc.edu> References: <201001140224.o0E2O7Rl001369@zion.cs.uiuc.edu> Message-ID: <4B4EEC02.4040608@free.fr> Hi Evan, > Add missing memory barrier after binary atomic builtin. r74403 apparently left this out by mistake. x86 target will optimize it away but it's looking for the barrier after the operation. what do you mean by "it's looking for the barrier after the operation"? > +#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) Should this really be conditioned on the OS (darwin)? After all, how barriers work should be a processor issue, not an OS one... Ciao, Duncan. From isanbard at gmail.com Thu Jan 14 04:19:58 2010 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 14 Jan 2010 10:19:58 -0000 Subject: [llvm-commits] [llvm] r93423 - /llvm/trunk/utils/buildit/GNUmakefile Message-ID: <201001141019.o0EAJxsL000424@zion.cs.uiuc.edu> Author: void Date: Thu Jan 14 04:19:55 2010 New Revision: 93423 URL: http://llvm.org/viewvc/llvm-project?rev=93423&view=rev Log: Use ENABLE_ASSERTIONS throughout. Modified: llvm/trunk/utils/buildit/GNUmakefile Modified: llvm/trunk/utils/buildit/GNUmakefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/buildit/GNUmakefile?rev=93423&r1=93422&r2=93423&view=diff ============================================================================== --- llvm/trunk/utils/buildit/GNUmakefile (original) +++ llvm/trunk/utils/buildit/GNUmakefile Thu Jan 14 04:19:55 2010 @@ -36,7 +36,7 @@ # Unless assertions are forced on in the GMAKE command line, enable them. ifndef ENABLE_ASSERTIONS -LLVM_ASSERTIONS := yes +ENABLE_ASSERTIONS := yes endif # Default is optimized build. @@ -59,7 +59,7 @@ cd $(OBJROOT) && \ $(SRC)/utils/buildit/build_llvm "$(RC_ARCHS)" "$(TARGETS)" \ $(SRC) $(PREFIX) $(DSTROOT) $(SYMROOT) \ - $(LLVM_ASSERTIONS) $(LLVM_OPTIMIZED) \ + $(ENABLE_ASSERTIONS) $(LLVM_OPTIMIZED) \ $(RC_ProjectSourceVersion) $(RC_ProjectSourceSubversion) From isanbard at gmail.com Thu Jan 14 04:20:19 2010 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 14 Jan 2010 10:20:19 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93424 - /llvm-gcc-4.2/trunk/GNUmakefile Message-ID: <201001141020.o0EAKJon000454@zion.cs.uiuc.edu> Author: void Date: Thu Jan 14 04:20:19 2010 New Revision: 93424 URL: http://llvm.org/viewvc/llvm-project?rev=93424&view=rev Log: Use ENABLE_ASSERTIONS throughout. Modified: llvm-gcc-4.2/trunk/GNUmakefile Modified: llvm-gcc-4.2/trunk/GNUmakefile URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/GNUmakefile?rev=93424&r1=93423&r2=93424&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/GNUmakefile (original) +++ llvm-gcc-4.2/trunk/GNUmakefile Thu Jan 14 04:20:19 2010 @@ -60,11 +60,9 @@ ENABLE_LLVM = false endif -# Unless assertions are forced on in the GMAKE command line, disable them. -ifdef ENABLE_ASSERTIONS -LLVM_ASSERTIONS := yes -else -LLVM_ASSERTIONS := no +# Unless assertions are forced on in the GMAKE command line, enable them. +ifndef ENABLE_ASSERTIONS +ENABLE_ASSERTIONS := yes endif ifndef LLVMCORE_PATH @@ -87,7 +85,7 @@ cd $(OBJROOT) && \ $(SRC)/build_gcc "$(RC_ARCHS)" "$(TARGETS)" \ $(SRC) $(PREFIX) $(DSTROOT) $(SYMROOT) $(ENABLE_LLVM) \ - $(LLVM_ASSERTIONS) $(LLVMCORE_PATH) \ + $(ENABLE_ASSERTIONS) $(LLVMCORE_PATH) \ $(RC_ProjectSourceVersion) $(RC_ProjectSourceSubversion) # LLVM LOCAL end From jay.foad at gmail.com Thu Jan 14 05:50:52 2010 From: jay.foad at gmail.com (Jay Foad) Date: Thu, 14 Jan 2010 11:50:52 +0000 Subject: [llvm-commits] [PATCH] bug 6028: fix interpreter assertion on use of undefined integer value Message-ID: The attached patch fixes bug 6028. I've only tested it on the test case cited in the bug. What other testing can I do that will exercise the interpreter? Or, OK to apply? Thanks, Jay. -------------- next part -------------- A non-text attachment was scrubbed... Name: 6028.diff Type: application/octet-stream Size: 1049 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100114/f04d21fc/attachment.obj From evan.cheng at apple.com Thu Jan 14 10:49:17 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 14 Jan 2010 08:49:17 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r93409 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <4B4EEC02.4040608@free.fr> References: <201001140224.o0E2O7Rl001369@zion.cs.uiuc.edu> <4B4EEC02.4040608@free.fr> Message-ID: <9FDBC158-AA17-4DE2-9A5C-DEA5C9A2D042@apple.com> On Jan 14, 2010, at 2:03 AM, Duncan Sands wrote: > Hi Evan, > >> Add missing memory barrier after binary atomic builtin. r74403 apparently left this out by mistake. x86 target will optimize it away but it's looking for the barrier after the operation. > > what do you mean by "it's looking for the barrier after the operation"? DAG combine is looking for the ISD::MemBarrier node that's the successor of the atomic op. > >> +#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) > > Should this really be conditioned on the OS (darwin)? After all, how > barriers work should be a processor issue, not an OS one... I have no idea. That's how it was written. Evan > > Ciao, > > Duncan. From stuart at apple.com Thu Jan 14 11:08:57 2010 From: stuart at apple.com (Stuart Hastings) Date: Thu, 14 Jan 2010 09:08:57 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r93424 - /llvm-gcc-4.2/trunk/GNUmakefile In-Reply-To: <201001141020.o0EAKJon000454@zion.cs.uiuc.edu> References: <201001141020.o0EAKJon000454@zion.cs.uiuc.edu> Message-ID: <9DD690BA-75F7-435B-B005-76F490EFF4A4@apple.com> On Jan 14, 2010, at 2:20 AM, Bill Wendling wrote: > Author: void > Date: Thu Jan 14 04:20:19 2010 > New Revision: 93424 > > URL: http://llvm.org/viewvc/llvm-project?rev=93424&view=rev > Log: > Use ENABLE_ASSERTIONS throughout. I had a similar, yet untested patch, but you're faster than I am. I'll copy this to the Zoidberg branch if you haven't beaten me to it. Thank you, stuart > > Modified: > llvm-gcc-4.2/trunk/GNUmakefile > > Modified: llvm-gcc-4.2/trunk/GNUmakefile > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/GNUmakefile?rev=93424&r1=93423&r2=93424&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm-gcc-4.2/trunk/GNUmakefile (original) > +++ llvm-gcc-4.2/trunk/GNUmakefile Thu Jan 14 04:20:19 2010 > @@ -60,11 +60,9 @@ > ENABLE_LLVM = false > endif > > -# Unless assertions are forced on in the GMAKE command line, > disable them. > -ifdef ENABLE_ASSERTIONS > -LLVM_ASSERTIONS := yes > -else > -LLVM_ASSERTIONS := no > +# Unless assertions are forced on in the GMAKE command line, enable > them. > +ifndef ENABLE_ASSERTIONS > +ENABLE_ASSERTIONS := yes > endif > > ifndef LLVMCORE_PATH > @@ -87,7 +85,7 @@ > cd $(OBJROOT) && \ > $(SRC)/build_gcc "$(RC_ARCHS)" "$(TARGETS)" \ > $(SRC) $(PREFIX) $(DSTROOT) $(SYMROOT) $(ENABLE_LLVM) \ > - $(LLVM_ASSERTIONS) $(LLVMCORE_PATH) \ > + $(ENABLE_ASSERTIONS) $(LLVMCORE_PATH) \ > $(RC_ProjectSourceVersion) $(RC_ProjectSourceSubversion) > > # LLVM LOCAL end > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From nicholas at mxc.ca Thu Jan 14 11:10:15 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 14 Jan 2010 09:10:15 -0800 Subject: [llvm-commits] [PATCH] bug 6028: fix interpreter assertion on use of undefined integer value In-Reply-To: References: Message-ID: <4B4F4FF7.90407@mxc.ca> Jay Foad wrote: > The attached patch fixes bug 6028. I've only tested it on the test > case cited in the bug. What other testing can I do that will exercise > the interpreter? Always make sure to run 'make check' before committing any change. If you're paranoid, you can also try out a nightly build before and after, but I don't think we care that much :) The nightly test has many failures due to things like taking addresses of functions and passing them around (to qsort for example). > Or, OK to apply? Why care about the type? Why not just: if (isa(C)) { GenericValue Result; Result.IntVal = APInt(C->getType()->getPrimitiveSizeInBits(), 0); return Result; } ? Nick From stuart at apple.com Thu Jan 14 11:32:21 2010 From: stuart at apple.com (Stuart Hastings) Date: Thu, 14 Jan 2010 09:32:21 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r93387 - /llvm-gcc-4.2/trunk/gcc/omp-low.c In-Reply-To: <4B4EEA0A.8070007@free.fr> References: <201001140044.o0E0i9ER030047@zion.cs.uiuc.edu> <4B4EEA0A.8070007@free.fr> Message-ID: On Jan 14, 2010, at 1:55 AM, Duncan Sands wrote: > Hi Stuart, > >> Decorate an OMP-specific MODIFY with correct lexical block. > > why? Where are you going with these patches? I'm supposed to teach llvm-gcc how to emit lexical blocks into DWARF. I've been testing with the GCC DejaGNU test suite, and my lexical- block emitter has uncovered many latent bugs, all on the GCC side. The lexical-block emitter itself is not likely to break anything. However, I was obliged to change the order of declaration of local variables. Currently, llvm-gcc declares all local variables at the entry to a function; in the new, lexical-block world, I cannot emit a declaration until we arrive at its lexical block (having emitted much unrelated code in the interim). Of course, I must declare the locals in the same order whether debug info is on or off. If the tree->LLVM converter discovers an un-emitted decl, it asserts, so it's now imperative to get the scoping correct. I suppose I could compensate for missing lexical block decorations with an extra tree walk, but this seems like a heavy compile-time penalty. The patches thus far are fixes for mostly harmless, latent bugs. The next patch is not harmless; it fixes a latent bug in the x86-64 ABI, specifically in the code that assigns structures to parameter registers. This code has proven very fragile, and difficult to get right. If it goes in without breaking anything, the lexical-block emitter is next, and then I'm done. I don't know much about your Dragon's Egg (did I spell that correctly?) project, but I wonder if the lexical block emitter might pose a problem for it. GCC hasn't been perfectly disciplined about lexical blocks, compensating with searching techniques in the tree/RTL interface. (If a tree is missing its lexical block decoration, GCC will use a binary search to identify the most probable lexical block when generating RTL.) The existing (and reasonable!) LLVM ABI does not afford me that luxury, thus I've been fixing GCC. BTW, I think clang is already generating correct lexical block info. Did I answer your question? stuart From devang.patel at gmail.com Thu Jan 14 11:39:38 2010 From: devang.patel at gmail.com (Devang Patel) Date: Thu, 14 Jan 2010 09:39:38 -0800 Subject: [llvm-commits] [llvm] r93400 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp In-Reply-To: <201001140145.o0E1jEDi032182@zion.cs.uiuc.edu> References: <201001140145.o0E1jEDi032182@zion.cs.uiuc.edu> Message-ID: <352a1fb21001140939k4f8055e0i90ee37ca4540e7eb@mail.gmail.com> On Wed, Jan 13, 2010 at 5:45 PM, Victor Hernandez wrote: > Author: hernande > Date: Wed Jan 13 19:45:14 2010 > New Revision: 93400 > > URL: http://llvm.org/viewvc/llvm-project?rev=93400&view=rev > Log: > Add MDNode::getFunction(), which figures out the metadata's function, if it has function that it is local to. so will this replace isFunctionLocal() ? - Devang From devang.patel at gmail.com Thu Jan 14 11:58:04 2010 From: devang.patel at gmail.com (Devang Patel) Date: Thu, 14 Jan 2010 09:58:04 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r93387 - /llvm-gcc-4.2/trunk/gcc/omp-low.c In-Reply-To: <4B4EEA0A.8070007@free.fr> References: <201001140044.o0E0i9ER030047@zion.cs.uiuc.edu> <4B4EEA0A.8070007@free.fr> Message-ID: <352a1fb21001140958t1f53b43er1db37108f2fb5e1@mail.gmail.com> On Thu, Jan 14, 2010 at 1:55 AM, Duncan Sands wrote: > Hi Stuart, > >> Decorate an OMP-specific MODIFY with correct lexical block. > > why? ?Where are you going with these patches? > llvm-gcc (and dragon-egg also?) converts gimplified gcc trees into llvm IR. Even at -O0. Unfortunately, during gimplification the lexical blocks info. is not kept upto date by the gimplifier. This results in not so pleasant, and many times confusing, debugging experience while debugging unoptimized code generated by llvm-gcc. This is because all local variables are made available at function level. Stuart is trying to keep lexical blocks info intact during gimplification, so the llvm converter can convert debug info appropriately. - Devang From stoklund at 2pi.dk Thu Jan 14 12:19:56 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 14 Jan 2010 18:19:56 -0000 Subject: [llvm-commits] [llvm] r93436 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <201001141819.o0EIJv3R019414@zion.cs.uiuc.edu> Author: stoklund Date: Thu Jan 14 12:19:56 2010 New Revision: 93436 URL: http://llvm.org/viewvc/llvm-project?rev=93436&view=rev Log: ARM "l" constraint for inline asm means R0-R7, also for Thumb2. This is consistent with llvm-gcc's arm/constraints.md. Certain instructions (e.g. CBZ, CBNZ) require a low register, even in Thumb2 mode. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=93436&r1=93435&r2=93436&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Jan 14 12:19:56 2010 @@ -4258,10 +4258,10 @@ ARMTargetLowering::getRegForInlineAsmConstraint(const std::string &Constraint, EVT VT) const { if (Constraint.size() == 1) { - // GCC RS6000 Constraint Letters + // GCC ARM Constraint Letters switch (Constraint[0]) { case 'l': - if (Subtarget->isThumb1Only()) + if (Subtarget->isThumb()) return std::make_pair(0U, ARM::tGPRRegisterClass); else return std::make_pair(0U, ARM::GPRRegisterClass); From vhernandez at apple.com Thu Jan 14 12:20:30 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 14 Jan 2010 10:20:30 -0800 Subject: [llvm-commits] [llvm] r93400 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp In-Reply-To: <352a1fb21001140939k4f8055e0i90ee37ca4540e7eb@mail.gmail.com> References: <201001140145.o0E1jEDi032182@zion.cs.uiuc.edu> <352a1fb21001140939k4f8055e0i90ee37ca4540e7eb@mail.gmail.com> Message-ID: <3AEBD80F-B03B-41F8-BD98-F6758DA36F85@apple.com> On Jan 14, 2010, at 9:39 AM, Devang Patel wrote: > On Wed, Jan 13, 2010 at 5:45 PM, Victor Hernandez wrote: >> Author: hernande >> Date: Wed Jan 13 19:45:14 2010 >> New Revision: 93400 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=93400&view=rev >> Log: >> Add MDNode::getFunction(), which figures out the metadata's function, if it has function that it is local to. > > so will this replace isFunctionLocal() ? No, I don't think it should replace isFunctionLocal(). getFunction() is an expensive operation that should not be used in performance-critical tasks (currently it is only used when printing out ll files). isFunctionLocal() is fast and will very rarely give a false positive (when a metadata is created function-local, but then the operands are modified later). > - > Devang From isanbard at gmail.com Thu Jan 14 12:56:11 2010 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 14 Jan 2010 10:56:11 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r93424 - /llvm-gcc-4.2/trunk/GNUmakefile In-Reply-To: <9DD690BA-75F7-435B-B005-76F490EFF4A4@apple.com> References: <201001141020.o0EAKJon000454@zion.cs.uiuc.edu> <9DD690BA-75F7-435B-B005-76F490EFF4A4@apple.com> Message-ID: <1B81D7E6-725E-43D1-BF4A-643DEE5EE1B5@gmail.com> On Jan 14, 2010, at 9:08 AM, Stuart Hastings wrote: > On Jan 14, 2010, at 2:20 AM, Bill Wendling wrote: > >> Author: void >> Date: Thu Jan 14 04:20:19 2010 >> New Revision: 93424 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=93424&view=rev >> Log: >> Use ENABLE_ASSERTIONS throughout. > > I had a similar, yet untested patch, but you're faster than I am. > > I'll copy this to the Zoidberg branch if you haven't beaten me to it. > I jumped the gun a bit. I'd already built with these options, though. So they looked okay to me. :-) -bw From vhernandez at apple.com Thu Jan 14 13:38:44 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 14 Jan 2010 19:38:44 -0000 Subject: [llvm-commits] [llvm] r93441 - in /llvm/trunk/lib/Bitcode/Writer: BitcodeWriter.cpp ValueEnumerator.h Message-ID: <201001141938.o0EJcidc022841@zion.cs.uiuc.edu> Author: hernande Date: Thu Jan 14 13:38:44 2010 New Revision: 93441 URL: http://llvm.org/viewvc/llvm-project?rev=93441&view=rev Log: Avoid modifying ValueEnumerator's MD ValueList by choosing which function-local MD to write based on the function currently being written Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=93441&r1=93440&r2=93441&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Thu Jan 14 13:38:44 2010 @@ -554,30 +554,22 @@ Stream.ExitBlock(); } -static void WriteFunctionLocalMetadata(const ValueEnumerator &VE, +static void WriteFunctionLocalMetadata(const Function &F, + const ValueEnumerator &VE, BitstreamWriter &Stream) { bool StartedMetadataBlock = false; SmallVector Record; - ValueEnumerator::ValueList Vals = VE.getMDValues(); - ValueEnumerator::ValueList::iterator it = Vals.begin(); - ValueEnumerator::ValueList::iterator end = Vals.end(); - - while (it != end) { - if (const MDNode *N = dyn_cast((*it).first)) { - if (N->isFunctionLocal()) { + const ValueEnumerator::ValueList &Vals = VE.getMDValues(); + + for (unsigned i = 0, e = Vals.size(); i != e; ++i) + if (const MDNode *N = dyn_cast(Vals[i].first)) + if (N->getFunction() == &F) { if (!StartedMetadataBlock) { Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); StartedMetadataBlock = true; } WriteMDNode(N, VE, Stream, Record); - // Remove function-local MD, since it is not used outside of function. - it = Vals.erase(it); - end = Vals.end(); - continue; } - } - ++it; - } if (StartedMetadataBlock) Stream.ExitBlock(); @@ -1227,7 +1219,7 @@ WriteConstants(CstStart, CstEnd, VE, Stream, false); // If there is function-local metadata, emit it now. - WriteFunctionLocalMetadata(VE, Stream); + WriteFunctionLocalMetadata(F, VE, Stream); // Keep a running idea of what the instruction ID is. unsigned InstID = CstEnd; Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h?rev=93441&r1=93440&r2=93441&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h (original) +++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h Thu Jan 14 13:38:44 2010 @@ -105,7 +105,6 @@ const ValueList &getValues() const { return Values; } const ValueList &getMDValues() const { return MDValues; } - ValueList getMDValues() { return MDValues; } const TypeList &getTypes() const { return Types; } const std::vector &getBasicBlocks() const { return BasicBlocks; From vhernandez at apple.com Thu Jan 14 13:38:54 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 14 Jan 2010 11:38:54 -0800 Subject: [llvm-commits] [llvm] r93339 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp In-Reply-To: <352a1fb21001131346w5b765debraa3159e87d1cbd0d@mail.gmail.com> References: <201001131937.o0DJbXO9017579@zion.cs.uiuc.edu> <352a1fb21001131305i49e7e817nda9f224ecb4d6537@mail.gmail.com> <352a1fb21001131315l2fd18436s84afa0767db3215c@mail.gmail.com> <80A05DBF-E67B-4B67-B55E-E5B33A8F95FE@apple.com> <352a1fb21001131346w5b765debraa3159e87d1cbd0d@mail.gmail.com> Message-ID: <9D79FA7C-D32D-449B-BA37-5CEC50A26F53@apple.com> On Jan 13, 2010, at 1:46 PM, Devang Patel wrote: > On Wed, Jan 13, 2010 at 1:19 PM, Victor Hernandez wrote: >> >> On Jan 13, 2010, at 1:15 PM, Devang Patel wrote: >> >> On Wed, Jan 13, 2010 at 1:07 PM, Victor Hernandez >> wrote: >> >> On Jan 13, 2010, at 1:05 PM, Devang Patel wrote: >> >> On Wed, Jan 13, 2010 at 11:37 AM, Victor Hernandez >> wrote: >> >> >> +static void WriteFunctionLocalMetadata(const ValueEnumerator &VE, >> >> + BitstreamWriter &Stream) { >> >> + bool StartedMetadataBlock = false; >> >> + SmallVector Record; >> >> + ValueEnumerator::ValueList Vals = VE.getMDValues(); >> >> + ValueEnumerator::ValueList::iterator it = Vals.begin(); >> >> + ValueEnumerator::ValueList::iterator end = Vals.end(); >> >> + >> >> + while (it != end) { >> >> + if (const MDNode *N = dyn_cast((*it).first)) { >> >> + if (N->isFunctionLocal()) { >> >> + if (!StartedMetadataBlock) { >> >> + Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); >> >> + StartedMetadataBlock = true; >> >> + } >> >> + WriteMDNode(N, VE, Stream, Record); >> >> + // Remove function-local MD, since it is used outside of function. >> >> how ? >> >> Sorry that is a typo. Meant to say "is not used". >> >> but why remove from value list ? >> >> Because the same ValueList (via VE.getMDValues()) is used during all of the >> bitcode-writing. Function-local metadata needs to exist in the ValueList >> only during the writing of the function it is local to (from its lazy >> enumeration during incorporateFunction until WriteFunctionLocalMetadata() is >> called). If it does not get removed here, then it will still be >> in VE.getMDValues() when we go to write the next function. >> >> >> >> + it = Vals.erase(it); >> >> + end = Vals.end(); >> >> + continue; >> >> + } >> >> + } >> >> + ++it; >> >> + } >> >> + >> >> + if (StartedMetadataBlock) >> >> + Stream.ExitBlock(); >> >> +} >> >> + >> >> static void WriteMetadataAttachment(const Function &F, >> >> const ValueEnumerator &VE, >> >> BitstreamWriter &Stream) { >> >> @@ -1210,6 +1241,7 @@ >> >> // Emit names for all the instructions etc. >> >> WriteValueSymbolTable(F.getValueSymbolTable(), VE, Stream); >> >> + WriteFunctionLocalMetadata(VE, Stream); >> >> This does not check function so will it write function local metadata >> >> from one function into another function's block ? >> >> That check is done by the Verifier. Do you think I need to do it here also? >> >> Are you sure that incoming VE will not have function local metadata >> for another function at this point? >> >> Yes, that is guaranteed by removing function-local metadata as soon as they >> get written. >> > > ValueList is not manipulated like this in BitCode Writer. Erasing > element one by one from ValueList may have performance impact. > Instead, it is better to keep ValueList intact and check function in > WriteFunctionLocalMetadata() and update isFunctionLocal() to return > Function *. Fixed in r93441. > > - > Devang From espindola at google.com Thu Jan 14 13:40:54 2010 From: espindola at google.com (Rafael Espindola) Date: Thu, 14 Jan 2010 14:40:54 -0500 Subject: [llvm-commits] [patch] Used TimedExec.sh everywhere Message-ID: <38a0d8451001141140j4c366ca5vc3c8927d3b1882df@mail.gmail.com> I left the test-suite running during the night just to find it stuck this morning. The problem is that an atomics test was frozen but not using any CPU, so it was not failing. There is no way to limit wall time with ulimit, so I think the best thing is to just use TimedExec.sh everywhere. Is the attached patch OK? Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: timed.patch Type: text/x-diff Size: 495 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100114/ded1e784/attachment.bin From stuart at apple.com Thu Jan 14 13:52:28 2010 From: stuart at apple.com (Stuart Hastings) Date: Thu, 14 Jan 2010 19:52:28 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93445 - in /llvm-gcc-4.2/trunk/gcc/config/i386: i386.c llvm-i386.cpp Message-ID: <201001141952.o0EJqSIC023752@zion.cs.uiuc.edu> Author: stuart Date: Thu Jan 14 13:52:28 2010 New Revision: 93445 URL: http://llvm.org/viewvc/llvm-project?rev=93445&view=rev Log: This is a fix for the x86-64 ABI code. When a struct is passed across a call, it will be broken into component machine types and passed in suitable registers. The callee is expected to use the values in place. However, if the callee is a variable-argument function, it will re-assemble the original structure in a local temporary. This code controls the registers and widths used during reassembly. The broken test case (in the GCC DejaGNU test suite) concerns a struct wrapping an array of three floats will be passed in two SSE registers. When storing into the temporary mentioned above, both compilers emit a 128-bit store, clobbering 32 adjacent bits. This patch arranges for a 96-bit store. (Both compilers are wrong, but GCC is luckier than llvm-gcc. :-) Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.c llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/i386.c?rev=93445&r1=93444&r2=93445&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/i386.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/i386.c Thu Jan 14 13:52:28 2010 @@ -3458,17 +3458,24 @@ if (!num) return 0; - /* The partial classes are now full classes. */ - if (subclasses[0] == X86_64_SSESF_CLASS && bytes != 4) - subclasses[0] = X86_64_SSE_CLASS; - if (subclasses[0] == X86_64_INTEGERSI_CLASS && bytes != 4) - subclasses[0] = X86_64_INTEGER_CLASS; - + /* LLVM LOCAL begin 7387470 */ for (i = 0; i < words; i++) classes[i] = subclasses[i % num]; - break; + /* If 32-bit class, consider upgrade to 64-bit. */ + if (bytes > 4 && + (subclasses[0] == X86_64_SSESF_CLASS || + subclasses[0] == X86_64_INTEGERSI_CLASS)) { + enum x86_64_reg_class upgrade64 = + (subclasses[0] == X86_64_SSESF_CLASS) ? + X86_64_SSE_CLASS : X86_64_INTEGER_CLASS; + classes[0] = upgrade64; + if (bytes > 12) + classes[1] = upgrade64; + } } + break; + /* LLVM LOCAL end 7387470 */ case UNION_TYPE: case QUAL_UNION_TYPE: /* Unions are similar to RECORD_TYPE but offset is always 0. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=93445&r1=93444&r2=93445&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Thu Jan 14 13:52:28 2010 @@ -839,10 +839,6 @@ if (!NumClasses) return false; - if (NumClasses == 1 && Class[0] == X86_64_INTEGERSI_CLASS) - // This will fit in one i32 register. - return false; - for (int i = 0; i < NumClasses; ++i) { switch (Class[i]) { case X86_64_INTEGER_CLASS: From vhernandez at apple.com Thu Jan 14 13:54:11 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 14 Jan 2010 19:54:11 -0000 Subject: [llvm-commits] [llvm] r93446 - in /llvm/trunk/lib/Bitcode/Writer: ValueEnumerator.cpp ValueEnumerator.h Message-ID: <201001141954.o0EJsCBu023871@zion.cs.uiuc.edu> Author: hernande Date: Thu Jan 14 13:54:11 2010 New Revision: 93446 URL: http://llvm.org/viewvc/llvm-project?rev=93446&view=rev Log: Simplify code that chooses when to enumerate function-local metadata operands Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=93446&r1=93445&r2=93446&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Thu Jan 14 13:54:11 2010 @@ -91,8 +91,13 @@ for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB) for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E;++I){ for (User::const_op_iterator OI = I->op_begin(), E = I->op_end(); - OI != E; ++OI) - EnumerateOperandType(*OI, true); + OI != E; ++OI) { + if (MDNode *MD = dyn_cast(*OI)) + if (MD->isFunctionLocal()) + // These will get enumerated during function-incorporation. + continue; + EnumerateOperandType(*OI); + } EnumerateType(I->getType()); if (const CallInst *CI = dyn_cast(I)) EnumerateAttributes(CI->getAttributes()); @@ -103,7 +108,7 @@ MDs.clear(); I->getAllMetadata(MDs); for (unsigned i = 0, e = MDs.size(); i != e; ++i) - EnumerateMetadata(MDs[i].second, true); + EnumerateMetadata(MDs[i].second); } } @@ -224,7 +229,7 @@ MDValueMap[MD] = Values.size(); } -void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD, bool isGlobal) { +void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD) { // Check to see if it's already in! unsigned &MDValueID = MDValueMap[MD]; if (MDValueID) { @@ -237,16 +242,14 @@ EnumerateType(MD->getType()); if (const MDNode *N = dyn_cast(MD)) { - if ((isGlobal && !N->isFunctionLocal()) || - (!isGlobal && N->isFunctionLocal())) { - MDValues.push_back(std::make_pair(MD, 1U)); - MDValueMap[MD] = MDValues.size(); - MDValueID = MDValues.size(); - for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) - if (Value *V = N->getOperand(i)) - EnumerateValue(V); - else - EnumerateType(Type::getVoidTy(MD->getContext())); + MDValues.push_back(std::make_pair(MD, 1U)); + MDValueMap[MD] = MDValues.size(); + MDValueID = MDValues.size(); + for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { + if (Value *V = N->getOperand(i)) + EnumerateValue(V); + else + EnumerateType(Type::getVoidTy(MD->getContext())); } return; } @@ -257,10 +260,10 @@ MDValueID = MDValues.size(); } -void ValueEnumerator::EnumerateValue(const Value *V, bool isGlobal) { +void ValueEnumerator::EnumerateValue(const Value *V) { assert(!V->getType()->isVoidTy() && "Can't insert void values!"); if (const MetadataBase *MB = dyn_cast(V)) - return EnumerateMetadata(MB, isGlobal); + return EnumerateMetadata(MB); else if (const NamedMDNode *NMD = dyn_cast(V)) return EnumerateNamedMDNode(NMD); @@ -294,7 +297,7 @@ for (User::const_op_iterator I = C->op_begin(), E = C->op_end(); I != E; ++I) if (!isa(*I)) // Don't enumerate BB operand to BlockAddress. - EnumerateValue(*I, isGlobal); + EnumerateValue(*I); // Finally, add the value. Doing this could make the ValueID reference be // dangling, don't reuse it. @@ -331,14 +334,9 @@ // Enumerate the types for the specified value. If the value is a constant, // walk through it, enumerating the types of the constant. -void ValueEnumerator::EnumerateOperandType(const Value *V, bool isGlobal) { +void ValueEnumerator::EnumerateOperandType(const Value *V) { EnumerateType(V->getType()); - // During function-incorporation, only enumerate metadata operands. - if (!isGlobal) - if (const MetadataBase *MB = dyn_cast(V)) - return EnumerateMetadata(MB, isGlobal); - if (const Constant *C = dyn_cast(V)) { // If this constant is already enumerated, ignore it, we know its type must // be enumerated. @@ -353,13 +351,13 @@ // blockaddress. if (isa(Op)) continue; - EnumerateOperandType(cast(Op), isGlobal); + EnumerateOperandType(cast(Op)); } if (const MDNode *N = dyn_cast(V)) { for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) if (Value *Elem = N->getOperand(i)) - EnumerateOperandType(Elem, isGlobal); + EnumerateOperandType(Elem); } } else if (isa(V) || isa(V)) EnumerateValue(V); @@ -414,7 +412,11 @@ for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) { for (User::const_op_iterator OI = I->op_begin(), E = I->op_end(); OI != E; ++OI) { - EnumerateOperandType(*OI, false); + if (MDNode *MD = dyn_cast(*OI)) + if (!MD->isFunctionLocal()) + // These were already enumerated during ValueEnumerator creation. + continue; + EnumerateOperandType(*OI); } if (!I->getType()->isVoidTy()) EnumerateValue(I); Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h?rev=93446&r1=93445&r2=93446&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h (original) +++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h Thu Jan 14 13:54:11 2010 @@ -127,11 +127,11 @@ private: void OptimizeConstants(unsigned CstStart, unsigned CstEnd); - void EnumerateMetadata(const MetadataBase *MD, bool isGlobal); + void EnumerateMetadata(const MetadataBase *MD); void EnumerateNamedMDNode(const NamedMDNode *NMD); - void EnumerateValue(const Value *V, bool isGlobal = true); + void EnumerateValue(const Value *V); void EnumerateType(const Type *T); - void EnumerateOperandType(const Value *V, bool isGlobal); + void EnumerateOperandType(const Value *V); void EnumerateAttributes(const AttrListPtr &PAL); void EnumerateTypeSymbolTable(const TypeSymbolTable &ST); From vhernandez at apple.com Thu Jan 14 13:54:39 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 14 Jan 2010 11:54:39 -0800 Subject: [llvm-commits] [llvm] r93338 - in /llvm/trunk/lib/Bitcode/Writer: ValueEnumerator.cpp ValueEnumerator.h In-Reply-To: <352a1fb21001131401i4c612f5fj2f26f0ee9982c2c1@mail.gmail.com> References: <201001131936.o0DJaGrj017512@zion.cs.uiuc.edu> <352a1fb21001131300q21c970c1r4ad677849aa3fc20@mail.gmail.com> <10AD2E2C-7D7A-4B5F-847A-EE228B900962@apple.com> <352a1fb21001131401i4c612f5fj2f26f0ee9982c2c1@mail.gmail.com> Message-ID: <1DF09720-26FA-4268-AA4A-CFDF95EF1F19@apple.com> On Jan 13, 2010, at 2:01 PM, Devang Patel wrote: > On Wed, Jan 13, 2010 at 1:23 PM, Victor Hernandez wrote: >> >> On Jan 13, 2010, at 1:00 PM, Devang Patel wrote: >> >>> On Wed, Jan 13, 2010 at 11:36 AM, Victor Hernandez wrote: >>> >>>> -void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD) { >>>> +void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD, bool isGlobal) { >>>> // Check to see if it's already in! >>>> unsigned &MDValueID = MDValueMap[MD]; >>>> if (MDValueID) { >>>> @@ -237,14 +237,18 @@ >>>> EnumerateType(MD->getType()); >>>> >>>> if (const MDNode *N = dyn_cast(MD)) { >>>> - MDValues.push_back(std::make_pair(MD, 1U)); >>>> - MDValueMap[MD] = MDValues.size(); >>>> - MDValueID = MDValues.size(); >>>> - for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { >>>> - if (Value *V = N->getOperand(i)) >>>> - EnumerateValue(V); >>>> - else >>>> - EnumerateType(Type::getVoidTy(MD->getContext())); >>>> + if ((isGlobal && !N->isFunctionLocal()) || >>>> + (!isGlobal && N->isFunctionLocal())) { >>> >>> What are the cases where isGlobal does not match N->isFunctionLocal() ? >> >> Prehaps isGlobal is not the best name, it means not-during-function-incorporation. I think I should improve that variable name. >> >> The case I have encountered is: >> 1. During ValueEnumerator creation (isGlobal = true), all metadata is iterated over, including those inside of functions, and the isFunctionLocal() metadata needs to be ignored until lazy function incorporation is done. >> >> The other case should be when incorporateFunction (isGlobal = false) comes across a non-function-local metadata. But in that case the lookup of it in MDValueMap should have succeeded and we will not reach here. >> > > This looks like a very complex approach! I do not like adding extra > parameter to EnumerateOperandType() just for this purpose. Is there a > alternative ? > > > What if you > - ignore function local metadata while processing function args in > ValueEnumerator construction > - ignore non function local metadata while processing function args > in ValueEnumerator::incorporateFunction() > ? > > This way you do not need to modify any interface. > > ? Fixed in r93446. > - > Devang From vhernandez at apple.com Thu Jan 14 14:12:35 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 14 Jan 2010 20:12:35 -0000 Subject: [llvm-commits] [llvm] r93449 - /llvm/trunk/lib/VMCore/Metadata.cpp Message-ID: <201001142012.o0EKCZ0O024800@zion.cs.uiuc.edu> Author: hernande Date: Thu Jan 14 14:12:34 2010 New Revision: 93449 URL: http://llvm.org/viewvc/llvm-project?rev=93449&view=rev Log: In debug builds, assert that function-local metadata has only 1 parent function Modified: llvm/trunk/lib/VMCore/Metadata.cpp Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=93449&r1=93448&r2=93449&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Thu Jan 14 14:12:34 2010 @@ -121,9 +121,39 @@ Op->~MDNodeOperand(); } +#ifndef NDEBUG +static Function *assertLocalFunction(const MDNode *N, + SmallPtrSet &Visited) { + Function *F = NULL; + // Only visit each MDNode once. + if (!Visited.insert(N)) return F; + + for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { + Value *V = N->getOperand(i); + Function *NewF = NULL; + if (!V) continue; + if (Instruction *I = dyn_cast(V)) + NewF = I->getParent()->getParent(); + else if (BasicBlock *BB = dyn_cast(V)) + NewF = BB->getParent(); + else if (Argument *A = dyn_cast(V)) + NewF = A->getParent(); + else if (MDNode *MD = dyn_cast(V)) + if (MD->isFunctionLocal()) + NewF = assertLocalFunction(MD, Visited); + if (F && NewF) assert(F == NewF && "inconsistent function-local metadata"); + if (!F) F = NewF; + } + return F; +} +#endif + static Function *getFunctionHelper(const MDNode *N, SmallPtrSet &Visited) { assert(N->isFunctionLocal() && "Should only be called on function-local MD"); +#ifndef NDEBUG + return assertLocalFunction(N, Visited); +#endif Function *F = NULL; // Only visit each MDNode once. if (!Visited.insert(N)) return F; @@ -142,7 +172,6 @@ F = getFunctionHelper(MD, Visited); if (F) break; } - return F; } From echristo at apple.com Thu Jan 14 14:12:34 2010 From: echristo at apple.com (Eric Christopher) Date: Thu, 14 Jan 2010 20:12:34 -0000 Subject: [llvm-commits] [llvm] r93448 - /llvm/trunk/lib/Analysis/InlineCost.cpp Message-ID: <201001142012.o0EKCYDs024788@zion.cs.uiuc.edu> Author: echristo Date: Thu Jan 14 14:12:34 2010 New Revision: 93448 URL: http://llvm.org/viewvc/llvm-project?rev=93448&view=rev Log: Reduce the inlining cost of functions that contain calls to easily, and frequently optimized functions. Modified: llvm/trunk/lib/Analysis/InlineCost.cpp Modified: llvm/trunk/lib/Analysis/InlineCost.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=93448&r1=93447&r2=93448&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InlineCost.cpp (original) +++ llvm/trunk/lib/Analysis/InlineCost.cpp Thu Jan 14 14:12:34 2010 @@ -102,6 +102,32 @@ return Reduction; } +// callIsSmall - If a call will lower to a single selection DAG node, or +// is otherwise deemed small return true. +// TODO: Perhaps calls like memcpy, strcpy, etc? +static bool callIsSmall(const Function *F) { + if (F && !F->hasLocalLinkage() && F->hasName()) { + StringRef Name = F->getName(); + + // These will all likely lower to a single selection DAG node. + if (Name == "copysign" || Name == "copysignf" || + Name == "fabs" || Name == "fabsf" || Name == "fabsl" || + Name == "sin" || Name == "sinf" || Name == "sinl" || + Name == "cos" || Name == "cosf" || Name == "cosl" || + Name == "sqrt" || Name == "sqrtf" || Name == "sqrtl" ) + return true; + + // These are all likely to be optimized into something smaller. + if (Name == "pow" || Name == "powf" || Name == "powl" || + Name == "exp2" || Name == "exp2l" || Name == "exp2f" || + Name == "floor" || Name == "floorf" || Name == "ceil" || + Name == "round" || Name == "ffs" || Name == "ffsl" || + Name == "abs" || Name == "labs" || Name == "llabs") + return true; + } + return false; +} + /// analyzeBasicBlock - Fill in the current structure with information gleaned /// from the specified block. void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB) { @@ -129,7 +155,7 @@ // Calls often compile into many machine instructions. Bump up their // cost to reflect this. - if (!isa(II)) + if (!isa(II) && !callIsSmall(CS.getCalledFunction())) NumInsts += InlineConstants::CallPenalty; } From vhernandez at apple.com Thu Jan 14 14:15:42 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 14 Jan 2010 12:15:42 -0800 Subject: [llvm-commits] [llvm] r93400 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp In-Reply-To: <3AEBD80F-B03B-41F8-BD98-F6758DA36F85@apple.com> References: <201001140145.o0E1jEDi032182@zion.cs.uiuc.edu> <352a1fb21001140939k4f8055e0i90ee37ca4540e7eb@mail.gmail.com> <3AEBD80F-B03B-41F8-BD98-F6758DA36F85@apple.com> Message-ID: On Jan 14, 2010, at 10:20 AM, Victor Hernandez wrote: > > On Jan 14, 2010, at 9:39 AM, Devang Patel wrote: > >> On Wed, Jan 13, 2010 at 5:45 PM, Victor Hernandez wrote: >>> Author: hernande >>> Date: Wed Jan 13 19:45:14 2010 >>> New Revision: 93400 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=93400&view=rev >>> Log: >>> Add MDNode::getFunction(), which figures out the metadata's function, if it has function that it is local to. >> >> so will this replace isFunctionLocal() ? > > No, I don't think it should replace isFunctionLocal(). getFunction() is an expensive operation that should not be used in performance-critical tasks (currently it is only used when printing out ll files). isFunctionLocal() is fast and will very rarely give a false positive (when a metadata is created function-local, but then the operands are modified later). After our discussion, I am more amenable to replacing isFunctionLocal() with getFunction(). I just committed a debug version of getFunction() that asserts that function-local metadata has only 1 parent function. I agree that avoiding the traversal of the MD operands at metadata-creation time helps performance. I need to make sure that none of the users of isFunctionLocal() are performance-critical or called alot. >> - >> Devang > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From asl at math.spbu.ru Thu Jan 14 14:19:52 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Thu, 14 Jan 2010 20:19:52 -0000 Subject: [llvm-commits] [llvm] r93450 - /llvm/trunk/lib/System/Win32/DynamicLibrary.inc Message-ID: <201001142019.o0EKJqPj025183@zion.cs.uiuc.edu> Author: asl Date: Thu Jan 14 14:19:51 2010 New Revision: 93450 URL: http://llvm.org/viewvc/llvm-project?rev=93450&view=rev Log: Remove spurious semicolon. Patch by Diego Iastrubni! Modified: llvm/trunk/lib/System/Win32/DynamicLibrary.inc Modified: llvm/trunk/lib/System/Win32/DynamicLibrary.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/DynamicLibrary.inc?rev=93450&r1=93449&r2=93450&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/DynamicLibrary.inc (original) +++ llvm/trunk/lib/System/Win32/DynamicLibrary.inc Thu Jan 14 14:19:51 2010 @@ -79,7 +79,7 @@ // Mingw32 uses msvcrt.dll by default. Don't ignore it. // Otherwise, user should be aware, what he's doing :) stricmp(ModuleName, "msvcrt") != 0 && -#endif +#endif stricmp(ModuleName, "msvcrt20") != 0 && stricmp(ModuleName, "msvcrt40") != 0) { OpenedHandles.push_back((HMODULE)ModuleBase); @@ -119,24 +119,24 @@ extern "C" { extern void *SYM; } #if defined(__MINGW32__) - EXPLICIT_SYMBOL_DEF(_alloca); - EXPLICIT_SYMBOL_DEF(__main); - EXPLICIT_SYMBOL_DEF(__ashldi3); - EXPLICIT_SYMBOL_DEF(__ashrdi3); - EXPLICIT_SYMBOL_DEF(__cmpdi2); - EXPLICIT_SYMBOL_DEF(__divdi3); - EXPLICIT_SYMBOL_DEF(__fixdfdi); - EXPLICIT_SYMBOL_DEF(__fixsfdi); - EXPLICIT_SYMBOL_DEF(__fixunsdfdi); - EXPLICIT_SYMBOL_DEF(__fixunssfdi); - EXPLICIT_SYMBOL_DEF(__floatdidf); - EXPLICIT_SYMBOL_DEF(__floatdisf); - EXPLICIT_SYMBOL_DEF(__lshrdi3); - EXPLICIT_SYMBOL_DEF(__moddi3); - EXPLICIT_SYMBOL_DEF(__udivdi3); - EXPLICIT_SYMBOL_DEF(__umoddi3); + EXPLICIT_SYMBOL_DEF(_alloca) + EXPLICIT_SYMBOL_DEF(__main) + EXPLICIT_SYMBOL_DEF(__ashldi3) + EXPLICIT_SYMBOL_DEF(__ashrdi3) + EXPLICIT_SYMBOL_DEF(__cmpdi2) + EXPLICIT_SYMBOL_DEF(__divdi3) + EXPLICIT_SYMBOL_DEF(__fixdfdi) + EXPLICIT_SYMBOL_DEF(__fixsfdi) + EXPLICIT_SYMBOL_DEF(__fixunsdfdi) + EXPLICIT_SYMBOL_DEF(__fixunssfdi) + EXPLICIT_SYMBOL_DEF(__floatdidf) + EXPLICIT_SYMBOL_DEF(__floatdisf) + EXPLICIT_SYMBOL_DEF(__lshrdi3) + EXPLICIT_SYMBOL_DEF(__moddi3) + EXPLICIT_SYMBOL_DEF(__udivdi3) + EXPLICIT_SYMBOL_DEF(__umoddi3) #elif defined(_MSC_VER) - EXPLICIT_SYMBOL_DEF(_alloca_probe); + EXPLICIT_SYMBOL_DEF(_alloca_probe) #endif #endif @@ -181,7 +181,7 @@ EXPLICIT_SYMBOL2(alloca, _alloca); #undef EXPLICIT_SYMBOL #undef EXPLICIT_SYMBOL2 -#undef EXPLICIT_SYMBOL_DEF +#undef EXPLICIT_SYMBOL_DEF } #elif defined(_MSC_VER) { @@ -189,8 +189,8 @@ EXPLICIT_SYMBOL2(_alloca, _alloca_probe); #undef EXPLICIT_SYMBOL #undef EXPLICIT_SYMBOL2 -#undef EXPLICIT_SYMBOL_DEF - } +#undef EXPLICIT_SYMBOL_DEF + } #endif return 0; From clattner at apple.com Thu Jan 14 14:54:17 2010 From: clattner at apple.com (Chris Lattner) Date: Thu, 14 Jan 2010 12:54:17 -0800 Subject: [llvm-commits] [llvm] r93448 - /llvm/trunk/lib/Analysis/InlineCost.cpp In-Reply-To: <201001142012.o0EKCYDs024788@zion.cs.uiuc.edu> References: <201001142012.o0EKCYDs024788@zion.cs.uiuc.edu> Message-ID: On Jan 14, 2010, at 12:12 PM, Eric Christopher wrote: > +// callIsSmall - If a call will lower to a single selection DAG > node, or > +// is otherwise deemed small return true. "is likely to lower to a single target instruction" > +// TODO: Perhaps calls like memcpy, strcpy, etc? > +static bool callIsSmall(const Function *F) { > + if (F && !F->hasLocalLinkage() && F->hasName()) { > + StringRef Name = F->getName(); > + Please use early return to avoid nesting this. + // These are all likely to be optimized into something smaller. + if (Name == "pow" || Name == "powf" || Name == "powl" || + Name == "exp2" || Name == "exp2l" || Name == "exp2f" || + Name == "floor" || Name == "floorf" || Name == "ceil" || + Name == "round" || Name == "ffs" || Name == "ffsl" || + Name == "abs" || Name == "labs" || Name == "llabs") exp* and pow* usually don't get inlined, do they? -Chris From devang.patel at gmail.com Thu Jan 14 14:54:51 2010 From: devang.patel at gmail.com (Devang Patel) Date: Thu, 14 Jan 2010 12:54:51 -0800 Subject: [llvm-commits] [llvm] r93339 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp In-Reply-To: <9D79FA7C-D32D-449B-BA37-5CEC50A26F53@apple.com> References: <201001131937.o0DJbXO9017579@zion.cs.uiuc.edu> <352a1fb21001131305i49e7e817nda9f224ecb4d6537@mail.gmail.com> <352a1fb21001131315l2fd18436s84afa0767db3215c@mail.gmail.com> <80A05DBF-E67B-4B67-B55E-E5B33A8F95FE@apple.com> <352a1fb21001131346w5b765debraa3159e87d1cbd0d@mail.gmail.com> <9D79FA7C-D32D-449B-BA37-5CEC50A26F53@apple.com> Message-ID: <352a1fb21001141254o4313f95ao15fbedae8a45fcf8@mail.gmail.com> On Thu, Jan 14, 2010 at 11:38 AM, Victor Hernandez wrote: > > > Fixed in r93441. > Thanks! - Devang From devang.patel at gmail.com Thu Jan 14 14:56:10 2010 From: devang.patel at gmail.com (Devang Patel) Date: Thu, 14 Jan 2010 12:56:10 -0800 Subject: [llvm-commits] [llvm] r93400 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp In-Reply-To: References: <201001140145.o0E1jEDi032182@zion.cs.uiuc.edu> <352a1fb21001140939k4f8055e0i90ee37ca4540e7eb@mail.gmail.com> <3AEBD80F-B03B-41F8-BD98-F6758DA36F85@apple.com> Message-ID: <352a1fb21001141256l6f3351c3u16a35d7aa2602cd@mail.gmail.com> On Thu, Jan 14, 2010 at 12:15 PM, Victor Hernandez wrote: > > On Jan 14, 2010, at 10:20 AM, Victor Hernandez wrote: > >> >> On Jan 14, 2010, at 9:39 AM, Devang Patel wrote: >> >>> On Wed, Jan 13, 2010 at 5:45 PM, Victor Hernandez wrote: >>>> Author: hernande >>>> Date: Wed Jan 13 19:45:14 2010 >>>> New Revision: 93400 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=93400&view=rev >>>> Log: >>>> Add MDNode::getFunction(), which figures out the metadata's function, if it has function that it is local to. >>> >>> so will this replace isFunctionLocal() ? >> >> No, I don't think it should replace isFunctionLocal(). ?getFunction() is an expensive operation that should not be used in performance-critical tasks (currently it is only used when printing out ll files). ?isFunctionLocal() is fast and will very rarely give a false positive (when a metadata is created function-local, but then the operands are modified later). > > After our discussion, I am more amenable to replacing isFunctionLocal() with getFunction(). ?I just committed a debug version of getFunction() that asserts that function-local metadata has only 1 parent function. > > I agree that avoiding the traversal of the MD operands at metadata-creation time helps performance. ?I need to make sure that none of the users of isFunctionLocal() are performance-critical or called alot. > ok. Thanks! -- - Devang From devang.patel at gmail.com Thu Jan 14 14:57:17 2010 From: devang.patel at gmail.com (Devang Patel) Date: Thu, 14 Jan 2010 12:57:17 -0800 Subject: [llvm-commits] [llvm] r93338 - in /llvm/trunk/lib/Bitcode/Writer: ValueEnumerator.cpp ValueEnumerator.h In-Reply-To: <1DF09720-26FA-4268-AA4A-CFDF95EF1F19@apple.com> References: <201001131936.o0DJaGrj017512@zion.cs.uiuc.edu> <352a1fb21001131300q21c970c1r4ad677849aa3fc20@mail.gmail.com> <10AD2E2C-7D7A-4B5F-847A-EE228B900962@apple.com> <352a1fb21001131401i4c612f5fj2f26f0ee9982c2c1@mail.gmail.com> <1DF09720-26FA-4268-AA4A-CFDF95EF1F19@apple.com> Message-ID: <352a1fb21001141257o383041e2sffffe7a833c79b24@mail.gmail.com> On Thu, Jan 14, 2010 at 11:54 AM, Victor Hernandez wrote: > > On Jan 13, 2010, at 2:01 PM, Devang Patel wrote: > >> On Wed, Jan 13, 2010 at 1:23 PM, Victor Hernandez wrote: >>> >>> On Jan 13, 2010, at 1:00 PM, Devang Patel wrote: >>> >>>> On Wed, Jan 13, 2010 at 11:36 AM, Victor Hernandez wrote: >>>> >>>>> -void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD) { >>>>> +void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD, bool isGlobal) { >>>>> ? // Check to see if it's already in! >>>>> ? unsigned &MDValueID = MDValueMap[MD]; >>>>> ? if (MDValueID) { >>>>> @@ -237,14 +237,18 @@ >>>>> ? EnumerateType(MD->getType()); >>>>> >>>>> ? if (const MDNode *N = dyn_cast(MD)) { >>>>> - ? ?MDValues.push_back(std::make_pair(MD, 1U)); >>>>> - ? ?MDValueMap[MD] = MDValues.size(); >>>>> - ? ?MDValueID = MDValues.size(); >>>>> - ? ?for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { >>>>> - ? ? ?if (Value *V = N->getOperand(i)) >>>>> - ? ? ? ?EnumerateValue(V); >>>>> - ? ? ?else >>>>> - ? ? ? ?EnumerateType(Type::getVoidTy(MD->getContext())); >>>>> + ? ?if ((isGlobal && !N->isFunctionLocal()) || >>>>> + ? ? ? ?(!isGlobal && N->isFunctionLocal())) { >>>> >>>> What are the cases where isGlobal does not match N->isFunctionLocal() ?? >>> >>> Prehaps isGlobal is not the best name, it means not-during-function-incorporation. ?I think I should improve that variable name. >>> >>> The case I have encountered is: >>> 1. During ValueEnumerator creation (isGlobal = true), all metadata is iterated over, including those inside of functions, and the isFunctionLocal() metadata needs to be ignored until lazy function incorporation is done. >>> >>> The other case should be when incorporateFunction (isGlobal = false) comes across a non-function-local metadata. ?But in that case the lookup of it in MDValueMap should have succeeded and we will not reach here. >>> >> >> This looks like a very complex approach! I do not like adding extra >> parameter to EnumerateOperandType() just for this purpose. Is there a >> alternative ? >> >> >> What if you >> - ignore function local metadata while processing function args in >> ValueEnumerator construction >> - ignore non function local metadata while processing function args >> in ValueEnumerator::incorporateFunction() >> ? >> >> This way you do not need to modify any interface. >> >> ? > > Fixed in r93446. > Thanks! -- - Devang From evan.cheng at apple.com Thu Jan 14 15:04:31 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 14 Jan 2010 21:04:31 -0000 Subject: [llvm-commits] [llvm] r93453 - /llvm/trunk/lib/Analysis/InlineCost.cpp Message-ID: <201001142104.o0EL4VGW026903@zion.cs.uiuc.edu> Author: evancheng Date: Thu Jan 14 15:04:31 2010 New Revision: 93453 URL: http://llvm.org/viewvc/llvm-project?rev=93453&view=rev Log: Small tweak to inline cost computation. Ext of i/fcmp results are mostly optimized away in codegen. Modified: llvm/trunk/lib/Analysis/InlineCost.cpp Modified: llvm/trunk/lib/Analysis/InlineCost.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=93453&r1=93452&r2=93453&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InlineCost.cpp (original) +++ llvm/trunk/lib/Analysis/InlineCost.cpp Thu Jan 14 15:04:31 2010 @@ -167,11 +167,16 @@ if (isa(II) || isa(II->getType())) ++NumVectorInsts; - // Noop casts, including ptr <-> int, don't count. if (const CastInst *CI = dyn_cast(II)) { + // Noop casts, including ptr <-> int, don't count. if (CI->isLosslessCast() || isa(CI) || isa(CI)) continue; + // Result of a cmp instruction is often extended (to be used by other + // cmp instructions, logical or return instructions). These are usually + // nop on most sane targets. + if (isa(CI->getOperand(0))) + continue; } else if (const GetElementPtrInst *GEPI = dyn_cast(II)){ // If a GEP has all constant indices, it will probably be folded with // a load/store. From jay.foad at gmail.com Thu Jan 14 15:14:23 2010 From: jay.foad at gmail.com (Jay Foad) Date: Thu, 14 Jan 2010 21:14:23 +0000 Subject: [llvm-commits] [PATCH] bug 6028: fix interpreter assertion on use of undefined integer value In-Reply-To: <4B4F4FF7.90407@mxc.ca> References: <4B4F4FF7.90407@mxc.ca> Message-ID: 2010/1/14 Nick Lewycky : > Always make sure to run 'make check' before committing any change. If you're > paranoid, you can also try out a nightly build before and after, but I don't > think we care that much :) The nightly test has many failures due to things > like taking addresses of functions and passing them around (to qsort for > example). OK, it passes "make check". > Why care about the type? Why not just: > > ?if (isa(C)) { > ? ?GenericValue Result; > ? ?Result.IntVal = APInt(C->getType()->getPrimitiveSizeInBits(), 0); > ? ?return Result; > ?} Because for pointer types this will try to create a 0-bit-wide APInt, and fail. Anyway, I think my version is clearer, because it initialises Result.IntVal when and only when it is necessary. Thanks, Jay. From echristo at apple.com Thu Jan 14 15:16:48 2010 From: echristo at apple.com (Eric Christopher) Date: Thu, 14 Jan 2010 13:16:48 -0800 Subject: [llvm-commits] [llvm] r93448 - /llvm/trunk/lib/Analysis/InlineCost.cpp In-Reply-To: References: <201001142012.o0EKCYDs024788@zion.cs.uiuc.edu> Message-ID: On Jan 14, 2010, at 12:54 PM, Chris Lattner wrote: > > On Jan 14, 2010, at 12:12 PM, Eric Christopher wrote: > >> +// callIsSmall - If a call will lower to a single selection DAG node, or >> +// is otherwise deemed small return true. > > "is likely to lower to a single target instruction" > >> +// TODO: Perhaps calls like memcpy, strcpy, etc? >> +static bool callIsSmall(const Function *F) { >> + if (F && !F->hasLocalLinkage() && F->hasName()) { >> + StringRef Name = F->getName(); >> + > > Please use early return to avoid nesting this. > Will do :) > + // These are all likely to be optimized into something smaller. > + if (Name == "pow" || Name == "powf" || Name == "powl" || > + Name == "exp2" || Name == "exp2l" || Name == "exp2f" || > + Name == "floor" || Name == "floorf" || Name == "ceil" || > + Name == "round" || Name == "ffs" || Name == "ffsl" || > + Name == "abs" || Name == "labs" || Name == "llabs") > > exp* and pow* usually don't get inlined, do they? These are for calls within a function, the idea is that the surrounding function doesn't get charged full "call" costs for these functions. Thanks! -eric From sabre at nondot.org Thu Jan 14 15:20:55 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 14 Jan 2010 21:20:55 -0000 Subject: [llvm-commits] [llvm] r93454 - in /llvm/trunk: include/llvm/MC/MCParsedAsmOperand.h lib/Target/X86/AsmParser/X86AsmParser.cpp Message-ID: <201001142120.o0ELKtE8027539@zion.cs.uiuc.edu> Author: lattner Date: Thu Jan 14 15:20:55 2010 New Revision: 93454 URL: http://llvm.org/viewvc/llvm-project?rev=93454&view=rev Log: introduce the MCParsedAsmOperand class. Added: llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Added: llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h?rev=93454&view=auto ============================================================================== --- llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h (added) +++ llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h Thu Jan 14 15:20:55 2010 @@ -0,0 +1,28 @@ +//===-- llvm/MC/MCParsedAsmOperand.h - Asm Parser Operand -------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_MC_MCASMOPERAND_H +#define LLVM_MC_MCASMOPERAND_H + +namespace llvm { + +/// MCParsedAsmOperand - This abstract class represents a source-level assembly +/// instruction operand. It should be subclassed by target-specific code. This +/// base class is used by target-independent clients and is the interface +/// between parsing an asm instruction and recognizing it. +class MCParsedAsmOperand { +public: + MCParsedAsmOperand(); + virtual ~MCParsedAsmOperand() = 0; + // TODO: Out of line vfun. +}; + +} // end namespace llvm. + +#endif Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=93454&r1=93453&r2=93454&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Thu Jan 14 15:20:55 2010 @@ -15,6 +15,7 @@ #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" +#include "llvm/MC/MCParsedAsmOperand.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetAsmParser.h" @@ -71,7 +72,7 @@ /// X86Operand - Instances of this class represent a parsed X86 machine /// instruction. -struct X86Operand { +struct X86Operand : public MCParsedAsmOperand { enum { Token, Register, From sabre at nondot.org Thu Jan 14 15:21:40 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 14 Jan 2010 21:21:40 -0000 Subject: [llvm-commits] [llvm] r93455 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <201001142121.o0ELLeLm027597@zion.cs.uiuc.edu> Author: lattner Date: Thu Jan 14 15:21:40 2010 New Revision: 93455 URL: http://llvm.org/viewvc/llvm-project?rev=93455&view=rev Log: introduce MCParsedAsmOperand Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=93455&r1=93454&r2=93455&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Thu Jan 14 15:21:40 2010 @@ -12,6 +12,7 @@ #include "llvm/ADT/Twine.h" #include "llvm/MC/MCAsmLexer.h" #include "llvm/MC/MCAsmParser.h" +#include "llvm/MC/MCParsedAsmOperand.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" @@ -101,7 +102,7 @@ /// ARMOperand - Instances of this class represent a parsed ARM machine /// instruction. -struct ARMOperand { +struct ARMOperand : public MCParsedAsmOperand { enum { Token, Register, From grosbach at apple.com Thu Jan 14 15:22:17 2010 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 14 Jan 2010 21:22:17 -0000 Subject: [llvm-commits] [llvm] r93456 - /llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Message-ID: <201001142122.o0ELMHYl027632@zion.cs.uiuc.edu> Author: grosbach Date: Thu Jan 14 15:22:16 2010 New Revision: 93456 URL: http://llvm.org/viewvc/llvm-project?rev=93456&view=rev Log: Dwarf EH prepare needs to be run after SjLj prepare. Otherwise, catch info can get misplaced when a selector ends up more than one block removed from the parent invoke(s). This could happen when a landing pad is shared by multiple invokes and is also a target of a normal edge from elsewhere. Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=93456&r1=93455&r2=93456&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Thu Jan 14 15:22:16 2010 @@ -280,8 +280,8 @@ { case ExceptionHandling::SjLj: // SjLj piggy-backs on dwarf for this bit. The cleanups done apply to both - PM.add(createDwarfEHPass(getTargetLowering(), OptLevel==CodeGenOpt::None)); PM.add(createSjLjEHPass(getTargetLowering())); + PM.add(createDwarfEHPass(getTargetLowering(), OptLevel==CodeGenOpt::None)); break; case ExceptionHandling::Dwarf: PM.add(createDwarfEHPass(getTargetLowering(), OptLevel==CodeGenOpt::None)); From sabre at nondot.org Thu Jan 14 15:32:46 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 14 Jan 2010 21:32:46 -0000 Subject: [llvm-commits] [llvm] r93457 - in /llvm/trunk: include/llvm/MC/MCAsmLexer.h include/llvm/MC/MCParsedAsmOperand.h include/llvm/Target/TargetAsmParser.h lib/Target/ARM/AsmParser/ARMAsmParser.cpp lib/Target/X86/AsmParser/X86AsmParser.cpp tools/llvm-mc/AsmParser.cpp Message-ID: <201001142132.o0ELWksQ028040@zion.cs.uiuc.edu> Author: lattner Date: Thu Jan 14 15:32:45 2010 New Revision: 93457 URL: http://llvm.org/viewvc/llvm-project?rev=93457&view=rev Log: prune #includes in TargetAsmParser.h Pass in SMLoc of instr opcode into ParseInstruction. Make AsmToken be a class, not a struct. Modified: llvm/trunk/include/llvm/MC/MCAsmLexer.h llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h llvm/trunk/include/llvm/Target/TargetAsmParser.h llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp llvm/trunk/tools/llvm-mc/AsmParser.cpp Modified: llvm/trunk/include/llvm/MC/MCAsmLexer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmLexer.h?rev=93457&r1=93456&r2=93457&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmLexer.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmLexer.h Thu Jan 14 15:32:45 2010 @@ -20,7 +20,8 @@ class Target; /// AsmToken - Target independent representation for an assembler token. -struct AsmToken { +class AsmToken { +public: enum TokenKind { // Markers Eof, Error, Modified: llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h?rev=93457&r1=93456&r2=93457&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h (original) +++ llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h Thu Jan 14 15:32:45 2010 @@ -18,8 +18,8 @@ /// between parsing an asm instruction and recognizing it. class MCParsedAsmOperand { public: - MCParsedAsmOperand(); - virtual ~MCParsedAsmOperand() = 0; + MCParsedAsmOperand() {} + virtual ~MCParsedAsmOperand() {} // TODO: Out of line vfun. }; Modified: llvm/trunk/include/llvm/Target/TargetAsmParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmParser.h?rev=93457&r1=93456&r2=93457&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetAsmParser.h (original) +++ llvm/trunk/include/llvm/Target/TargetAsmParser.h Thu Jan 14 15:32:45 2010 @@ -10,13 +10,13 @@ #ifndef LLVM_TARGET_TARGETPARSER_H #define LLVM_TARGET_TARGETPARSER_H -#include "llvm/MC/MCAsmLexer.h" - namespace llvm { class MCAsmParser; class MCInst; class StringRef; class Target; +class SMLoc; +class AsmToken; /// TargetAsmParser - Generic interface to target specific assembly parsers. class TargetAsmParser { @@ -45,7 +45,8 @@ /// \param Name - The instruction name. /// \param Inst [out] - On success, the parsed instruction. /// \return True on failure. - virtual bool ParseInstruction(const StringRef &Name, MCInst &Inst) = 0; + virtual bool ParseInstruction(const StringRef &Name, SMLoc NameLoc, + MCInst &Inst) = 0; /// ParseDirective - Parse a target specific assembler directive /// Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=93457&r1=93456&r2=93457&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Thu Jan 14 15:32:45 2010 @@ -95,7 +95,8 @@ ARMAsmParser(const Target &T, MCAsmParser &_Parser) : TargetAsmParser(T), Parser(_Parser) {} - virtual bool ParseInstruction(const StringRef &Name, MCInst &Inst); + virtual bool ParseInstruction(const StringRef &Name, SMLoc NameLoc, + MCInst &Inst); virtual bool ParseDirective(AsmToken DirectiveID); }; @@ -579,7 +580,8 @@ } /// Parse an arm instruction mnemonic followed by its operands. -bool ARMAsmParser::ParseInstruction(const StringRef &Name, MCInst &Inst) { +bool ARMAsmParser::ParseInstruction(const StringRef &Name, SMLoc NameLoc, + MCInst &Inst) { SmallVector Operands; Operands.push_back(ARMOperand::CreateToken(Name)); Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=93457&r1=93456&r2=93457&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Thu Jan 14 15:32:45 2010 @@ -60,7 +60,8 @@ X86ATTAsmParser(const Target &T, MCAsmParser &_Parser) : TargetAsmParser(T), Parser(_Parser) {} - virtual bool ParseInstruction(const StringRef &Name, MCInst &Inst); + virtual bool ParseInstruction(const StringRef &Name, SMLoc NameLoc, + MCInst &Inst); virtual bool ParseDirective(AsmToken DirectiveID); }; @@ -401,7 +402,8 @@ return false; } -bool X86ATTAsmParser::ParseInstruction(const StringRef &Name, MCInst &Inst) { +bool X86ATTAsmParser::ParseInstruction(const StringRef &Name, + SMLoc NameLoc, MCInst &Inst) { SmallVector Operands; Operands.push_back(X86Operand::CreateToken(Name)); Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=93457&r1=93456&r2=93457&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original) +++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Thu Jan 14 15:32:45 2010 @@ -711,7 +711,7 @@ } MCInst Inst; - if (getTargetParser().ParseInstruction(IDVal, Inst)) + if (getTargetParser().ParseInstruction(IDVal, IDLoc, Inst)) return true; if (Lexer.isNot(AsmToken::EndOfStatement)) From echristo at apple.com Thu Jan 14 15:35:49 2010 From: echristo at apple.com (Eric Christopher) Date: Thu, 14 Jan 2010 13:35:49 -0800 Subject: [llvm-commits] [llvm] r93456 - /llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp In-Reply-To: <201001142122.o0ELMHYl027632@zion.cs.uiuc.edu> References: <201001142122.o0ELMHYl027632@zion.cs.uiuc.edu> Message-ID: <7BE9D202-758E-48AD-B36F-9F0AB7E6B6B3@apple.com> > > Dwarf EH prepare needs to be run after SjLj prepare. Otherwise, > catch info can get misplaced when a selector ends up more than one block > removed from the parent invoke(s). This could happen when a landing pad is > shared by multiple invokes and is also a target of a normal edge from > elsewhere. > > // SjLj piggy-backs on dwarf for this bit. The cleanups done apply to both > - PM.add(createDwarfEHPass(getTargetLowering(), OptLevel==CodeGenOpt::None)); > PM.add(createSjLjEHPass(getTargetLowering())); > + PM.add(createDwarfEHPass(getTargetLowering(), OptLevel==CodeGenOpt::None)); Can you please add a comment to this effect? Thanks! -eric From grosbach at apple.com Thu Jan 14 15:38:31 2010 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 14 Jan 2010 21:38:31 -0000 Subject: [llvm-commits] [llvm] r93459 - /llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Message-ID: <201001142138.o0ELcVUe028252@zion.cs.uiuc.edu> Author: grosbach Date: Thu Jan 14 15:38:31 2010 New Revision: 93459 URL: http://llvm.org/viewvc/llvm-project?rev=93459&view=rev Log: Add comment explaining the necessity of r93456 Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=93459&r1=93458&r2=93459&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Thu Jan 14 15:38:31 2010 @@ -280,6 +280,11 @@ { case ExceptionHandling::SjLj: // SjLj piggy-backs on dwarf for this bit. The cleanups done apply to both + // Dwarf EH prepare needs to be run after SjLj prepare. Otherwise, + // catch info can get misplaced when a selector ends up more than one block + // removed from the parent invoke(s). This could happen when a landing + // pad is shared by multiple invokes and is also a target of a normal + // edge from elsewhere. PM.add(createSjLjEHPass(getTargetLowering())); PM.add(createDwarfEHPass(getTargetLowering(), OptLevel==CodeGenOpt::None)); break; From grosbach at apple.com Thu Jan 14 15:39:08 2010 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 14 Jan 2010 13:39:08 -0800 Subject: [llvm-commits] [llvm] r93456 - /llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp In-Reply-To: <7BE9D202-758E-48AD-B36F-9F0AB7E6B6B3@apple.com> References: <201001142122.o0ELMHYl027632@zion.cs.uiuc.edu> <7BE9D202-758E-48AD-B36F-9F0AB7E6B6B3@apple.com> Message-ID: <5446B6A7-B9D2-4EA3-9D84-9565CCED9124@apple.com> On Jan 14, 2010, at 1:35 PM, Eric Christopher wrote: >> >> Dwarf EH prepare needs to be run after SjLj prepare. Otherwise, >> catch info can get misplaced when a selector ends up more than one >> block >> removed from the parent invoke(s). This could happen when a landing >> pad is >> shared by multiple invokes and is also a target of a normal edge from >> elsewhere. >> >> // SjLj piggy-backs on dwarf for this bit. The cleanups done >> apply to both >> - PM.add(createDwarfEHPass(getTargetLowering(), >> OptLevel==CodeGenOpt::None)); >> PM.add(createSjLjEHPass(getTargetLowering())); >> + PM.add(createDwarfEHPass(getTargetLowering(), >> OptLevel==CodeGenOpt::None)); > > Can you please add a comment to this effect? > Good point. Definitely worth some exposition. Done in r93459. > Thanks! > > -eric From nlewycky at google.com Thu Jan 14 15:39:04 2010 From: nlewycky at google.com (Nick Lewycky) Date: Thu, 14 Jan 2010 13:39:04 -0800 Subject: [llvm-commits] [patch] Used TimedExec.sh everywhere In-Reply-To: <38a0d8451001141140j4c366ca5vc3c8927d3b1882df@mail.gmail.com> References: <38a0d8451001141140j4c366ca5vc3c8927d3b1882df@mail.gmail.com> Message-ID: On 14 January 2010 11:40, Rafael Espindola wrote: > I left the test-suite running during the night just to find it stuck > this morning. The problem is that an atomics test was frozen but not > using any CPU, so it was not failing. > > There is no way to limit wall time with ulimit, so I think the best > thing is to just use TimedExec.sh everywhere. Is the attached patch > OK? > > I gave this a shot: TimedExec.sh 1 . sleep 10 and found that it slept for 10 seconds, not 1. I think we may need to change how TimedExec.sh works to make it support Linux. Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100114/769cb88c/attachment.html From nlewycky at google.com Thu Jan 14 15:42:50 2010 From: nlewycky at google.com (Nick Lewycky) Date: Thu, 14 Jan 2010 13:42:50 -0800 Subject: [llvm-commits] [PATCH] bug 6028: fix interpreter assertion on use of undefined integer value In-Reply-To: References: <4B4F4FF7.90407@mxc.ca> Message-ID: On 14 January 2010 13:14, Jay Foad wrote: > 2010/1/14 Nick Lewycky : > > Always make sure to run 'make check' before committing any change. If > you're > > paranoid, you can also try out a nightly build before and after, but I > don't > > think we care that much :) The nightly test has many failures due to > things > > like taking addresses of functions and passing them around (to qsort for > > example). > > OK, it passes "make check". > > > Why care about the type? Why not just: > > > > if (isa(C)) { > > GenericValue Result; > > Result.IntVal = APInt(C->getType()->getPrimitiveSizeInBits(), 0); > > return Result; > > } > > Because for pointer types this will try to create a 0-bit-wide APInt, and > fail. > > Anyway, I think my version is clearer, because it initialises > Result.IntVal when and only when it is necessary. > Ah, pointers are a "sized type" in the LangRef, but you don't necessarily know the size without target data. Then your patch sounds good, please commit it! Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100114/b191154e/attachment.html From echristo at apple.com Thu Jan 14 15:48:00 2010 From: echristo at apple.com (Eric Christopher) Date: Thu, 14 Jan 2010 21:48:00 -0000 Subject: [llvm-commits] [llvm] r93462 - /llvm/trunk/lib/Analysis/InlineCost.cpp Message-ID: <201001142148.o0ELm0CK028786@zion.cs.uiuc.edu> Author: echristo Date: Thu Jan 14 15:48:00 2010 New Revision: 93462 URL: http://llvm.org/viewvc/llvm-project?rev=93462&view=rev Log: Few minor changes that were requested. No functional change. Modified: llvm/trunk/lib/Analysis/InlineCost.cpp Modified: llvm/trunk/lib/Analysis/InlineCost.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=93462&r1=93461&r2=93462&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InlineCost.cpp (original) +++ llvm/trunk/lib/Analysis/InlineCost.cpp Thu Jan 14 15:48:00 2010 @@ -102,11 +102,15 @@ return Reduction; } -// callIsSmall - If a call will lower to a single selection DAG node, or +// callIsSmall - If a call is likely to lower to a single target instruction, or // is otherwise deemed small return true. // TODO: Perhaps calls like memcpy, strcpy, etc? static bool callIsSmall(const Function *F) { - if (F && !F->hasLocalLinkage() && F->hasName()) { + if (!F) return false; + + if (F->hasLocalLinkage()) return false; + + if (F->hasName()) { StringRef Name = F->getName(); // These will all likely lower to a single selection DAG node. From dalej at apple.com Thu Jan 14 15:50:18 2010 From: dalej at apple.com (Dale Johannesen) Date: Thu, 14 Jan 2010 21:50:18 -0000 Subject: [llvm-commits] [llvm] r93463 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <201001142150.o0ELoIrw028930@zion.cs.uiuc.edu> Author: johannes Date: Thu Jan 14 15:50:17 2010 New Revision: 93463 URL: http://llvm.org/viewvc/llvm-project?rev=93463&view=rev Log: Fix a comment. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93463&r1=93462&r2=93463&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Jan 14 15:50:17 2010 @@ -1649,7 +1649,7 @@ /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM /// instruction, using the specified assembler variant. Targets should -/// overried this to format as appropriate. +/// override this to format as appropriate. bool AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode) { // Target doesn't support this yet! From asl at math.spbu.ru Thu Jan 14 16:09:12 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Thu, 14 Jan 2010 22:09:12 -0000 Subject: [llvm-commits] [llvm] r93467 - /llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Message-ID: <201001142209.o0EM9Cic029730@zion.cs.uiuc.edu> Author: asl Date: Thu Jan 14 16:09:11 2010 New Revision: 93467 URL: http://llvm.org/viewvc/llvm-project?rev=93467&view=rev Log: Remove pseudo-MI in custom inserter. Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=93467&r1=93466&r2=93467&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Thu Jan 14 16:09:11 2010 @@ -1045,6 +1045,7 @@ .addReg(SrcReg).addMBB(BB) .addReg(ShiftReg2).addMBB(LoopBB); + F->DeleteMachineInstr(MI); // The pseudo instruction is gone now. return RemBB; } From asl at math.spbu.ru Thu Jan 14 16:09:38 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Thu, 14 Jan 2010 22:09:38 -0000 Subject: [llvm-commits] [llvm] r93468 - /llvm/trunk/test/CodeGen/MSP430/shifts.ll Message-ID: <201001142209.o0EM9cCq029752@zion.cs.uiuc.edu> Author: asl Date: Thu Jan 14 16:09:38 2010 New Revision: 93468 URL: http://llvm.org/viewvc/llvm-project?rev=93468&view=rev Log: Add variable-width shifts for MSP430 Added: llvm/trunk/test/CodeGen/MSP430/shifts.ll Added: llvm/trunk/test/CodeGen/MSP430/shifts.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/shifts.ll?rev=93468&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/shifts.ll (added) +++ llvm/trunk/test/CodeGen/MSP430/shifts.ll Thu Jan 14 16:09:38 2010 @@ -0,0 +1,51 @@ +; RUN: llc < %s | FileCheck %s +target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8-n8:16" +target triple = "msp430-elf" + +define zeroext i8 @lshr8(i8 zeroext %a, i8 zeroext %cnt) nounwind readnone { +entry: +; CHECK: lshr8: +; CHECK: rrc.b + %shr = lshr i8 %a, %cnt + ret i8 %shr +} + +define signext i8 @ashr8(i8 signext %a, i8 zeroext %cnt) nounwind readnone { +entry: +; CHECK: ashr8: +; CHECK: rra.b + %shr = ashr i8 %a, %cnt + ret i8 %shr +} + +define zeroext i8 @shl8(i8 zeroext %a, i8 zeroext %cnt) nounwind readnone { +entry: +; CHECK: shl8 +; CHECK: rla.b + %shl = shl i8 %a, %cnt + ret i8 %shl +} + +define zeroext i16 @lshr16(i16 zeroext %a, i16 zeroext %cnt) nounwind readnone { +entry: +; CHECK: lshr16: +; CHECK: rrc.w + %shr = lshr i16 %a, %cnt + ret i16 %shr +} + +define signext i16 @ashr16(i16 signext %a, i16 zeroext %cnt) nounwind readnone { +entry: +; CHECK: ashr16: +; CHECK: rra.w + %shr = ashr i16 %a, %cnt + ret i16 %shr +} + +define zeroext i16 @shl16(i16 zeroext %a, i16 zeroext %cnt) nounwind readnone { +entry: +; CHECK: shl16: +; CHECK: rla.w + %shl = shl i16 %a, %cnt + ret i16 %shl +} From sabre at nondot.org Thu Jan 14 16:21:20 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 14 Jan 2010 22:21:20 -0000 Subject: [llvm-commits] [llvm] r93469 - in /llvm/trunk: include/llvm/Target/TargetAsmParser.h lib/Target/ARM/AsmParser/ARMAsmParser.cpp lib/Target/X86/AsmParser/X86AsmParser.cpp tools/llvm-mc/AsmLexer.cpp tools/llvm-mc/AsmParser.cpp utils/TableGen/AsmMatcherEmitter.cpp Message-ID: <201001142221.o0EMLKd5030326@zion.cs.uiuc.edu> Author: lattner Date: Thu Jan 14 16:21:20 2010 New Revision: 93469 URL: http://llvm.org/viewvc/llvm-project?rev=93469&view=rev Log: Split the TargetAsmParser "ParseInstruction" interface in half: the new ParseInstruction method just parses and returns a list of target operands. A new MatchInstruction interface is used to turn the operand list into an MCInst. This requires new/deleting all the operands, but it also gives targets the ability to use polymorphic operands if they want to. Modified: llvm/trunk/include/llvm/Target/TargetAsmParser.h llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp llvm/trunk/tools/llvm-mc/AsmLexer.cpp llvm/trunk/tools/llvm-mc/AsmParser.cpp llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Modified: llvm/trunk/include/llvm/Target/TargetAsmParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmParser.h?rev=93469&r1=93468&r2=93469&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetAsmParser.h (original) +++ llvm/trunk/include/llvm/Target/TargetAsmParser.h Thu Jan 14 16:21:20 2010 @@ -17,6 +17,8 @@ class Target; class SMLoc; class AsmToken; +class MCParsedAsmOperand; +template class SmallVectorImpl; /// TargetAsmParser - Generic interface to target specific assembly parsers. class TargetAsmParser { @@ -43,10 +45,11 @@ // /// \param AP - The current parser object. /// \param Name - The instruction name. - /// \param Inst [out] - On success, the parsed instruction. + /// \param Operands [out] - The list of parsed operands, this returns + /// ownership of them to the caller. /// \return True on failure. virtual bool ParseInstruction(const StringRef &Name, SMLoc NameLoc, - MCInst &Inst) = 0; + SmallVectorImpl &Operands) = 0; /// ParseDirective - Parse a target specific assembler directive /// @@ -59,6 +62,14 @@ /// /// \param ID - the identifier token of the directive. virtual bool ParseDirective(AsmToken DirectiveID) = 0; + + /// MatchInstruction - Recognize a series of operands of a parsed instruction + /// as an actual MCInst. This returns false and fills in Inst on success and + /// returns true on failure to match. + virtual bool + MatchInstruction(const SmallVectorImpl &Operands, + MCInst &Inst) = 0; + }; } // End llvm namespace Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=93469&r1=93468&r2=93469&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Thu Jan 14 16:21:20 2010 @@ -79,7 +79,7 @@ /// @name Auto-generated Match Functions /// { - bool MatchInstruction(SmallVectorImpl &Operands, + bool MatchInstruction(const SmallVectorImpl &Operands, MCInst &Inst); /// MatchRegisterName - Match the given string to a register name and return @@ -96,7 +96,7 @@ : TargetAsmParser(T), Parser(_Parser) {} virtual bool ParseInstruction(const StringRef &Name, SMLoc NameLoc, - MCInst &Inst); + SmallVectorImpl &Operands); virtual bool ParseDirective(AsmToken DirectiveID); }; @@ -517,9 +517,10 @@ } /// A hack to allow some testing, to be replaced by a real table gen version. -bool ARMAsmParser::MatchInstruction(SmallVectorImpl &Operands, - MCInst &Inst) { - struct ARMOperand Op0 = Operands[0]; +bool ARMAsmParser:: +MatchInstruction(const SmallVectorImpl &Operands, + MCInst &Inst) { + ARMOperand &Op0 = *(ARMOperand*)Operands[0]; assert(Op0.Kind == ARMOperand::Token && "First operand not a Token"); const StringRef &Mnemonic = Op0.getToken(); if (Mnemonic == "add" || @@ -581,33 +582,26 @@ /// Parse an arm instruction mnemonic followed by its operands. bool ARMAsmParser::ParseInstruction(const StringRef &Name, SMLoc NameLoc, - MCInst &Inst) { - SmallVector Operands; - - Operands.push_back(ARMOperand::CreateToken(Name)); + SmallVectorImpl &Operands) { + Operands.push_back(new ARMOperand(ARMOperand::CreateToken(Name))); SMLoc Loc = getLexer().getTok().getLoc(); if (getLexer().isNot(AsmToken::EndOfStatement)) { // Read the first operand. - Operands.push_back(ARMOperand()); - if (ParseOperand(Operands.back())) - return true; + ARMOperand Op; + if (ParseOperand(Op)) return true; + Operands.push_back(new ARMOperand(Op)); while (getLexer().is(AsmToken::Comma)) { getLexer().Lex(); // Eat the comma. // Parse and remember the operand. - Operands.push_back(ARMOperand()); - if (ParseOperand(Operands.back())) - return true; + if (ParseOperand(Op)) return true; + Operands.push_back(new ARMOperand(Op)); } } - if (!MatchInstruction(Operands, Inst)) - return false; - - Error(Loc, "ARMAsmParser::ParseInstruction only partly implemented"); - return true; + return false; } /// ParseDirective parses the arm specific directives Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=93469&r1=93468&r2=93469&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Thu Jan 14 16:21:20 2010 @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Target/TargetAsmParser.h" #include "X86.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Twine.h" @@ -47,7 +48,7 @@ /// @name Auto-generated Match Functions /// { - bool MatchInstruction(SmallVectorImpl &Operands, + bool MatchInstruction(const SmallVectorImpl &Operands, MCInst &Inst); /// MatchRegisterName - Match the given string to a register name, or 0 if @@ -61,7 +62,7 @@ : TargetAsmParser(T), Parser(_Parser) {} virtual bool ParseInstruction(const StringRef &Name, SMLoc NameLoc, - MCInst &Inst); + SmallVectorImpl &Operands); virtual bool ParseDirective(AsmToken DirectiveID); }; @@ -402,11 +403,11 @@ return false; } -bool X86ATTAsmParser::ParseInstruction(const StringRef &Name, - SMLoc NameLoc, MCInst &Inst) { - SmallVector Operands; +bool X86ATTAsmParser:: +ParseInstruction(const StringRef &Name, SMLoc NameLoc, + SmallVectorImpl &Operands) { - Operands.push_back(X86Operand::CreateToken(Name)); + Operands.push_back(new X86Operand(X86Operand::CreateToken(Name))); SMLoc Loc = getLexer().getTok().getLoc(); if (getLexer().isNot(AsmToken::EndOfStatement)) { @@ -414,31 +415,27 @@ // Parse '*' modifier. if (getLexer().is(AsmToken::Star)) { getLexer().Lex(); // Eat the star. - Operands.push_back(X86Operand::CreateToken("*")); + Operands.push_back(new X86Operand(X86Operand::CreateToken("*"))); } // Read the first operand. - Operands.push_back(X86Operand()); - if (ParseOperand(Operands.back())) + X86Operand Op; + if (ParseOperand(Op)) return true; + Operands.push_back(new X86Operand(Op)); + while (getLexer().is(AsmToken::Comma)) { getLexer().Lex(); // Eat the comma. // Parse and remember the operand. - Operands.push_back(X86Operand()); - if (ParseOperand(Operands.back())) + if (ParseOperand(Op)) return true; + Operands.push_back(new X86Operand(Op)); } } - if (!MatchInstruction(Operands, Inst)) - return false; - - // FIXME: We should give nicer diagnostics about the exact failure. - - Error(Loc, "unrecognized instruction"); - return true; + return false; } bool X86ATTAsmParser::ParseDirective(AsmToken DirectiveID) { Modified: llvm/trunk/tools/llvm-mc/AsmLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmLexer.cpp?rev=93469&r1=93468&r2=93469&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/AsmLexer.cpp (original) +++ llvm/trunk/tools/llvm-mc/AsmLexer.cpp Thu Jan 14 16:21:20 2010 @@ -44,7 +44,7 @@ /// ReturnError - Set the error to the specified string at the specified /// location. This is defined to always return AsmToken::Error. AsmToken AsmLexer::ReturnError(const char *Loc, const std::string &Msg) { - SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), Msg, "error"); + PrintMessage(SMLoc::getFromPointer(Loc), Msg, "error"); return AsmToken(AsmToken::Error, StringRef(Loc, 0)); } Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=93469&r1=93468&r2=93469&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original) +++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Thu Jan 14 16:21:20 2010 @@ -18,6 +18,7 @@ #include "llvm/MC/MCContext.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" +#include "llvm/MC/MCParsedAsmOperand.h" #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" @@ -710,16 +711,34 @@ return false; } - MCInst Inst; - if (getTargetParser().ParseInstruction(IDVal, IDLoc, Inst)) + + SmallVector ParsedOperands; + if (getTargetParser().ParseInstruction(IDVal, IDLoc, ParsedOperands)) + // FIXME: Leaking ParsedOperands on failure. return true; if (Lexer.isNot(AsmToken::EndOfStatement)) + // FIXME: Leaking ParsedOperands on failure. return TokError("unexpected token in argument list"); // Eat the end of statement marker. Lexer.Lex(); + + MCInst Inst; + + bool MatchFail = getTargetParser().MatchInstruction(ParsedOperands, Inst); + + // Free any parsed operands. + for (unsigned i = 0, e = ParsedOperands.size(); i != e; ++i) + delete ParsedOperands[i]; + + if (MatchFail) { + // FIXME: We should give nicer diagnostics about the exact failure. + Error(IDLoc, "unrecognized instruction"); + return true; + } + // Instruction is good, process it. Out.EmitInstruction(Inst); Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=93469&r1=93468&r2=93469&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Thu Jan 14 16:21:20 2010 @@ -961,8 +961,8 @@ CvtOS << "static bool ConvertToMCInst(ConversionKind Kind, MCInst &Inst, " << "unsigned Opcode,\n" - << " SmallVectorImpl<" - << Target.getName() << "Operand> &Operands) {\n"; + << " const SmallVectorImpl &Operands) {\n"; CvtOS << " Inst.setOpcode(Opcode);\n"; CvtOS << " switch (Kind) {\n"; CvtOS << " default:\n"; @@ -972,6 +972,9 @@ OS << "// Unified function for converting operants to MCInst instances.\n\n"; OS << "enum ConversionKind {\n"; + // TargetOperandClass - This is the target's operand class, like X86Operand. + std::string TargetOperandClass = Target.getName() + "Operand"; + for (std::vector::const_iterator it = Infos.begin(), ie = Infos.end(); it != ie; ++it) { InstructionInfo &II = **it; @@ -1050,8 +1053,9 @@ for (; CurIndex != Op.OperandInfo->MIOperandNo; ++CurIndex) CvtOS << " Inst.addOperand(MCOperand::CreateReg(0));\n"; - CvtOS << " Operands[" << MIOperandList[i].second - << "]." << Op.Class->RenderMethod + CvtOS << " ((" << TargetOperandClass << "*)Operands[" + << MIOperandList[i].second + << "])->" << Op.Class->RenderMethod << "(Inst, " << Op.OperandInfo->MINumOperands << ");\n"; CurIndex += Op.OperandInfo->MINumOperands; } @@ -1111,8 +1115,9 @@ static void EmitClassifyOperand(CodeGenTarget &Target, AsmMatcherInfo &Info, raw_ostream &OS) { - OS << "static MatchClassKind ClassifyOperand(" - << Target.getName() << "Operand &Operand) {\n"; + OS << "static MatchClassKind ClassifyOperand(MCParsedAsmOperand *GOp) {\n" + << " " << Target.getName() << "Operand &Operand = *(" + << Target.getName() << "Operand*)GOp;\n"; // Classify tokens. OS << " if (Operand.isToken())\n"; @@ -1467,9 +1472,8 @@ MaxNumOperands = std::max(MaxNumOperands, (*it)->Operands.size()); OS << "bool " << Target.getName() << ClassName - << "::MatchInstruction(" - << "SmallVectorImpl<" << Target.getName() << "Operand> &Operands, " - << "MCInst &Inst) {\n"; + << "::\nMatchInstruction(const SmallVectorImpl " + "&Operands,\n MCInst &Inst) {\n"; // Emit the static match table; unused classes get initalized to 0 which is // guaranteed to be InvalidMatchClass. From sabre at nondot.org Thu Jan 14 16:29:58 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 14 Jan 2010 22:29:58 -0000 Subject: [llvm-commits] [llvm] r93470 - in /llvm/trunk: include/llvm/MC/MCParsedAsmOperand.h tools/llvm-mc/AsmParser.cpp Message-ID: <201001142229.o0EMTwX7030949@zion.cs.uiuc.edu> Author: lattner Date: Thu Jan 14 16:29:57 2010 New Revision: 93470 URL: http://llvm.org/viewvc/llvm-project?rev=93470&view=rev Log: add virtual methods to get the start/end of a MCParsedAsmOperand, the default implementation returns "unknown". Modified: llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h llvm/trunk/tools/llvm-mc/AsmParser.cpp Modified: llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h?rev=93470&r1=93469&r2=93470&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h (original) +++ llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h Thu Jan 14 16:29:57 2010 @@ -20,7 +20,11 @@ public: MCParsedAsmOperand() {} virtual ~MCParsedAsmOperand() {} - // TODO: Out of line vfun. + + /// getStartLoc - Get the location of the first token of this operand. + virtual SMLoc getStartLoc() const; + /// getEndLoc - Get the location of the last token of this operand. + virtual SMLoc getEndLoc() const; }; } // end namespace llvm. Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=93470&r1=93469&r2=93470&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original) +++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Thu Jan 14 16:29:57 2010 @@ -29,6 +29,11 @@ #include "llvm/Target/TargetAsmParser.h" using namespace llvm; +/// getStartLoc - Get the location of the first token of this operand. +SMLoc MCParsedAsmOperand::getStartLoc() const { return SMLoc(); } +SMLoc MCParsedAsmOperand::getEndLoc() const { return SMLoc(); } + + // Mach-O section uniquing. // // FIXME: Figure out where this should live, it should be shared by From johnny.chen at apple.com Thu Jan 14 16:42:17 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 14 Jan 2010 22:42:17 -0000 Subject: [llvm-commits] [llvm] r93471 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Message-ID: <201001142242.o0EMgHOD031351@zion.cs.uiuc.edu> Author: johnny Date: Thu Jan 14 16:42:17 2010 New Revision: 93471 URL: http://llvm.org/viewvc/llvm-project?rev=93471&view=rev Log: Added 16-bit Thumb Load/Store immediate instructions with encoding bits so that the disassembler can properly decode Load/Store register/immediate instructions. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=93471&r1=93470&r2=93471&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Thu Jan 14 16:42:17 2010 @@ -341,16 +341,28 @@ "ldr", "\t$dst, $addr", [(set tGPR:$dst, (load t_addrmode_s4:$addr))]>, T1LdSt<0b100>; +def tLDRi: T1pI4<(outs tGPR:$dst), (ins t_addrmode_s4:$addr), IIC_iLoadr, + "ldr", "\t$dst, $addr", + []>, + T1LdSt4Imm<{1,?,?}>; def tLDRB : T1pI1<(outs tGPR:$dst), (ins t_addrmode_s1:$addr), IIC_iLoadr, "ldrb", "\t$dst, $addr", [(set tGPR:$dst, (zextloadi8 t_addrmode_s1:$addr))]>, T1LdSt<0b110>; +def tLDRBi: T1pI1<(outs tGPR:$dst), (ins t_addrmode_s1:$addr), IIC_iLoadr, + "ldrb", "\t$dst, $addr", + []>, + T1LdSt1Imm<{1,?,?}>; def tLDRH : T1pI2<(outs tGPR:$dst), (ins t_addrmode_s2:$addr), IIC_iLoadr, "ldrh", "\t$dst, $addr", [(set tGPR:$dst, (zextloadi16 t_addrmode_s2:$addr))]>, T1LdSt<0b101>; +def tLDRHi: T1pI2<(outs tGPR:$dst), (ins t_addrmode_s2:$addr), IIC_iLoadr, + "ldrh", "\t$dst, $addr", + []>, + T1LdSt2Imm<{1,?,?}>; let AddedComplexity = 10 in def tLDRSB : T1pI1<(outs tGPR:$dst), (ins t_addrmode_rr:$addr), IIC_iLoadr, @@ -396,16 +408,28 @@ "str", "\t$src, $addr", [(store tGPR:$src, t_addrmode_s4:$addr)]>, T1LdSt<0b000>; +def tSTRi: T1pI4<(outs), (ins tGPR:$src, t_addrmode_s4:$addr), IIC_iStorer, + "str", "\t$src, $addr", + []>, + T1LdSt4Imm<{0,?,?}>; def tSTRB : T1pI1<(outs), (ins tGPR:$src, t_addrmode_s1:$addr), IIC_iStorer, "strb", "\t$src, $addr", [(truncstorei8 tGPR:$src, t_addrmode_s1:$addr)]>, T1LdSt<0b010>; +def tSTRBi: T1pI1<(outs), (ins tGPR:$src, t_addrmode_s1:$addr), IIC_iStorer, + "strb", "\t$src, $addr", + []>, + T1LdSt1Imm<{0,?,?}>; def tSTRH : T1pI2<(outs), (ins tGPR:$src, t_addrmode_s2:$addr), IIC_iStorer, "strh", "\t$src, $addr", [(truncstorei16 tGPR:$src, t_addrmode_s2:$addr)]>, T1LdSt<0b001>; +def tSTRHi: T1pI2<(outs), (ins tGPR:$src, t_addrmode_s2:$addr), IIC_iStorer, + "strh", "\t$src, $addr", + []>, + T1LdSt2Imm<{0,?,?}>; def tSTRspi : T1pIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr), IIC_iStorei, "str", "\t$src, $addr", From clattner at apple.com Thu Jan 14 16:48:23 2010 From: clattner at apple.com (Chris Lattner) Date: Thu, 14 Jan 2010 14:48:23 -0800 Subject: [llvm-commits] [llvm] r93462 - /llvm/trunk/lib/Analysis/InlineCost.cpp In-Reply-To: <201001142148.o0ELm0CK028786@zion.cs.uiuc.edu> References: <201001142148.o0ELm0CK028786@zion.cs.uiuc.edu> Message-ID: On Jan 14, 2010, at 1:48 PM, Eric Christopher wrote: > Author: echristo > Date: Thu Jan 14 15:48:00 2010 > New Revision: 93462 > > URL: http://llvm.org/viewvc/llvm-project?rev=93462&view=rev > Log: > Few minor changes that were requested. No functional change. Ok, now invert the "if (F->hasName())" branch too please :) -Chris > > Modified: > llvm/trunk/lib/Analysis/InlineCost.cpp > > Modified: llvm/trunk/lib/Analysis/InlineCost.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=93462&r1=93461&r2=93462&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Analysis/InlineCost.cpp (original) > +++ llvm/trunk/lib/Analysis/InlineCost.cpp Thu Jan 14 15:48:00 2010 > @@ -102,11 +102,15 @@ > return Reduction; > } > > -// callIsSmall - If a call will lower to a single selection DAG > node, or > +// callIsSmall - If a call is likely to lower to a single target > instruction, or > // is otherwise deemed small return true. > // TODO: Perhaps calls like memcpy, strcpy, etc? > static bool callIsSmall(const Function *F) { > - if (F && !F->hasLocalLinkage() && F->hasName()) { > + if (!F) return false; > + > + if (F->hasLocalLinkage()) return false; > + > + if (F->hasName()) { > StringRef Name = F->getName(); > > // These will all likely lower to a single selection DAG node. > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From espindola at google.com Thu Jan 14 16:57:19 2010 From: espindola at google.com (Rafael Espindola) Date: Thu, 14 Jan 2010 17:57:19 -0500 Subject: [llvm-commits] [patch] Used TimedExec.sh everywhere In-Reply-To: References: <38a0d8451001141140j4c366ca5vc3c8927d3b1882df@mail.gmail.com> Message-ID: <38a0d8451001141457i6893b38eq30d5c5ab44b18047@mail.gmail.com> > I gave this a shot: > > ? TimedExec.sh 1 . sleep 10 > > and found that it slept for 10 seconds, not 1. I think we may need to change > how TimedExec.sh works to make it support Linux. Yes, I noticed that too. The attached patch fixes it by using the CONT signal instead of INFO. I tested that it does kill after the specified timeout. I am currently running the test-suite. Lets hope it completes this time :-) > Nick > Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: timed.patch Type: text/x-diff Size: 910 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100114/89ac8aef/attachment.bin From echristo at apple.com Thu Jan 14 17:00:10 2010 From: echristo at apple.com (Eric Christopher) Date: Thu, 14 Jan 2010 23:00:10 -0000 Subject: [llvm-commits] [llvm] r93473 - /llvm/trunk/lib/Analysis/InlineCost.cpp Message-ID: <201001142300.o0EN0BS9032000@zion.cs.uiuc.edu> Author: echristo Date: Thu Jan 14 17:00:10 2010 New Revision: 93473 URL: http://llvm.org/viewvc/llvm-project?rev=93473&view=rev Log: Pad my commit stats by reducing indentation in this now separate commit. Modified: llvm/trunk/lib/Analysis/InlineCost.cpp Modified: llvm/trunk/lib/Analysis/InlineCost.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=93473&r1=93472&r2=93473&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InlineCost.cpp (original) +++ llvm/trunk/lib/Analysis/InlineCost.cpp Thu Jan 14 17:00:10 2010 @@ -110,25 +110,26 @@ if (F->hasLocalLinkage()) return false; - if (F->hasName()) { - StringRef Name = F->getName(); - - // These will all likely lower to a single selection DAG node. - if (Name == "copysign" || Name == "copysignf" || - Name == "fabs" || Name == "fabsf" || Name == "fabsl" || - Name == "sin" || Name == "sinf" || Name == "sinl" || - Name == "cos" || Name == "cosf" || Name == "cosl" || - Name == "sqrt" || Name == "sqrtf" || Name == "sqrtl" ) - return true; - - // These are all likely to be optimized into something smaller. - if (Name == "pow" || Name == "powf" || Name == "powl" || - Name == "exp2" || Name == "exp2l" || Name == "exp2f" || - Name == "floor" || Name == "floorf" || Name == "ceil" || - Name == "round" || Name == "ffs" || Name == "ffsl" || - Name == "abs" || Name == "labs" || Name == "llabs") - return true; - } + if (!F->hasName()) return false; + + StringRef Name = F->getName(); + + // These will all likely lower to a single selection DAG node. + if (Name == "copysign" || Name == "copysignf" || + Name == "fabs" || Name == "fabsf" || Name == "fabsl" || + Name == "sin" || Name == "sinf" || Name == "sinl" || + Name == "cos" || Name == "cosf" || Name == "cosl" || + Name == "sqrt" || Name == "sqrtf" || Name == "sqrtl" ) + return true; + + // These are all likely to be optimized into something smaller. + if (Name == "pow" || Name == "powf" || Name == "powl" || + Name == "exp2" || Name == "exp2l" || Name == "exp2f" || + Name == "floor" || Name == "floorf" || Name == "ceil" || + Name == "round" || Name == "ffs" || Name == "ffsl" || + Name == "abs" || Name == "labs" || Name == "llabs") + return true; + return false; } From jyasskin at google.com Thu Jan 14 17:15:27 2010 From: jyasskin at google.com (Jeffrey Yasskin) Date: Thu, 14 Jan 2010 23:15:27 -0000 Subject: [llvm-commits] [llvm] r93475 - /llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp Message-ID: <201001142315.o0ENFRgI032598@zion.cs.uiuc.edu> Author: jyasskin Date: Thu Jan 14 17:15:26 2010 New Revision: 93475 URL: http://llvm.org/viewvc/llvm-project?rev=93475&view=rev Log: Teach PPC how to replaceMachineCodeForFunction correctly. (Fixes JITTest.FunctionIsRecompiledAndRelinked.) Modified: llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp Modified: llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp?rev=93475&r1=93474&r2=93475&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp Thu Jan 14 17:15:26 2010 @@ -308,6 +308,7 @@ // Rewrite the stub with an unconditional branch to the target, for any users // who took the address of the stub. EmitBranchToAt((intptr_t)StubCallAddr, (intptr_t)Target, false, is64Bit); + sys::Memory::InvalidateInstructionCache(StubCallAddr, 7*4); // Put the address of the target function to call and the address to return to // after calling the target function in a place that is easy to get on the @@ -441,4 +442,5 @@ void PPCJITInfo::replaceMachineCodeForFunction(void *Old, void *New) { EmitBranchToAt((intptr_t)Old, (intptr_t)New, false, is64Bit); + sys::Memory::InvalidateInstructionCache(Old, 7*4); } From grosbach at apple.com Thu Jan 14 17:18:23 2010 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 14 Jan 2010 15:18:23 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r93409 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <4B4EEC02.4040608@free.fr> References: <201001140224.o0E2O7Rl001369@zion.cs.uiuc.edu> <4B4EEC02.4040608@free.fr> Message-ID: <4D5DEC21-539B-4983-9E7B-FF5AF780E477@apple.com> On Jan 14, 2010, at 2:03 AM, Duncan Sands wrote: > Hi Evan, > >> Add missing memory barrier after binary atomic builtin. r74403 >> apparently left this out by mistake. x86 target will optimize it >> away but it's looking for the barrier after the operation. > > what do you mean by "it's looking for the barrier after the > operation"? > >> +#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) > > Should this really be conditioned on the OS (darwin)? After all, how > barriers work should be a processor issue, not an OS one... > Unfortunately, it's a bit of both, and there's not a really good way of expressing everything right now. For example, on ARMv7, which instructions should be used, and which sharability regions should be specified, can vary depending on thing like whether the system is multi-core or not, whether synchronization with peripherals is required, etc.. For the time being, the OS+Target pair is being used to express that. I'm not really fond of that aspect, but don't have a strong answer for a replacement. -Jim From nlewycky at google.com Thu Jan 14 17:32:13 2010 From: nlewycky at google.com (Nick Lewycky) Date: Thu, 14 Jan 2010 15:32:13 -0800 Subject: [llvm-commits] [patch] Used TimedExec.sh everywhere In-Reply-To: <38a0d8451001141457i6893b38eq30d5c5ab44b18047@mail.gmail.com> References: <38a0d8451001141140j4c366ca5vc3c8927d3b1882df@mail.gmail.com> <38a0d8451001141457i6893b38eq30d5c5ab44b18047@mail.gmail.com> Message-ID: On 14 January 2010 14:57, Rafael Espindola wrote: > > I gave this a shot: > > > > TimedExec.sh 1 . sleep 10 > > > > and found that it slept for 10 seconds, not 1. I think we may need to > change > > how TimedExec.sh works to make it support Linux. > > Yes, I noticed that too. The attached patch fixes it by using the CONT > signal instead of INFO. I tested that it does kill after the specified > timeout. > Could you explain this to me? Why does this make a difference? > I am currently running the test-suite. Lets hope it completes this time :-) > > > Nick > > > > Cheers, > -- > Rafael ?vila de Esp?ndola > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100114/d77c887f/attachment.html From gohman at apple.com Thu Jan 14 17:42:53 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 14 Jan 2010 15:42:53 -0800 Subject: [llvm-commits] [patch] Used TimedExec.sh everywhere In-Reply-To: <38a0d8451001141457i6893b38eq30d5c5ab44b18047@mail.gmail.com> References: <38a0d8451001141140j4c366ca5vc3c8927d3b1882df@mail.gmail.com> <38a0d8451001141457i6893b38eq30d5c5ab44b18047@mail.gmail.com> Message-ID: <3947AC30-C8E3-4F20-9443-310B2C9F3B86@apple.com> On Jan 14, 2010, at 2:57 PM, Rafael Espindola wrote: >> I gave this a shot: >> >> TimedExec.sh 1 . sleep 10 >> >> and found that it slept for 10 seconds, not 1. I think we may need to change >> how TimedExec.sh works to make it support Linux. > > Yes, I noticed that too. The attached patch fixes it by using the CONT > signal instead of INFO. I tested that it does kill after the specified > timeout. Why SIGCONT? Wouldn't SIGTERM be more conventional? Or, would SIGKILL be best, since you may not necessarily trust the application's signal handlers to quit promptly? Dan From espindola at google.com Thu Jan 14 18:04:28 2010 From: espindola at google.com (Rafael Espindola) Date: Thu, 14 Jan 2010 19:04:28 -0500 Subject: [llvm-commits] [patch] Used TimedExec.sh everywhere In-Reply-To: <3947AC30-C8E3-4F20-9443-310B2C9F3B86@apple.com> References: <38a0d8451001141140j4c366ca5vc3c8927d3b1882df@mail.gmail.com> <38a0d8451001141457i6893b38eq30d5c5ab44b18047@mail.gmail.com> <3947AC30-C8E3-4F20-9443-310B2C9F3B86@apple.com> Message-ID: <38a0d8451001141604y174ae3e0s8d0a2b2faf372cc0@mail.gmail.com> > Why SIGCONT? Wouldn't SIGTERM be more conventional? Or, would > SIGKILL be best, since you may not necessarily trust the > application's signal handlers to quit promptly? This is not to kill the application, it is to check that it is running. The idea is that kill will return an error if it cannot send the signal, that is why I changed it to a signal that will have no effect on a running application. > Dan > > Cheers, -- Rafael ?vila de Esp?ndola From grosbach at apple.com Thu Jan 14 18:18:35 2010 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 15 Jan 2010 00:18:35 -0000 Subject: [llvm-commits] [llvm] r93479 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <201001150018.o0F0IZB0002375@zion.cs.uiuc.edu> Author: grosbach Date: Thu Jan 14 18:18:34 2010 New Revision: 93479 URL: http://llvm.org/viewvc/llvm-project?rev=93479&view=rev Log: EmitAtomicCmpSwap() custome inserter needs to delete the MI passed in. EmitAtomicBinary() already does this. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=93479&r1=93478&r2=93479&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Jan 14 18:18:34 2010 @@ -3130,6 +3130,9 @@ // exitMBB: // ... BB = exitMBB; + + MF->DeleteMachineInstr(MI); // The instruction is gone now. + return BB; } From grosbach at apple.com Thu Jan 14 18:22:19 2010 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 15 Jan 2010 00:22:19 -0000 Subject: [llvm-commits] [llvm] r93480 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <201001150022.o0F0MJ2G002494@zion.cs.uiuc.edu> Author: grosbach Date: Thu Jan 14 18:22:18 2010 New Revision: 93480 URL: http://llvm.org/viewvc/llvm-project?rev=93480&view=rev Log: Name change for consistency. No functional change. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=93480&r1=93479&r2=93480&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Jan 14 18:22:18 2010 @@ -3143,7 +3143,7 @@ const TargetInstrInfo *TII = getTargetMachine().getInstrInfo(); const BasicBlock *LLVM_BB = BB->getBasicBlock(); - MachineFunction *F = BB->getParent(); + MachineFunction *MF = BB->getParent(); MachineFunction::iterator It = BB; ++It; @@ -3170,13 +3170,13 @@ break; } - MachineBasicBlock *loopMBB = F->CreateMachineBasicBlock(LLVM_BB); - MachineBasicBlock *exitMBB = F->CreateMachineBasicBlock(LLVM_BB); - F->insert(It, loopMBB); - F->insert(It, exitMBB); + MachineBasicBlock *loopMBB = MF->CreateMachineBasicBlock(LLVM_BB); + MachineBasicBlock *exitMBB = MF->CreateMachineBasicBlock(LLVM_BB); + MF->insert(It, loopMBB); + MF->insert(It, exitMBB); exitMBB->transferSuccessors(BB); - MachineRegisterInfo &RegInfo = F->getRegInfo(); + MachineRegisterInfo &RegInfo = MF->getRegInfo(); unsigned scratch = RegInfo.createVirtualRegister(ARM::GPRRegisterClass); unsigned scratch2 = (!BinOpcode) ? incr : RegInfo.createVirtualRegister(ARM::GPRRegisterClass); @@ -3219,7 +3219,7 @@ // ... BB = exitMBB; - F->DeleteMachineInstr(MI); // The instruction is gone now. + MF->DeleteMachineInstr(MI); // The instruction is gone now. return BB; } From dpatel at apple.com Thu Jan 14 18:26:31 2010 From: dpatel at apple.com (Devang Patel) Date: Fri, 15 Jan 2010 00:26:31 -0000 Subject: [llvm-commits] [llvm] r93481 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <201001150026.o0F0QVpj002620@zion.cs.uiuc.edu> Author: dpatel Date: Thu Jan 14 18:26:31 2010 New Revision: 93481 URL: http://llvm.org/viewvc/llvm-project?rev=93481&view=rev Log: Do not emit multiple AT_container_type attributes. We need to find a better way to emit this info. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=93481&r1=93480&r2=93481&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Jan 14 18:26:31 2010 @@ -1813,7 +1813,8 @@ DIE *NDie = ModuleCU->getDIE(N); if (!NDie) continue; addDIEEntry(SPDie, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, NDie); - addDIEEntry(NDie, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, NDie); + // FIXME - This is not the correct approach. + // addDIEEntry(NDie, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, NDie); } // Standard sections final addresses. From grosbach at apple.com Thu Jan 14 18:32:47 2010 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 15 Jan 2010 00:32:47 -0000 Subject: [llvm-commits] [llvm] r93484 - /llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Message-ID: <201001150032.o0F0Wlq5002840@zion.cs.uiuc.edu> Author: grosbach Date: Thu Jan 14 18:32:47 2010 New Revision: 93484 URL: http://llvm.org/viewvc/llvm-project?rev=93484&view=rev Log: Fix 80 column violations and clean up whitespace Modified: llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Modified: llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp?rev=93484&r1=93483&r2=93484&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp (original) +++ llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Thu Jan 14 18:32:47 2010 @@ -381,9 +381,6 @@ I->eraseFromParent(); } - - - // The entry block changes to have the eh.sjlj.setjmp, with a conditional // branch to a dispatch block for non-zero returns. If we return normally, // we're not handling an exception and just register the function context @@ -397,13 +394,15 @@ // Insert a load in the Catch block, and a switch on its value. By default, // we go to a block that just does an unwind (which is the correct action // for a standard call). - BasicBlock *UnwindBlock = BasicBlock::Create(F.getContext(), "unwindbb", &F); + BasicBlock *UnwindBlock = + BasicBlock::Create(F.getContext(), "unwindbb", &F); Unwinds.push_back(new UnwindInst(F.getContext(), UnwindBlock)); Value *DispatchLoad = new LoadInst(CallSite, "invoke.num", true, DispatchBlock); SwitchInst *DispatchSwitch = - SwitchInst::Create(DispatchLoad, UnwindBlock, Invokes.size(), DispatchBlock); + SwitchInst::Create(DispatchLoad, UnwindBlock, Invokes.size(), + DispatchBlock); // Split the entry block to insert the conditional branch for the setjmp. BasicBlock *ContBlock = EntryBB->splitBasicBlock(EntryBB->getTerminator(), "eh.sjlj.setjmp.cont"); From dpatel at apple.com Thu Jan 14 18:33:29 2010 From: dpatel at apple.com (Devang Patel) Date: Fri, 15 Jan 2010 00:33:29 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93485 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Message-ID: <201001150033.o0F0XUk0002875@zion.cs.uiuc.edu> Author: dpatel Date: Thu Jan 14 18:33:29 2010 New Revision: 93485 URL: http://llvm.org/viewvc/llvm-project?rev=93485&view=rev Log: Avoid recursive while emitting debug info for function types. test/FrontendC/2010-01-14-FnType-DebugInfo.c is the test case. Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.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=93485&r1=93484&r2=93485&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Thu Jan 14 18:33:29 2010 @@ -512,6 +512,21 @@ /// createMethodType - Create MethodType. DIType DebugInfo::createMethodType(tree type) { + // Create a place holder type first. The may be used as a context + // for the argument types. + llvm::DIType FwdType = + DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type, + getOrCreateCompileUnit(NULL), + StringRef(), + getOrCreateCompileUnit(NULL), + 0, 0, 0, 0, 0, + llvm::DIType(), llvm::DIArray()); + llvm::TrackingVH FwdTypeNode = FwdType.getNode(); + TypeCache[type] = WeakVH(FwdType.getNode()); + // Push the struct on region stack. + RegionStack.push_back(WeakVH(FwdType.getNode())); + RegionMap[type] = WeakVH(FwdType.getNode()); + llvm::SmallVector EltTys; // Add the result type at least. @@ -527,12 +542,24 @@ llvm::DIArray EltTypeArray = DebugFactory.GetOrCreateArray(EltTys.data(), EltTys.size()); - return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type, - findRegion(TYPE_CONTEXT(type)), - StringRef(), - getOrCreateCompileUnit(NULL), - 0, 0, 0, 0, 0, - llvm::DIType(), EltTypeArray); + RegionStack.pop_back(); + std::map::iterator RI = RegionMap.find(type); + if (RI != RegionMap.end()) + RegionMap.erase(RI); + + llvm::DIType RealType = + DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type, + findRegion(TYPE_CONTEXT(type)), + StringRef(), + getOrCreateCompileUnit(NULL), + 0, 0, 0, 0, 0, + llvm::DIType(), EltTypeArray); + + // Now that we have a real decl for the struct, replace anything using the + // old decl with the new one. This will recursively update the debug info. + llvm::DIDerivedType(FwdTypeNode).replaceAllUsesWith(RealType); + + return RealType; } /// createPointerType - Create PointerType. From dpatel at apple.com Thu Jan 14 18:34:26 2010 From: dpatel at apple.com (Devang Patel) Date: Fri, 15 Jan 2010 00:34:26 -0000 Subject: [llvm-commits] [llvm] r93486 - /llvm/trunk/test/FrontendC/2010-01-14-FnType-DebugInfo.c Message-ID: <201001150034.o0F0YQrk002911@zion.cs.uiuc.edu> Author: dpatel Date: Thu Jan 14 18:34:26 2010 New Revision: 93486 URL: http://llvm.org/viewvc/llvm-project?rev=93486&view=rev Log: new test case for r93485. Added: llvm/trunk/test/FrontendC/2010-01-14-FnType-DebugInfo.c Added: llvm/trunk/test/FrontendC/2010-01-14-FnType-DebugInfo.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2010-01-14-FnType-DebugInfo.c?rev=93486&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/2010-01-14-FnType-DebugInfo.c (added) +++ llvm/trunk/test/FrontendC/2010-01-14-FnType-DebugInfo.c Thu Jan 14 18:34:26 2010 @@ -0,0 +1,4 @@ +// RUN: %llvmgcc %s -S -g -o /dev/null +typedef void (*sigcatch_t)( struct sigcontext *); +sigcatch_t sigcatch[50] = {(sigcatch_t) 0}; + From grosbach at apple.com Thu Jan 14 18:36:16 2010 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 15 Jan 2010 00:36:16 -0000 Subject: [llvm-commits] [llvm] r93487 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <201001150036.o0F0aG0L002980@zion.cs.uiuc.edu> Author: grosbach Date: Thu Jan 14 18:36:15 2010 New Revision: 93487 URL: http://llvm.org/viewvc/llvm-project?rev=93487&view=rev Log: fix 80-column violations Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=93487&r1=93486&r2=93487&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu Jan 14 18:36:15 2010 @@ -819,10 +819,10 @@ // information is provided by an intrinsic (eh.selector) that can be moved // to unexpected places by the optimizers: if the unwind edge is critical, // then breaking it can result in the intrinsics being in the successor of - // the landing pad, not the landing pad itself. This results in exceptions - // not being caught because no typeids are associated with the invoke. - // This may not be the only way things can go wrong, but it is the only way - // we try to work around for the moment. + // the landing pad, not the landing pad itself. This results + // in exceptions not being caught because no typeids are associated with + // the invoke. This may not be the only way things can go wrong, but it + // is the only way we try to work around for the moment. BranchInst *Br = dyn_cast(LLVMBB->getTerminator()); if (Br && Br->isUnconditional()) { // Critical edge? @@ -1005,11 +1005,11 @@ // This is "default" BB. We have two jumps to it. From "header" BB and // from last "case" BB. if (PHIBB == SDB->BitTestCases[i].Default) { - PHI->addOperand(MachineOperand::CreateReg(SDB->PHINodesToUpdate[pi].second, - false)); + PHI->addOperand(MachineOperand:: + CreateReg(SDB->PHINodesToUpdate[pi].second, false)); PHI->addOperand(MachineOperand::CreateMBB(SDB->BitTestCases[i].Parent)); - PHI->addOperand(MachineOperand::CreateReg(SDB->PHINodesToUpdate[pi].second, - false)); + PHI->addOperand(MachineOperand:: + CreateReg(SDB->PHINodesToUpdate[pi].second, false)); PHI->addOperand(MachineOperand::CreateMBB(SDB->BitTestCases[i].Cases. back().ThisBB)); } @@ -1018,8 +1018,8 @@ j != ej; ++j) { MachineBasicBlock* cBB = SDB->BitTestCases[i].Cases[j].ThisBB; if (cBB->isSuccessor(PHIBB)) { - PHI->addOperand(MachineOperand::CreateReg(SDB->PHINodesToUpdate[pi].second, - false)); + PHI->addOperand(MachineOperand:: + CreateReg(SDB->PHINodesToUpdate[pi].second, false)); PHI->addOperand(MachineOperand::CreateMBB(cBB)); } } @@ -1433,9 +1433,11 @@ void SelectionDAGISel::CannotYetSelectIntrinsic(SDNode *N) { dbgs() << "Cannot yet select: "; unsigned iid = - cast(N->getOperand(N->getOperand(0).getValueType() == MVT::Other))->getZExtValue(); + cast(N->getOperand(N->getOperand(0).getValueType() == + MVT::Other))->getZExtValue(); if (iid < Intrinsic::num_intrinsics) - llvm_report_error("Cannot yet select: intrinsic %" + Intrinsic::getName((Intrinsic::ID)iid)); + llvm_report_error("Cannot yet select: intrinsic %" + + Intrinsic::getName((Intrinsic::ID)iid)); else if (const TargetIntrinsicInfo *tii = TM.getIntrinsicInfo()) llvm_report_error(Twine("Cannot yet select: target intrinsic %") + tii->getName(iid)); From jyasskin at google.com Thu Jan 14 18:41:54 2010 From: jyasskin at google.com (Jeffrey Yasskin) Date: Fri, 15 Jan 2010 00:41:54 -0000 Subject: [llvm-commits] [llvm] r93492 - /llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h Message-ID: <201001150041.o0F0fsdS003239@zion.cs.uiuc.edu> Author: jyasskin Date: Thu Jan 14 18:41:53 2010 New Revision: 93492 URL: http://llvm.org/viewvc/llvm-project?rev=93492&view=rev Log: Make sure include/llvm/MC/MCParsedAsmOperand.h can be compiled alone. Modified: llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h Modified: llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h?rev=93492&r1=93491&r2=93492&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h (original) +++ llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h Thu Jan 14 18:41:53 2010 @@ -11,6 +11,7 @@ #define LLVM_MC_MCASMOPERAND_H namespace llvm { +class SMLoc; /// MCParsedAsmOperand - This abstract class represents a source-level assembly /// instruction operand. It should be subclassed by target-specific code. This From dpatel at apple.com Thu Jan 14 19:12:23 2010 From: dpatel at apple.com (Devang Patel) Date: Fri, 15 Jan 2010 01:12:23 -0000 Subject: [llvm-commits] [llvm] r93494 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp test/FrontendC/2010-01-14-StaticVariable.c Message-ID: <201001150112.o0F1CNSS004233@zion.cs.uiuc.edu> Author: dpatel Date: Thu Jan 14 19:12:22 2010 New Revision: 93494 URL: http://llvm.org/viewvc/llvm-project?rev=93494&view=rev Log: Do not use AT_specification die for static variables. It confuses gdb. Added: llvm/trunk/test/FrontendC/2010-01-14-StaticVariable.c Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=93494&r1=93493&r2=93494&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Jan 14 19:12:22 2010 @@ -1653,8 +1653,11 @@ ModuleCU->insertDIE(N, VariableDie); // Add to context owner. - if (DI_GV.isDefinition() - && !DI_GV.getContext().isCompileUnit()) { + DIDescriptor GVContext = DI_GV.getContext(); + // Do not create specification DIE if context is either compile unit + // or a subprogram. + if (DI_GV.isDefinition() && !GVContext.isCompileUnit() + && !GVContext.isSubprogram()) { // Create specification DIE. DIE *VariableSpecDIE = new DIE(dwarf::DW_TAG_variable); addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification, @@ -1672,7 +1675,7 @@ Asm->Mang->getMangledName(DI_GV.getGlobal())); addBlock(VariableDie, dwarf::DW_AT_location, 0, Block); } - addToContextOwner(VariableDie, DI_GV.getContext()); + addToContextOwner(VariableDie, GVContext); // Expose as global. FIXME - need to check external flag. ModuleCU->addGlobal(DI_GV.getName(), VariableDie); Added: llvm/trunk/test/FrontendC/2010-01-14-StaticVariable.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2010-01-14-StaticVariable.c?rev=93494&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/2010-01-14-StaticVariable.c (added) +++ llvm/trunk/test/FrontendC/2010-01-14-StaticVariable.c Thu Jan 14 19:12:22 2010 @@ -0,0 +1,12 @@ +// This is a regression test on debug info to make sure that llvm emitted +// debug info does not crash gdb. +// RUN: %llvmgcc -S -O0 -g %s -o - | \ +// RUN: llc --disable-fp-elim -o %t.s -O0 -relocation-model=pic +// RUN: %compile_c %t.s -o %t.o +// RUN: echo {quit\n} > %t.in +// RUN: gdb -q -batch -n -x %t.in %t.o > /dev/null + +int foo() { + static int i = 42; + return i; +} From asl at math.spbu.ru Thu Jan 14 19:29:49 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Fri, 15 Jan 2010 01:29:49 -0000 Subject: [llvm-commits] [llvm] r93496 - in /llvm/trunk/lib/Target/MSP430: MSP430ISelLowering.cpp MSP430InstrInfo.td Message-ID: <201001150129.o0F1Tnxj004779@zion.cs.uiuc.edu> Author: asl Date: Thu Jan 14 19:29:49 2010 New Revision: 93496 URL: http://llvm.org/viewvc/llvm-project?rev=93496&view=rev Log: Fix cmp emission on msp430: we definitely should turn stuff like "icmp lhs, rhs" into "cmp rhs, lhs". This should fix PR5979. Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=93496&r1=93495&r2=93496&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Thu Jan 14 19:29:49 2010 @@ -660,16 +660,16 @@ default: llvm_unreachable("Invalid integer condition!"); case ISD::SETEQ: TCC = MSP430CC::COND_E; // aka COND_Z - // Minor optimization: if RHS is a constant, swap operands, then the + // Minor optimization: if LHS is a constant, swap operands, then the // constant can be folded into comparison. - if (RHS.getOpcode() == ISD::Constant) + if (LHS.getOpcode() == ISD::Constant) std::swap(LHS, RHS); break; case ISD::SETNE: TCC = MSP430CC::COND_NE; // aka COND_NZ - // Minor optimization: if RHS is a constant, swap operands, then the + // Minor optimization: if LHS is a constant, swap operands, then the // constant can be folded into comparison. - if (RHS.getOpcode() == ISD::Constant) + if (LHS.getOpcode() == ISD::Constant) std::swap(LHS, RHS); break; case ISD::SETULE: @@ -1014,8 +1014,8 @@ // BB: // cmp 0, N // je RemBB - BuildMI(BB, dl, TII.get(MSP430::CMP8ir)) - .addImm(0).addReg(ShiftAmtSrcReg); + BuildMI(BB, dl, TII.get(MSP430::CMP8ri)) + .addReg(ShiftAmtSrcReg).addImm(0); BuildMI(BB, dl, TII.get(MSP430::JCC)) .addMBB(RemBB) .addImm(MSP430CC::COND_E); Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td?rev=93496&r1=93495&r2=93496&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td Thu Jan 14 19:29:49 2010 @@ -819,38 +819,40 @@ // Integer comparisons let Defs = [SRW] in { def CMP8rr : Pseudo<(outs), (ins GR8:$src1, GR8:$src2), - "cmp.b\t{$src1, $src2}", + "cmp.b\t{$src2, $src1}", [(MSP430cmp GR8:$src1, GR8:$src2), (implicit SRW)]>; def CMP16rr : Pseudo<(outs), (ins GR16:$src1, GR16:$src2), - "cmp.w\t{$src1, $src2}", + "cmp.w\t{$src2, $src1}", [(MSP430cmp GR16:$src1, GR16:$src2), (implicit SRW)]>; -def CMP8ir : Pseudo<(outs), (ins i8imm:$src1, GR8:$src2), - "cmp.b\t{$src1, $src2}", - [(MSP430cmp imm:$src1, GR8:$src2), (implicit SRW)]>; -def CMP16ir : Pseudo<(outs), (ins i16imm:$src1, GR16:$src2), - "cmp.w\t{$src1, $src2}", - [(MSP430cmp imm:$src1, GR16:$src2), (implicit SRW)]>; - -def CMP8im : Pseudo<(outs), (ins i8imm:$src1, memsrc:$src2), - "cmp.b\t{$src1, $src2}", - [(MSP430cmp (i8 imm:$src1), (load addr:$src2)), (implicit SRW)]>; -def CMP16im : Pseudo<(outs), (ins i16imm:$src1, memsrc:$src2), - "cmp.w\t{$src1, $src2}", - [(MSP430cmp (i16 imm:$src1), (load addr:$src2)), (implicit SRW)]>; +def CMP8ri : Pseudo<(outs), (ins GR8:$src1, i8imm:$src2), + "cmp.b\t{$src2, $src1}", + [(MSP430cmp GR8:$src1, imm:$src2), (implicit SRW)]>; +def CMP16ri : Pseudo<(outs), (ins GR16:$src1, i16imm:$src2), + "cmp.w\t{$src2, $src1}", + [(MSP430cmp GR16:$src1, imm:$src2), (implicit SRW)]>; + +def CMP8mi : Pseudo<(outs), (ins memsrc:$src1, i8imm:$src2), + "cmp.b\t{$src2, $src1}", + [(MSP430cmp (load addr:$src1), + (i8 imm:$src2)), (implicit SRW)]>; +def CMP16mi : Pseudo<(outs), (ins memsrc:$src1, i16imm:$src2), + "cmp.w\t{$src2, $src1}", + [(MSP430cmp (load addr:$src1), + (i16 imm:$src2)), (implicit SRW)]>; def CMP8rm : Pseudo<(outs), (ins GR8:$src1, memsrc:$src2), - "cmp.b\t{$src1, $src2}", + "cmp.b\t{$src2, $src1}", [(MSP430cmp GR8:$src1, (load addr:$src2)), (implicit SRW)]>; def CMP16rm : Pseudo<(outs), (ins GR16:$src1, memsrc:$src2), - "cmp.w\t{$src1, $src2}", + "cmp.w\t{$src2, $src1}", [(MSP430cmp GR16:$src1, (load addr:$src2)), (implicit SRW)]>; def CMP8mr : Pseudo<(outs), (ins memsrc:$src1, GR8:$src2), - "cmp.b\t{$src1, $src2}", + "cmp.b\t{$src2, $src1}", [(MSP430cmp (load addr:$src1), GR8:$src2), (implicit SRW)]>; def CMP16mr : Pseudo<(outs), (ins memsrc:$src1, GR16:$src2), - "cmp.w\t{$src1, $src2}", + "cmp.w\t{$src2, $src1}", [(MSP430cmp (load addr:$src1), GR16:$src2), (implicit SRW)]>; From dalej at apple.com Thu Jan 14 19:50:45 2010 From: dalej at apple.com (Dale Johannesen) Date: Fri, 15 Jan 2010 01:50:45 -0000 Subject: [llvm-commits] [llvm] r93498 - in /llvm/trunk: include/llvm/Target/Target.td include/llvm/Target/TargetInstrInfo.h utils/TableGen/CodeEmitterGen.cpp utils/TableGen/CodeGenTarget.cpp utils/TableGen/InstrInfoEmitter.cpp Message-ID: <201001150150.o0F1ojlY005568@zion.cs.uiuc.edu> Author: johannes Date: Thu Jan 14 19:50:44 2010 New Revision: 93498 URL: http://llvm.org/viewvc/llvm-project?rev=93498&view=rev Log: Remove DEBUG_DECLARE, looks like we don't need it. Also, DEBUG_VALUE has side effects. Modified: llvm/trunk/include/llvm/Target/Target.td llvm/trunk/include/llvm/Target/TargetInstrInfo.h llvm/trunk/utils/TableGen/CodeEmitterGen.cpp llvm/trunk/utils/TableGen/CodeGenTarget.cpp llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp Modified: llvm/trunk/include/llvm/Target/Target.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/Target.td?rev=93498&r1=93497&r2=93498&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/Target.td (original) +++ llvm/trunk/include/llvm/Target/Target.td Thu Jan 14 19:50:44 2010 @@ -482,15 +482,6 @@ let InOperandList = (ops unknown:$value, i64imm:$offset, unknown:$meta); let AsmString = "DEBUG_VALUE"; let Namespace = "TargetInstrInfo"; - let neverHasSideEffects = 1; - let isAsCheapAsAMove = 1; -} -def DEBUG_DECLARE : Instruction { - let OutOperandList = (ops); - let InOperandList = (ops unknown:$vbl, unknown:$meta); - let AsmString = "DEBUG_DECLARE"; - let Namespace = "TargetInstrInfo"; - let neverHasSideEffects = 1; let isAsCheapAsAMove = 1; } } Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=93498&r1=93497&r2=93498&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Thu Jan 14 19:50:44 2010 @@ -91,10 +91,7 @@ COPY_TO_REGCLASS = 10, // DEBUG_VALUE - a mapping of the llvm.dbg.value intrinsic - DEBUG_VALUE = 11, - - // DEBUG_DECLARE - a mapping of the llvm.dbg.declare intrinsic - DEBUG_DECLARE = 12 + DEBUG_VALUE = 11 }; unsigned getNumOpcodes() const { return NumOpcodes; } Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeEmitterGen.cpp?rev=93498&r1=93497&r2=93498&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeEmitterGen.cpp (original) +++ llvm/trunk/utils/TableGen/CodeEmitterGen.cpp Thu Jan 14 19:50:44 2010 @@ -35,8 +35,7 @@ R->getName() == "IMPLICIT_DEF" || R->getName() == "SUBREG_TO_REG" || R->getName() == "COPY_TO_REGCLASS" || - R->getName() == "DEBUG_VALUE" || - R->getName() == "DEBUG_DECLARE") continue; + R->getName() == "DEBUG_VALUE") continue; BitsInit *BI = R->getValueAsBitsInit("Inst"); @@ -114,8 +113,7 @@ R->getName() == "IMPLICIT_DEF" || R->getName() == "SUBREG_TO_REG" || R->getName() == "COPY_TO_REGCLASS" || - R->getName() == "DEBUG_VALUE" || - R->getName() == "DEBUG_DECLARE") { + R->getName() == "DEBUG_VALUE") { o << " 0U,\n"; continue; } @@ -154,8 +152,7 @@ InstName == "IMPLICIT_DEF" || InstName == "SUBREG_TO_REG" || InstName == "COPY_TO_REGCLASS" || - InstName == "DEBUG_VALUE" || - InstName == "DEBUG_DECLARE") continue; + InstName == "DEBUG_VALUE") continue; BitsInit *BI = R->getValueAsBitsInit("Inst"); const std::vector &Vals = R->getValues(); Modified: llvm/trunk/utils/TableGen/CodeGenTarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.cpp?rev=93498&r1=93497&r2=93498&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenTarget.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenTarget.cpp Thu Jan 14 19:50:44 2010 @@ -342,11 +342,6 @@ throw "Could not find 'DEBUG_VALUE' instruction!"; const CodeGenInstruction *DEBUG_VALUE = &I->second; - I = getInstructions().find("DEBUG_DECLARE"); - if (I == Instructions.end()) - throw "Could not find 'DEBUG_DECLARE' instruction!"; - const CodeGenInstruction *DEBUG_DECLARE = &I->second; - // Print out the rest of the instructions now. NumberedInstructions.push_back(PHI); NumberedInstructions.push_back(INLINEASM); @@ -360,7 +355,6 @@ NumberedInstructions.push_back(SUBREG_TO_REG); NumberedInstructions.push_back(COPY_TO_REGCLASS); NumberedInstructions.push_back(DEBUG_VALUE); - NumberedInstructions.push_back(DEBUG_DECLARE); for (inst_iterator II = inst_begin(), E = inst_end(); II != E; ++II) if (&II->second != PHI && &II->second != INLINEASM && @@ -373,8 +367,7 @@ &II->second != IMPLICIT_DEF && &II->second != SUBREG_TO_REG && &II->second != COPY_TO_REGCLASS && - &II->second != DEBUG_VALUE && - &II->second != DEBUG_DECLARE) + &II->second != DEBUG_VALUE) NumberedInstructions.push_back(&II->second); } Modified: llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp?rev=93498&r1=93497&r2=93498&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp Thu Jan 14 19:50:44 2010 @@ -346,8 +346,7 @@ R->getName() != "IMPLICIT_DEF" && R->getName() != "SUBREG_TO_REG" && R->getName() != "COPY_TO_REGCLASS" && - R->getName() != "DEBUG_VALUE" && - R->getName() != "DEBUG_DECLARE") + R->getName() != "DEBUG_VALUE") throw R->getName() + " doesn't have a field named '" + Val->getValue() + "'!"; return; From dalej at apple.com Thu Jan 14 19:54:55 2010 From: dalej at apple.com (Dale Johannesen) Date: Fri, 15 Jan 2010 01:54:55 -0000 Subject: [llvm-commits] [llvm] r93499 - in /llvm/trunk/lib/Target/X86: AsmPrinter/X86MCInstLower.cpp X86RegisterInfo.cpp Message-ID: <201001150154.o0F1st7W005688@zion.cs.uiuc.edu> Author: johannes Date: Thu Jan 14 19:54:55 2010 New Revision: 93499 URL: http://llvm.org/viewvc/llvm-project?rev=93499&view=rev Log: Lower FrameIndex operand of DEBUG_VALUE (specially) and print it as a comment on X86. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=93499&r1=93498&r2=93499&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Thu Jan 14 19:54:55 2010 @@ -25,6 +25,7 @@ #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Mangler.h" #include "llvm/ADT/SmallString.h" +#include "llvm/Analysis/DebugInfo.h" using namespace llvm; @@ -420,6 +421,25 @@ case TargetInstrInfo::GC_LABEL: printLabel(MI); return; + case TargetInstrInfo::DEBUG_VALUE: { + if (!VerboseAsm) + return; + O << '\t' << MAI->getCommentString() << "DEBUG_VALUE: "; + // cast away const; DIetc do not take const operands for some reason + DIVariable V((MDNode*)(MI->getOperand(2).getMetadata())); + O << V.getName(); + O << " <- "; + if (MI->getOperand(0).getType()==MachineOperand::MO_Register) + printOperand(MI, 0); + else { + assert(MI->getOperand(0).getType()==MachineOperand::MO_Immediate); + int64_t imm = MI->getOperand(0).getImm(); + O << '[' << ((imm<0) ? "EBP" : "ESP+") << imm << ']'; + } + O << "+"; + printOperand(MI, 1); + return; + } case TargetInstrInfo::INLINEASM: printInlineAsm(MI); return; Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=93499&r1=93498&r2=93499&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Thu Jan 14 19:54:55 2010 @@ -591,6 +591,15 @@ int FrameIndex = MI.getOperand(i).getIndex(); unsigned BasePtr; + // DEBUG_VALUE has a special representation, and is only robust enough to + // represent SP(or BP) +- offset addressing modes. We rewrite the + // FrameIndex to be a constant; implicitly positive constants are relative + // to ESP and negative ones to EBP. + if (MI.getOpcode()==TargetInstrInfo::DEBUG_VALUE) { + MI.getOperand(i).ChangeToImmediate(getFrameIndexOffset(MF, FrameIndex)); + return 0; + } + if (needsStackRealignment(MF)) BasePtr = (FrameIndex < 0 ? FramePtr : StackPtr); else From clattner at apple.com Thu Jan 14 20:01:22 2010 From: clattner at apple.com (Chris Lattner) Date: Thu, 14 Jan 2010 18:01:22 -0800 Subject: [llvm-commits] [llvm] r93492 - /llvm/trunk/include/llvm/MC/MCParsedAsmOperand.h In-Reply-To: <201001150041.o0F0fsdS003239@zion.cs.uiuc.edu> References: <201001150041.o0F0fsdS003239@zion.cs.uiuc.edu> Message-ID: <1777C0CA-EE24-4C00-A070-78D9ADF6037B@apple.com> On Jan 14, 2010, at 4:41 PM, Jeffrey Yasskin wrote: > Author: jyasskin > Date: Thu Jan 14 18:41:53 2010 > New Revision: 93492 > > URL: http://llvm.org/viewvc/llvm-project?rev=93492&view=rev > Log: > Make sure include/llvm/MC/MCParsedAsmOperand.h can be compiled alone. Thanks! -Chris From clattner at apple.com Thu Jan 14 20:06:57 2010 From: clattner at apple.com (Chris Lattner) Date: Thu, 14 Jan 2010 18:06:57 -0800 Subject: [llvm-commits] [llvm] r93473 - /llvm/trunk/lib/Analysis/InlineCost.cpp In-Reply-To: <201001142300.o0EN0BS9032000@zion.cs.uiuc.edu> References: <201001142300.o0EN0BS9032000@zion.cs.uiuc.edu> Message-ID: <83D352D0-9254-421E-A031-E209EAEA3787@apple.com> On Jan 14, 2010, at 3:00 PM, Eric Christopher wrote: > Author: echristo > Date: Thu Jan 14 17:00:10 2010 > New Revision: 93473 > > URL: http://llvm.org/viewvc/llvm-project?rev=93473&view=rev > Log: > Pad my commit stats by reducing indentation in this now separate > commit. woot, thanks :) -Chris From asl at math.spbu.ru Thu Jan 14 20:09:27 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Fri, 15 Jan 2010 02:09:27 -0000 Subject: [llvm-commits] [llvm] r93501 - in /llvm/trunk/test/CodeGen/MSP430: bit.ll setcc.ll Message-ID: <201001150209.o0F29RVZ006238@zion.cs.uiuc.edu> Author: asl Date: Thu Jan 14 20:09:27 2010 New Revision: 93501 URL: http://llvm.org/viewvc/llvm-project?rev=93501&view=rev Log: Temporary disable tests Modified: llvm/trunk/test/CodeGen/MSP430/bit.ll llvm/trunk/test/CodeGen/MSP430/setcc.ll Modified: llvm/trunk/test/CodeGen/MSP430/bit.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/bit.ll?rev=93501&r1=93500&r2=93501&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/bit.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/bit.ll Thu Jan 14 20:09:27 2010 @@ -1,4 +1,5 @@ ; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s +; XFAIL: * target datalayout = "e-p:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:16:32" target triple = "msp430-generic-generic" Modified: llvm/trunk/test/CodeGen/MSP430/setcc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/setcc.ll?rev=93501&r1=93500&r2=93501&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/setcc.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/setcc.ll Thu Jan 14 20:09:27 2010 @@ -1,4 +1,5 @@ ; RUN: llc -march=msp430 < %s | FileCheck %s +; XFAIL: * target datalayout = "e-p:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:16:32" target triple = "msp430-generic-generic" From vhernandez at apple.com Thu Jan 14 21:37:48 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 15 Jan 2010 03:37:48 -0000 Subject: [llvm-commits] [llvm] r93504 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/VMCore/Verifier.cpp test/Assembler/functionlocal-metadata.ll test/DebugInfo/2009-10-16-Scope.ll test/DebugInfo/printdbginfo2.ll Message-ID: <201001150337.o0F3bn79008993@zion.cs.uiuc.edu> Author: hernande Date: Thu Jan 14 21:37:48 2010 New Revision: 93504 URL: http://llvm.org/viewvc/llvm-project?rev=93504&view=rev Log: Improve llvm.dbg.declare intrinsic by referring directly to the storage in its first argument, via function-local metadata (instead of via a bitcast). This patch also cleans up code that expects there to be a bitcast in the first argument and testcases that call llvm.dbg.declare. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/include/llvm/IntrinsicInst.h llvm/trunk/include/llvm/Intrinsics.td llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/VMCore/Verifier.cpp llvm/trunk/test/Assembler/functionlocal-metadata.ll llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll llvm/trunk/test/DebugInfo/printdbginfo2.ll Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=93504&r1=93503&r2=93504&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Thu Jan 14 21:37:48 2010 @@ -491,7 +491,6 @@ Module &M; LLVMContext& VMContext; - const Type *EmptyStructPtr; // "{}*". Function *DeclareFn; // llvm.dbg.declare Function *ValueFn; // llvm.dbg.value @@ -659,7 +658,7 @@ /// Finds the dbg.declare intrinsic corresponding to this value if any. /// It looks through pointer casts too. - const DbgDeclareInst *findDbgDeclare(const Value *V, bool stripCasts = true); + const DbgDeclareInst *findDbgDeclare(const Value *V); /// Find the debug info descriptor corresponding to this global variable. Value *findDbgGlobalDeclare(GlobalVariable *V); Modified: llvm/trunk/include/llvm/IntrinsicInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=93504&r1=93503&r2=93504&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicInst.h (original) +++ llvm/trunk/include/llvm/IntrinsicInst.h Thu Jan 14 21:37:48 2010 @@ -25,6 +25,7 @@ #define LLVM_INTRINSICINST_H #include "llvm/Constants.h" +#include "llvm/Metadata.h" #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Intrinsics.h" @@ -82,7 +83,12 @@ /// class DbgDeclareInst : public DbgInfoIntrinsic { public: - Value *getAddress() const { return getOperand(1); } + Value *getAddress() const { + if (MDNode* MD = dyn_cast(getOperand(1))) + return MD->getOperand(0); + else + return NULL; + } MDNode *getVariable() const { return cast(getOperand(2)); } // Methods for support type inquiry through isa, cast, and dyn_cast: Modified: llvm/trunk/include/llvm/Intrinsics.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=93504&r1=93503&r2=93504&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.td (original) +++ llvm/trunk/include/llvm/Intrinsics.td Thu Jan 14 21:37:48 2010 @@ -283,7 +283,7 @@ // places. let Properties = [IntrNoMem] in { def int_dbg_declare : Intrinsic<[llvm_void_ty], - [llvm_descriptor_ty, llvm_metadata_ty]>; + [llvm_metadata_ty, llvm_metadata_ty]>; def int_dbg_value : Intrinsic<[llvm_void_ty], [llvm_metadata_ty, llvm_i64_ty, llvm_metadata_ty]>; Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=93504&r1=93503&r2=93504&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Thu Jan 14 21:37:48 2010 @@ -599,9 +599,7 @@ //===----------------------------------------------------------------------===// DIFactory::DIFactory(Module &m) - : M(m), VMContext(M.getContext()), DeclareFn(0) { - EmptyStructPtr = PointerType::getUnqual(StructType::get(VMContext)); -} + : M(m), VMContext(M.getContext()), DeclareFn(0) {} Constant *DIFactory::GetTagConstant(unsigned TAG) { assert((TAG & LLVMDebugVersionMask) == 0 && @@ -1034,26 +1032,22 @@ /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, Instruction *InsertBefore) { - // Cast the storage to a {}* for the call to llvm.dbg.declare. - Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertBefore); - if (!DeclareFn) DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); - Value *Args[] = { Storage, D.getNode() }; + Value *Elts[] = { Storage }; + Value *Args[] = { MDNode::get(Storage->getContext(), Elts, 1), D.getNode() }; 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) { - // Cast the storage to a {}* for the call to llvm.dbg.declare. - Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertAtEnd); - if (!DeclareFn) DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); - Value *Args[] = { Storage, D.getNode() }; + Value *Elts[] = { Storage }; + Value *Args[] = { MDNode::get(Storage->getContext(), Elts, 1), D.getNode() }; return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd); } @@ -1258,25 +1252,24 @@ /// Finds the llvm.dbg.declare intrinsic corresponding to this value if any. /// It looks through pointer casts too. -const DbgDeclareInst *llvm::findDbgDeclare(const Value *V, bool stripCasts) { - if (stripCasts) { - V = V->stripPointerCasts(); - - // Look for the bitcast. - for (Value::use_const_iterator I = V->use_begin(), E =V->use_end(); - I != E; ++I) - if (isa(I)) { - const DbgDeclareInst *DDI = findDbgDeclare(*I, false); - if (DDI) return DDI; - } +const DbgDeclareInst *llvm::findDbgDeclare(const Value *V) { + V = V->stripPointerCasts(); + + if (!isa(V) && !isa(V)) return 0; - } - - // Find llvm.dbg.declare among uses of the instruction. - for (Value::use_const_iterator I = V->use_begin(), E =V->use_end(); - I != E; ++I) - if (const DbgDeclareInst *DDI = dyn_cast(I)) - return DDI; + + const Function *F = NULL; + if (const Instruction *I = dyn_cast(V)) + F = I->getParent()->getParent(); + else if (const Argument *A = dyn_cast(V)) + F = A->getParent(); + + for (Function::const_iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI) + for (BasicBlock::const_iterator BI = (*FI).begin(), BE = (*FI).end(); + BI != BE; ++BI) + if (const DbgDeclareInst *DDI = dyn_cast(BI)) + if (DDI->getAddress() == V) + return DDI; return 0; } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=93504&r1=93503&r2=93504&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Thu Jan 14 21:37:48 2010 @@ -332,8 +332,6 @@ return true; Value *Address = DI->getAddress(); - if (BitCastInst *BCI = dyn_cast(Address)) - Address = BCI->getOperand(0); AllocaInst *AI = dyn_cast(Address); // Don't handle byval struct arguments or VLAs, for example. if (!AI) break; Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=93504&r1=93503&r2=93504&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Thu Jan 14 21:37:48 2010 @@ -1590,9 +1590,10 @@ default: break; case Intrinsic::dbg_declare: // llvm.dbg.declare - if (Constant *C = dyn_cast(CI.getOperand(1))) - Assert1(C && !isa(C), - "invalid llvm.dbg.declare intrinsic call", &CI); + if (MDNode *MD = dyn_cast(CI.getOperand(1))) + if (Constant *C = dyn_cast(MD->getOperand(0))) + Assert1(C && !isa(C), + "invalid llvm.dbg.declare intrinsic call", &CI); break; case Intrinsic::memcpy: case Intrinsic::memmove: Modified: llvm/trunk/test/Assembler/functionlocal-metadata.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/functionlocal-metadata.ll?rev=93504&r1=93503&r2=93504&view=diff ============================================================================== --- llvm/trunk/test/Assembler/functionlocal-metadata.ll (original) +++ llvm/trunk/test/Assembler/functionlocal-metadata.ll Thu Jan 14 21:37:48 2010 @@ -5,23 +5,21 @@ %0 = add i32 %a, 1 ; [#uses=1] %two = add i32 %b, %0 ; [#uses=0] %1 = alloca i32 ; [#uses=1] - %three = bitcast i32* %1 to { }* ; <{ }*> [#uses=6] - call void @llvm.dbg.declare({ }* %three, metadata !{i32* %1}) -; CHECK: metadata !{i32* %1} - call void @llvm.dbg.declare({ }* %three, metadata !{{ }* %three}) - call void @llvm.dbg.declare({ }* %three, metadata !{i32 %0}) - call void @llvm.dbg.declare({ }* %three, metadata !{{ }* %three, i32 %0}) - call void @llvm.dbg.declare({ }* %three, metadata !{i32 %b, i32 %0}) - call void @llvm.dbg.declare({ }* %three, metadata !{i32 %a, metadata !"foo"}) + call void @llvm.dbg.declare(metadata !{i32* %1}, metadata !{i32* %1}) +; CHECK: metadata !{i32* %1}, metadata !{i32* %1} + call void @llvm.dbg.declare(metadata !{i32 %two}, metadata !{i32 %0}) + call void @llvm.dbg.declare(metadata !{i32 %0}, metadata !{i32* %1, i32 %0}) + call void @llvm.dbg.declare(metadata !{i32* %1}, metadata !{i32 %b, i32 %0}) + call void @llvm.dbg.declare(metadata !{i32 %a}, metadata !{i32 %a, metadata !"foo"}) ; CHECK: metadata !{i32 %a, metadata !"foo"} - call void @llvm.dbg.declare({ }* %three, metadata !{metadata !0, i32 %two}) + call void @llvm.dbg.declare(metadata !{i32 %b}, metadata !{metadata !0, i32 %two}) call void @llvm.dbg.value(metadata !{ i32 %a }, i64 0, metadata !1) call void @llvm.dbg.value(metadata !{ i32 %0 }, i64 25, metadata !0) call void @llvm.dbg.value(metadata !{ i32* %1 }, i64 16, metadata !"foo") ; CHECK: call void @llvm.dbg.value(metadata !{i32* %1}, i64 16, metadata !"foo") - call void @llvm.dbg.value(metadata !{ { }* %three }, i64 12, metadata !"bar") + call void @llvm.dbg.value(metadata !"foo", i64 12, metadata !"bar") ret void, !foo !0, !bar !1 ; CHECK: ret void, !foo !0, !bar !1 @@ -30,7 +28,7 @@ !0 = metadata !{i32 662302, i32 26, metadata !1, null} !1 = metadata !{i32 4, metadata !"foo"} -declare void @llvm.dbg.declare({ }*, metadata) nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone !foo = !{ !0 } Modified: llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll?rev=93504&r1=93503&r2=93504&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll (original) +++ llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll Thu Jan 14 21:37:48 2010 @@ -9,8 +9,7 @@ br label %do.body, !dbg !0 do.body: ; preds = %entry - %0 = bitcast i32* %count_ to { }* ; <{ }*> [#uses=1] - call void @llvm.dbg.declare({ }* %0, metadata !4) + call void @llvm.dbg.declare(metadata !{i32* %count_}, metadata !4) %conv = ptrtoint i32* %count_ to i32, !dbg !0 ; [#uses=1] %call = call i32 @foo(i32 %conv) ssp, !dbg !0 ; [#uses=0] br label %do.end, !dbg !0 @@ -19,7 +18,7 @@ ret void, !dbg !7 } -declare void @llvm.dbg.declare({ }*, metadata) nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone declare i32 @foo(i32) ssp Modified: llvm/trunk/test/DebugInfo/printdbginfo2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/printdbginfo2.ll?rev=93504&r1=93503&r2=93504&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/printdbginfo2.ll (original) +++ llvm/trunk/test/DebugInfo/printdbginfo2.ll Thu Jan 14 21:37:48 2010 @@ -19,11 +19,11 @@ call void @llvm.dbg.stoppoint(i32 6, i32 3, metadata !1) call void @llvm.dbg.stoppoint(i32 7, i32 3, metadata !1) %0 = bitcast %struct.foo* %b to { }* ; <{ }*> [#uses=1] - call void @llvm.dbg.declare({ }* %0, metadata !4) + call void @llvm.dbg.declare(metadata !{%struct.foo* %b}, metadata !4) ; CHECK:; %0 is variable b of type foo declared at x.c:7 call void @llvm.dbg.stoppoint(i32 8, i32 3, metadata !1) %1 = bitcast [4 x i32]* %a to { }* ; <{ }*> [#uses=1] - call void @llvm.dbg.declare({ }* %1, metadata !8) + call void @llvm.dbg.declare(metadata !{[4 x i32]* %a}, metadata !8) ; CHECK:; %1 is variable a of type declared at x.c:8 call void @llvm.dbg.stoppoint(i32 9, i32 3, metadata !1) %tmp = getelementptr inbounds %struct.foo* %b, i32 0, i32 0 ; [#uses=1] @@ -46,7 +46,7 @@ declare void @llvm.dbg.stoppoint(i32, i32, metadata) nounwind readnone -declare void @llvm.dbg.declare({ }*, metadata) nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone declare void @llvm.dbg.region.end(metadata) nounwind readnone From clattner at apple.com Thu Jan 14 22:28:03 2010 From: clattner at apple.com (Chris Lattner) Date: Thu, 14 Jan 2010 20:28:03 -0800 Subject: [llvm-commits] [llvm] r93499 - in /llvm/trunk/lib/Target/X86: AsmPrinter/X86MCInstLower.cpp X86RegisterInfo.cpp In-Reply-To: <201001150154.o0F1st7W005688@zion.cs.uiuc.edu> References: <201001150154.o0F1st7W005688@zion.cs.uiuc.edu> Message-ID: On Jan 14, 2010, at 5:54 PM, Dale Johannesen wrote: > Author: johannes > Date: Thu Jan 14 19:54:55 2010 > New Revision: 93499 > > URL: http://llvm.org/viewvc/llvm-project?rev=93499&view=rev > Log: > Lower FrameIndex operand of DEBUG_VALUE (specially) and > print it as a comment on X86. Hi Dale, Like GC_LABEL, I think this should just call a method on the parent asmprinter class (like printLabel) so that this can be implemented in target-independent code. The target independent code can just print it as "FI#4" it doesn't necessarily have to resolve it to "%esp+127" -Chris > > > Modified: > llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp > llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp > > Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=93499&r1=93498&r2=93499&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) > +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Thu Jan 14 19:54:55 2010 > @@ -25,6 +25,7 @@ > #include "llvm/Support/FormattedStream.h" > #include "llvm/Support/Mangler.h" > #include "llvm/ADT/SmallString.h" > +#include "llvm/Analysis/DebugInfo.h" > using namespace llvm; > > > @@ -420,6 +421,25 @@ > case TargetInstrInfo::GC_LABEL: > printLabel(MI); > return; > + case TargetInstrInfo::DEBUG_VALUE: { > + if (!VerboseAsm) > + return; > + O << '\t' << MAI->getCommentString() << "DEBUG_VALUE: "; > + // cast away const; DIetc do not take const operands for some reason > + DIVariable V((MDNode*)(MI->getOperand(2).getMetadata())); > + O << V.getName(); > + O << " <- "; > + if (MI->getOperand(0).getType()==MachineOperand::MO_Register) > + printOperand(MI, 0); > + else { > + assert(MI->getOperand(0).getType()==MachineOperand::MO_Immediate); > + int64_t imm = MI->getOperand(0).getImm(); > + O << '[' << ((imm<0) ? "EBP" : "ESP+") << imm << ']'; > + } > + O << "+"; > + printOperand(MI, 1); > + return; > + } > case TargetInstrInfo::INLINEASM: > printInlineAsm(MI); > return; > > Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=93499&r1=93498&r2=93499&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Thu Jan 14 19:54:55 2010 > @@ -591,6 +591,15 @@ > int FrameIndex = MI.getOperand(i).getIndex(); > unsigned BasePtr; > > + // DEBUG_VALUE has a special representation, and is only robust enough to > + // represent SP(or BP) +- offset addressing modes. We rewrite the > + // FrameIndex to be a constant; implicitly positive constants are relative > + // to ESP and negative ones to EBP. > + if (MI.getOpcode()==TargetInstrInfo::DEBUG_VALUE) { > + MI.getOperand(i).ChangeToImmediate(getFrameIndexOffset(MF, FrameIndex)); > + return 0; > + } > + > if (needsStackRealignment(MF)) > BasePtr = (FrameIndex < 0 ? FramePtr : StackPtr); > else > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From bob.wilson at apple.com Fri Jan 15 00:29:18 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 15 Jan 2010 06:29:18 -0000 Subject: [llvm-commits] [llvm] r93505 - /llvm/trunk/lib/CodeGen/TailDuplication.cpp Message-ID: <201001150629.o0F6TIEd014224@zion.cs.uiuc.edu> Author: bwilson Date: Fri Jan 15 00:29:17 2010 New Revision: 93505 URL: http://llvm.org/viewvc/llvm-project?rev=93505&view=rev Log: Change pre-regalloc tail duplication to only duplicate indirect branch blocks. The pre-regalloc pass caused some regressions in both compile time and performance of the generated code, and it did not improve performance, except for indirect branches. I also moved the check for single-block loops to speed up the common case when running the taildup pass before reg allocation. Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=93505&r1=93504&r2=93505&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original) +++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Fri Jan 15 00:29:17 2010 @@ -253,7 +253,7 @@ SSAUpdateVals.clear(); } - // Eliminate some of the copies inserted tail duplication to maintain + // Eliminate some of the copies inserted by tail duplication to maintain // SSA form. for (unsigned i = 0, e = Copies.size(); i != e; ++i) { MachineInstr *Copy = Copies[i]; @@ -437,8 +437,11 @@ TailDuplicatePass::TailDuplicate(MachineBasicBlock *TailBB, MachineFunction &MF, SmallVector &TDBBs, SmallVector &Copies) { - // Don't try to tail-duplicate single-block loops. - if (TailBB->isSuccessor(TailBB)) + // Pre-regalloc tail duplication hurts compile time and doesn't help + // much except for indirect branches. + bool hasIndirectBranch = (!TailBB->empty() && + TailBB->back().getDesc().isIndirectBranch()); + if (PreRegAlloc && !hasIndirectBranch) return false; // Set the limit on the number of instructions to duplicate, with a default @@ -446,7 +449,7 @@ // duplicate only one, because one branch instruction can be eliminated to // compensate for the duplication. unsigned MaxDuplicateCount; - if (!TailBB->empty() && TailBB->back().getDesc().isIndirectBranch()) + if (hasIndirectBranch) // If the target has hardware branch prediction that can handle indirect // branches, duplicating them can often make them predictable when there // are common paths through the code. The limit needs to be high enough @@ -457,6 +460,10 @@ else MaxDuplicateCount = TailDuplicateSize; + // Don't try to tail-duplicate single-block loops. + if (TailBB->isSuccessor(TailBB)) + return false; + // Check the instructions in the block to determine whether tail-duplication // is invalid or unlikely to be profitable. unsigned InstrCount = 0; From baldrick at free.fr Fri Jan 15 02:03:45 2010 From: baldrick at free.fr (Duncan Sands) Date: Fri, 15 Jan 2010 09:03:45 +0100 Subject: [llvm-commits] [llvm-gcc-4.2] r93409 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <4D5DEC21-539B-4983-9E7B-FF5AF780E477@apple.com> References: <201001140224.o0E2O7Rl001369@zion.cs.uiuc.edu> <4B4EEC02.4040608@free.fr> <4D5DEC21-539B-4983-9E7B-FF5AF780E477@apple.com> Message-ID: <4B502161.4030300@free.fr> Hi Jim, >>> +#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) >> >> Should this really be conditioned on the OS (darwin)? After all, how >> barriers work should be a processor issue, not an OS one... >> > > Unfortunately, it's a bit of both, and there's not a really good way of > expressing everything right now. For example, on ARMv7, which > instructions should be used, and which sharability regions should be > specified, can vary depending on thing like whether the system is > multi-core or not, whether synchronization with peripherals is required, > etc.. For the time being, the OS+Target pair is being used to express > that. I'm not really fond of that aspect, but don't have a strong answer > for a replacement. thanks for the explanation. Ciao, Duncan. From baldrick at free.fr Fri Jan 15 02:10:28 2010 From: baldrick at free.fr (Duncan Sands) Date: Fri, 15 Jan 2010 09:10:28 +0100 Subject: [llvm-commits] [llvm] r93448 - /llvm/trunk/lib/Analysis/InlineCost.cpp In-Reply-To: <201001142012.o0EKCYDs024788@zion.cs.uiuc.edu> References: <201001142012.o0EKCYDs024788@zion.cs.uiuc.edu> Message-ID: <4B5022F4.4010704@free.fr> Hi Eric, if you check the code in SelectionDAGBuilder.cpp, you will see that it checks more than just the name before deciding whether to change into a SDag node. For example, here is the code for sqrt: } else if (Name == "sqrt" || Name == "sqrtf" || Name == "sqrtl") { if (I.getNumOperands() == 2 && // Basic sanity checks. I.getOperand(1)->getType()->isFloatingPoint() && I.getType() == I.getOperand(1)->getType() && I.onlyReadsMemory()) { SDValue Tmp = getValue(I.getOperand(1)); setValue(&I, DAG.getNode(ISD::FSQRT, getCurDebugLoc(), Tmp.getValueType(), Tmp)); return; } Notice how it checks I.onlyReadsMemory to see if sqrt writes errno or not? Also, your code (and that in SDag) suffers from not being turn-offable. How about factoring the checks out of SelectionDAGBuilder.cpp and reusing them here? Ciao, Duncan. From echristo at apple.com Fri Jan 15 02:27:02 2010 From: echristo at apple.com (Eric Christopher) Date: Fri, 15 Jan 2010 00:27:02 -0800 Subject: [llvm-commits] [llvm] r93448 - /llvm/trunk/lib/Analysis/InlineCost.cpp In-Reply-To: <4B5022F4.4010704@free.fr> References: <201001142012.o0EKCYDs024788@zion.cs.uiuc.edu> <4B5022F4.4010704@free.fr> Message-ID: <9A504B89-77DA-4D60-9D60-6393A4B2DE00@apple.com> On Jan 15, 2010, at 12:10 AM, Duncan Sands wrote: > Hi Eric, if you check the code in SelectionDAGBuilder.cpp, you will see that > it checks more than just the name before deciding whether to change into a > SDag node. For example, here is the code for sqrt: > > } else if (Name == "sqrt" || Name == "sqrtf" || Name == "sqrtl") { > if (I.getNumOperands() == 2 && // Basic sanity checks. > I.getOperand(1)->getType()->isFloatingPoint() && > I.getType() == I.getOperand(1)->getType() && > I.onlyReadsMemory()) { > SDValue Tmp = getValue(I.getOperand(1)); > setValue(&I, DAG.getNode(ISD::FSQRT, getCurDebugLoc(), > Tmp.getValueType(), Tmp)); > return; > } > > Notice how it checks I.onlyReadsMemory to see if sqrt writes errno or not? > Also, your code (and that in SDag) suffers from not being turn-offable. > How about factoring the checks out of SelectionDAGBuilder.cpp and reusing > them here? Yes, I saw that. Largely I wasn't as concerned with that since, in general, I don't think it's still much of an issue even still since most of those functions are still going to be lowered or optimized. That said, I'm not wedded to not doing it either. :) The errno checks are probably a good idea, but the sanity checks really aren't necessary. I don't think the code should be able to be turned off - I can see doing it in SelectionDAGBuilder since it's an "optimization", but we're already in an opt pass here. Sorry for the wishy washy email, but unfortunately that was my general thought while looking at it anyhow ;) -eric From jay.foad at gmail.com Fri Jan 15 02:32:59 2010 From: jay.foad at gmail.com (Jay Foad) Date: Fri, 15 Jan 2010 08:32:59 -0000 Subject: [llvm-commits] [llvm] r93509 - /llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Message-ID: <201001150832.o0F8WxwZ018901@zion.cs.uiuc.edu> Author: foad Date: Fri Jan 15 02:32:58 2010 New Revision: 93509 URL: http://llvm.org/viewvc/llvm-project?rev=93509&view=rev Log: Fix http://llvm.org/PR6028, an assertion failure when an UndefValue of integer type is used. Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=93509&r1=93508&r2=93509&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Fri Jan 15 02:32:58 2010 @@ -491,8 +491,22 @@ /// @brief Get a GenericValue for a Constant* GenericValue ExecutionEngine::getConstantValue(const Constant *C) { // If its undefined, return the garbage. - if (isa(C)) - return GenericValue(); + if (isa(C)) { + GenericValue Result; + switch (C->getType()->getTypeID()) { + case Type::IntegerTyID: + case Type::X86_FP80TyID: + case Type::FP128TyID: + case Type::PPC_FP128TyID: + // Although the value is undefined, we still have to construct an APInt + // with the correct bit width. + Result.IntVal = APInt(C->getType()->getPrimitiveSizeInBits(), 0); + break; + default: + break; + } + return Result; + } // If the value is a ConstantExpr if (const ConstantExpr *CE = dyn_cast(C)) { From jay.foad at gmail.com Fri Jan 15 05:29:27 2010 From: jay.foad at gmail.com (Jay Foad) Date: Fri, 15 Jan 2010 11:29:27 -0000 Subject: [llvm-commits] [llvm] r93511 - /llvm/trunk/test/ExecutionEngine/2010-01-15-UndefValue.ll Message-ID: <201001151129.o0FBTRXf008687@zion.cs.uiuc.edu> Author: foad Date: Fri Jan 15 05:29:26 2010 New Revision: 93511 URL: http://llvm.org/viewvc/llvm-project?rev=93511&view=rev Log: Test case for http://llvm.org/PR6028. Added: llvm/trunk/test/ExecutionEngine/2010-01-15-UndefValue.ll (with props) Added: llvm/trunk/test/ExecutionEngine/2010-01-15-UndefValue.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/2010-01-15-UndefValue.ll?rev=93511&view=auto ============================================================================== --- llvm/trunk/test/ExecutionEngine/2010-01-15-UndefValue.ll (added) +++ llvm/trunk/test/ExecutionEngine/2010-01-15-UndefValue.ll Fri Jan 15 05:29:26 2010 @@ -0,0 +1,9 @@ +; RUN: llvm-as %s -o %t.bc +; RUN: lli -force-interpreter=true %t.bc + +define i32 @main() { + %a = add i32 0, undef + %b = add float 0.0, undef + %c = add double 0.0, undef + ret i32 0 +} Propchange: llvm/trunk/test/ExecutionEngine/2010-01-15-UndefValue.ll ------------------------------------------------------------------------------ svn:keywords = Id URL From Ken.Dyck at onsemi.com Fri Jan 15 07:37:49 2010 From: Ken.Dyck at onsemi.com (Ken Dyck) Date: Fri, 15 Jan 2010 06:37:49 -0700 Subject: [llvm-commits] [Review] Integer type legalization capable of supporting non-power-of-2 value types In-Reply-To: <8F2E4A8BCDA0B84DA6C9088EB5B27747D5F31E@NAMAIL.ad.onsemi.com> References: <8F2E4A8BCDA0B84DA6C9088EB5B27747D5F31E@NAMAIL.ad.onsemi.com> Message-ID: <8F2E4A8BCDA0B84DA6C9088EB5B27747E66293@NAMAIL.ad.onsemi.com> On Tuesday, January 05, 2010 11:13 AM, I wrote: > > The attached patch is an implementation of the changes to > integer type legalization that Duncan Sands outlined [1] for > supporting > non-power-of-2 integer value types. Reviews appreciated. > > [1] > http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-December/027939.html Ping? -Ken -------------- next part -------------- A non-text attachment was scrubbed... Name: non-po2.TargetLowering.diff Type: application/octet-stream Size: 11748 bytes Desc: non-po2.TargetLowering.diff Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100115/0cfe4984/attachment.obj From espindola at google.com Fri Jan 15 08:59:55 2010 From: espindola at google.com (Rafael Espindola) Date: Fri, 15 Jan 2010 09:59:55 -0500 Subject: [llvm-commits] [patch] Used TimedExec.sh everywhere In-Reply-To: <38a0d8451001141457i6893b38eq30d5c5ab44b18047@mail.gmail.com> References: <38a0d8451001141140j4c366ca5vc3c8927d3b1882df@mail.gmail.com> <38a0d8451001141457i6893b38eq30d5c5ab44b18047@mail.gmail.com> Message-ID: <38a0d8451001150659g7ce49ed0pff4e569d7132595a@mail.gmail.com> > I am currently running the test-suite. Lets hope it completes this time :-) It completed successfully. The logs shows some timeouts, but that is actually good thing for testing the patch. Cheers, -- Rafael ?vila de Esp?ndola From edwintorok at gmail.com Fri Jan 15 09:31:41 2010 From: edwintorok at gmail.com (=?UTF-8?B?VMO2csO2ayBFZHdpbg==?=) Date: Fri, 15 Jan 2010 17:31:41 +0200 Subject: [llvm-commits] [patch] Used TimedExec.sh everywhere In-Reply-To: <38a0d8451001141604y174ae3e0s8d0a2b2faf372cc0@mail.gmail.com> References: <38a0d8451001141140j4c366ca5vc3c8927d3b1882df@mail.gmail.com> <38a0d8451001141457i6893b38eq30d5c5ab44b18047@mail.gmail.com> <3947AC30-C8E3-4F20-9443-310B2C9F3B86@apple.com> <38a0d8451001141604y174ae3e0s8d0a2b2faf372cc0@mail.gmail.com> Message-ID: <4B508A5D.4090808@gmail.com> On 2010-01-15 02:04, Rafael Espindola wrote: >> Why SIGCONT? Wouldn't SIGTERM be more conventional? Or, would >> SIGKILL be best, since you may not necessarily trust the >> application's signal handlers to quit promptly? >> > > This is not to kill the application, it is to check that it is running. > The idea is that kill will return an error if it cannot send the signal, > that is why I changed it to a signal that will have no effect on a > running application. > The usual way to do that is kill -0 Best regards, --Edwin From Ken.Dyck at onsemi.com Fri Jan 15 09:30:45 2010 From: Ken.Dyck at onsemi.com (Ken Dyck) Date: Fri, 15 Jan 2010 08:30:45 -0700 Subject: [llvm-commits] [llvm] r91614 - in /llvm/trunk: include/llvm/CodeGen/ValueTypes.h lib/CodeGen/SelectionDAG/LegalizeDAG.cpp In-Reply-To: <4B4470B1.8080005@free.fr> References: <200912172009.nBHK9hPQ001888@zion.cs.uiuc.edu> <4B4470B1.8080005@free.fr> Message-ID: <8F2E4A8BCDA0B84DA6C9088EB5B27747E662CF@NAMAIL.ad.onsemi.com> On Wednesday, January 06, 2010 6:15 AM, Duncan Sands wrote: > > > Introduce EVT::getHalfSizedIntegerVT() for use in > > ExpandUnalignedStore() in LegalizeDAG.cpp. Unlike the code it > > replaces, which simply decrements the simple type by one, > > getHalfSizedIntegerVT() searches for the smallest simple > integer type > > that is at least half the size of the type it is called on. This > > approach has the advantage that it will continue working if a new > > value type (such as > > i24) is added to MVT. > > I don't think this is correct. Consider an unaligned store > of i24. This should write 3 bytes to memory. It looks like > getHalfSizedIntegerVT will return i16. > ExpandUnalignedStore will then write an i16 followed by > another one, writing > 4 bytes, which is wrong. I still have some more work to do before I get a general solution working. In the meantime, the attached patch should fix the problem you describe (albeit with potentially more unaligned stores than necessary for non-power-of-2 types). Any objections to committing this patch as a temporary fix? -Ken -------------- next part -------------- A non-text attachment was scrubbed... Name: LegalizeDAG.ExpandUnalignedStore-stop-gap-fix.diff Type: application/octet-stream Size: 1684 bytes Desc: LegalizeDAG.ExpandUnalignedStore-stop-gap-fix.diff Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100115/3fa4a347/attachment.obj From espindola at google.com Fri Jan 15 09:34:22 2010 From: espindola at google.com (Rafael Espindola) Date: Fri, 15 Jan 2010 10:34:22 -0500 Subject: [llvm-commits] [patch] Used TimedExec.sh everywhere In-Reply-To: <4B508A5D.4090808@gmail.com> References: <38a0d8451001141140j4c366ca5vc3c8927d3b1882df@mail.gmail.com> <38a0d8451001141457i6893b38eq30d5c5ab44b18047@mail.gmail.com> <3947AC30-C8E3-4F20-9443-310B2C9F3B86@apple.com> <38a0d8451001141604y174ae3e0s8d0a2b2faf372cc0@mail.gmail.com> <4B508A5D.4090808@gmail.com> Message-ID: <38a0d8451001150734r131e3ac2kb419e7fd59b6e853@mail.gmail.com> > The usual way to do that is kill -0 Thanks! Is the patch OK with s/SIGCONT/0/ ? > Best regards, > --Edwin Cheers, -- Rafael ?vila de Esp?ndola From edwintorok at gmail.com Fri Jan 15 09:36:51 2010 From: edwintorok at gmail.com (=?UTF-8?B?VMO2csO2ayBFZHdpbg==?=) Date: Fri, 15 Jan 2010 17:36:51 +0200 Subject: [llvm-commits] [patch] Used TimedExec.sh everywhere In-Reply-To: <38a0d8451001150734r131e3ac2kb419e7fd59b6e853@mail.gmail.com> References: <38a0d8451001141140j4c366ca5vc3c8927d3b1882df@mail.gmail.com> <38a0d8451001141457i6893b38eq30d5c5ab44b18047@mail.gmail.com> <3947AC30-C8E3-4F20-9443-310B2C9F3B86@apple.com> <38a0d8451001141604y174ae3e0s8d0a2b2faf372cc0@mail.gmail.com> <4B508A5D.4090808@gmail.com> <38a0d8451001150734r131e3ac2kb419e7fd59b6e853@mail.gmail.com> Message-ID: <4B508B93.6040603@gmail.com> On 2010-01-15 17:34, Rafael Espindola wrote: >> The usual way to do that is kill -0 >> > > Thanks! > > Is the patch OK with s/SIGCONT/0/ ? > No, because 0 is not a signal name ;) Should be something like this (haven't tested though): - kill -s INFO $PARENT 2>/dev/null + kill -0 $PARENT 2>/dev/null I am using kill -0 in other scripts though, and it works fine. Best regards, --Edwin From espindola at google.com Fri Jan 15 09:53:34 2010 From: espindola at google.com (Rafael Espindola) Date: Fri, 15 Jan 2010 10:53:34 -0500 Subject: [llvm-commits] [patch] Used TimedExec.sh everywhere In-Reply-To: <4B508B93.6040603@gmail.com> References: <38a0d8451001141140j4c366ca5vc3c8927d3b1882df@mail.gmail.com> <38a0d8451001141457i6893b38eq30d5c5ab44b18047@mail.gmail.com> <3947AC30-C8E3-4F20-9443-310B2C9F3B86@apple.com> <38a0d8451001141604y174ae3e0s8d0a2b2faf372cc0@mail.gmail.com> <4B508A5D.4090808@gmail.com> <38a0d8451001150734r131e3ac2kb419e7fd59b6e853@mail.gmail.com> <4B508B93.6040603@gmail.com> Message-ID: <38a0d8451001150753h59a28b28lb20666feb7ec1725@mail.gmail.com> > No, because 0 is not a signal name ;) > > Should be something like this (haven't tested though): > > - ? ? ? ?kill -s INFO $PARENT 2>/dev/null > + ? ? ? ?kill -0 $PARENT 2>/dev/null > > I am using kill -0 in other scripts though, and it works fine. Sure. So, is it ok? I tested kill -0 on linux and it does return 0 if the process exists and 1 if it doesn't which is all that we need. > Best regards, > --Edwin Cheers, -- Rafael ?vila de Esp?ndola From edwintorok at gmail.com Fri Jan 15 09:59:53 2010 From: edwintorok at gmail.com (=?UTF-8?B?VMO2csO2ayBFZHdpbg==?=) Date: Fri, 15 Jan 2010 17:59:53 +0200 Subject: [llvm-commits] [patch] Used TimedExec.sh everywhere In-Reply-To: <38a0d8451001150753h59a28b28lb20666feb7ec1725@mail.gmail.com> References: <38a0d8451001141140j4c366ca5vc3c8927d3b1882df@mail.gmail.com> <38a0d8451001141457i6893b38eq30d5c5ab44b18047@mail.gmail.com> <3947AC30-C8E3-4F20-9443-310B2C9F3B86@apple.com> <38a0d8451001141604y174ae3e0s8d0a2b2faf372cc0@mail.gmail.com> <4B508A5D.4090808@gmail.com> <38a0d8451001150734r131e3ac2kb419e7fd59b6e853@mail.gmail.com> <4B508B93.6040603@gmail.com> <38a0d8451001150753h59a28b28lb20666feb7ec1725@mail.gmail.com> Message-ID: <4B5090F9.8020808@gmail.com> On 2010-01-15 17:53, Rafael Espindola wrote: >> No, because 0 is not a signal name ;) >> >> Should be something like this (haven't tested though): >> >> - kill -s INFO $PARENT 2>/dev/null >> + kill -0 $PARENT 2>/dev/null >> >> I am using kill -0 in other scripts though, and it works fine. >> > > Sure. So, is it ok? > > Yes. > I tested kill -0 on linux and it does return 0 if the process exists > and 1 if it doesn't which is all that we need. > Yes, I just double-checked and it also works on Solaris. Best regards, --Edwin From nlewycky at google.com Fri Jan 15 11:09:09 2010 From: nlewycky at google.com (Nick Lewycky) Date: Fri, 15 Jan 2010 09:09:09 -0800 Subject: [llvm-commits] [patch] Used TimedExec.sh everywhere In-Reply-To: <4B5090F9.8020808@gmail.com> References: <38a0d8451001141140j4c366ca5vc3c8927d3b1882df@mail.gmail.com> <38a0d8451001141457i6893b38eq30d5c5ab44b18047@mail.gmail.com> <3947AC30-C8E3-4F20-9443-310B2C9F3B86@apple.com> <38a0d8451001141604y174ae3e0s8d0a2b2faf372cc0@mail.gmail.com> <4B508A5D.4090808@gmail.com> <38a0d8451001150734r131e3ac2kb419e7fd59b6e853@mail.gmail.com> <4B508B93.6040603@gmail.com> <38a0d8451001150753h59a28b28lb20666feb7ec1725@mail.gmail.com> <4B5090F9.8020808@gmail.com> Message-ID: Works on my mac too. Please commit that plus the change to RunSafely.sh you sent earlier. Thanks! 2010/1/15 T?r?k Edwin > On 2010-01-15 17:53, Rafael Espindola wrote: > >> No, because 0 is not a signal name ;) > >> > >> Should be something like this (haven't tested though): > >> > >> - kill -s INFO $PARENT 2>/dev/null > >> + kill -0 $PARENT 2>/dev/null > >> > >> I am using kill -0 in other scripts though, and it works fine. > >> > > > > Sure. So, is it ok? > > > > > > Yes. > > > I tested kill -0 on linux and it does return 0 if the process exists > > and 1 if it doesn't which is all that we need. > > > > Yes, I just double-checked and it also works on Solaris. > > Best regards, > --Edwin > _______________________________________________ > 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/20100115/6367d9e2/attachment.html From clattner at apple.com Fri Jan 15 11:12:58 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 09:12:58 -0800 Subject: [llvm-commits] [llvm] r93504 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/VMCore/Verifier.cpp test/Assembler/functionlocal-metadata.ll test/DebugInfo/2009-10-16-Scope.ll test/DebugInfo/printdbginfo2.ll In-Reply-To: <201001150337.o0F3bn79008993@zion.cs.uiuc.edu> References: <201001150337.o0F3bn79008993@zion.cs.uiuc.edu> Message-ID: <5C0866CA-AC98-42A9-9EA3-1F0603334F0C@apple.com> On Jan 14, 2010, at 7:37 PM, Victor Hernandez wrote: > Author: hernande > Date: Thu Jan 14 21:37:48 2010 > New Revision: 93504 > > URL: http://llvm.org/viewvc/llvm-project?rev=93504&view=rev > Log: > Improve llvm.dbg.declare intrinsic by referring directly to the > storage in its first argument, via function-local metadata (instead > of via a bitcast). > This patch also cleans up code that expects there to be a bitcast in > the first argument and testcases that call llvm.dbg.declare. Hi Victor, This is a IR incompatibility, and this intrinsic existed in LLVM 2.6 and earlier. Please add "autoupgrade" support to the .ll and .bc readers. Thanks, -Chris From vhernandez at apple.com Fri Jan 15 11:36:47 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 15 Jan 2010 17:36:47 -0000 Subject: [llvm-commits] [llvm] r93515 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/VMCore/Verifier.cpp test/Assembler/functionlocal-metadata.ll test/DebugInfo/2009-10-16-Scope.ll test/DebugInfo/printdbginfo2.ll Message-ID: <201001151736.o0FHamGU022981@zion.cs.uiuc.edu> Author: hernande Date: Fri Jan 15 11:36:47 2010 New Revision: 93515 URL: http://llvm.org/viewvc/llvm-project?rev=93515&view=rev Log: Revert r93504 because older uses of llvm.dbg.declare intrinsics need to be auto-upgraded Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/include/llvm/IntrinsicInst.h llvm/trunk/include/llvm/Intrinsics.td llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/VMCore/Verifier.cpp llvm/trunk/test/Assembler/functionlocal-metadata.ll llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll llvm/trunk/test/DebugInfo/printdbginfo2.ll Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=93515&r1=93514&r2=93515&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Fri Jan 15 11:36:47 2010 @@ -491,6 +491,7 @@ Module &M; LLVMContext& VMContext; + const Type *EmptyStructPtr; // "{}*". Function *DeclareFn; // llvm.dbg.declare Function *ValueFn; // llvm.dbg.value @@ -658,7 +659,7 @@ /// Finds the dbg.declare intrinsic corresponding to this value if any. /// It looks through pointer casts too. - const DbgDeclareInst *findDbgDeclare(const Value *V); + const DbgDeclareInst *findDbgDeclare(const Value *V, bool stripCasts = true); /// Find the debug info descriptor corresponding to this global variable. Value *findDbgGlobalDeclare(GlobalVariable *V); Modified: llvm/trunk/include/llvm/IntrinsicInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=93515&r1=93514&r2=93515&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicInst.h (original) +++ llvm/trunk/include/llvm/IntrinsicInst.h Fri Jan 15 11:36:47 2010 @@ -25,7 +25,6 @@ #define LLVM_INTRINSICINST_H #include "llvm/Constants.h" -#include "llvm/Metadata.h" #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Intrinsics.h" @@ -83,12 +82,7 @@ /// class DbgDeclareInst : public DbgInfoIntrinsic { public: - Value *getAddress() const { - if (MDNode* MD = dyn_cast(getOperand(1))) - return MD->getOperand(0); - else - return NULL; - } + Value *getAddress() const { return getOperand(1); } MDNode *getVariable() const { return cast(getOperand(2)); } // Methods for support type inquiry through isa, cast, and dyn_cast: Modified: llvm/trunk/include/llvm/Intrinsics.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=93515&r1=93514&r2=93515&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.td (original) +++ llvm/trunk/include/llvm/Intrinsics.td Fri Jan 15 11:36:47 2010 @@ -283,7 +283,7 @@ // places. let Properties = [IntrNoMem] in { def int_dbg_declare : Intrinsic<[llvm_void_ty], - [llvm_metadata_ty, llvm_metadata_ty]>; + [llvm_descriptor_ty, llvm_metadata_ty]>; def int_dbg_value : Intrinsic<[llvm_void_ty], [llvm_metadata_ty, llvm_i64_ty, llvm_metadata_ty]>; Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=93515&r1=93514&r2=93515&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Fri Jan 15 11:36:47 2010 @@ -599,7 +599,9 @@ //===----------------------------------------------------------------------===// DIFactory::DIFactory(Module &m) - : M(m), VMContext(M.getContext()), DeclareFn(0) {} + : M(m), VMContext(M.getContext()), DeclareFn(0) { + EmptyStructPtr = PointerType::getUnqual(StructType::get(VMContext)); +} Constant *DIFactory::GetTagConstant(unsigned TAG) { assert((TAG & LLVMDebugVersionMask) == 0 && @@ -1032,22 +1034,26 @@ /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, Instruction *InsertBefore) { + // Cast the storage to a {}* for the call to llvm.dbg.declare. + Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertBefore); + if (!DeclareFn) DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); - Value *Elts[] = { Storage }; - Value *Args[] = { MDNode::get(Storage->getContext(), Elts, 1), D.getNode() }; + Value *Args[] = { Storage, D.getNode() }; 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) { + // Cast the storage to a {}* for the call to llvm.dbg.declare. + Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertAtEnd); + if (!DeclareFn) DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); - Value *Elts[] = { Storage }; - Value *Args[] = { MDNode::get(Storage->getContext(), Elts, 1), D.getNode() }; + Value *Args[] = { Storage, D.getNode() }; return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd); } @@ -1252,24 +1258,25 @@ /// Finds the llvm.dbg.declare intrinsic corresponding to this value if any. /// It looks through pointer casts too. -const DbgDeclareInst *llvm::findDbgDeclare(const Value *V) { - V = V->stripPointerCasts(); - - if (!isa(V) && !isa(V)) +const DbgDeclareInst *llvm::findDbgDeclare(const Value *V, bool stripCasts) { + if (stripCasts) { + V = V->stripPointerCasts(); + + // Look for the bitcast. + for (Value::use_const_iterator I = V->use_begin(), E =V->use_end(); + I != E; ++I) + if (isa(I)) { + const DbgDeclareInst *DDI = findDbgDeclare(*I, false); + if (DDI) return DDI; + } return 0; - - const Function *F = NULL; - if (const Instruction *I = dyn_cast(V)) - F = I->getParent()->getParent(); - else if (const Argument *A = dyn_cast(V)) - F = A->getParent(); - - for (Function::const_iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI) - for (BasicBlock::const_iterator BI = (*FI).begin(), BE = (*FI).end(); - BI != BE; ++BI) - if (const DbgDeclareInst *DDI = dyn_cast(BI)) - if (DDI->getAddress() == V) - return DDI; + } + + // Find llvm.dbg.declare among uses of the instruction. + for (Value::use_const_iterator I = V->use_begin(), E =V->use_end(); + I != E; ++I) + if (const DbgDeclareInst *DDI = dyn_cast(I)) + return DDI; return 0; } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=93515&r1=93514&r2=93515&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Fri Jan 15 11:36:47 2010 @@ -332,6 +332,8 @@ return true; Value *Address = DI->getAddress(); + if (BitCastInst *BCI = dyn_cast(Address)) + Address = BCI->getOperand(0); AllocaInst *AI = dyn_cast(Address); // Don't handle byval struct arguments or VLAs, for example. if (!AI) break; Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=93515&r1=93514&r2=93515&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Fri Jan 15 11:36:47 2010 @@ -1590,10 +1590,9 @@ default: break; case Intrinsic::dbg_declare: // llvm.dbg.declare - if (MDNode *MD = dyn_cast(CI.getOperand(1))) - if (Constant *C = dyn_cast(MD->getOperand(0))) - Assert1(C && !isa(C), - "invalid llvm.dbg.declare intrinsic call", &CI); + if (Constant *C = dyn_cast(CI.getOperand(1))) + Assert1(C && !isa(C), + "invalid llvm.dbg.declare intrinsic call", &CI); break; case Intrinsic::memcpy: case Intrinsic::memmove: Modified: llvm/trunk/test/Assembler/functionlocal-metadata.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/functionlocal-metadata.ll?rev=93515&r1=93514&r2=93515&view=diff ============================================================================== --- llvm/trunk/test/Assembler/functionlocal-metadata.ll (original) +++ llvm/trunk/test/Assembler/functionlocal-metadata.ll Fri Jan 15 11:36:47 2010 @@ -5,21 +5,23 @@ %0 = add i32 %a, 1 ; [#uses=1] %two = add i32 %b, %0 ; [#uses=0] %1 = alloca i32 ; [#uses=1] + %three = bitcast i32* %1 to { }* ; <{ }*> [#uses=6] - call void @llvm.dbg.declare(metadata !{i32* %1}, metadata !{i32* %1}) -; CHECK: metadata !{i32* %1}, metadata !{i32* %1} - call void @llvm.dbg.declare(metadata !{i32 %two}, metadata !{i32 %0}) - call void @llvm.dbg.declare(metadata !{i32 %0}, metadata !{i32* %1, i32 %0}) - call void @llvm.dbg.declare(metadata !{i32* %1}, metadata !{i32 %b, i32 %0}) - call void @llvm.dbg.declare(metadata !{i32 %a}, metadata !{i32 %a, metadata !"foo"}) + call void @llvm.dbg.declare({ }* %three, metadata !{i32* %1}) +; CHECK: metadata !{i32* %1} + call void @llvm.dbg.declare({ }* %three, metadata !{{ }* %three}) + call void @llvm.dbg.declare({ }* %three, metadata !{i32 %0}) + call void @llvm.dbg.declare({ }* %three, metadata !{{ }* %three, i32 %0}) + call void @llvm.dbg.declare({ }* %three, metadata !{i32 %b, i32 %0}) + call void @llvm.dbg.declare({ }* %three, metadata !{i32 %a, metadata !"foo"}) ; CHECK: metadata !{i32 %a, metadata !"foo"} - call void @llvm.dbg.declare(metadata !{i32 %b}, metadata !{metadata !0, i32 %two}) + call void @llvm.dbg.declare({ }* %three, metadata !{metadata !0, i32 %two}) call void @llvm.dbg.value(metadata !{ i32 %a }, i64 0, metadata !1) call void @llvm.dbg.value(metadata !{ i32 %0 }, i64 25, metadata !0) call void @llvm.dbg.value(metadata !{ i32* %1 }, i64 16, metadata !"foo") ; CHECK: call void @llvm.dbg.value(metadata !{i32* %1}, i64 16, metadata !"foo") - call void @llvm.dbg.value(metadata !"foo", i64 12, metadata !"bar") + call void @llvm.dbg.value(metadata !{ { }* %three }, i64 12, metadata !"bar") ret void, !foo !0, !bar !1 ; CHECK: ret void, !foo !0, !bar !1 @@ -28,7 +30,7 @@ !0 = metadata !{i32 662302, i32 26, metadata !1, null} !1 = metadata !{i32 4, metadata !"foo"} -declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone +declare void @llvm.dbg.declare({ }*, metadata) nounwind readnone declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone !foo = !{ !0 } Modified: llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll?rev=93515&r1=93514&r2=93515&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll (original) +++ llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll Fri Jan 15 11:36:47 2010 @@ -9,7 +9,8 @@ br label %do.body, !dbg !0 do.body: ; preds = %entry - call void @llvm.dbg.declare(metadata !{i32* %count_}, metadata !4) + %0 = bitcast i32* %count_ to { }* ; <{ }*> [#uses=1] + call void @llvm.dbg.declare({ }* %0, metadata !4) %conv = ptrtoint i32* %count_ to i32, !dbg !0 ; [#uses=1] %call = call i32 @foo(i32 %conv) ssp, !dbg !0 ; [#uses=0] br label %do.end, !dbg !0 @@ -18,7 +19,7 @@ ret void, !dbg !7 } -declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone +declare void @llvm.dbg.declare({ }*, metadata) nounwind readnone declare i32 @foo(i32) ssp Modified: llvm/trunk/test/DebugInfo/printdbginfo2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/printdbginfo2.ll?rev=93515&r1=93514&r2=93515&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/printdbginfo2.ll (original) +++ llvm/trunk/test/DebugInfo/printdbginfo2.ll Fri Jan 15 11:36:47 2010 @@ -19,11 +19,11 @@ call void @llvm.dbg.stoppoint(i32 6, i32 3, metadata !1) call void @llvm.dbg.stoppoint(i32 7, i32 3, metadata !1) %0 = bitcast %struct.foo* %b to { }* ; <{ }*> [#uses=1] - call void @llvm.dbg.declare(metadata !{%struct.foo* %b}, metadata !4) + call void @llvm.dbg.declare({ }* %0, metadata !4) ; CHECK:; %0 is variable b of type foo declared at x.c:7 call void @llvm.dbg.stoppoint(i32 8, i32 3, metadata !1) %1 = bitcast [4 x i32]* %a to { }* ; <{ }*> [#uses=1] - call void @llvm.dbg.declare(metadata !{[4 x i32]* %a}, metadata !8) + call void @llvm.dbg.declare({ }* %1, metadata !8) ; CHECK:; %1 is variable a of type declared at x.c:8 call void @llvm.dbg.stoppoint(i32 9, i32 3, metadata !1) %tmp = getelementptr inbounds %struct.foo* %b, i32 0, i32 0 ; [#uses=1] @@ -46,7 +46,7 @@ declare void @llvm.dbg.stoppoint(i32, i32, metadata) nounwind readnone -declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone +declare void @llvm.dbg.declare({ }*, metadata) nounwind readnone declare void @llvm.dbg.region.end(metadata) nounwind readnone From devang.patel at gmail.com Fri Jan 15 11:45:38 2010 From: devang.patel at gmail.com (Devang Patel) Date: Fri, 15 Jan 2010 09:45:38 -0800 Subject: [llvm-commits] [llvm] r93504 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/VMCore/Verifier.cpp test/Assembler/funct Message-ID: <352a1fb21001150945j44e1edf4y831100e68d5f08b9@mail.gmail.com> On Fri, Jan 15, 2010 at 9:12 AM, Chris Lattner wrote: > > On Jan 14, 2010, at 7:37 PM, Victor Hernandez wrote: > >> Author: hernande >> Date: Thu Jan 14 21:37:48 2010 >> New Revision: 93504 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=93504&view=rev >> Log: >> Improve llvm.dbg.declare intrinsic by referring directly to the >> storage in its first argument, via function-local metadata (instead >> of via a bitcast). >> This patch also cleans up code that expects there to be a bitcast in >> the first argument and testcases that call llvm.dbg.declare. > > Hi Victor, > > This is a IR incompatibility, and this intrinsic existed in LLVM 2.6 > and earlier. ?Please add "autoupgrade" support to the .ll and .bc > readers. > Chris, 2.6 uses GVs for debug info. The autoupgrade support already discards dbg intrinsics that do not use use metadata. - Devang From devang.patel at gmail.com Fri Jan 15 11:51:57 2010 From: devang.patel at gmail.com (Devang Patel) Date: Fri, 15 Jan 2010 09:51:57 -0800 Subject: [llvm-commits] [llvm] r93504 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/VMCore/Verifier.cpp test/Assembler/funct Message-ID: <352a1fb21001150951o6c53d8dbgf179f635388c2591@mail.gmail.com> Hi Victor, On Thu, Jan 14, 2010 at 7:37 PM, Victor Hernandez wrote: > Author: hernande > Date: Thu Jan 14 21:37:48 2010 > New Revision: 93504 > > URL: http://llvm.org/viewvc/llvm-project?rev=93504&view=rev > Log: > Improve llvm.dbg.declare intrinsic by referring directly to the storage in its first argument, via function-local metadata (instead of via a bitcast). > This patch also cleans up code that expects there to be a bitcast in the first argument and testcases that call llvm.dbg.declare. > > > Modified: > ? ?llvm/trunk/include/llvm/Analysis/DebugInfo.h > ? ?llvm/trunk/include/llvm/IntrinsicInst.h > ? ?llvm/trunk/include/llvm/Intrinsics.td > ? ?llvm/trunk/lib/Analysis/DebugInfo.cpp > ? ?llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp > ? ?llvm/trunk/lib/VMCore/Verifier.cpp > ? ?llvm/trunk/test/Assembler/functionlocal-metadata.ll > ? ?llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll > ? ?llvm/trunk/test/DebugInfo/printdbginfo2.ll > > Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=93504&r1=93503&r2=93504&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) > +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Thu Jan 14 21:37:48 2010 > @@ -491,7 +491,6 @@ > ? ? Module &M; > ? ? LLVMContext& VMContext; > > - ? ?const Type *EmptyStructPtr; // "{}*". > ? ? Function *DeclareFn; ? ? // llvm.dbg.declare > ? ? Function *ValueFn; ? ? ? // llvm.dbg.value > > @@ -659,7 +658,7 @@ > > ? /// Finds the dbg.declare intrinsic corresponding to this value if any. > ? /// It looks through pointer casts too. > - ?const DbgDeclareInst *findDbgDeclare(const Value *V, bool stripCasts = true); > + ?const DbgDeclareInst *findDbgDeclare(const Value *V); > > ? /// Find the debug info descriptor corresponding to this global variable. > ? Value *findDbgGlobalDeclare(GlobalVariable *V); > > Modified: llvm/trunk/include/llvm/IntrinsicInst.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=93504&r1=93503&r2=93504&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/IntrinsicInst.h (original) > +++ llvm/trunk/include/llvm/IntrinsicInst.h Thu Jan 14 21:37:48 2010 > @@ -25,6 +25,7 @@ > ?#define LLVM_INTRINSICINST_H > > ?#include "llvm/Constants.h" > +#include "llvm/Metadata.h" > ?#include "llvm/Function.h" > ?#include "llvm/Instructions.h" > ?#include "llvm/Intrinsics.h" > @@ -82,7 +83,12 @@ > ? /// > ? class DbgDeclareInst : public DbgInfoIntrinsic { > ? public: > - ? ?Value *getAddress() ?const { return getOperand(1); } > + ? ?Value *getAddress() const { > + ? ? ?if (MDNode* MD = dyn_cast(getOperand(1))) > + ? ? ? return MD->getOperand(0); > + ? ? ?else > + ? ? ? return NULL; > + ? ?} If getOperand(1) is either MDNode or NULL. Pl. add an assert to check if it is anything else. If you move this def. in .cpp then you can avoid including Metadata.h here. - Devang From stoklund at 2pi.dk Fri Jan 15 12:07:31 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 15 Jan 2010 18:07:31 -0000 Subject: [llvm-commits] [test-suite] r93517 - /test-suite/trunk/RunSafely.sh Message-ID: <201001151807.o0FI7VID024275@zion.cs.uiuc.edu> Author: stoklund Date: Fri Jan 15 12:07:31 2010 New Revision: 93517 URL: http://llvm.org/viewvc/llvm-project?rev=93517&view=rev Log: Properly transfer the exit code when running tests remotely. The $? exit code was getting expanded on the local host. Modified: test-suite/trunk/RunSafely.sh Modified: test-suite/trunk/RunSafely.sh URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/RunSafely.sh?rev=93517&r1=93516&r2=93517&view=diff ============================================================================== --- test-suite/trunk/RunSafely.sh (original) +++ test-suite/trunk/RunSafely.sh Fri Jan 15 12:07:31 2010 @@ -145,7 +145,7 @@ rm -f "$PWD/${PROG}.command" rm -f "$PWD/${PROG}.remote" rm -f "$PWD/${PROG}.remote.time" - echo "$ULIMITCMD cd $PWD; (time -p ($COMMAND > $PWD/${OUTFILE}.remote 2>&1 < $INFILE;); echo exit $?) > $PWD/${OUTFILE}.remote.time 2>&1" > "$PWD/${PROG}.command" + echo "$ULIMITCMD cd $PWD; (time -p ($COMMAND > $PWD/${OUTFILE}.remote 2>&1 < $INFILE;); echo exit \$?) > $PWD/${OUTFILE}.remote.time 2>&1" > "$PWD/${PROG}.command" chmod +x "$PWD/${PROG}.command" ( $RCLIENT -l $RUSER $RHOST $RPORT "ls $PWD/${PROG}.command" ) > /dev/null 2>&1 From sabre at nondot.org Fri Jan 15 12:08:38 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 18:08:38 -0000 Subject: [llvm-commits] [llvm] r93518 - /llvm/trunk/docs/LangRef.html Message-ID: <201001151808.o0FI8cx2024316@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 12:08:37 2010 New Revision: 93518 URL: http://llvm.org/viewvc/llvm-project?rev=93518&view=rev Log: mention that unwind isn't to be trusted, patch by Dustin Laurence 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=93518&r1=93517&r2=93518&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Fri Jan 15 12:08:37 2010 @@ -2840,6 +2840,9 @@ block to the "normal" label. If the callee unwinds then no return value is available.

    +

    Note that the code generator does not yet completely support unwind, and +that the invoke/unwind semantics are likely to change in future versions.

    +
    Example:
       %retval = invoke i32 @Test(i32 15) to label %Continue
    @@ -2876,6 +2879,9 @@
        specified by the invoke instruction.  If there is no invoke
        instruction in the dynamic call chain, undefined behavior results.

    +

    Note that the code generator does not yet completely support unwind, and +that the invoke/unwind semantics are likely to change in future versions.

    + From vhernandez at apple.com Fri Jan 15 12:12:54 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 15 Jan 2010 10:12:54 -0800 Subject: [llvm-commits] [llvm] r93504 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/VMCore/Verifier.cpp test/Assembler/funct In-Reply-To: <352a1fb21001150945j44e1edf4y831100e68d5f08b9@mail.gmail.com> References: <352a1fb21001150945j44e1edf4y831100e68d5f08b9@mail.gmail.com> Message-ID: <7D7B977D-BD33-4532-8FAE-7E8E75B37186@apple.com> On Jan 15, 2010, at 9:45 AM, Devang Patel wrote: > On Fri, Jan 15, 2010 at 9:12 AM, Chris Lattner wrote: >> >> On Jan 14, 2010, at 7:37 PM, Victor Hernandez wrote: >> >>> Author: hernande >>> Date: Thu Jan 14 21:37:48 2010 >>> New Revision: 93504 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=93504&view=rev >>> Log: >>> Improve llvm.dbg.declare intrinsic by referring directly to the >>> storage in its first argument, via function-local metadata (instead >>> of via a bitcast). >>> This patch also cleans up code that expects there to be a bitcast in >>> the first argument and testcases that call llvm.dbg.declare. >> >> Hi Victor, >> >> This is a IR incompatibility, and this intrinsic existed in LLVM 2.6 >> and earlier. Please add "autoupgrade" support to the .ll and .bc >> readers. >> > > Chris, > > 2.6 uses GVs for debug info. The autoupgrade support already discards > dbg intrinsics that do not use use metadata. No, it only discards llvm.dbg.declare instrinsics whose second argument is not metadata. My patch affects the first argument. I'll be updating autoupgrade to fix the first argument of llvm.dbg.declare instrinsics, not just discard the intrinsic. > > - > Devang From vhdez at mac.com Fri Jan 15 12:16:55 2010 From: vhdez at mac.com (Victor Hernandez) Date: Fri, 15 Jan 2010 10:16:55 -0800 Subject: [llvm-commits] [llvm] r93504 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/VMCore/Verifier.cpp test/Assembler/funct In-Reply-To: <7D7B977D-BD33-4532-8FAE-7E8E75B37186@apple.com> References: <352a1fb21001150945j44e1edf4y831100e68d5f08b9@mail.gmail.com> <7D7B977D-BD33-4532-8FAE-7E8E75B37186@apple.com> Message-ID: <59911BA6-8838-4008-A067-A9964EAB426F@mac.com> On Jan 15, 2010, at 10:12 AM, Victor Hernandez wrote: > > On Jan 15, 2010, at 9:45 AM, Devang Patel wrote: > >> On Fri, Jan 15, 2010 at 9:12 AM, Chris Lattner wrote: >>> >>> On Jan 14, 2010, at 7:37 PM, Victor Hernandez wrote: >>> >>>> Author: hernande >>>> Date: Thu Jan 14 21:37:48 2010 >>>> New Revision: 93504 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=93504&view=rev >>>> Log: >>>> Improve llvm.dbg.declare intrinsic by referring directly to the >>>> storage in its first argument, via function-local metadata (instead >>>> of via a bitcast). >>>> This patch also cleans up code that expects there to be a bitcast in >>>> the first argument and testcases that call llvm.dbg.declare. >>> >>> Hi Victor, >>> >>> This is a IR incompatibility, and this intrinsic existed in LLVM 2.6 >>> and earlier. Please add "autoupgrade" support to the .ll and .bc >>> readers. >>> >> >> Chris, >> >> 2.6 uses GVs for debug info. The autoupgrade support already discards >> dbg intrinsics that do not use use metadata. > > No, it only discards llvm.dbg.declare instrinsics whose second argument is not metadata. My patch affects the first argument. I'll be updating autoupgrade to fix the first argument of llvm.dbg.declare instrinsics, not just discard the intrinsic. Strike that. I won't be able to fix the global variables, so I'll actually be discarding older llvm.dbg.declare instrinsics. > >> >> - >> Devang > From clattner at apple.com Fri Jan 15 12:18:11 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 10:18:11 -0800 Subject: [llvm-commits] [llvm] r93504 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/VMCore/Verifier.cpp test/Assembler/funct In-Reply-To: <7D7B977D-BD33-4532-8FAE-7E8E75B37186@apple.com> References: <352a1fb21001150945j44e1edf4y831100e68d5f08b9@mail.gmail.com> <7D7B977D-BD33-4532-8FAE-7E8E75B37186@apple.com> Message-ID: <9A0CEBD4-7EE1-41B5-AF94-F355DC78A774@apple.com> On Jan 15, 2010, at 10:12 AM, Victor Hernandez wrote: >>> >>> Hi Victor, >>> >>> This is a IR incompatibility, and this intrinsic existed in LLVM 2.6 >>> and earlier. Please add "autoupgrade" support to the .ll and .bc >>> readers. >>> >> >> Chris, >> >> 2.6 uses GVs for debug info. The autoupgrade support already discards >> dbg intrinsics that do not use use metadata. Just discarding them makes sense to me, but this isn't happening. -Chris From devang.patel at gmail.com Fri Jan 15 12:18:56 2010 From: devang.patel at gmail.com (Devang Patel) Date: Fri, 15 Jan 2010 10:18:56 -0800 Subject: [llvm-commits] [llvm] r93504 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/VMCore/Verifier.cpp test/Assembler/funct In-Reply-To: <59911BA6-8838-4008-A067-A9964EAB426F@mac.com> References: <352a1fb21001150945j44e1edf4y831100e68d5f08b9@mail.gmail.com> <7D7B977D-BD33-4532-8FAE-7E8E75B37186@apple.com> <59911BA6-8838-4008-A067-A9964EAB426F@mac.com> Message-ID: <352a1fb21001151018y788d2d9fp50fb502c760a77f6@mail.gmail.com> On Fri, Jan 15, 2010 at 10:16 AM, Victor Hernandez wrote: > > On Jan 15, 2010, at 10:12 AM, Victor Hernandez wrote: > >> >> On Jan 15, 2010, at 9:45 AM, Devang Patel wrote: >> >>> On Fri, Jan 15, 2010 at 9:12 AM, Chris Lattner wrote: >>>> >>>> On Jan 14, 2010, at 7:37 PM, Victor Hernandez wrote: >>>> >>>>> Author: hernande >>>>> Date: Thu Jan 14 21:37:48 2010 >>>>> New Revision: 93504 >>>>> >>>>> URL: http://llvm.org/viewvc/llvm-project?rev=93504&view=rev >>>>> Log: >>>>> Improve llvm.dbg.declare intrinsic by referring directly to the >>>>> storage in its first argument, via function-local metadata (instead >>>>> of via a bitcast). >>>>> This patch also cleans up code that expects there to be a bitcast in >>>>> the first argument and testcases that call llvm.dbg.declare. >>>> >>>> Hi Victor, >>>> >>>> This is a IR incompatibility, and this intrinsic existed in LLVM 2.6 >>>> and earlier. ?Please add "autoupgrade" support to the .ll and .bc >>>> readers. >>>> >>> >>> Chris, >>> >>> 2.6 uses GVs for debug info. The autoupgrade support already discards >>> dbg intrinsics that do not use use metadata. >> >> No, it only discards llvm.dbg.declare instrinsics whose second argument is not metadata. ?My patch affects the first argument. ?I'll be updating autoupgrade to fix the first argument of llvm.dbg.declare instrinsics, not just discard the intrinsic. > > Strike that. ?I won't be able to fix the global variables, so I'll actually be discarding older llvm.dbg.declare instrinsics. > >> >>> In 2.6, the second argument is not metadata so it is already discarding 2.6 llvm.dbg.declare intrinsics. - Devang From clattner at apple.com Fri Jan 15 12:20:01 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 10:20:01 -0800 Subject: [llvm-commits] [llvm] r93504 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/VMCore/Verifier.cpp test/Assembler/funct In-Reply-To: <352a1fb21001150951o6c53d8dbgf179f635388c2591@mail.gmail.com> References: <352a1fb21001150951o6c53d8dbgf179f635388c2591@mail.gmail.com> Message-ID: On Jan 15, 2010, at 9:51 AM, Devang Patel wrote: >> +++ llvm/trunk/include/llvm/IntrinsicInst.h Thu Jan 14 21:37:48 2010 >> @@ -25,6 +25,7 @@ >> #define LLVM_INTRINSICINST_H >> >> #include "llvm/Constants.h" >> +#include "llvm/Metadata.h" >> #include "llvm/Function.h" >> #include "llvm/Instructions.h" >> #include "llvm/Intrinsics.h" >> @@ -82,7 +83,12 @@ >> /// >> class DbgDeclareInst : public DbgInfoIntrinsic { >> public: >> - Value *getAddress() const { return getOperand(1); } >> + Value *getAddress() const { >> + if (MDNode* MD = dyn_cast(getOperand(1))) >> + return MD->getOperand(0); >> + else >> + return NULL; >> + } > > If getOperand(1) is either MDNode or NULL. Pl. add an assert to check > if it is anything else. Right, please use cast_or_null instead of dyn_cast. > > If you move this def. in .cpp then you can avoid including > Metadata.h here. Agreed, please do. -Chris From sabre at nondot.org Fri Jan 15 12:27:19 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 18:27:19 -0000 Subject: [llvm-commits] [llvm] r93521 - /llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Message-ID: <201001151827.o0FIRJhV025191@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 12:27:19 2010 New Revision: 93521 URL: http://llvm.org/viewvc/llvm-project?rev=93521&view=rev Log: refactor ParseRegister to avoid using X86Operand as a temporary datastructure when parsing a mem operand. Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=93521&r1=93520&r2=93521&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Fri Jan 15 12:27:19 2010 @@ -37,7 +37,7 @@ bool Error(SMLoc L, const Twine &Msg) { return Parser.Error(L, Msg); } - bool ParseRegister(X86Operand &Op); + bool ParseRegister(unsigned &RegNo); bool ParseOperand(X86Operand &Op); @@ -237,7 +237,8 @@ } // end anonymous namespace. -bool X86ATTAsmParser::ParseRegister(X86Operand &Op) { +bool X86ATTAsmParser::ParseRegister(unsigned &RegNo) { + RegNo = 0; const AsmToken &TokPercent = getLexer().getTok(); (void)TokPercent; // Avoid warning when assertions are disabled. assert(TokPercent.is(AsmToken::Percent) && "Invalid token kind!"); @@ -249,13 +250,10 @@ // FIXME: Validate register for the current architecture; we have to do // validation later, so maybe there is no need for this here. - unsigned RegNo; - RegNo = MatchRegisterName(Tok.getString()); if (RegNo == 0) return Error(Tok.getLoc(), "invalid register name"); - Op = X86Operand::CreateReg(RegNo); getLexer().Lex(); // Eat identifier token. return false; @@ -265,10 +263,14 @@ switch (getLexer().getKind()) { default: return ParseMemOperand(Op); - case AsmToken::Percent: + case AsmToken::Percent: { // FIXME: if a segment register, this could either be just the seg reg, or // the start of a memory operand. - return ParseRegister(Op); + unsigned RegNo; + if (ParseRegister(RegNo)) return true; + Op = X86Operand::CreateReg(RegNo); + return false; + } case AsmToken::Dollar: { // $42 -> immediate. getLexer().Lex(); @@ -340,11 +342,8 @@ // the rest of the memory operand. unsigned BaseReg = 0, IndexReg = 0, Scale = 1; - if (getLexer().is(AsmToken::Percent)) { - if (ParseRegister(Op)) - return true; - BaseReg = Op.getReg(); - } + if (getLexer().is(AsmToken::Percent)) + if (ParseRegister(BaseReg)) return true; if (getLexer().is(AsmToken::Comma)) { getLexer().Lex(); // Eat the comma. @@ -356,9 +355,7 @@ // Not that even though it would be completely consistent to support syntax // like "1(%eax,,1)", the assembler doesn't. if (getLexer().is(AsmToken::Percent)) { - if (ParseRegister(Op)) - return true; - IndexReg = Op.getReg(); + if (ParseRegister(IndexReg)) return true; if (getLexer().isNot(AsmToken::RParen)) { // Parse the scale amount: From sabre at nondot.org Fri Jan 15 12:44:13 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 18:44:13 -0000 Subject: [llvm-commits] [llvm] r93526 - /llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Message-ID: <201001151844.o0FIiEqD025915@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 12:44:13 2010 New Revision: 93526 URL: http://llvm.org/viewvc/llvm-project?rev=93526&view=rev Log: clean up the memory management of the operands. Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=93526&r1=93525&r2=93526&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Fri Jan 15 12:44:13 2010 @@ -39,9 +39,8 @@ bool ParseRegister(unsigned &RegNo); - bool ParseOperand(X86Operand &Op); - - bool ParseMemOperand(X86Operand &Op); + X86Operand *ParseOperand(); + X86Operand *ParseMemOperand(); bool ParseDirectiveWord(unsigned Size, SMLoc L); @@ -200,23 +199,23 @@ return Res; } - static X86Operand CreateReg(unsigned RegNo) { + static X86Operand *CreateReg(unsigned RegNo) { X86Operand Res; Res.Kind = Register; Res.Reg.RegNo = RegNo; - return Res; + return new X86Operand(Res); } - static X86Operand CreateImm(const MCExpr *Val) { + static X86Operand *CreateImm(const MCExpr *Val) { X86Operand Res; Res.Kind = Immediate; Res.Imm.Val = Val; - return Res; + return new X86Operand(Res); } - static X86Operand CreateMem(unsigned SegReg, const MCExpr *Disp, - unsigned BaseReg, unsigned IndexReg, - unsigned Scale) { + static X86Operand *CreateMem(unsigned SegReg, const MCExpr *Disp, + unsigned BaseReg, unsigned IndexReg, + unsigned Scale) { // We should never just have a displacement, that would be an immediate. assert((SegReg || BaseReg || IndexReg) && "Invalid memory operand!"); @@ -230,7 +229,7 @@ Res.Mem.BaseReg = BaseReg; Res.Mem.IndexReg = IndexReg; Res.Mem.Scale = Scale; - return Res; + return new X86Operand(Res); } }; @@ -259,32 +258,30 @@ return false; } -bool X86ATTAsmParser::ParseOperand(X86Operand &Op) { +X86Operand *X86ATTAsmParser::ParseOperand() { switch (getLexer().getKind()) { default: - return ParseMemOperand(Op); + return ParseMemOperand(); case AsmToken::Percent: { // FIXME: if a segment register, this could either be just the seg reg, or // the start of a memory operand. unsigned RegNo; - if (ParseRegister(RegNo)) return true; - Op = X86Operand::CreateReg(RegNo); - return false; + if (ParseRegister(RegNo)) return 0; + return X86Operand::CreateReg(RegNo); } case AsmToken::Dollar: { // $42 -> immediate. getLexer().Lex(); const MCExpr *Val; if (getParser().ParseExpression(Val)) - return true; - Op = X86Operand::CreateImm(Val); - return false; + return 0; + return X86Operand::CreateImm(Val); } } } /// ParseMemOperand: segment: disp(basereg, indexreg, scale) -bool X86ATTAsmParser::ParseMemOperand(X86Operand &Op) { +X86Operand *X86ATTAsmParser::ParseMemOperand() { // FIXME: If SegReg ':' (e.g. %gs:), eat and remember. unsigned SegReg = 0; @@ -294,17 +291,15 @@ // it. const MCExpr *Disp = MCConstantExpr::Create(0, getParser().getContext()); if (getLexer().isNot(AsmToken::LParen)) { - if (getParser().ParseExpression(Disp)) return true; + if (getParser().ParseExpression(Disp)) return 0; // After parsing the base expression we could either have a parenthesized // memory address or not. If not, return now. If so, eat the (. if (getLexer().isNot(AsmToken::LParen)) { // Unless we have a segment register, treat this as an immediate. - if (SegReg) - Op = X86Operand::CreateMem(SegReg, Disp, 0, 0, 1); - else - Op = X86Operand::CreateImm(Disp); - return false; + if (SegReg == 0) + return X86Operand::CreateImm(Disp); + return X86Operand::CreateMem(SegReg, Disp, 0, 0, 1); } // Eat the '('. @@ -320,17 +315,15 @@ } else { // It must be an parenthesized expression, parse it now. if (getParser().ParseParenExpression(Disp)) - return true; + return 0; // After parsing the base expression we could either have a parenthesized // memory address or not. If not, return now. If so, eat the (. if (getLexer().isNot(AsmToken::LParen)) { // Unless we have a segment register, treat this as an immediate. - if (SegReg) - Op = X86Operand::CreateMem(SegReg, Disp, 0, 0, 1); - else - Op = X86Operand::CreateImm(Disp); - return false; + if (SegReg == 0) + return X86Operand::CreateImm(Disp); + return X86Operand::CreateMem(SegReg, Disp, 0, 0, 1); } // Eat the '('. @@ -343,7 +336,7 @@ unsigned BaseReg = 0, IndexReg = 0, Scale = 1; if (getLexer().is(AsmToken::Percent)) - if (ParseRegister(BaseReg)) return true; + if (ParseRegister(BaseReg)) return 0; if (getLexer().is(AsmToken::Comma)) { getLexer().Lex(); // Eat the comma. @@ -355,13 +348,16 @@ // Not that even though it would be completely consistent to support syntax // like "1(%eax,,1)", the assembler doesn't. if (getLexer().is(AsmToken::Percent)) { - if (ParseRegister(IndexReg)) return true; + if (ParseRegister(IndexReg)) return 0; if (getLexer().isNot(AsmToken::RParen)) { // Parse the scale amount: // ::= ',' [scale-expression] - if (getLexer().isNot(AsmToken::Comma)) - return true; + if (getLexer().isNot(AsmToken::Comma)) { + Error(getLexer().getTok().getLoc(), + "expected comma in scale expression"); + return 0; + } getLexer().Lex(); // Eat the comma. if (getLexer().isNot(AsmToken::RParen)) { @@ -369,11 +365,13 @@ int64_t ScaleVal; if (getParser().ParseAbsoluteExpression(ScaleVal)) - return true; + return 0; // Validate the scale amount. - if (ScaleVal != 1 && ScaleVal != 2 && ScaleVal != 4 && ScaleVal != 8) - return Error(Loc, "scale factor in address must be 1, 2, 4 or 8"); + if (ScaleVal != 1 && ScaleVal != 2 && ScaleVal != 4 && ScaleVal != 8){ + Error(Loc, "scale factor in address must be 1, 2, 4 or 8"); + return 0; + } Scale = (unsigned)ScaleVal; } } @@ -384,20 +382,21 @@ int64_t Value; if (getParser().ParseAbsoluteExpression(Value)) - return true; + return 0; - return Error(Loc, "cannot have scale factor without index register"); + Error(Loc, "cannot have scale factor without index register"); + return 0; } } // Ok, we've eaten the memory operand, verify we have a ')' and eat it too. - if (getLexer().isNot(AsmToken::RParen)) - return Error(getLexer().getTok().getLoc(), - "unexpected token in memory operand"); + if (getLexer().isNot(AsmToken::RParen)) { + Error(getLexer().getTok().getLoc(), "unexpected token in memory operand"); + return 0; + } getLexer().Lex(); // Eat the ')'. - Op = X86Operand::CreateMem(SegReg, Disp, BaseReg, IndexReg, Scale); - return false; + return X86Operand::CreateMem(SegReg, Disp, BaseReg, IndexReg, Scale); } bool X86ATTAsmParser:: @@ -416,19 +415,19 @@ } // Read the first operand. - X86Operand Op; - if (ParseOperand(Op)) + if (X86Operand *Op = ParseOperand()) + Operands.push_back(Op); + else return true; - - Operands.push_back(new X86Operand(Op)); - + while (getLexer().is(AsmToken::Comma)) { getLexer().Lex(); // Eat the comma. // Parse and remember the operand. - if (ParseOperand(Op)) + if (X86Operand *Op = ParseOperand()) + Operands.push_back(Op); + else return true; - Operands.push_back(new X86Operand(Op)); } } From natebegeman at mac.com Fri Jan 15 12:51:19 2010 From: natebegeman at mac.com (Nate Begeman) Date: Fri, 15 Jan 2010 18:51:19 -0000 Subject: [llvm-commits] [llvm] r93527 - in /llvm/trunk: include/llvm/CodeGen/FileWriters.h include/llvm/Target/TargetMachine.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/MachO.h lib/CodeGen/MachOCodeEmitter.cpp lib/CodeGen/MachOCodeEmitter.h lib/CodeGen/MachOWriter.cpp lib/CodeGen/MachOWriter.h tools/llc/llc.cpp tools/lto/LTOCodeGenerator.cpp Message-ID: <201001151851.o0FIpKgd026122@zion.cs.uiuc.edu> Author: sampo Date: Fri Jan 15 12:51:18 2010 New Revision: 93527 URL: http://llvm.org/viewvc/llvm-project?rev=93527&view=rev Log: Hook up llc's -filetype=obj to use MCStreamer if an MCCodeEmitter is available. Remove most of old Mach-O Writer support, it has been replaced by MCMachOStreamer Further refactoring to completely remove MachOWriter and drive the object file writer with the AsmPrinter MCInst/MCSection logic is forthcoming. Removed: llvm/trunk/lib/CodeGen/MachO.h llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp llvm/trunk/lib/CodeGen/MachOCodeEmitter.h Modified: llvm/trunk/include/llvm/CodeGen/FileWriters.h llvm/trunk/include/llvm/Target/TargetMachine.h llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp llvm/trunk/lib/CodeGen/MachOWriter.cpp llvm/trunk/lib/CodeGen/MachOWriter.h llvm/trunk/tools/llc/llc.cpp llvm/trunk/tools/lto/LTOCodeGenerator.cpp Modified: llvm/trunk/include/llvm/CodeGen/FileWriters.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FileWriters.h?rev=93527&r1=93526&r2=93527&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/FileWriters.h (original) +++ llvm/trunk/include/llvm/CodeGen/FileWriters.h Fri Jan 15 12:51:18 2010 @@ -20,11 +20,17 @@ class ObjectCodeEmitter; class TargetMachine; class raw_ostream; + class formatted_raw_ostream; + class MachineFunctionPass; + class MCAsmInfo; + class MCCodeEmitter; ObjectCodeEmitter *AddELFWriter(PassManagerBase &FPM, raw_ostream &O, TargetMachine &TM); - ObjectCodeEmitter *AddMachOWriter(PassManagerBase &FPM, raw_ostream &O, - TargetMachine &TM); + MachineFunctionPass *createMachOWriter(formatted_raw_ostream &O, + TargetMachine &TM, + const MCAsmInfo *T, + MCCodeEmitter *MCE); } // end llvm namespace Modified: llvm/trunk/include/llvm/Target/TargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=93527&r1=93526&r2=93527&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetMachine.h (original) +++ llvm/trunk/include/llvm/Target/TargetMachine.h Fri Jan 15 12:51:18 2010 @@ -452,6 +452,14 @@ bool addAssemblyEmitter(PassManagerBase &, CodeGenOpt::Level, bool /* VerboseAsmDefault */, formatted_raw_ostream &); + + /// addObjectFileEmitter - Helper function which creates a target specific + /// object files emitter, if available. This interface is temporary, for + /// bringing up MCAssembler-based object file emitters. + /// + /// \return Returns 'false' on success. + bool addObjectFileEmitter(PassManagerBase &, CodeGenOpt::Level, + formatted_raw_ostream &); }; } // End llvm namespace Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=93527&r1=93526&r2=93527&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Fri Jan 15 12:51:18 2010 @@ -17,6 +17,7 @@ #include "llvm/Assembly/PrintModulePass.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/Passes.h" +#include "llvm/CodeGen/FileWriters.h" #include "llvm/CodeGen/GCStrategy.h" #include "llvm/CodeGen/MachineFunctionAnalysis.h" #include "llvm/Target/TargetOptions.h" @@ -115,12 +116,11 @@ return FileModel::Error; return FileModel::AsmFile; case TargetMachine::ObjectFile: - if (getMachOWriterInfo()) + if (!addObjectFileEmitter(PM, OptLevel, Out)) return FileModel::MachOFile; else if (getELFWriterInfo()) - return FileModel::ElfFile; + return FileModel::ElfFile; } - return FileModel::Error; } @@ -137,6 +137,17 @@ return false; } +bool LLVMTargetMachine::addObjectFileEmitter(PassManagerBase &PM, + CodeGenOpt::Level OptLevel, + formatted_raw_ostream &Out) { + MCCodeEmitter *Emitter = getTarget().createCodeEmitter(*this); + if (!Emitter) + return true; + + PM.add(createMachOWriter(Out, *this, getMCAsmInfo(), Emitter)); + return false; +} + /// addPassesToEmitFileFinish - If the passes to emit the specified file had to /// be split up (e.g., to add an object writer pass), this method can be used to /// finish up adding passes to emit the file, if necessary. Removed: llvm/trunk/lib/CodeGen/MachO.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachO.h?rev=93526&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/MachO.h (original) +++ llvm/trunk/lib/CodeGen/MachO.h (removed) @@ -1,412 +0,0 @@ -//=== MachO.h - Mach-O structures and constants -----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines MachO . -// -//===----------------------------------------------------------------------===// - -#ifndef MACHO_H -#define MACHO_H - -#include "llvm/CodeGen/BinaryObject.h" -#include -#include - -namespace llvm { - -class GlobalValue; -class MCAsmInfo; - -/// MachOSym - This struct contains information about each symbol that is -/// added to logical symbol table for the module. This is eventually -/// turned into a real symbol table in the file. -struct MachOSym { - const GlobalValue *GV; // The global value this corresponds to. - std::string GVName; // The mangled name of the global value. - uint32_t n_strx; // index into the string table - uint8_t n_type; // type flag - uint8_t n_sect; // section number or NO_SECT - int16_t n_desc; // see - uint64_t n_value; // value for this symbol (or stab offset) - - // Constants for the n_sect field - // see - enum { NO_SECT = 0 }; // symbol is not in any section - - // Constants for the n_type field - // see - enum { N_UNDF = 0x0, // undefined, n_sect == NO_SECT - N_ABS = 0x2, // absolute, n_sect == NO_SECT - N_SECT = 0xe, // defined in section number n_sect - N_PBUD = 0xc, // prebound undefined (defined in a dylib) - N_INDR = 0xa // indirect - }; - // The following bits are OR'd into the types above. For example, a type - // of 0x0f would be an external N_SECT symbol (0x0e | 0x01). - enum { N_EXT = 0x01, // external symbol bit - N_PEXT = 0x10 // private external symbol bit - }; - - // Constants for the n_desc field - // see - enum { REFERENCE_FLAG_UNDEFINED_NON_LAZY = 0, - REFERENCE_FLAG_UNDEFINED_LAZY = 1, - REFERENCE_FLAG_DEFINED = 2, - REFERENCE_FLAG_PRIVATE_DEFINED = 3, - REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY = 4, - REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY = 5 - }; - enum { N_NO_DEAD_STRIP = 0x0020, // symbol is not to be dead stripped - N_WEAK_REF = 0x0040, // symbol is weak referenced - N_WEAK_DEF = 0x0080 // coalesced symbol is a weak definition - }; - - MachOSym(const GlobalValue *gv, std::string name, uint8_t sect, - const MCAsmInfo *MAI); - - struct SymCmp { - // FIXME: this does not appear to be sorting 'f' after 'F' - bool operator()(const MachOSym &LHS, const MachOSym &RHS) { - return LHS.GVName < RHS.GVName; - } - }; - - - /// PartitionByLocal - Simple boolean predicate that returns true if Sym is - /// a local symbol rather than an external symbol. - - static inline bool PartitionByLocal(const MachOSym &Sym) { - return (Sym.n_type & (MachOSym::N_EXT | MachOSym::N_PEXT)) == 0; - } - - /// PartitionByDefined - Simple boolean predicate that returns true if Sym is - /// defined in this module. - - static inline bool PartitionByDefined(const MachOSym &Sym) { - // FIXME: Do N_ABS or N_INDR count as defined? - return (Sym.n_type & MachOSym::N_SECT) == MachOSym::N_SECT; - } - -}; // end struct MachOSym - -/// MachOHeader - This struct contains the header information about a -/// specific architecture type/subtype pair that is emitted to the file. - -struct MachOHeader { - uint32_t magic; // mach magic number identifier - uint32_t filetype; // type of file - uint32_t ncmds; // number of load commands - uint32_t sizeofcmds; // the size of all the load commands - uint32_t flags; // flags - uint32_t reserved; // 64-bit only - - /// HeaderData - The actual data for the header which we are building - /// up for emission to the file. - std::vector HeaderData; - - // Constants for the filetype field - // see for additional info on the various types - enum { MH_OBJECT = 1, // relocatable object file - MH_EXECUTE = 2, // demand paged executable file - MH_FVMLIB = 3, // fixed VM shared library file - MH_CORE = 4, // core file - MH_PRELOAD = 5, // preloaded executable file - MH_DYLIB = 6, // dynamically bound shared library - MH_DYLINKER = 7, // dynamic link editor - MH_BUNDLE = 8, // dynamically bound bundle file - MH_DYLIB_STUB = 9, // shared library stub for static linking only - MH_DSYM = 10 // companion file wiht only debug sections - }; - - // Constants for the flags field - enum { MH_NOUNDEFS = 1 << 0, - // the object file has no undefined references - MH_INCRLINK = 1 << 1, - // the object file is the output of an incremental link against - // a base file and cannot be link edited again - MH_DYLDLINK = 1 << 2, - // the object file is input for the dynamic linker and cannot be - // statically link edited again. - MH_BINDATLOAD = 1 << 3, - // the object file's undefined references are bound by the - // dynamic linker when loaded. - MH_PREBOUND = 1 << 4, - // the file has its dynamic undefined references prebound - MH_SPLIT_SEGS = 1 << 5, - // the file has its read-only and read-write segments split - // see - MH_LAZY_INIT = 1 << 6, - // the shared library init routine is to be run lazily via - // catching memory faults to its writable segments (obsolete) - MH_TWOLEVEL = 1 << 7, - // the image is using two-level namespace bindings - MH_FORCE_FLAT = 1 << 8, - // the executable is forcing all images to use flat namespace - // bindings. - MH_NOMULTIDEFS = 1 << 8, - // this umbrella guarantees no multiple definitions of symbols - // in its sub-images so the two-level namespace hints can - // always be used. - MH_NOFIXPREBINDING = 1 << 10, - // do not have dyld notify the prebidning agent about this - // executable. - MH_PREBINDABLE = 1 << 11, - // the binary is not prebound but can have its prebinding - // redone. only used when MH_PREBOUND is not set. - MH_ALLMODSBOUND = 1 << 12, - // indicates that this binary binds to all two-level namespace - // modules of its dependent libraries. Only used when - // MH_PREBINDABLE and MH_TWOLEVEL are both set. - MH_SUBSECTIONS_VIA_SYMBOLS = 1 << 13, - // safe to divide up the sections into sub-sections via symbols - // for dead code stripping. - MH_CANONICAL = 1 << 14, - // the binary has been canonicalized via the unprebind operation - MH_WEAK_DEFINES = 1 << 15, - // the final linked image contains external weak symbols - MH_BINDS_TO_WEAK = 1 << 16, - // the final linked image uses weak symbols - MH_ALLOW_STACK_EXECUTION = 1 << 17 - // When this bit is set, all stacks in the task will be given - // stack execution privilege. Only used in MH_EXECUTE filetype - }; - - MachOHeader() : magic(0), filetype(0), ncmds(0), sizeofcmds(0), flags(0), - reserved(0) {} - - /// cmdSize - This routine returns the size of the MachOSection as written - /// to disk, depending on whether the destination is a 64 bit Mach-O file. - unsigned cmdSize(bool is64Bit) const { - if (is64Bit) - return 8 * sizeof(uint32_t); - else - return 7 * sizeof(uint32_t); - } - - /// setMagic - This routine sets the appropriate value for the 'magic' - /// field based on pointer size and endianness. - void setMagic(bool isLittleEndian, bool is64Bit) { - if (isLittleEndian) - if (is64Bit) magic = 0xcffaedfe; - else magic = 0xcefaedfe; - else - if (is64Bit) magic = 0xfeedfacf; - else magic = 0xfeedface; - } - -}; // end struct MachOHeader - -/// MachOSegment - This struct contains the necessary information to -/// emit the load commands for each section in the file. -struct MachOSegment { - uint32_t cmd; // LC_SEGMENT or LC_SEGMENT_64 - uint32_t cmdsize; // Total size of this struct and section commands - std::string segname; // segment name - uint64_t vmaddr; // address of this segment - uint64_t vmsize; // size of this segment, may be larger than filesize - uint64_t fileoff; // offset in file - uint64_t filesize; // amount to read from file - uint32_t maxprot; // maximum VM protection - uint32_t initprot; // initial VM protection - uint32_t nsects; // number of sections in this segment - uint32_t flags; // flags - - // The following constants are getting pulled in by one of the - // system headers, which creates a neat clash with the enum. -#if !defined(VM_PROT_NONE) -#define VM_PROT_NONE 0x00 -#endif -#if !defined(VM_PROT_READ) -#define VM_PROT_READ 0x01 -#endif -#if !defined(VM_PROT_WRITE) -#define VM_PROT_WRITE 0x02 -#endif -#if !defined(VM_PROT_EXECUTE) -#define VM_PROT_EXECUTE 0x04 -#endif -#if !defined(VM_PROT_ALL) -#define VM_PROT_ALL 0x07 -#endif - - // Constants for the vm protection fields - // see - enum { SEG_VM_PROT_NONE = VM_PROT_NONE, - SEG_VM_PROT_READ = VM_PROT_READ, // read permission - SEG_VM_PROT_WRITE = VM_PROT_WRITE, // write permission - SEG_VM_PROT_EXECUTE = VM_PROT_EXECUTE, - SEG_VM_PROT_ALL = VM_PROT_ALL - }; - - // Constants for the cmd field - // see - enum { LC_SEGMENT = 0x01, // segment of this file to be mapped - LC_SEGMENT_64 = 0x19 // 64-bit segment of this file to be mapped - }; - - /// cmdSize - This routine returns the size of the MachOSection as written - /// to disk, depending on whether the destination is a 64 bit Mach-O file. - unsigned cmdSize(bool is64Bit) const { - if (is64Bit) - return 6 * sizeof(uint32_t) + 4 * sizeof(uint64_t) + 16; - else - return 10 * sizeof(uint32_t) + 16; // addresses only 32 bits - } - - MachOSegment(const std::string &seg, bool is64Bit) - : cmd(is64Bit ? LC_SEGMENT_64 : LC_SEGMENT), cmdsize(0), segname(seg), - vmaddr(0), vmsize(0), fileoff(0), filesize(0), maxprot(VM_PROT_ALL), - initprot(VM_PROT_ALL), nsects(0), flags(0) { } -}; - -/// MachOSection - This struct contains information about each section in a -/// particular segment that is emitted to the file. This is eventually -/// turned into the SectionCommand in the load command for a particlar -/// segment. - -struct MachOSection : public BinaryObject { - std::string sectname; // name of this section, - std::string segname; // segment this section goes in - uint64_t addr; // memory address of this section - uint32_t offset; // file offset of this section - uint32_t align; // section alignment (power of 2) - uint32_t reloff; // file offset of relocation entries - uint32_t nreloc; // number of relocation entries - uint32_t flags; // flags (section type and attributes) - uint32_t reserved1; // reserved (for offset or index) - uint32_t reserved2; // reserved (for count or sizeof) - uint32_t reserved3; // reserved (64 bit only) - - /// A unique number for this section, which will be used to match symbols - /// to the correct section. - uint32_t Index; - - /// RelocBuffer - A buffer to hold the mach-o relocations before we write - /// them out at the appropriate location in the file. - std::vector RelocBuffer; - - // Constants for the section types (low 8 bits of flags field) - // see - enum { S_REGULAR = 0, - // regular section - S_ZEROFILL = 1, - // zero fill on demand section - S_CSTRING_LITERALS = 2, - // section with only literal C strings - S_4BYTE_LITERALS = 3, - // section with only 4 byte literals - S_8BYTE_LITERALS = 4, - // section with only 8 byte literals - S_LITERAL_POINTERS = 5, - // section with only pointers to literals - S_NON_LAZY_SYMBOL_POINTERS = 6, - // section with only non-lazy symbol pointers - S_LAZY_SYMBOL_POINTERS = 7, - // section with only lazy symbol pointers - S_SYMBOL_STUBS = 8, - // section with only symbol stubs - // byte size of stub in the reserved2 field - S_MOD_INIT_FUNC_POINTERS = 9, - // section with only function pointers for initialization - S_MOD_TERM_FUNC_POINTERS = 10, - // section with only function pointers for termination - S_COALESCED = 11, - // section contains symbols that are coalesced - S_GB_ZEROFILL = 12, - // zero fill on demand section (that can be larger than 4GB) - S_INTERPOSING = 13, - // section with only pairs of function pointers for interposing - S_16BYTE_LITERALS = 14 - // section with only 16 byte literals - }; - - // Constants for the section flags (high 24 bits of flags field) - // see - enum { S_ATTR_PURE_INSTRUCTIONS = 1 << 31, - // section contains only true machine instructions - S_ATTR_NO_TOC = 1 << 30, - // section contains coalesced symbols that are not to be in a - // ranlib table of contents - S_ATTR_STRIP_STATIC_SYMS = 1 << 29, - // ok to strip static symbols in this section in files with the - // MY_DYLDLINK flag - S_ATTR_NO_DEAD_STRIP = 1 << 28, - // no dead stripping - S_ATTR_LIVE_SUPPORT = 1 << 27, - // blocks are live if they reference live blocks - S_ATTR_SELF_MODIFYING_CODE = 1 << 26, - // used with i386 code stubs written on by dyld - S_ATTR_DEBUG = 1 << 25, - // a debug section - S_ATTR_SOME_INSTRUCTIONS = 1 << 10, - // section contains some machine instructions - S_ATTR_EXT_RELOC = 1 << 9, - // section has external relocation entries - S_ATTR_LOC_RELOC = 1 << 8 - // section has local relocation entries - }; - - /// cmdSize - This routine returns the size of the MachOSection as written - /// to disk, depending on whether the destination is a 64 bit Mach-O file. - unsigned cmdSize(bool is64Bit) const { - if (is64Bit) - return 7 * sizeof(uint32_t) + 2 * sizeof(uint64_t) + 32; - else - return 9 * sizeof(uint32_t) + 32; // addresses only 32 bits - } - - MachOSection(const std::string &seg, const std::string §) - : BinaryObject(), sectname(sect), segname(seg), addr(0), offset(0), - align(2), reloff(0), nreloc(0), flags(0), reserved1(0), reserved2(0), - reserved3(0) { } - -}; // end struct MachOSection - -/// MachOSymTab - This struct contains information about the offsets and -/// size of symbol table information. -/// segment. -struct MachODySymTab { - uint32_t cmd; // LC_DYSYMTAB - uint32_t cmdsize; // sizeof(MachODySymTab) - uint32_t ilocalsym; // index to local symbols - uint32_t nlocalsym; // number of local symbols - uint32_t iextdefsym; // index to externally defined symbols - uint32_t nextdefsym; // number of externally defined symbols - uint32_t iundefsym; // index to undefined symbols - uint32_t nundefsym; // number of undefined symbols - uint32_t tocoff; // file offset to table of contents - uint32_t ntoc; // number of entries in table of contents - uint32_t modtaboff; // file offset to module table - uint32_t nmodtab; // number of module table entries - uint32_t extrefsymoff; // offset to referenced symbol table - uint32_t nextrefsyms; // number of referenced symbol table entries - uint32_t indirectsymoff; // file offset to the indirect symbol table - uint32_t nindirectsyms; // number of indirect symbol table entries - uint32_t extreloff; // offset to external relocation entries - uint32_t nextrel; // number of external relocation entries - uint32_t locreloff; // offset to local relocation entries - uint32_t nlocrel; // number of local relocation entries - - // Constants for the cmd field - // see - enum { LC_DYSYMTAB = 0x0B // dynamic link-edit symbol table info - }; - - MachODySymTab() : cmd(LC_DYSYMTAB), cmdsize(20 * sizeof(uint32_t)), - ilocalsym(0), nlocalsym(0), iextdefsym(0), nextdefsym(0), - iundefsym(0), nundefsym(0), tocoff(0), ntoc(0), modtaboff(0), - nmodtab(0), extrefsymoff(0), nextrefsyms(0), indirectsymoff(0), - nindirectsyms(0), extreloff(0), nextrel(0), locreloff(0), nlocrel(0) {} - -}; // end struct MachODySymTab - -} // end namespace llvm - -#endif - Removed: llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp?rev=93526&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp (original) +++ llvm/trunk/lib/CodeGen/MachOCodeEmitter.cpp (removed) @@ -1,193 +0,0 @@ -//===-- MachOEmitter.cpp - Target-independent Mach-O Emitter code --------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "MachO.h" -#include "MachOWriter.h" -#include "MachOCodeEmitter.h" -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" -#include "llvm/Function.h" -#include "llvm/CodeGen/MachineConstantPool.h" -#include "llvm/CodeGen/MachineFunction.h" -#include "llvm/CodeGen/MachineJumpTableInfo.h" -#include "llvm/CodeGen/MachineRelocation.h" -#include "llvm/MC/MCAsmInfo.h" -#include "llvm/Target/TargetData.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/Mangler.h" -#include "llvm/Support/OutputBuffer.h" -#include - -//===----------------------------------------------------------------------===// -// MachOCodeEmitter Implementation -//===----------------------------------------------------------------------===// - -namespace llvm { - -MachOCodeEmitter::MachOCodeEmitter(MachOWriter &mow, MachOSection &mos) : - ObjectCodeEmitter(&mos), MOW(mow), TM(MOW.TM) { - is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64; - isLittleEndian = TM.getTargetData()->isLittleEndian(); - MAI = TM.getMCAsmInfo(); -} - -/// startFunction - This callback is invoked when a new machine function is -/// about to be emitted. - -void MachOCodeEmitter::startFunction(MachineFunction &MF) { - const TargetData *TD = TM.getTargetData(); - const Function *F = MF.getFunction(); - - // Align the output buffer to the appropriate alignment, power of 2. - unsigned FnAlign = F->getAlignment(); - unsigned TDAlign = TD->getPrefTypeAlignment(F->getType()); - unsigned Align = Log2_32(std::max(FnAlign, TDAlign)); - assert(!(Align & (Align-1)) && "Alignment is not a power of two!"); - - // Get the Mach-O Section that this function belongs in. - MachOSection *MOS = MOW.getTextSection(); - - // Upgrade the section alignment if required. - if (MOS->align < Align) MOS->align = Align; - - MOS->emitAlignment(Align); - - // Create symbol for function entry - const GlobalValue *FuncV = MF.getFunction(); - MachOSym FnSym(FuncV, MOW.Mang->getMangledName(FuncV), MOS->Index, MAI); - FnSym.n_value = getCurrentPCOffset(); - - // add it to the symtab. - MOW.SymbolTable.push_back(FnSym); -} - -/// finishFunction - This callback is invoked after the function is completely -/// finished. - -bool MachOCodeEmitter::finishFunction(MachineFunction &MF) { - - // Get the Mach-O Section that this function belongs in. - MachOSection *MOS = MOW.getTextSection(); - - // Emit constant pool to appropriate section(s) - emitConstantPool(MF.getConstantPool()); - - // Emit jump tables to appropriate section - emitJumpTables(MF.getJumpTableInfo()); - - // If we have emitted any relocations to function-specific objects such as - // basic blocks, constant pools entries, or jump tables, record their - // addresses now so that we can rewrite them with the correct addresses - // later. - for (unsigned i = 0, e = Relocations.size(); i != e; ++i) { - MachineRelocation &MR = Relocations[i]; - intptr_t Addr; - - if (MR.isBasicBlock()) { - Addr = getMachineBasicBlockAddress(MR.getBasicBlock()); - MR.setConstantVal(MOS->Index); - MR.setResultPointer((void*)Addr); - } else if (MR.isJumpTableIndex()) { - Addr = getJumpTableEntryAddress(MR.getJumpTableIndex()); - MR.setConstantVal(MOW.getJumpTableSection()->Index); - MR.setResultPointer((void*)Addr); - } else if (MR.isConstantPoolIndex()) { - Addr = getConstantPoolEntryAddress(MR.getConstantPoolIndex()); - MR.setConstantVal(CPSections[MR.getConstantPoolIndex()]); - MR.setResultPointer((void*)Addr); - } else if (MR.isGlobalValue()) { - // FIXME: This should be a set or something that uniques - MOW.PendingGlobals.push_back(MR.getGlobalValue()); - } else { - llvm_unreachable("Unhandled relocation type"); - } - MOS->addRelocation(MR); - } - Relocations.clear(); - - // Clear per-function data structures. - CPLocations.clear(); - CPSections.clear(); - JTLocations.clear(); - MBBLocations.clear(); - - return false; -} - -/// emitConstantPool - For each constant pool entry, figure out which section -/// the constant should live in, allocate space for it, and emit it to the -/// Section data buffer. -void MachOCodeEmitter::emitConstantPool(MachineConstantPool *MCP) { - const std::vector &CP = MCP->getConstants(); - if (CP.empty()) return; - - // FIXME: handle PIC codegen - assert(TM.getRelocationModel() != Reloc::PIC_ && - "PIC codegen not yet handled for mach-o jump tables!"); - - // Although there is no strict necessity that I am aware of, we will do what - // gcc for OS X does and put each constant pool entry in a section of constant - // objects of a certain size. That means that float constants go in the - // literal4 section, and double objects go in literal8, etc. - // - // FIXME: revisit this decision if we ever do the "stick everything into one - // "giant object for PIC" optimization. - for (unsigned i = 0, e = CP.size(); i != e; ++i) { - const Type *Ty = CP[i].getType(); - unsigned Size = TM.getTargetData()->getTypeAllocSize(Ty); - - MachOSection *Sec = MOW.getConstSection(CP[i].Val.ConstVal); - OutputBuffer SecDataOut(Sec->getData(), is64Bit, isLittleEndian); - - CPLocations.push_back(Sec->size()); - CPSections.push_back(Sec->Index); - - // Allocate space in the section for the global. - // FIXME: need alignment? - // FIXME: share between here and AddSymbolToSection? - for (unsigned j = 0; j < Size; ++j) - SecDataOut.outbyte(0); - - MachOWriter::InitMem(CP[i].Val.ConstVal, CPLocations[i], - TM.getTargetData(), Sec); - } -} - -/// emitJumpTables - Emit all the jump tables for a given jump table info -/// record to the appropriate section. -void MachOCodeEmitter::emitJumpTables(MachineJumpTableInfo *MJTI) { - const std::vector &JT = MJTI->getJumpTables(); - if (JT.empty()) return; - - // FIXME: handle PIC codegen - assert(TM.getRelocationModel() != Reloc::PIC_ && - "PIC codegen not yet handled for mach-o jump tables!"); - - MachOSection *Sec = MOW.getJumpTableSection(); - unsigned TextSecIndex = MOW.getTextSection()->Index; - OutputBuffer SecDataOut(Sec->getData(), is64Bit, isLittleEndian); - - for (unsigned i = 0, e = JT.size(); i != e; ++i) { - // For each jump table, record its offset from the start of the section, - // reserve space for the relocations to the MBBs, and add the relocations. - const std::vector &MBBs = JT[i].MBBs; - JTLocations.push_back(Sec->size()); - for (unsigned mi = 0, me = MBBs.size(); mi != me; ++mi) { - MachineRelocation MR(MOW.GetJTRelocation(Sec->size(), MBBs[mi])); - MR.setResultPointer((void *)JTLocations[i]); - MR.setConstantVal(TextSecIndex); - Sec->addRelocation(MR); - SecDataOut.outaddr(0); - } - } -} - -} // end namespace llvm - Removed: llvm/trunk/lib/CodeGen/MachOCodeEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOCodeEmitter.h?rev=93526&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/MachOCodeEmitter.h (original) +++ llvm/trunk/lib/CodeGen/MachOCodeEmitter.h (removed) @@ -1,69 +0,0 @@ -//===-- MachOEmitter.h - Target-independent Mach-O Emitter class ----------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef MACHOCODEEMITTER_H -#define MACHOCODEEMITTER_H - -#include "llvm/CodeGen/ObjectCodeEmitter.h" -#include - -namespace llvm { - -class MachOWriter; - -/// MachOCodeEmitter - This class is used by the MachOWriter to emit the code -/// for functions to the Mach-O file. - -class MachOCodeEmitter : public ObjectCodeEmitter { - MachOWriter &MOW; - - /// Target machine description. - TargetMachine &TM; - - /// is64Bit/isLittleEndian - This information is inferred from the target - /// machine directly, indicating what header values and flags to set. - bool is64Bit, isLittleEndian; - - const MCAsmInfo *MAI; - - /// Relocations - These are the relocations that the function needs, as - /// emitted. - std::vector Relocations; - - std::map Labels; - -public: - MachOCodeEmitter(MachOWriter &mow, MachOSection &mos); - - virtual void startFunction(MachineFunction &MF); - virtual bool finishFunction(MachineFunction &MF); - - virtual void addRelocation(const MachineRelocation &MR) { - Relocations.push_back(MR); - } - - void emitConstantPool(MachineConstantPool *MCP); - void emitJumpTables(MachineJumpTableInfo *MJTI); - - virtual void emitLabel(uint64_t LabelID) { - Labels[LabelID] = getCurrentPCOffset(); - } - - virtual uintptr_t getLabelAddress(uint64_t Label) const { - return Labels.find(Label)->second; - } - - virtual void setModuleInfo(llvm::MachineModuleInfo* MMI) { } - -}; // end class MachOCodeEmitter - -} // end namespace llvm - -#endif - Modified: llvm/trunk/lib/CodeGen/MachOWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.cpp?rev=93527&r1=93526&r2=93527&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachOWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/MachOWriter.cpp Fri Jan 15 12:51:18 2010 @@ -22,33 +22,31 @@ // //===----------------------------------------------------------------------===// -#include "MachO.h" #include "MachOWriter.h" -#include "MachOCodeEmitter.h" -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" -#include "llvm/Module.h" -#include "llvm/PassManager.h" +#include "llvm/Function.h" +#include "llvm/CodeGen/FileWriters.h" +#include "llvm/CodeGen/MachineFunction.h" #include "llvm/MC/MCAsmInfo.h" -#include "llvm/Target/TargetData.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetMachOWriterInfo.h" -#include "llvm/Support/Debug.h" -#include "llvm/Support/Mangler.h" -#include "llvm/Support/OutputBuffer.h" +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCCodeEmitter.h" +#include "llvm/MC/MCInst.h" +#include "llvm/MC/MCStreamer.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/FormattedStream.h" +#include "llvm/Support/Mangler.h" #include "llvm/Support/raw_ostream.h" - -namespace llvm { - -/// AddMachOWriter - Concrete function to add the Mach-O writer to the function -/// pass manager. -ObjectCodeEmitter *AddMachOWriter(PassManagerBase &PM, - raw_ostream &O, - TargetMachine &TM) { - MachOWriter *MOW = new MachOWriter(O, TM); - PM.add(MOW); - return MOW->getObjectCodeEmitter(); +#include "llvm/Target/TargetData.h" +#include "llvm/Target/TargetLowering.h" +#include "llvm/Target/TargetLoweringObjectFile.h" +using namespace llvm; + +namespace llvm { +MachineFunctionPass *createMachOWriter(formatted_raw_ostream &O, + TargetMachine &TM, + const MCAsmInfo *T, + MCCodeEmitter *MCE) { + return new MachOWriter(O, TM, T, MCE); +} } //===----------------------------------------------------------------------===// @@ -57,722 +55,83 @@ char MachOWriter::ID = 0; -MachOWriter::MachOWriter(raw_ostream &o, TargetMachine &tm) - : MachineFunctionPass(&ID), O(o), TM(tm) { - is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64; - isLittleEndian = TM.getTargetData()->isLittleEndian(); - - MAI = TM.getMCAsmInfo(); - - // Create the machine code emitter object for this target. - MachOCE = new MachOCodeEmitter(*this, *getTextSection(true)); +MachOWriter::MachOWriter(formatted_raw_ostream &o, TargetMachine &tm, + const MCAsmInfo *T, MCCodeEmitter *MCE) + : MachineFunctionPass(&ID), O(o), TM(tm), MAI(T), MCCE(MCE), + OutContext(*new MCContext()), + OutStreamer(*createMachOStreamer(OutContext, O, MCCE)) { } MachOWriter::~MachOWriter() { - delete MachOCE; + delete &OutStreamer; + delete &OutContext; + delete MCCE; } bool MachOWriter::doInitialization(Module &M) { - // Set the magic value, now that we know the pointer size and endianness - Header.setMagic(isLittleEndian, is64Bit); - - // Set the file type - // FIXME: this only works for object files, we do not support the creation - // of dynamic libraries or executables at this time. - Header.filetype = MachOHeader::MH_OBJECT; - - Mang = new Mangler(M); - return false; -} + Mang = new Mangler(M, MAI->getGlobalPrefix(), MAI->getPrivateGlobalPrefix(), + MAI->getLinkerPrivateGlobalPrefix()); + + if (MAI->doesAllowQuotesInName()) + Mang->setUseQuotes(true); + + if (MAI->doesAllowNameToStartWithDigit()) + Mang->setSymbolsCanStartWithDigit(true); + + // Initialize TargetLoweringObjectFile. + TM.getTargetLowering()->getObjFileLowering().Initialize(OutContext, TM); -bool MachOWriter::runOnMachineFunction(MachineFunction &MF) { return false; } /// doFinalization - Now that the module has been completely processed, emit /// the Mach-O file to 'O'. bool MachOWriter::doFinalization(Module &M) { - // FIXME: we don't handle debug info yet, we should probably do that. - // Okay, the.text section has been completed, build the .data, .bss, and - // "common" sections next. - - for (Module::global_iterator I = M.global_begin(), E = M.global_end(); - I != E; ++I) - EmitGlobal(I); - - // Emit the header and load commands. - EmitHeaderAndLoadCommands(); - - // Emit the various sections and their relocation info. - EmitSections(); - EmitRelocations(); - - // Write the symbol table and the string table to the end of the file. - O.write((char*)&SymT[0], SymT.size()); - O.write((char*)&StrT[0], StrT.size()); - - // We are done with the abstract symbols. - SectionList.clear(); - SymbolTable.clear(); - DynamicSymbolTable.clear(); - // Release the name mangler object. delete Mang; Mang = 0; - return false; -} - -// getConstSection - Get constant section for Constant 'C' -MachOSection *MachOWriter::getConstSection(Constant *C) { - const ConstantArray *CVA = dyn_cast(C); - if (CVA && CVA->isCString()) - return getSection("__TEXT", "__cstring", - MachOSection::S_CSTRING_LITERALS); - - const Type *Ty = C->getType(); - if (Ty->isPrimitiveType() || Ty->isInteger()) { - unsigned Size = TM.getTargetData()->getTypeAllocSize(Ty); - switch(Size) { - default: break; // Fall through to __TEXT,__const - case 4: - return getSection("__TEXT", "__literal4", - MachOSection::S_4BYTE_LITERALS); - case 8: - return getSection("__TEXT", "__literal8", - MachOSection::S_8BYTE_LITERALS); - case 16: - return getSection("__TEXT", "__literal16", - MachOSection::S_16BYTE_LITERALS); - } - } - return getSection("__TEXT", "__const"); -} - -// getJumpTableSection - Select the Jump Table section -MachOSection *MachOWriter::getJumpTableSection() { - if (TM.getRelocationModel() == Reloc::PIC_) - return getTextSection(false); - else - return getSection("__TEXT", "__const"); -} - -// getSection - Return the section with the specified name, creating a new -// section if one does not already exist. -MachOSection *MachOWriter::getSection(const std::string &seg, - const std::string §, - unsigned Flags /* = 0 */ ) { - MachOSection *MOS = SectionLookup[seg+sect]; - if (MOS) return MOS; - - MOS = new MachOSection(seg, sect); - SectionList.push_back(MOS); - MOS->Index = SectionList.size(); - MOS->flags = MachOSection::S_REGULAR | Flags; - SectionLookup[seg+sect] = MOS; - return MOS; -} - -// getTextSection - Return text section with different flags for code/data -MachOSection *MachOWriter::getTextSection(bool isCode /* = true */ ) { - if (isCode) - return getSection("__TEXT", "__text", - MachOSection::S_ATTR_PURE_INSTRUCTIONS | - MachOSection::S_ATTR_SOME_INSTRUCTIONS); - else - return getSection("__TEXT", "__text"); -} - -MachOSection *MachOWriter::getBSSSection() { - return getSection("__DATA", "__bss", MachOSection::S_ZEROFILL); -} - -// GetJTRelocation - Get a relocation a new BB relocation based -// on target information. -MachineRelocation MachOWriter::GetJTRelocation(unsigned Offset, - MachineBasicBlock *MBB) const { - return TM.getMachOWriterInfo()->GetJTRelocation(Offset, MBB); -} - -// GetTargetRelocation - Returns the number of relocations. -unsigned MachOWriter::GetTargetRelocation(MachineRelocation &MR, - unsigned FromIdx, unsigned ToAddr, - unsigned ToIndex, OutputBuffer &RelocOut, - OutputBuffer &SecOut, bool Scattered, - bool Extern) { - return TM.getMachOWriterInfo()->GetTargetRelocation(MR, FromIdx, ToAddr, - ToIndex, RelocOut, - SecOut, Scattered, - Extern); -} - -void MachOWriter::AddSymbolToSection(MachOSection *Sec, GlobalVariable *GV) { - const Type *Ty = GV->getType()->getElementType(); - unsigned Size = TM.getTargetData()->getTypeAllocSize(Ty); - unsigned Align = TM.getTargetData()->getPreferredAlignment(GV); - - // Reserve space in the .bss section for this symbol while maintaining the - // desired section alignment, which must be at least as much as required by - // this symbol. - OutputBuffer SecDataOut(Sec->getData(), is64Bit, isLittleEndian); - - if (Align) { - Align = Log2_32(Align); - Sec->align = std::max(unsigned(Sec->align), Align); - - Sec->emitAlignment(Sec->align); - } - // Globals without external linkage apparently do not go in the symbol table. - if (!GV->hasLocalLinkage()) { - MachOSym Sym(GV, Mang->getMangledName(GV), Sec->Index, MAI); - Sym.n_value = Sec->size(); - SymbolTable.push_back(Sym); - } - - // Record the offset of the symbol, and then allocate space for it. - // FIXME: remove when we have unified size + output buffer - - // Now that we know what section the GlovalVariable is going to be emitted - // into, update our mappings. - // FIXME: We may also need to update this when outputting non-GlobalVariable - // GlobalValues such as functions. - - GVSection[GV] = Sec; - GVOffset[GV] = Sec->size(); - - // Allocate space in the section for the global. - for (unsigned i = 0; i < Size; ++i) - SecDataOut.outbyte(0); -} - -void MachOWriter::EmitGlobal(GlobalVariable *GV) { - const Type *Ty = GV->getType()->getElementType(); - unsigned Size = TM.getTargetData()->getTypeAllocSize(Ty); - bool NoInit = !GV->hasInitializer(); - - // If this global has a zero initializer, it is part of the .bss or common - // section. - if (NoInit || GV->getInitializer()->isNullValue()) { - // If this global is part of the common block, add it now. Variables are - // part of the common block if they are zero initialized and allowed to be - // merged with other symbols. - if (NoInit || GV->hasLinkOnceLinkage() || GV->hasWeakLinkage() || - GV->hasCommonLinkage()) { - MachOSym ExtOrCommonSym(GV, Mang->getMangledName(GV), - MachOSym::NO_SECT, MAI); - // For undefined (N_UNDF) external (N_EXT) types, n_value is the size in - // bytes of the symbol. - ExtOrCommonSym.n_value = Size; - SymbolTable.push_back(ExtOrCommonSym); - // Remember that we've seen this symbol - GVOffset[GV] = Size; - return; - } - // Otherwise, this symbol is part of the .bss section. - MachOSection *BSS = getBSSSection(); - AddSymbolToSection(BSS, GV); - return; - } - - // Scalar read-only data goes in a literal section if the scalar is 4, 8, or - // 16 bytes, or a cstring. Other read only data goes into a regular const - // section. Read-write data goes in the data section. - MachOSection *Sec = GV->isConstant() ? getConstSection(GV->getInitializer()) : - getDataSection(); - AddSymbolToSection(Sec, GV); - InitMem(GV->getInitializer(), GVOffset[GV], TM.getTargetData(), Sec); -} - - -void MachOWriter::EmitHeaderAndLoadCommands() { - // Step #0: Fill in the segment load command size, since we need it to figure - // out the rest of the header fields - - MachOSegment SEG("", is64Bit); - SEG.nsects = SectionList.size(); - SEG.cmdsize = SEG.cmdSize(is64Bit) + - SEG.nsects * SectionList[0]->cmdSize(is64Bit); - - // Step #1: calculate the number of load commands. We always have at least - // one, for the LC_SEGMENT load command, plus two for the normal - // and dynamic symbol tables, if there are any symbols. - Header.ncmds = SymbolTable.empty() ? 1 : 3; - - // Step #2: calculate the size of the load commands - Header.sizeofcmds = SEG.cmdsize; - if (!SymbolTable.empty()) - Header.sizeofcmds += SymTab.cmdsize + DySymTab.cmdsize; - - // Step #3: write the header to the file - // Local alias to shortenify coming code. - std::vector &FH = Header.HeaderData; - OutputBuffer FHOut(FH, is64Bit, isLittleEndian); - - FHOut.outword(Header.magic); - FHOut.outword(TM.getMachOWriterInfo()->getCPUType()); - FHOut.outword(TM.getMachOWriterInfo()->getCPUSubType()); - FHOut.outword(Header.filetype); - FHOut.outword(Header.ncmds); - FHOut.outword(Header.sizeofcmds); - FHOut.outword(Header.flags); - if (is64Bit) - FHOut.outword(Header.reserved); - - // Step #4: Finish filling in the segment load command and write it out - for (std::vector::iterator I = SectionList.begin(), - E = SectionList.end(); I != E; ++I) - SEG.filesize += (*I)->size(); - - SEG.vmsize = SEG.filesize; - SEG.fileoff = Header.cmdSize(is64Bit) + Header.sizeofcmds; - - FHOut.outword(SEG.cmd); - FHOut.outword(SEG.cmdsize); - FHOut.outstring(SEG.segname, 16); - FHOut.outaddr(SEG.vmaddr); - FHOut.outaddr(SEG.vmsize); - FHOut.outaddr(SEG.fileoff); - FHOut.outaddr(SEG.filesize); - FHOut.outword(SEG.maxprot); - FHOut.outword(SEG.initprot); - FHOut.outword(SEG.nsects); - FHOut.outword(SEG.flags); - - // Step #5: Finish filling in the fields of the MachOSections - uint64_t currentAddr = 0; - for (std::vector::iterator I = SectionList.begin(), - E = SectionList.end(); I != E; ++I) { - MachOSection *MOS = *I; - MOS->addr = currentAddr; - MOS->offset = currentAddr + SEG.fileoff; - // FIXME: do we need to do something with alignment here? - currentAddr += MOS->size(); - } - - // Step #6: Emit the symbol table to temporary buffers, so that we know the - // size of the string table when we write the next load command. This also - // sorts and assigns indices to each of the symbols, which is necessary for - // emitting relocations to externally-defined objects. - BufferSymbolAndStringTable(); - - // Step #7: Calculate the number of relocations for each section and write out - // the section commands for each section - currentAddr += SEG.fileoff; - for (std::vector::iterator I = SectionList.begin(), - E = SectionList.end(); I != E; ++I) { - MachOSection *MOS = *I; - - // Convert the relocations to target-specific relocations, and fill in the - // relocation offset for this section. - CalculateRelocations(*MOS); - MOS->reloff = MOS->nreloc ? currentAddr : 0; - currentAddr += MOS->nreloc * 8; - - // write the finalized section command to the output buffer - FHOut.outstring(MOS->sectname, 16); - FHOut.outstring(MOS->segname, 16); - FHOut.outaddr(MOS->addr); - FHOut.outaddr(MOS->size()); - FHOut.outword(MOS->offset); - FHOut.outword(MOS->align); - FHOut.outword(MOS->reloff); - FHOut.outword(MOS->nreloc); - FHOut.outword(MOS->flags); - FHOut.outword(MOS->reserved1); - FHOut.outword(MOS->reserved2); - if (is64Bit) - FHOut.outword(MOS->reserved3); - } - - // Step #8: Emit LC_SYMTAB/LC_DYSYMTAB load commands - SymTab.symoff = currentAddr; - SymTab.nsyms = SymbolTable.size(); - SymTab.stroff = SymTab.symoff + SymT.size(); - SymTab.strsize = StrT.size(); - FHOut.outword(SymTab.cmd); - FHOut.outword(SymTab.cmdsize); - FHOut.outword(SymTab.symoff); - FHOut.outword(SymTab.nsyms); - FHOut.outword(SymTab.stroff); - FHOut.outword(SymTab.strsize); - - // FIXME: set DySymTab fields appropriately - // We should probably just update these in BufferSymbolAndStringTable since - // thats where we're partitioning up the different kinds of symbols. - FHOut.outword(DySymTab.cmd); - FHOut.outword(DySymTab.cmdsize); - FHOut.outword(DySymTab.ilocalsym); - FHOut.outword(DySymTab.nlocalsym); - FHOut.outword(DySymTab.iextdefsym); - FHOut.outword(DySymTab.nextdefsym); - FHOut.outword(DySymTab.iundefsym); - FHOut.outword(DySymTab.nundefsym); - FHOut.outword(DySymTab.tocoff); - FHOut.outword(DySymTab.ntoc); - FHOut.outword(DySymTab.modtaboff); - FHOut.outword(DySymTab.nmodtab); - FHOut.outword(DySymTab.extrefsymoff); - FHOut.outword(DySymTab.nextrefsyms); - FHOut.outword(DySymTab.indirectsymoff); - FHOut.outword(DySymTab.nindirectsyms); - FHOut.outword(DySymTab.extreloff); - FHOut.outword(DySymTab.nextrel); - FHOut.outword(DySymTab.locreloff); - FHOut.outword(DySymTab.nlocrel); - - O.write((char*)&FH[0], FH.size()); -} - -/// EmitSections - Now that we have constructed the file header and load -/// commands, emit the data for each section to the file. -void MachOWriter::EmitSections() { - for (std::vector::iterator I = SectionList.begin(), - E = SectionList.end(); I != E; ++I) - // Emit the contents of each section - if ((*I)->size()) - O.write((char*)&(*I)->getData()[0], (*I)->size()); -} - -/// EmitRelocations - emit relocation data from buffer. -void MachOWriter::EmitRelocations() { - for (std::vector::iterator I = SectionList.begin(), - E = SectionList.end(); I != E; ++I) - // Emit the relocation entry data for each section. - if ((*I)->RelocBuffer.size()) - O.write((char*)&(*I)->RelocBuffer[0], (*I)->RelocBuffer.size()); -} - -/// BufferSymbolAndStringTable - Sort the symbols we encountered and assign them -/// each a string table index so that they appear in the correct order in the -/// output file. -void MachOWriter::BufferSymbolAndStringTable() { - // The order of the symbol table is: - // 1. local symbols - // 2. defined external symbols (sorted by name) - // 3. undefined external symbols (sorted by name) - - // Before sorting the symbols, check the PendingGlobals for any undefined - // globals that need to be put in the symbol table. - for (std::vector::iterator I = PendingGlobals.begin(), - E = PendingGlobals.end(); I != E; ++I) { - if (GVOffset[*I] == 0 && GVSection[*I] == 0) { - MachOSym UndfSym(*I, Mang->getMangledName(*I), MachOSym::NO_SECT, MAI); - SymbolTable.push_back(UndfSym); - GVOffset[*I] = -1; - } - } - - // Sort the symbols by name, so that when we partition the symbols by scope - // of definition, we won't have to sort by name within each partition. - std::sort(SymbolTable.begin(), SymbolTable.end(), MachOSym::SymCmp()); - - // Parition the symbol table entries so that all local symbols come before - // all symbols with external linkage. { 1 | 2 3 } - std::partition(SymbolTable.begin(), SymbolTable.end(), - MachOSym::PartitionByLocal); - - // Advance iterator to beginning of external symbols and partition so that - // all external symbols defined in this module come before all external - // symbols defined elsewhere. { 1 | 2 | 3 } - for (std::vector::iterator I = SymbolTable.begin(), - E = SymbolTable.end(); I != E; ++I) { - if (!MachOSym::PartitionByLocal(*I)) { - std::partition(I, E, MachOSym::PartitionByDefined); - break; - } - } - - // Calculate the starting index for each of the local, extern defined, and - // undefined symbols, as well as the number of each to put in the LC_DYSYMTAB - // load command. - for (std::vector::iterator I = SymbolTable.begin(), - E = SymbolTable.end(); I != E; ++I) { - if (MachOSym::PartitionByLocal(*I)) { - ++DySymTab.nlocalsym; - ++DySymTab.iextdefsym; - ++DySymTab.iundefsym; - } else if (MachOSym::PartitionByDefined(*I)) { - ++DySymTab.nextdefsym; - ++DySymTab.iundefsym; - } else { - ++DySymTab.nundefsym; - } - } - - // Write out a leading zero byte when emitting string table, for n_strx == 0 - // which means an empty string. - OutputBuffer StrTOut(StrT, is64Bit, isLittleEndian); - StrTOut.outbyte(0); - - // The order of the string table is: - // 1. strings for external symbols - // 2. strings for local symbols - // Since this is the opposite order from the symbol table, which we have just - // sorted, we can walk the symbol table backwards to output the string table. - for (std::vector::reverse_iterator I = SymbolTable.rbegin(), - E = SymbolTable.rend(); I != E; ++I) { - if (I->GVName == "") { - I->n_strx = 0; - } else { - I->n_strx = StrT.size(); - StrTOut.outstring(I->GVName, I->GVName.length()+1); - } - } - - OutputBuffer SymTOut(SymT, is64Bit, isLittleEndian); - - unsigned index = 0; - for (std::vector::iterator I = SymbolTable.begin(), - E = SymbolTable.end(); I != E; ++I, ++index) { - // Add the section base address to the section offset in the n_value field - // to calculate the full address. - // FIXME: handle symbols where the n_value field is not the address - GlobalValue *GV = const_cast(I->GV); - if (GV && GVSection[GV]) - I->n_value += GVSection[GV]->addr; - if (GV && (GVOffset[GV] == -1)) - GVOffset[GV] = index; - - // Emit nlist to buffer - SymTOut.outword(I->n_strx); - SymTOut.outbyte(I->n_type); - SymTOut.outbyte(I->n_sect); - SymTOut.outhalf(I->n_desc); - SymTOut.outaddr(I->n_value); - } -} - -/// CalculateRelocations - For each MachineRelocation in the current section, -/// calculate the index of the section containing the object to be relocated, -/// and the offset into that section. From this information, create the -/// appropriate target-specific MachORelocation type and add buffer it to be -/// written out after we are finished writing out sections. -void MachOWriter::CalculateRelocations(MachOSection &MOS) { - std::vector Relocations = MOS.getRelocations(); - for (unsigned i = 0, e = Relocations.size(); i != e; ++i) { - MachineRelocation &MR = Relocations[i]; - unsigned TargetSection = MR.getConstantVal(); - unsigned TargetAddr = 0; - unsigned TargetIndex = 0; - - // This is a scattered relocation entry if it points to a global value with - // a non-zero offset. - bool Scattered = false; - bool Extern = false; - - // Since we may not have seen the GlobalValue we were interested in yet at - // the time we emitted the relocation for it, fix it up now so that it - // points to the offset into the correct section. - if (MR.isGlobalValue()) { - GlobalValue *GV = MR.getGlobalValue(); - MachOSection *MOSPtr = GVSection[GV]; - intptr_t Offset = GVOffset[GV]; - - // If we have never seen the global before, it must be to a symbol - // defined in another module (N_UNDF). - if (!MOSPtr) { - // FIXME: need to append stub suffix - Extern = true; - TargetAddr = 0; - TargetIndex = GVOffset[GV]; - } else { - Scattered = TargetSection != 0; - TargetSection = MOSPtr->Index; - } - MR.setResultPointer((void*)Offset); - } - - // If the symbol is locally defined, pass in the address of the section and - // the section index to the code which will generate the target relocation. - if (!Extern) { - MachOSection &To = *SectionList[TargetSection - 1]; - TargetAddr = To.addr; - TargetIndex = To.Index; - } - - OutputBuffer RelocOut(MOS.RelocBuffer, is64Bit, isLittleEndian); - OutputBuffer SecOut(MOS.getData(), is64Bit, isLittleEndian); - - MOS.nreloc += GetTargetRelocation(MR, MOS.Index, TargetAddr, TargetIndex, - RelocOut, SecOut, Scattered, Extern); - } + OutStreamer.Finish(); + return false; } -// InitMem - Write the value of a Constant to the specified memory location, -// converting it into bytes and relocations. -void MachOWriter::InitMem(const Constant *C, uintptr_t Offset, - const TargetData *TD, MachOSection* mos) { - typedef std::pair CPair; - std::vector WorkList; - uint8_t *Addr = &mos->getData()[0]; - - WorkList.push_back(CPair(C,(intptr_t)Addr + Offset)); - - intptr_t ScatteredOffset = 0; - - while (!WorkList.empty()) { - const Constant *PC = WorkList.back().first; - intptr_t PA = WorkList.back().second; - WorkList.pop_back(); - - if (isa(PC)) { - continue; - } else if (const ConstantVector *CP = dyn_cast(PC)) { - unsigned ElementSize = - TD->getTypeAllocSize(CP->getType()->getElementType()); - for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i) - WorkList.push_back(CPair(CP->getOperand(i), PA+i*ElementSize)); - } else if (const ConstantExpr *CE = dyn_cast(PC)) { - // - // FIXME: Handle ConstantExpression. See EE::getConstantValue() - // - switch (CE->getOpcode()) { - case Instruction::GetElementPtr: { - SmallVector Indices(CE->op_begin()+1, CE->op_end()); - ScatteredOffset = TD->getIndexedOffset(CE->getOperand(0)->getType(), - &Indices[0], Indices.size()); - WorkList.push_back(CPair(CE->getOperand(0), PA)); - break; - } - case Instruction::Add: - default: - dbgs() << "ConstantExpr not handled as global var init: " << *CE <<"\n"; - llvm_unreachable(0); - } - } else if (PC->getType()->isSingleValueType()) { - unsigned char *ptr = (unsigned char *)PA; - switch (PC->getType()->getTypeID()) { - case Type::IntegerTyID: { - unsigned NumBits = cast(PC->getType())->getBitWidth(); - uint64_t val = cast(PC)->getZExtValue(); - if (NumBits <= 8) - ptr[0] = val; - else if (NumBits <= 16) { - if (TD->isBigEndian()) - val = ByteSwap_16(val); - ptr[0] = val; - ptr[1] = val >> 8; - } else if (NumBits <= 32) { - if (TD->isBigEndian()) - val = ByteSwap_32(val); - ptr[0] = val; - ptr[1] = val >> 8; - ptr[2] = val >> 16; - ptr[3] = val >> 24; - } else if (NumBits <= 64) { - if (TD->isBigEndian()) - val = ByteSwap_64(val); - ptr[0] = val; - ptr[1] = val >> 8; - ptr[2] = val >> 16; - ptr[3] = val >> 24; - ptr[4] = val >> 32; - ptr[5] = val >> 40; - ptr[6] = val >> 48; - ptr[7] = val >> 56; - } else { - llvm_unreachable("Not implemented: bit widths > 64"); +bool MachOWriter::runOnMachineFunction(MachineFunction &MF) { + const Function *F = MF.getFunction(); + TargetLoweringObjectFile &TLOF = TM.getTargetLowering()->getObjFileLowering(); + const MCSection *S = TLOF.SectionForGlobal(F, Mang, TM); + OutStreamer.SwitchSection(S); + + for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); + I != E; ++I) { + // Print a label for the basic block. + for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end(); + II != IE; ++II) { + const MachineInstr *MI = II; + MCInst OutMI; + OutMI.setOpcode(MI->getOpcode()); + + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = MI->getOperand(i); + MCOperand MCOp; + + switch (MO.getType()) { + default: + MI->dump(); + llvm_unreachable("unknown operand type"); + case MachineOperand::MO_Register: + // Ignore all implicit register operands. + if (MO.isImplicit()) continue; + MCOp = MCOperand::CreateReg(MO.getReg()); + break; + case MachineOperand::MO_Immediate: + MCOp = MCOperand::CreateImm(MO.getImm()); + break; } - break; - } - case Type::FloatTyID: { - uint32_t val = cast(PC)->getValueAPF().bitcastToAPInt(). - getZExtValue(); - if (TD->isBigEndian()) - val = ByteSwap_32(val); - ptr[0] = val; - ptr[1] = val >> 8; - ptr[2] = val >> 16; - ptr[3] = val >> 24; - break; - } - case Type::DoubleTyID: { - uint64_t val = cast(PC)->getValueAPF().bitcastToAPInt(). - getZExtValue(); - if (TD->isBigEndian()) - val = ByteSwap_64(val); - ptr[0] = val; - ptr[1] = val >> 8; - ptr[2] = val >> 16; - ptr[3] = val >> 24; - ptr[4] = val >> 32; - ptr[5] = val >> 40; - ptr[6] = val >> 48; - ptr[7] = val >> 56; - break; + OutMI.addOperand(MCOp); } - case Type::PointerTyID: - if (isa(PC)) - memset(ptr, 0, TD->getPointerSize()); - else if (const GlobalValue* GV = dyn_cast(PC)) { - // FIXME: what about function stubs? - mos->addRelocation(MachineRelocation::getGV(PA-(intptr_t)Addr, - MachineRelocation::VANILLA, - const_cast(GV), - ScatteredOffset)); - ScatteredOffset = 0; - } else - llvm_unreachable("Unknown constant pointer type!"); - break; - default: - std::string msg; - raw_string_ostream Msg(msg); - Msg << "ERROR: Constant unimp for type: " << *PC->getType(); - llvm_report_error(Msg.str()); - } - } else if (isa(PC)) { - memset((void*)PA, 0, (size_t)TD->getTypeAllocSize(PC->getType())); - } else if (const ConstantArray *CPA = dyn_cast(PC)) { - unsigned ElementSize = - TD->getTypeAllocSize(CPA->getType()->getElementType()); - for (unsigned i = 0, e = CPA->getNumOperands(); i != e; ++i) - WorkList.push_back(CPair(CPA->getOperand(i), PA+i*ElementSize)); - } else if (const ConstantStruct *CPS = dyn_cast(PC)) { - const StructLayout *SL = - TD->getStructLayout(cast(CPS->getType())); - for (unsigned i = 0, e = CPS->getNumOperands(); i != e; ++i) - WorkList.push_back(CPair(CPS->getOperand(i), - PA+SL->getElementOffset(i))); - } else { - dbgs() << "Bad Type: " << *PC->getType() << "\n"; - llvm_unreachable("Unknown constant type to initialize memory with!"); + + OutStreamer.EmitInstruction(OutMI); } } -} -//===----------------------------------------------------------------------===// -// MachOSym Implementation -//===----------------------------------------------------------------------===// - -MachOSym::MachOSym(const GlobalValue *gv, std::string name, uint8_t sect, - const MCAsmInfo *MAI) : - GV(gv), n_strx(0), n_type(sect == NO_SECT ? N_UNDF : N_SECT), n_sect(sect), - n_desc(0), n_value(0) { - - // FIXME: This is completely broken, it should use the mangler interface. - switch (GV->getLinkage()) { - default: - llvm_unreachable("Unexpected linkage type!"); - break; - case GlobalValue::WeakAnyLinkage: - case GlobalValue::WeakODRLinkage: - case GlobalValue::LinkOnceAnyLinkage: - case GlobalValue::LinkOnceODRLinkage: - case GlobalValue::CommonLinkage: - assert(!isa(gv) && "Unexpected linkage type for Function!"); - case GlobalValue::ExternalLinkage: - GVName = MAI->getGlobalPrefix() + name; - n_type |= GV->hasHiddenVisibility() ? N_PEXT : N_EXT; - break; - case GlobalValue::PrivateLinkage: - GVName = MAI->getPrivateGlobalPrefix() + name; - break; - case GlobalValue::LinkerPrivateLinkage: - GVName = MAI->getLinkerPrivateGlobalPrefix() + name; - break; - case GlobalValue::InternalLinkage: - GVName = MAI->getGlobalPrefix() + name; - break; - } + return false; } - -} // end namespace llvm Modified: llvm/trunk/lib/CodeGen/MachOWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.h?rev=93527&r1=93526&r2=93527&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachOWriter.h (original) +++ llvm/trunk/lib/CodeGen/MachOWriter.h Fri Jan 15 12:51:18 2010 @@ -15,191 +15,73 @@ #define MACHOWRITER_H #include "llvm/CodeGen/MachineFunctionPass.h" -#include -#include +#include "llvm/Target/TargetMachine.h" namespace llvm { - class Constant; class GlobalVariable; class Mangler; - class MachineBasicBlock; - class MachineRelocation; - class MachOCodeEmitter; - struct MachODySymTab; - struct MachOHeader; - struct MachOSection; - struct MachOSym; - class TargetData; - class TargetMachine; - class MCAsmInfo; - class ObjectCodeEmitter; - class OutputBuffer; - class raw_ostream; - + class MCCodeEmitter; + class MCContext; + class MCStreamer; + /// MachOWriter - This class implements the common target-independent code for /// writing Mach-O files. Targets should derive a class from this to /// parameterize the output format. /// class MachOWriter : public MachineFunctionPass { - friend class MachOCodeEmitter; - public: static char ID; - ObjectCodeEmitter *getObjectCodeEmitter() { - return reinterpret_cast(MachOCE); - } - - MachOWriter(raw_ostream &O, TargetMachine &TM); - virtual ~MachOWriter(); - - virtual const char *getPassName() const { - return "Mach-O Writer"; - } - protected: /// Output stream to send the resultant object file to. /// - raw_ostream &O; + formatted_raw_ostream &O; /// Target machine description. /// TargetMachine &TM; - /// Mang - The object used to perform name mangling for this module. + /// Target Asm Printer information. /// - Mangler *Mang; - - /// MachOCE - The MachineCodeEmitter object that we are exposing to emit - /// machine code for functions to the .o file. - MachOCodeEmitter *MachOCE; - - /// is64Bit/isLittleEndian - This information is inferred from the target - /// machine directly, indicating what header values and flags to set. - bool is64Bit, isLittleEndian; - - // Target Asm Info const MCAsmInfo *MAI; - - /// Header - An instance of MachOHeader that we will update while we build - /// the file, and then emit during finalization. - MachOHeader Header; - + + /// MCCE - The MCCodeEmitter object that we are exposing to emit machine + /// code for functions to the .o file. + MCCodeEmitter *MCCE; + + /// OutContext - This is the context for the output file that we are + /// streaming. This owns all of the global MC-related objects for the + /// generated translation unit. + MCContext &OutContext; + + /// OutStreamer - This is the MCStreamer object for the file we are + /// generating. This contains the transient state for the current + /// translation unit that we are generating (such as the current section + /// etc). + MCStreamer &OutStreamer; + + /// Name-mangler for global names. + /// + Mangler *Mang; + /// doInitialization - Emit the file header and all of the global variables /// for the module to the Mach-O file. bool doInitialization(Module &M); - bool runOnMachineFunction(MachineFunction &MF); - /// doFinalization - Now that the module has been completely processed, emit /// the Mach-O file to 'O'. bool doFinalization(Module &M); - private: - - /// SectionList - This is the list of sections that we have emitted to the - /// file. Once the file has been completely built, the segment load command - /// SectionCommands are constructed from this info. - std::vector SectionList; - - /// SectionLookup - This is a mapping from section name to SectionList entry - std::map SectionLookup; - - /// GVSection - This is a mapping from a GlobalValue to a MachOSection, - /// to aid in emitting relocations. - std::map GVSection; - - /// GVOffset - This is a mapping from a GlobalValue to an offset from the - /// start of the section in which the GV resides, to aid in emitting - /// relocations. - std::map GVOffset; - - /// getSection - Return the section with the specified name, creating a new - /// section if one does not already exist. - MachOSection *getSection(const std::string &seg, const std::string §, - unsigned Flags = 0); - - /// getTextSection - Return text section with different flags for code/data - MachOSection *getTextSection(bool isCode = true); - - MachOSection *getDataSection() { - return getSection("__DATA", "__data"); + bool runOnMachineFunction(MachineFunction &MF); + + public: + explicit MachOWriter(formatted_raw_ostream &O, TargetMachine &TM, + const MCAsmInfo *T, MCCodeEmitter *MCE); + + virtual ~MachOWriter(); + + virtual const char *getPassName() const { + return "Mach-O Writer"; } - - MachOSection *getBSSSection(); - MachOSection *getConstSection(Constant *C); - MachOSection *getJumpTableSection(); - - /// MachOSymTab - This struct contains information about the offsets and - /// size of symbol table information. - /// segment. - struct MachOSymTab { - uint32_t cmd; // LC_SYMTAB - uint32_t cmdsize; // sizeof( MachOSymTab ) - uint32_t symoff; // symbol table offset - uint32_t nsyms; // number of symbol table entries - uint32_t stroff; // string table offset - uint32_t strsize; // string table size in bytes - - // Constants for the cmd field - // see - enum { LC_SYMTAB = 0x02 // link-edit stab symbol table info - }; - - MachOSymTab() : cmd(LC_SYMTAB), cmdsize(6 * sizeof(uint32_t)), symoff(0), - nsyms(0), stroff(0), strsize(0) { } - }; - - /// SymTab - The "stab" style symbol table information - MachOSymTab SymTab; - /// DySymTab - symbol table info for the dynamic link editor - MachODySymTab DySymTab; - - protected: - - /// SymbolTable - This is the list of symbols we have emitted to the file. - /// This actually gets rearranged before emission to the file (to put the - /// local symbols first in the list). - std::vector SymbolTable; - - /// SymT - A buffer to hold the symbol table before we write it out at the - /// appropriate location in the file. - std::vector SymT; - - /// StrT - A buffer to hold the string table before we write it out at the - /// appropriate location in the file. - std::vector StrT; - - /// PendingSyms - This is a list of externally defined symbols that we have - /// been asked to emit, but have not seen a reference to. When a reference - /// is seen, the symbol will move from this list to the SymbolTable. - std::vector PendingGlobals; - - /// DynamicSymbolTable - This is just a vector of indices into - /// SymbolTable to aid in emitting the DYSYMTAB load command. - std::vector DynamicSymbolTable; - - static void InitMem(const Constant *C, uintptr_t Offset, - const TargetData *TD, MachOSection* mos); - - private: - void AddSymbolToSection(MachOSection *MOS, GlobalVariable *GV); - void EmitGlobal(GlobalVariable *GV); - void EmitHeaderAndLoadCommands(); - void EmitSections(); - void EmitRelocations(); - void BufferSymbolAndStringTable(); - void CalculateRelocations(MachOSection &MOS); - - // GetJTRelocation - Get a relocation a new BB relocation based - // on target information. - MachineRelocation GetJTRelocation(unsigned Offset, - MachineBasicBlock *MBB) const; - - /// GetTargetRelocation - Returns the number of relocations. - unsigned GetTargetRelocation(MachineRelocation &MR, unsigned FromIdx, - unsigned ToAddr, unsigned ToIndex, - OutputBuffer &RelocOut, OutputBuffer &SecOut, - bool Scattered, bool Extern); }; } Modified: llvm/trunk/tools/llc/llc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=93527&r1=93526&r2=93527&view=diff ============================================================================== --- llvm/trunk/tools/llc/llc.cpp (original) +++ llvm/trunk/tools/llc/llc.cpp Fri Jan 15 12:51:18 2010 @@ -366,9 +366,7 @@ sys::Path(OutputFilename).eraseFromDisk(); return 1; case FileModel::AsmFile: - break; case FileModel::MachOFile: - OCE = AddMachOWriter(Passes, *Out, Target); break; case FileModel::ElfFile: OCE = AddELFWriter(Passes, *Out, Target); Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=93527&r1=93526&r2=93527&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Fri Jan 15 12:51:18 2010 @@ -403,14 +403,12 @@ switch (_target->addPassesToEmitFile(*codeGenPasses, out, TargetMachine::AssemblyFile, CodeGenOpt::Aggressive)) { - case FileModel::MachOFile: - oce = AddMachOWriter(*codeGenPasses, out, *_target); - break; case FileModel::ElfFile: oce = AddELFWriter(*codeGenPasses, out, *_target); break; case FileModel::AsmFile: break; + case FileModel::MachOFile: case FileModel::Error: case FileModel::None: errMsg = "target file type not supported"; From sabre at nondot.org Fri Jan 15 12:51:29 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 18:51:29 -0000 Subject: [llvm-commits] [llvm] r93528 - /llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Message-ID: <201001151851.o0FIpT9C026141@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 12:51:29 2010 New Revision: 93528 URL: http://llvm.org/viewvc/llvm-project?rev=93528&view=rev Log: add range location info for registers, change X86Operand::Create* implementations to avoid copy ctor use. Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=93528&r1=93527&r2=93528&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Fri Jan 15 12:51:29 2010 @@ -37,7 +37,7 @@ bool Error(SMLoc L, const Twine &Msg) { return Parser.Error(L, Msg); } - bool ParseRegister(unsigned &RegNo); + bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc); X86Operand *ParseOperand(); X86Operand *ParseMemOperand(); @@ -81,6 +81,8 @@ Memory } Kind; + SMLoc StartLoc, EndLoc; + union { struct { const char *Data; @@ -191,26 +193,28 @@ Inst.addOperand(MCOperand::CreateReg(getMemSegReg())); } - static X86Operand CreateToken(StringRef Str) { - X86Operand Res; - Res.Kind = Token; - Res.Tok.Data = Str.data(); - Res.Tok.Length = Str.size(); + static X86Operand *CreateToken(StringRef Str) { + X86Operand *Res = new X86Operand(); + Res->Kind = Token; + Res->Tok.Data = Str.data(); + Res->Tok.Length = Str.size(); return Res; } - static X86Operand *CreateReg(unsigned RegNo) { - X86Operand Res; - Res.Kind = Register; - Res.Reg.RegNo = RegNo; - return new X86Operand(Res); + static X86Operand *CreateReg(unsigned RegNo, SMLoc StartLoc, SMLoc EndLoc) { + X86Operand *Res = new X86Operand(); + Res->Kind = Register; + Res->Reg.RegNo = RegNo; + Res->StartLoc = StartLoc; + Res->EndLoc = EndLoc; + return Res; } static X86Operand *CreateImm(const MCExpr *Val) { - X86Operand Res; - Res.Kind = Immediate; - Res.Imm.Val = Val; - return new X86Operand(Res); + X86Operand *Res = new X86Operand(); + Res->Kind = Immediate; + Res->Imm.Val = Val; + return Res; } static X86Operand *CreateMem(unsigned SegReg, const MCExpr *Disp, @@ -222,25 +226,26 @@ // The scale should always be one of {1,2,4,8}. assert(((Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8)) && "Invalid scale!"); - X86Operand Res; - Res.Kind = Memory; - Res.Mem.SegReg = SegReg; - Res.Mem.Disp = Disp; - Res.Mem.BaseReg = BaseReg; - Res.Mem.IndexReg = IndexReg; - Res.Mem.Scale = Scale; - return new X86Operand(Res); + X86Operand *Res = new X86Operand(); + Res->Kind = Memory; + Res->Mem.SegReg = SegReg; + Res->Mem.Disp = Disp; + Res->Mem.BaseReg = BaseReg; + Res->Mem.IndexReg = IndexReg; + Res->Mem.Scale = Scale; + return Res; } }; } // end anonymous namespace. -bool X86ATTAsmParser::ParseRegister(unsigned &RegNo) { +bool X86ATTAsmParser::ParseRegister(unsigned &RegNo, + SMLoc &StartLoc, SMLoc &EndLoc) { RegNo = 0; const AsmToken &TokPercent = getLexer().getTok(); - (void)TokPercent; // Avoid warning when assertions are disabled. assert(TokPercent.is(AsmToken::Percent) && "Invalid token kind!"); + StartLoc = TokPercent.getLoc(); getLexer().Lex(); // Eat percent token. const AsmToken &Tok = getLexer().getTok(); @@ -253,8 +258,8 @@ if (RegNo == 0) return Error(Tok.getLoc(), "invalid register name"); + EndLoc = Tok.getLoc(); getLexer().Lex(); // Eat identifier token. - return false; } @@ -266,8 +271,9 @@ // FIXME: if a segment register, this could either be just the seg reg, or // the start of a memory operand. unsigned RegNo; - if (ParseRegister(RegNo)) return 0; - return X86Operand::CreateReg(RegNo); + SMLoc Start, End; + if (ParseRegister(RegNo, Start, End)) return 0; + return X86Operand::CreateReg(RegNo, Start, End); } case AsmToken::Dollar: { // $42 -> immediate. @@ -335,8 +341,10 @@ // the rest of the memory operand. unsigned BaseReg = 0, IndexReg = 0, Scale = 1; - if (getLexer().is(AsmToken::Percent)) - if (ParseRegister(BaseReg)) return 0; + if (getLexer().is(AsmToken::Percent)) { + SMLoc L; + if (ParseRegister(BaseReg, L, L)) return 0; + } if (getLexer().is(AsmToken::Comma)) { getLexer().Lex(); // Eat the comma. @@ -348,7 +356,8 @@ // Not that even though it would be completely consistent to support syntax // like "1(%eax,,1)", the assembler doesn't. if (getLexer().is(AsmToken::Percent)) { - if (ParseRegister(IndexReg)) return 0; + SMLoc L; + if (ParseRegister(IndexReg, L, L)) return 0; if (getLexer().isNot(AsmToken::RParen)) { // Parse the scale amount: @@ -403,7 +412,7 @@ ParseInstruction(const StringRef &Name, SMLoc NameLoc, SmallVectorImpl &Operands) { - Operands.push_back(new X86Operand(X86Operand::CreateToken(Name))); + Operands.push_back(X86Operand::CreateToken(Name)); SMLoc Loc = getLexer().getTok().getLoc(); if (getLexer().isNot(AsmToken::EndOfStatement)) { @@ -411,7 +420,7 @@ // Parse '*' modifier. if (getLexer().is(AsmToken::Star)) { getLexer().Lex(); // Eat the star. - Operands.push_back(new X86Operand(X86Operand::CreateToken("*"))); + Operands.push_back(X86Operand::CreateToken("*")); } // Read the first operand. From dalej at apple.com Fri Jan 15 12:58:16 2010 From: dalej at apple.com (Dale Johannesen) Date: Fri, 15 Jan 2010 18:58:16 -0000 Subject: [llvm-commits] [llvm] r93530 - in /llvm/trunk/lib/Target/X86: AsmPrinter/X86MCInstLower.cpp X86RegisterInfo.cpp Message-ID: <201001151858.o0FIwGma026400@zion.cs.uiuc.edu> Author: johannes Date: Fri Jan 15 12:58:14 2010 New Revision: 93530 URL: http://llvm.org/viewvc/llvm-project?rev=93530&view=rev Log: Revert 93499. After discussion with Chris we agreed FrameIndexes should be lowered, but the same way as everything else (target dependent) rather than in a special hacked way. The lowering needs to be done for eventual purposes of Dwarf generation. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=93530&r1=93529&r2=93530&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Fri Jan 15 12:58:14 2010 @@ -25,7 +25,6 @@ #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Mangler.h" #include "llvm/ADT/SmallString.h" -#include "llvm/Analysis/DebugInfo.h" using namespace llvm; @@ -421,25 +420,6 @@ case TargetInstrInfo::GC_LABEL: printLabel(MI); return; - case TargetInstrInfo::DEBUG_VALUE: { - if (!VerboseAsm) - return; - O << '\t' << MAI->getCommentString() << "DEBUG_VALUE: "; - // cast away const; DIetc do not take const operands for some reason - DIVariable V((MDNode*)(MI->getOperand(2).getMetadata())); - O << V.getName(); - O << " <- "; - if (MI->getOperand(0).getType()==MachineOperand::MO_Register) - printOperand(MI, 0); - else { - assert(MI->getOperand(0).getType()==MachineOperand::MO_Immediate); - int64_t imm = MI->getOperand(0).getImm(); - O << '[' << ((imm<0) ? "EBP" : "ESP+") << imm << ']'; - } - O << "+"; - printOperand(MI, 1); - return; - } case TargetInstrInfo::INLINEASM: printInlineAsm(MI); return; Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=93530&r1=93529&r2=93530&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Fri Jan 15 12:58:14 2010 @@ -591,15 +591,6 @@ int FrameIndex = MI.getOperand(i).getIndex(); unsigned BasePtr; - // DEBUG_VALUE has a special representation, and is only robust enough to - // represent SP(or BP) +- offset addressing modes. We rewrite the - // FrameIndex to be a constant; implicitly positive constants are relative - // to ESP and negative ones to EBP. - if (MI.getOpcode()==TargetInstrInfo::DEBUG_VALUE) { - MI.getOperand(i).ChangeToImmediate(getFrameIndexOffset(MF, FrameIndex)); - return 0; - } - if (needsStackRealignment(MF)) BasePtr = (FrameIndex < 0 ? FramePtr : StackPtr); else From vhernandez at apple.com Fri Jan 15 13:04:10 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 15 Jan 2010 19:04:10 -0000 Subject: [llvm-commits] [llvm] r93531 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/VMCore/AutoUpgrade.cpp lib/VMCore/IntrinsicInst.cpp lib/VMCore/Verifier.cpp test/Assembler/functionlocal-metadata.ll test/DebugInfo/2009-10-16-Scope.ll test/DebugInfo/printdbginfo2.ll Message-ID: <201001151904.o0FJ4AkT026653@zion.cs.uiuc.edu> Author: hernande Date: Fri Jan 15 13:04:09 2010 New Revision: 93531 URL: http://llvm.org/viewvc/llvm-project?rev=93531&view=rev Log: Improve llvm.dbg.declare intrinsic by referring directly to the storage in its first argument, via function-local metadata (instead of via a bitcast). This patch also cleans up code that expects there to be a bitcast in the first argument and testcases that call llvm.dbg.declare. It also strips old llvm.dbg.declare intrinsics that did not pass metadata as the first argument. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/include/llvm/IntrinsicInst.h llvm/trunk/include/llvm/Intrinsics.td llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/VMCore/AutoUpgrade.cpp llvm/trunk/lib/VMCore/IntrinsicInst.cpp llvm/trunk/lib/VMCore/Verifier.cpp llvm/trunk/test/Assembler/functionlocal-metadata.ll llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll llvm/trunk/test/DebugInfo/printdbginfo2.ll Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=93531&r1=93530&r2=93531&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Fri Jan 15 13:04:09 2010 @@ -491,7 +491,6 @@ Module &M; LLVMContext& VMContext; - const Type *EmptyStructPtr; // "{}*". Function *DeclareFn; // llvm.dbg.declare Function *ValueFn; // llvm.dbg.value @@ -659,7 +658,7 @@ /// Finds the dbg.declare intrinsic corresponding to this value if any. /// It looks through pointer casts too. - const DbgDeclareInst *findDbgDeclare(const Value *V, bool stripCasts = true); + const DbgDeclareInst *findDbgDeclare(const Value *V); /// Find the debug info descriptor corresponding to this global variable. Value *findDbgGlobalDeclare(GlobalVariable *V); Modified: llvm/trunk/include/llvm/IntrinsicInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=93531&r1=93530&r2=93531&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicInst.h (original) +++ llvm/trunk/include/llvm/IntrinsicInst.h Fri Jan 15 13:04:09 2010 @@ -82,7 +82,7 @@ /// class DbgDeclareInst : public DbgInfoIntrinsic { public: - Value *getAddress() const { return getOperand(1); } + Value *getAddress() const; MDNode *getVariable() const { return cast(getOperand(2)); } // Methods for support type inquiry through isa, cast, and dyn_cast: Modified: llvm/trunk/include/llvm/Intrinsics.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=93531&r1=93530&r2=93531&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.td (original) +++ llvm/trunk/include/llvm/Intrinsics.td Fri Jan 15 13:04:09 2010 @@ -283,7 +283,7 @@ // places. let Properties = [IntrNoMem] in { def int_dbg_declare : Intrinsic<[llvm_void_ty], - [llvm_descriptor_ty, llvm_metadata_ty]>; + [llvm_metadata_ty, llvm_metadata_ty]>; def int_dbg_value : Intrinsic<[llvm_void_ty], [llvm_metadata_ty, llvm_i64_ty, llvm_metadata_ty]>; Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=93531&r1=93530&r2=93531&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Fri Jan 15 13:04:09 2010 @@ -599,9 +599,7 @@ //===----------------------------------------------------------------------===// DIFactory::DIFactory(Module &m) - : M(m), VMContext(M.getContext()), DeclareFn(0) { - EmptyStructPtr = PointerType::getUnqual(StructType::get(VMContext)); -} + : M(m), VMContext(M.getContext()), DeclareFn(0) {} Constant *DIFactory::GetTagConstant(unsigned TAG) { assert((TAG & LLVMDebugVersionMask) == 0 && @@ -1034,26 +1032,22 @@ /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, Instruction *InsertBefore) { - // Cast the storage to a {}* for the call to llvm.dbg.declare. - Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertBefore); - if (!DeclareFn) DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); - Value *Args[] = { Storage, D.getNode() }; + Value *Elts[] = { Storage }; + Value *Args[] = { MDNode::get(Storage->getContext(), Elts, 1), D.getNode() }; 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) { - // Cast the storage to a {}* for the call to llvm.dbg.declare. - Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertAtEnd); - if (!DeclareFn) DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); - Value *Args[] = { Storage, D.getNode() }; + Value *Elts[] = { Storage }; + Value *Args[] = { MDNode::get(Storage->getContext(), Elts, 1), D.getNode() }; return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd); } @@ -1258,25 +1252,24 @@ /// Finds the llvm.dbg.declare intrinsic corresponding to this value if any. /// It looks through pointer casts too. -const DbgDeclareInst *llvm::findDbgDeclare(const Value *V, bool stripCasts) { - if (stripCasts) { - V = V->stripPointerCasts(); - - // Look for the bitcast. - for (Value::use_const_iterator I = V->use_begin(), E =V->use_end(); - I != E; ++I) - if (isa(I)) { - const DbgDeclareInst *DDI = findDbgDeclare(*I, false); - if (DDI) return DDI; - } +const DbgDeclareInst *llvm::findDbgDeclare(const Value *V) { + V = V->stripPointerCasts(); + + if (!isa(V) && !isa(V)) return 0; - } - - // Find llvm.dbg.declare among uses of the instruction. - for (Value::use_const_iterator I = V->use_begin(), E =V->use_end(); - I != E; ++I) - if (const DbgDeclareInst *DDI = dyn_cast(I)) - return DDI; + + const Function *F = NULL; + if (const Instruction *I = dyn_cast(V)) + F = I->getParent()->getParent(); + else if (const Argument *A = dyn_cast(V)) + F = A->getParent(); + + for (Function::const_iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI) + for (BasicBlock::const_iterator BI = (*FI).begin(), BE = (*FI).end(); + BI != BE; ++BI) + if (const DbgDeclareInst *DDI = dyn_cast(BI)) + if (DDI->getAddress() == V) + return DDI; return 0; } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=93531&r1=93530&r2=93531&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Fri Jan 15 13:04:09 2010 @@ -332,8 +332,6 @@ return true; Value *Address = DI->getAddress(); - if (BitCastInst *BCI = dyn_cast(Address)) - Address = BCI->getOperand(0); AllocaInst *AI = dyn_cast(Address); // Don't handle byval struct arguments or VLAs, for example. if (!AI) break; Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=93531&r1=93530&r2=93531&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original) +++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Fri Jan 15 13:04:09 2010 @@ -521,7 +521,7 @@ if (Function *Declare = M->getFunction("llvm.dbg.declare")) { if (!Declare->use_empty()) { DbgDeclareInst *DDI = cast(Declare->use_back()); - if (!isa(DDI->getOperand(2))) { + if (!isa(DDI->getOperand(1)) ||!isa(DDI->getOperand(2))) { while (!Declare->use_empty()) { CallInst *CI = cast(Declare->use_back()); CI->eraseFromParent(); Modified: llvm/trunk/lib/VMCore/IntrinsicInst.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/IntrinsicInst.cpp?rev=93531&r1=93530&r2=93531&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/IntrinsicInst.cpp (original) +++ llvm/trunk/lib/VMCore/IntrinsicInst.cpp Fri Jan 15 13:04:09 2010 @@ -51,6 +51,17 @@ } //===----------------------------------------------------------------------===// +/// DbgDeclareInst - This represents the llvm.dbg.declare instruction. +/// + +Value *DbgDeclareInst::getAddress() const { + if (MDNode* MD = cast_or_null(getOperand(1))) + return MD->getOperand(0); + else + return NULL; +} + +//===----------------------------------------------------------------------===// /// DbgValueInst - This represents the llvm.dbg.value instruction. /// Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=93531&r1=93530&r2=93531&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Fri Jan 15 13:04:09 2010 @@ -1590,9 +1590,10 @@ default: break; case Intrinsic::dbg_declare: // llvm.dbg.declare - if (Constant *C = dyn_cast(CI.getOperand(1))) - Assert1(C && !isa(C), - "invalid llvm.dbg.declare intrinsic call", &CI); + if (MDNode *MD = dyn_cast(CI.getOperand(1))) + if (Constant *C = dyn_cast(MD->getOperand(0))) + Assert1(C && !isa(C), + "invalid llvm.dbg.declare intrinsic call", &CI); break; case Intrinsic::memcpy: case Intrinsic::memmove: Modified: llvm/trunk/test/Assembler/functionlocal-metadata.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/functionlocal-metadata.ll?rev=93531&r1=93530&r2=93531&view=diff ============================================================================== --- llvm/trunk/test/Assembler/functionlocal-metadata.ll (original) +++ llvm/trunk/test/Assembler/functionlocal-metadata.ll Fri Jan 15 13:04:09 2010 @@ -5,23 +5,28 @@ %0 = add i32 %a, 1 ; [#uses=1] %two = add i32 %b, %0 ; [#uses=0] %1 = alloca i32 ; [#uses=1] - %three = bitcast i32* %1 to { }* ; <{ }*> [#uses=6] - call void @llvm.dbg.declare({ }* %three, metadata !{i32* %1}) -; CHECK: metadata !{i32* %1} - call void @llvm.dbg.declare({ }* %three, metadata !{{ }* %three}) - call void @llvm.dbg.declare({ }* %three, metadata !{i32 %0}) - call void @llvm.dbg.declare({ }* %three, metadata !{{ }* %three, i32 %0}) - call void @llvm.dbg.declare({ }* %three, metadata !{i32 %b, i32 %0}) - call void @llvm.dbg.declare({ }* %three, metadata !{i32 %a, metadata !"foo"}) -; CHECK: metadata !{i32 %a, metadata !"foo"} - call void @llvm.dbg.declare({ }* %three, metadata !{metadata !0, i32 %two}) + call void @llvm.dbg.declare(metadata !{i32* %1}, metadata !{i32* %1}) +; CHECK: metadata !{i32* %1}, metadata !{i32* %1} + call void @llvm.dbg.declare(metadata !{i32 %two}, metadata !{i32 %0}) +; CHECK: metadata !{i32 %two}, metadata !{i32 %0} + call void @llvm.dbg.declare(metadata !{i32 %0}, metadata !{i32* %1, i32 %0}) +; CHECK: metadata !{i32 %0}, metadata !{i32* %1, i32 %0} + call void @llvm.dbg.declare(metadata !{i32* %1}, metadata !{i32 %b, i32 %0}) +; CHECK: metadata !{i32* %1}, metadata !{i32 %b, i32 %0} + call void @llvm.dbg.declare(metadata !{i32 %a}, metadata !{i32 %a, metadata !"foo"}) +; CHECK: metadata !{i32 %a}, metadata !{i32 %a, metadata !"foo"} + call void @llvm.dbg.declare(metadata !{i32 %b}, metadata !{metadata !0, i32 %two}) +; CHECK: metadata !{i32 %b}, metadata !{metadata !0, i32 %two} call void @llvm.dbg.value(metadata !{ i32 %a }, i64 0, metadata !1) +; CHECK: metadata !{i32 %a}, i64 0, metadata !1 call void @llvm.dbg.value(metadata !{ i32 %0 }, i64 25, metadata !0) +; CHECK: metadata !{i32 %0}, i64 25, metadata !0 call void @llvm.dbg.value(metadata !{ i32* %1 }, i64 16, metadata !"foo") ; CHECK: call void @llvm.dbg.value(metadata !{i32* %1}, i64 16, metadata !"foo") - call void @llvm.dbg.value(metadata !{ { }* %three }, i64 12, metadata !"bar") + call void @llvm.dbg.value(metadata !"foo", i64 12, metadata !"bar") +; CHECK: metadata !"foo", i64 12, metadata !"bar" ret void, !foo !0, !bar !1 ; CHECK: ret void, !foo !0, !bar !1 @@ -30,7 +35,7 @@ !0 = metadata !{i32 662302, i32 26, metadata !1, null} !1 = metadata !{i32 4, metadata !"foo"} -declare void @llvm.dbg.declare({ }*, metadata) nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone !foo = !{ !0 } Modified: llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll?rev=93531&r1=93530&r2=93531&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll (original) +++ llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll Fri Jan 15 13:04:09 2010 @@ -9,8 +9,7 @@ br label %do.body, !dbg !0 do.body: ; preds = %entry - %0 = bitcast i32* %count_ to { }* ; <{ }*> [#uses=1] - call void @llvm.dbg.declare({ }* %0, metadata !4) + call void @llvm.dbg.declare(metadata !{i32* %count_}, metadata !4) %conv = ptrtoint i32* %count_ to i32, !dbg !0 ; [#uses=1] %call = call i32 @foo(i32 %conv) ssp, !dbg !0 ; [#uses=0] br label %do.end, !dbg !0 @@ -19,7 +18,7 @@ ret void, !dbg !7 } -declare void @llvm.dbg.declare({ }*, metadata) nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone declare i32 @foo(i32) ssp Modified: llvm/trunk/test/DebugInfo/printdbginfo2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/printdbginfo2.ll?rev=93531&r1=93530&r2=93531&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/printdbginfo2.ll (original) +++ llvm/trunk/test/DebugInfo/printdbginfo2.ll Fri Jan 15 13:04:09 2010 @@ -19,11 +19,11 @@ call void @llvm.dbg.stoppoint(i32 6, i32 3, metadata !1) call void @llvm.dbg.stoppoint(i32 7, i32 3, metadata !1) %0 = bitcast %struct.foo* %b to { }* ; <{ }*> [#uses=1] - call void @llvm.dbg.declare({ }* %0, metadata !4) + call void @llvm.dbg.declare(metadata !{%struct.foo* %b}, metadata !4) ; CHECK:; %0 is variable b of type foo declared at x.c:7 call void @llvm.dbg.stoppoint(i32 8, i32 3, metadata !1) %1 = bitcast [4 x i32]* %a to { }* ; <{ }*> [#uses=1] - call void @llvm.dbg.declare({ }* %1, metadata !8) + call void @llvm.dbg.declare(metadata !{[4 x i32]* %a}, metadata !8) ; CHECK:; %1 is variable a of type declared at x.c:8 call void @llvm.dbg.stoppoint(i32 9, i32 3, metadata !1) %tmp = getelementptr inbounds %struct.foo* %b, i32 0, i32 0 ; [#uses=1] @@ -46,7 +46,7 @@ declare void @llvm.dbg.stoppoint(i32, i32, metadata) nounwind readnone -declare void @llvm.dbg.declare({ }*, metadata) nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone declare void @llvm.dbg.region.end(metadata) nounwind readnone From vhernandez at apple.com Fri Jan 15 13:04:33 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 15 Jan 2010 11:04:33 -0800 Subject: [llvm-commits] [llvm] r93504 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/VMCore/Verifier.cpp test/Assembler/funct In-Reply-To: <9A0CEBD4-7EE1-41B5-AF94-F355DC78A774@apple.com> References: <352a1fb21001150945j44e1edf4y831100e68d5f08b9@mail.gmail.com> <7D7B977D-BD33-4532-8FAE-7E8E75B37186@apple.com> <9A0CEBD4-7EE1-41B5-AF94-F355DC78A774@apple.com> Message-ID: <68E16DE5-3F64-4A93-AA94-64BD0FF6A41A@apple.com> Fixed in r93531. Victor On Jan 15, 2010, at 10:18 AM, Chris Lattner wrote: > > On Jan 15, 2010, at 10:12 AM, Victor Hernandez wrote: > >>>> >>>> Hi Victor, >>>> >>>> This is a IR incompatibility, and this intrinsic existed in LLVM 2.6 >>>> and earlier. Please add "autoupgrade" support to the .ll and .bc >>>> readers. >>>> >>> >>> Chris, >>> >>> 2.6 uses GVs for debug info. The autoupgrade support already discards >>> dbg intrinsics that do not use use metadata. > > Just discarding them makes sense to me, but this isn't happening. > > -Chris > From vhernandez at apple.com Fri Jan 15 13:05:06 2010 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 15 Jan 2010 11:05:06 -0800 Subject: [llvm-commits] [llvm] r93504 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/VMCore/Verifier.cpp test/Assembler/funct In-Reply-To: References: <352a1fb21001150951o6c53d8dbgf179f635388c2591@mail.gmail.com> Message-ID: <43549968-40CA-4E3F-8309-2A22D97148DD@apple.com> Both issues fixed in r93531. Victor On Jan 15, 2010, at 10:20 AM, Chris Lattner wrote: > > On Jan 15, 2010, at 9:51 AM, Devang Patel wrote: > >>> +++ llvm/trunk/include/llvm/IntrinsicInst.h Thu Jan 14 21:37:48 2010 >>> @@ -25,6 +25,7 @@ >>> #define LLVM_INTRINSICINST_H >>> >>> #include "llvm/Constants.h" >>> +#include "llvm/Metadata.h" >>> #include "llvm/Function.h" >>> #include "llvm/Instructions.h" >>> #include "llvm/Intrinsics.h" >>> @@ -82,7 +83,12 @@ >>> /// >>> class DbgDeclareInst : public DbgInfoIntrinsic { >>> public: >>> - Value *getAddress() const { return getOperand(1); } >>> + Value *getAddress() const { >>> + if (MDNode* MD = dyn_cast(getOperand(1))) >>> + return MD->getOperand(0); >>> + else >>> + return NULL; >>> + } >> >> If getOperand(1) is either MDNode or NULL. Pl. add an assert to check >> if it is anything else. > > Right, please use cast_or_null instead of dyn_cast. > >> >> If you move this def. in .cpp then you can avoid including Metadata.h here. > > > Agreed, please do. > > -Chris From sabre at nondot.org Fri Jan 15 13:06:59 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 19:06:59 -0000 Subject: [llvm-commits] [llvm] r93532 - /llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Message-ID: <201001151907.o0FJ70uS026806@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 13:06:59 2010 New Revision: 93532 URL: http://llvm.org/viewvc/llvm-project?rev=93532&view=rev Log: give X86Operand a ctor and start passing SMLoc's into it. Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=93532&r1=93531&r2=93532&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Fri Jan 15 13:06:59 2010 @@ -74,7 +74,7 @@ /// X86Operand - Instances of this class represent a parsed X86 machine /// instruction. struct X86Operand : public MCParsedAsmOperand { - enum { + enum KindTy { Token, Register, Immediate, @@ -106,6 +106,14 @@ } Mem; }; + X86Operand(KindTy K, SMLoc Start = SMLoc(), SMLoc End = SMLoc()) + : Kind(K), StartLoc(Start), EndLoc(End) {} + + /// getStartLoc - Get the location of the first token of this operand. + SMLoc getStartLoc() const { return StartLoc; } + /// getEndLoc - Get the location of the last token of this operand. + SMLoc getEndLoc() const { return EndLoc; } + StringRef getToken() const { assert(Kind == Token && "Invalid access!"); return StringRef(Tok.Data, Tok.Length); @@ -194,25 +202,20 @@ } static X86Operand *CreateToken(StringRef Str) { - X86Operand *Res = new X86Operand(); - Res->Kind = Token; + X86Operand *Res = new X86Operand(Token); Res->Tok.Data = Str.data(); Res->Tok.Length = Str.size(); return Res; } static X86Operand *CreateReg(unsigned RegNo, SMLoc StartLoc, SMLoc EndLoc) { - X86Operand *Res = new X86Operand(); - Res->Kind = Register; + X86Operand *Res = new X86Operand(Register, StartLoc, EndLoc); Res->Reg.RegNo = RegNo; - Res->StartLoc = StartLoc; - Res->EndLoc = EndLoc; return Res; } static X86Operand *CreateImm(const MCExpr *Val) { - X86Operand *Res = new X86Operand(); - Res->Kind = Immediate; + X86Operand *Res = new X86Operand(Immediate); Res->Imm.Val = Val; return Res; } @@ -226,8 +229,7 @@ // The scale should always be one of {1,2,4,8}. assert(((Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8)) && "Invalid scale!"); - X86Operand *Res = new X86Operand(); - Res->Kind = Memory; + X86Operand *Res = new X86Operand(Memory); Res->Mem.SegReg = SegReg; Res->Mem.Disp = Disp; Res->Mem.BaseReg = BaseReg; From sabre at nondot.org Fri Jan 15 13:28:39 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 19:28:39 -0000 Subject: [llvm-commits] [llvm] r93534 - in /llvm/trunk: include/llvm/MC/MCAsmParser.h lib/MC/MCAsmParser.cpp lib/Target/X86/AsmParser/X86AsmParser.cpp tools/llvm-mc/AsmParser.cpp tools/llvm-mc/AsmParser.h Message-ID: <201001151928.o0FJSd3f027752@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 13:28:38 2010 New Revision: 93534 URL: http://llvm.org/viewvc/llvm-project?rev=93534&view=rev Log: extend MCAsmParser::ParseExpression and ParseParenExpression to return range information for subexpressions. Use this to provide range info for several new X86Operands. Modified: llvm/trunk/include/llvm/MC/MCAsmParser.h llvm/trunk/lib/MC/MCAsmParser.cpp llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp llvm/trunk/tools/llvm-mc/AsmParser.cpp llvm/trunk/tools/llvm-mc/AsmParser.h Modified: llvm/trunk/include/llvm/MC/MCAsmParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmParser.h?rev=93534&r1=93533&r2=93534&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmParser.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmParser.h Fri Jan 15 13:28:38 2010 @@ -55,15 +55,17 @@ /// @param Res - The value of the expression. The result is undefined /// on error. /// @result - False on success. - virtual bool ParseExpression(const MCExpr *&Res) = 0; - + virtual bool ParseExpression(const MCExpr *&Res, + SMLoc &StartLoc, SMLoc &EndLoc) = 0; + bool ParseExpression(const MCExpr *&Res); + /// ParseParenExpression - Parse an arbitrary expression, assuming that an /// initial '(' has already been consumed. /// /// @param Res - The value of the expression. The result is undefined /// on error. /// @result - False on success. - virtual bool ParseParenExpression(const MCExpr *&Res) = 0; + virtual bool ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0; /// ParseAbsoluteExpression - Parse an expression which must evaluate to an /// absolute value. Modified: llvm/trunk/lib/MC/MCAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmParser.cpp?rev=93534&r1=93533&r2=93534&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmParser.cpp (original) +++ llvm/trunk/lib/MC/MCAsmParser.cpp Fri Jan 15 13:28:38 2010 @@ -8,7 +8,8 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCAsmParser.h" - +#include "llvm/MC/MCParsedAsmOperand.h" +#include "llvm/Support/SourceMgr.h" using namespace llvm; MCAsmParser::MCAsmParser() { @@ -16,3 +17,15 @@ MCAsmParser::~MCAsmParser() { } + +bool MCAsmParser::ParseExpression(const MCExpr *&Res) { + SMLoc L; + return ParseExpression(Res, L, L); +} + + +/// getStartLoc - Get the location of the first token of this operand. +SMLoc MCParsedAsmOperand::getStartLoc() const { return SMLoc(); } +SMLoc MCParsedAsmOperand::getEndLoc() const { return SMLoc(); } + + Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=93534&r1=93533&r2=93534&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Fri Jan 15 13:28:38 2010 @@ -201,8 +201,8 @@ Inst.addOperand(MCOperand::CreateReg(getMemSegReg())); } - static X86Operand *CreateToken(StringRef Str) { - X86Operand *Res = new X86Operand(Token); + static X86Operand *CreateToken(StringRef Str, SMLoc Loc) { + X86Operand *Res = new X86Operand(Token, Loc, Loc); Res->Tok.Data = Str.data(); Res->Tok.Length = Str.size(); return Res; @@ -214,8 +214,8 @@ return Res; } - static X86Operand *CreateImm(const MCExpr *Val) { - X86Operand *Res = new X86Operand(Immediate); + static X86Operand *CreateImm(const MCExpr *Val, SMLoc StartLoc, SMLoc EndLoc){ + X86Operand *Res = new X86Operand(Immediate, StartLoc, EndLoc); Res->Imm.Val = Val; return Res; } @@ -281,9 +281,10 @@ // $42 -> immediate. getLexer().Lex(); const MCExpr *Val; - if (getParser().ParseExpression(Val)) + SMLoc Start, End; + if (getParser().ParseExpression(Val, Start, End)) return 0; - return X86Operand::CreateImm(Val); + return X86Operand::CreateImm(Val, Start, End); } } } @@ -299,14 +300,15 @@ // it. const MCExpr *Disp = MCConstantExpr::Create(0, getParser().getContext()); if (getLexer().isNot(AsmToken::LParen)) { - if (getParser().ParseExpression(Disp)) return 0; + SMLoc ExprStart, ExprEnd; + if (getParser().ParseExpression(Disp, ExprStart, ExprEnd)) return 0; // After parsing the base expression we could either have a parenthesized // memory address or not. If not, return now. If so, eat the (. if (getLexer().isNot(AsmToken::LParen)) { // Unless we have a segment register, treat this as an immediate. if (SegReg == 0) - return X86Operand::CreateImm(Disp); + return X86Operand::CreateImm(Disp, ExprStart, ExprEnd); return X86Operand::CreateMem(SegReg, Disp, 0, 0, 1); } @@ -315,14 +317,17 @@ } else { // Okay, we have a '('. We don't know if this is an expression or not, but // so we have to eat the ( to see beyond it. + SMLoc LParenLoc = getLexer().getTok().getLoc(); getLexer().Lex(); // Eat the '('. if (getLexer().is(AsmToken::Percent) || getLexer().is(AsmToken::Comma)) { // Nothing to do here, fall into the code below with the '(' part of the // memory operand consumed. } else { + SMLoc ExprEnd; + // It must be an parenthesized expression, parse it now. - if (getParser().ParseParenExpression(Disp)) + if (getParser().ParseParenExpression(Disp, ExprEnd)) return 0; // After parsing the base expression we could either have a parenthesized @@ -330,7 +335,7 @@ if (getLexer().isNot(AsmToken::LParen)) { // Unless we have a segment register, treat this as an immediate. if (SegReg == 0) - return X86Operand::CreateImm(Disp); + return X86Operand::CreateImm(Disp, LParenLoc, ExprEnd); return X86Operand::CreateMem(SegReg, Disp, 0, 0, 1); } @@ -414,15 +419,15 @@ ParseInstruction(const StringRef &Name, SMLoc NameLoc, SmallVectorImpl &Operands) { - Operands.push_back(X86Operand::CreateToken(Name)); + Operands.push_back(X86Operand::CreateToken(Name, NameLoc)); - SMLoc Loc = getLexer().getTok().getLoc(); if (getLexer().isNot(AsmToken::EndOfStatement)) { // Parse '*' modifier. if (getLexer().is(AsmToken::Star)) { + SMLoc Loc = getLexer().getTok().getLoc(); + Operands.push_back(X86Operand::CreateToken("*", Loc)); getLexer().Lex(); // Eat the star. - Operands.push_back(X86Operand::CreateToken("*")); } // Read the first operand. Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=93534&r1=93533&r2=93534&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original) +++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Fri Jan 15 13:28:38 2010 @@ -29,11 +29,6 @@ #include "llvm/Target/TargetAsmParser.h" using namespace llvm; -/// getStartLoc - Get the location of the first token of this operand. -SMLoc MCParsedAsmOperand::getStartLoc() const { return SMLoc(); } -SMLoc MCParsedAsmOperand::getEndLoc() const { return SMLoc(); } - - // Mach-O section uniquing. // // FIXME: Figure out where this should live, it should be shared by @@ -193,10 +188,11 @@ /// /// parenexpr ::= expr) /// -bool AsmParser::ParseParenExpr(const MCExpr *&Res) { +bool AsmParser::ParseParenExpr(const MCExpr *&Res, SMLoc &EndLoc) { if (ParseExpression(Res)) return true; if (Lexer.isNot(AsmToken::RParen)) return TokError("expected ')' in parentheses expression"); + EndLoc = Lexer.getLoc(); Lexer.Lex(); return false; } @@ -217,13 +213,13 @@ /// primaryexpr ::= symbol /// primaryexpr ::= number /// primaryexpr ::= ~,+,- primaryexpr -bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res) { +bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) { switch (Lexer.getKind()) { default: return TokError("unknown token in expression"); case AsmToken::Exclaim: Lexer.Lex(); // Eat the operator. - if (ParsePrimaryExpr(Res)) + if (ParsePrimaryExpr(Res, EndLoc)) return true; Res = MCUnaryExpr::CreateLNot(Res, getContext()); return false; @@ -231,6 +227,7 @@ case AsmToken::Identifier: { // This is a symbol reference. MCSymbol *Sym = CreateSymbol(Lexer.getTok().getIdentifier()); + EndLoc = Lexer.getLoc(); Lexer.Lex(); // Eat identifier. // If this is an absolute variable reference, substitute it now to preserve @@ -246,32 +243,38 @@ } case AsmToken::Integer: Res = MCConstantExpr::Create(Lexer.getTok().getIntVal(), getContext()); + EndLoc = Lexer.getLoc(); Lexer.Lex(); // Eat token. return false; case AsmToken::LParen: Lexer.Lex(); // Eat the '('. - return ParseParenExpr(Res); + return ParseParenExpr(Res, EndLoc); case AsmToken::Minus: Lexer.Lex(); // Eat the operator. - if (ParsePrimaryExpr(Res)) + if (ParsePrimaryExpr(Res, EndLoc)) return true; Res = MCUnaryExpr::CreateMinus(Res, getContext()); return false; case AsmToken::Plus: Lexer.Lex(); // Eat the operator. - if (ParsePrimaryExpr(Res)) + if (ParsePrimaryExpr(Res, EndLoc)) return true; Res = MCUnaryExpr::CreatePlus(Res, getContext()); return false; case AsmToken::Tilde: Lexer.Lex(); // Eat the operator. - if (ParsePrimaryExpr(Res)) + if (ParsePrimaryExpr(Res, EndLoc)) return true; Res = MCUnaryExpr::CreateNot(Res, getContext()); return false; } } +bool AsmParser::ParseExpression(const MCExpr *&Res) { + SMLoc L; + return ParseExpression(Res, L, L); +} + /// ParseExpression - Parse an expression and return it. /// /// expr ::= expr +,- expr -> lowest. @@ -279,14 +282,16 @@ /// expr ::= expr *,/,%,<<,>> expr -> highest. /// expr ::= primaryexpr /// -bool AsmParser::ParseExpression(const MCExpr *&Res) { +bool AsmParser::ParseExpression(const MCExpr *&Res, + SMLoc &StartLoc, SMLoc &EndLoc) { + StartLoc = Lexer.getLoc(); Res = 0; - return ParsePrimaryExpr(Res) || - ParseBinOpRHS(1, Res); + return ParsePrimaryExpr(Res, EndLoc) || + ParseBinOpRHS(1, Res, EndLoc); } -bool AsmParser::ParseParenExpression(const MCExpr *&Res) { - if (ParseParenExpr(Res)) +bool AsmParser::ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) { + if (ParseParenExpr(Res, EndLoc)) return true; return false; @@ -381,7 +386,8 @@ /// ParseBinOpRHS - Parse all binary operators with precedence >= 'Precedence'. /// Res contains the LHS of the expression on input. -bool AsmParser::ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res) { +bool AsmParser::ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res, + SMLoc &EndLoc) { while (1) { MCBinaryExpr::Opcode Kind = MCBinaryExpr::Add; unsigned TokPrec = getBinOpPrecedence(Lexer.getKind(), Kind); @@ -395,14 +401,14 @@ // Eat the next primary expression. const MCExpr *RHS; - if (ParsePrimaryExpr(RHS)) return true; + if (ParsePrimaryExpr(RHS, EndLoc)) return true; // If BinOp binds less tightly with RHS than the operator after RHS, let // the pending operator take RHS as its LHS. MCBinaryExpr::Opcode Dummy; unsigned NextTokPrec = getBinOpPrecedence(Lexer.getKind(), Dummy); if (TokPrec < NextTokPrec) { - if (ParseBinOpRHS(Precedence+1, RHS)) return true; + if (ParseBinOpRHS(Precedence+1, RHS, EndLoc)) return true; } // Merge LHS and RHS according to operator. Modified: llvm/trunk/tools/llvm-mc/AsmParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.h?rev=93534&r1=93533&r2=93534&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/AsmParser.h (original) +++ llvm/trunk/tools/llvm-mc/AsmParser.h Fri Jan 15 13:28:38 2010 @@ -79,8 +79,10 @@ virtual void Warning(SMLoc L, const Twine &Meg); virtual bool Error(SMLoc L, const Twine &Msg); - virtual bool ParseExpression(const MCExpr *&Res); - virtual bool ParseParenExpression(const MCExpr *&Res); + bool ParseExpression(const MCExpr *&Res); + virtual bool ParseExpression(const MCExpr *&Res, + SMLoc &StartLoc, SMLoc &EndLoc); + virtual bool ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc); virtual bool ParseAbsoluteExpression(int64_t &Res); /// } @@ -105,9 +107,9 @@ bool ParseAssignment(const StringRef &Name); - bool ParsePrimaryExpr(const MCExpr *&Res); - bool ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res); - bool ParseParenExpr(const MCExpr *&Res); + bool ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc); + bool ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res, SMLoc &EndLoc); + bool ParseParenExpr(const MCExpr *&Res, SMLoc &EndLoc); /// ParseIdentifier - Parse an identifier or string (as a quoted identifier) /// and set \arg Res to the identifier contents. From sabre at nondot.org Fri Jan 15 13:33:44 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 19:33:44 -0000 Subject: [llvm-commits] [llvm] r93535 - /llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Message-ID: <201001151933.o0FJXi0I027952@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 13:33:43 2010 New Revision: 93535 URL: http://llvm.org/viewvc/llvm-project?rev=93535&view=rev Log: add range information for mem X86Operand's, now all X86Operand's have range info. Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=93535&r1=93534&r2=93535&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Fri Jan 15 13:33:43 2010 @@ -106,7 +106,7 @@ } Mem; }; - X86Operand(KindTy K, SMLoc Start = SMLoc(), SMLoc End = SMLoc()) + X86Operand(KindTy K, SMLoc Start, SMLoc End) : Kind(K), StartLoc(Start), EndLoc(End) {} /// getStartLoc - Get the location of the first token of this operand. @@ -222,14 +222,14 @@ static X86Operand *CreateMem(unsigned SegReg, const MCExpr *Disp, unsigned BaseReg, unsigned IndexReg, - unsigned Scale) { + unsigned Scale, SMLoc StartLoc, SMLoc EndLoc) { // We should never just have a displacement, that would be an immediate. assert((SegReg || BaseReg || IndexReg) && "Invalid memory operand!"); // The scale should always be one of {1,2,4,8}. assert(((Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8)) && "Invalid scale!"); - X86Operand *Res = new X86Operand(Memory); + X86Operand *Res = new X86Operand(Memory, StartLoc, EndLoc); Res->Mem.SegReg = SegReg; Res->Mem.Disp = Disp; Res->Mem.BaseReg = BaseReg; @@ -291,6 +291,8 @@ /// ParseMemOperand: segment: disp(basereg, indexreg, scale) X86Operand *X86ATTAsmParser::ParseMemOperand() { + SMLoc MemStart = getLexer().getTok().getLoc(); + // FIXME: If SegReg ':' (e.g. %gs:), eat and remember. unsigned SegReg = 0; @@ -301,7 +303,7 @@ const MCExpr *Disp = MCConstantExpr::Create(0, getParser().getContext()); if (getLexer().isNot(AsmToken::LParen)) { SMLoc ExprStart, ExprEnd; - if (getParser().ParseExpression(Disp, ExprStart, ExprEnd)) return 0; + if (getParser().ParseExpression(Disp, MemStart, ExprEnd)) return 0; // After parsing the base expression we could either have a parenthesized // memory address or not. If not, return now. If so, eat the (. @@ -309,7 +311,7 @@ // Unless we have a segment register, treat this as an immediate. if (SegReg == 0) return X86Operand::CreateImm(Disp, ExprStart, ExprEnd); - return X86Operand::CreateMem(SegReg, Disp, 0, 0, 1); + return X86Operand::CreateMem(SegReg, Disp, 0, 0, 1, MemStart, ExprEnd); } // Eat the '('. @@ -336,7 +338,7 @@ // Unless we have a segment register, treat this as an immediate. if (SegReg == 0) return X86Operand::CreateImm(Disp, LParenLoc, ExprEnd); - return X86Operand::CreateMem(SegReg, Disp, 0, 0, 1); + return X86Operand::CreateMem(SegReg, Disp, 0, 0, 1, MemStart, ExprEnd); } // Eat the '('. @@ -410,9 +412,11 @@ Error(getLexer().getTok().getLoc(), "unexpected token in memory operand"); return 0; } + SMLoc MemEnd = getLexer().getTok().getLoc(); getLexer().Lex(); // Eat the ')'. - return X86Operand::CreateMem(SegReg, Disp, BaseReg, IndexReg, Scale); + return X86Operand::CreateMem(SegReg, Disp, BaseReg, IndexReg, Scale, + MemStart, MemEnd); } bool X86ATTAsmParser:: From sabre at nondot.org Fri Jan 15 13:39:23 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 19:39:23 -0000 Subject: [llvm-commits] [llvm] r93536 - in /llvm/trunk: include/llvm/MC/MCAsmParser.h lib/Target/X86/AsmParser/X86AsmParser.cpp tools/llvm-mc/AsmParser.cpp tools/llvm-mc/AsmParser.h Message-ID: <201001151939.o0FJdN00028145@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 13:39:23 2010 New Revision: 93536 URL: http://llvm.org/viewvc/llvm-project?rev=93536&view=rev Log: fix a bug in range information for $42, eliminate an unneeded argument from ParseExpression. Modified: llvm/trunk/include/llvm/MC/MCAsmParser.h llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp llvm/trunk/tools/llvm-mc/AsmParser.cpp llvm/trunk/tools/llvm-mc/AsmParser.h Modified: llvm/trunk/include/llvm/MC/MCAsmParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmParser.h?rev=93536&r1=93535&r2=93536&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmParser.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmParser.h Fri Jan 15 13:39:23 2010 @@ -55,8 +55,7 @@ /// @param Res - The value of the expression. The result is undefined /// on error. /// @result - False on success. - virtual bool ParseExpression(const MCExpr *&Res, - SMLoc &StartLoc, SMLoc &EndLoc) = 0; + virtual bool ParseExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0; bool ParseExpression(const MCExpr *&Res); /// ParseParenExpression - Parse an arbitrary expression, assuming that an Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=93536&r1=93535&r2=93536&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Fri Jan 15 13:39:23 2010 @@ -279,10 +279,10 @@ } case AsmToken::Dollar: { // $42 -> immediate. + SMLoc Start = getLexer().getTok().getLoc(), End; getLexer().Lex(); const MCExpr *Val; - SMLoc Start, End; - if (getParser().ParseExpression(Val, Start, End)) + if (getParser().ParseExpression(Val, End)) return 0; return X86Operand::CreateImm(Val, Start, End); } @@ -302,15 +302,15 @@ // it. const MCExpr *Disp = MCConstantExpr::Create(0, getParser().getContext()); if (getLexer().isNot(AsmToken::LParen)) { - SMLoc ExprStart, ExprEnd; - if (getParser().ParseExpression(Disp, MemStart, ExprEnd)) return 0; + SMLoc ExprEnd; + if (getParser().ParseExpression(Disp, ExprEnd)) return 0; // After parsing the base expression we could either have a parenthesized // memory address or not. If not, return now. If so, eat the (. if (getLexer().isNot(AsmToken::LParen)) { // Unless we have a segment register, treat this as an immediate. if (SegReg == 0) - return X86Operand::CreateImm(Disp, ExprStart, ExprEnd); + return X86Operand::CreateImm(Disp, MemStart, ExprEnd); return X86Operand::CreateMem(SegReg, Disp, 0, 0, 1, MemStart, ExprEnd); } Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=93536&r1=93535&r2=93536&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original) +++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Fri Jan 15 13:39:23 2010 @@ -271,8 +271,8 @@ } bool AsmParser::ParseExpression(const MCExpr *&Res) { - SMLoc L; - return ParseExpression(Res, L, L); + SMLoc EndLoc; + return ParseExpression(Res, EndLoc); } /// ParseExpression - Parse an expression and return it. @@ -282,9 +282,7 @@ /// expr ::= expr *,/,%,<<,>> expr -> highest. /// expr ::= primaryexpr /// -bool AsmParser::ParseExpression(const MCExpr *&Res, - SMLoc &StartLoc, SMLoc &EndLoc) { - StartLoc = Lexer.getLoc(); +bool AsmParser::ParseExpression(const MCExpr *&Res, SMLoc &EndLoc) { Res = 0; return ParsePrimaryExpr(Res, EndLoc) || ParseBinOpRHS(1, Res, EndLoc); Modified: llvm/trunk/tools/llvm-mc/AsmParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.h?rev=93536&r1=93535&r2=93536&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/AsmParser.h (original) +++ llvm/trunk/tools/llvm-mc/AsmParser.h Fri Jan 15 13:39:23 2010 @@ -80,8 +80,7 @@ virtual bool Error(SMLoc L, const Twine &Msg); bool ParseExpression(const MCExpr *&Res); - virtual bool ParseExpression(const MCExpr *&Res, - SMLoc &StartLoc, SMLoc &EndLoc); + virtual bool ParseExpression(const MCExpr *&Res, SMLoc &EndLoc); virtual bool ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc); virtual bool ParseAbsoluteExpression(int64_t &Res); From greened at obbligato.org Fri Jan 15 13:43:24 2010 From: greened at obbligato.org (David Greene) Date: Fri, 15 Jan 2010 19:43:24 -0000 Subject: [llvm-commits] [llvm] r93538 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <201001151943.o0FJhO34028333@zion.cs.uiuc.edu> Author: greened Date: Fri Jan 15 13:43:23 2010 New Revision: 93538 URL: http://llvm.org/viewvc/llvm-project?rev=93538&view=rev Log: Add some debug routines to SelectionDAG to dump full DAGs. print/dumpWithDepth allows one to dump a DAG up to N levels deep. dump/printWithFullDepth prints the whole DAG, subject to a depth limit on 100 in the default case (to prevent infinite recursion). Have CannotYetSelect to a dumpWithFullDepth so it is clearer exactly what the non-matching DAG looks like. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=93538&r1=93537&r2=93538&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Fri Jan 15 13:43:23 2010 @@ -1285,10 +1285,29 @@ void print_details(raw_ostream &OS, const SelectionDAG *G) const; void print(raw_ostream &OS, const SelectionDAG *G = 0) const; void printr(raw_ostream &OS, const SelectionDAG *G = 0) const; + /// printWithDepth - Print a SelectionDAG node and children up to + /// depth "depth." "limit" controls whether a message should be + /// printed if we hit depth "depth." + /// + void printWithDepth(raw_ostream &O, const SelectionDAG *G = 0, + unsigned depth = -1, unsigned indent = 0, + bool limit = false) const; + /// printWithFullDepth - Print a SelectionDAG node and all children + /// down to the leaves. + /// + void printWithFullDepth(raw_ostream &O, const SelectionDAG *G = 0, + unsigned indent = 0) const; void dump() const; void dumpr() const; void dump(const SelectionDAG *G) const; void dumpr(const SelectionDAG *G) const; + /// dumpWithDepth - printWithDepth to dbgs(). + /// + void dumpWithDepth(const SelectionDAG *G = 0, unsigned depth = 1, + unsigned indent = 0, bool limit = false) const; + /// dumpWithFullDepth - printWithFullDepth to dbgs(). + /// + void dumpWithFullDepth(const SelectionDAG *G = 0, unsigned indent = 0) const; static bool classof(const SDNode *) { return true; } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=93538&r1=93537&r2=93538&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Jan 15 13:43:23 2010 @@ -5893,6 +5893,49 @@ print_details(OS, G); } +void SDNode::printWithDepth(raw_ostream &OS, const SelectionDAG *G, + unsigned depth, unsigned indent, + bool limit) const { + if (depth == 0) { + if (limit) + OS << "*** - Cycle? ***\n"; + return; + } + + int myindent = indent; + + while (myindent--) { + OS << ' '; + } + + print(OS, G); + + if (depth > 1) { + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { + OS << '\n'; + getOperand(i).getNode()->printWithDepth(OS, G, + depth > 0 ? depth-1 : depth, + indent+2); + } + } +} + +void SDNode::printWithFullDepth(raw_ostream &OS, const SelectionDAG *G, + unsigned indent) const { + // Don't print impossibly deep things. + printWithDepth(OS, G, 100, indent, true); +} + +void SDNode::dumpWithDepth(const SelectionDAG *G, unsigned depth, + unsigned indent, bool limit) const { + printWithDepth(dbgs(), G, depth, indent, limit); +} + +void SDNode::dumpWithFullDepth(const SelectionDAG *G, unsigned indent) const { + // Don't print impossibly deep things. + dumpWithDepth(G, 100, indent, true); +} + static void DumpNodes(const SDNode *N, unsigned indent, const SelectionDAG *G) { for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) if (N->getOperand(i).getNode()->hasOneUse()) Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=93538&r1=93537&r2=93538&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Jan 15 13:43:23 2010 @@ -1426,7 +1426,7 @@ std::string msg; raw_string_ostream Msg(msg); Msg << "Cannot yet select: "; - N->print(Msg, CurDAG); + N->printWithFullDepth(Msg, CurDAG); llvm_report_error(Msg.str()); } From clattner at apple.com Fri Jan 15 13:47:28 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 11:47:28 -0800 Subject: [llvm-commits] [llvm] r93538 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp In-Reply-To: <201001151943.o0FJhO34028333@zion.cs.uiuc.edu> References: <201001151943.o0FJhO34028333@zion.cs.uiuc.edu> Message-ID: <6BCA97EE-3764-4705-B60B-2788C3B8E998@apple.com> On Jan 15, 2010, at 11:43 AM, David Greene wrote: > Add some debug routines to SelectionDAG to dump full DAGs. > print/dumpWithDepth allows one to dump a DAG up to N levels deep. > dump/printWithFullDepth prints the whole DAG, subject to a depth limit > on 100 in the default case (to prevent infinite recursion). > > Have CannotYetSelect to a dumpWithFullDepth so it is clearer exactly > what the non-matching DAG looks like. As Dan requested, please remove limit. > +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Jan 15 > 13:43:23 2010 > @@ -5893,6 +5893,49 @@ > print_details(OS, G); > } > > +void SDNode::printWithDepth(raw_ostream &OS, const SelectionDAG *G, > + unsigned depth, unsigned indent, What is the relation here between depth and indent? why not always print the message and remove limit? > + while (myindent--) { > + OS << ' '; > + } O.indent(indent). > + > + print(OS, G); > + > + if (depth > 1) { Please use early exit here. > > +void SDNode::printWithFullDepth(raw_ostream &OS, const SelectionDAG > *G, > + unsigned indent) const { > + // Don't print impossibly deep things. > + printWithDepth(OS, G, 100, indent, true); > +} > + > +void SDNode::dumpWithDepth(const SelectionDAG *G, unsigned depth, > + unsigned indent, bool limit) const { > + printWithDepth(dbgs(), G, depth, indent, limit); > +} > + > +void SDNode::dumpWithFullDepth(const SelectionDAG *G, unsigned > indent) const { > + // Don't print impossibly deep things. > + dumpWithDepth(G, 100, indent, true); > +} It would be nice to eliminate some of these unless they are all truly useful. -Chris From sabre at nondot.org Fri Jan 15 13:51:06 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 19:51:06 -0000 Subject: [llvm-commits] [llvm] r93539 - /llvm/trunk/lib/MC/MCAsmParser.cpp Message-ID: <201001151951.o0FJp6Zx028663@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 13:51:05 2010 New Revision: 93539 URL: http://llvm.org/viewvc/llvm-project?rev=93539&view=rev Log: unbreak the build, grr symlinks. Modified: llvm/trunk/lib/MC/MCAsmParser.cpp Modified: llvm/trunk/lib/MC/MCAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmParser.cpp?rev=93539&r1=93538&r2=93539&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmParser.cpp (original) +++ llvm/trunk/lib/MC/MCAsmParser.cpp Fri Jan 15 13:51:05 2010 @@ -20,7 +20,7 @@ bool MCAsmParser::ParseExpression(const MCExpr *&Res) { SMLoc L; - return ParseExpression(Res, L, L); + return ParseExpression(Res, L); } From clattner at apple.com Fri Jan 15 13:55:43 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 11:55:43 -0800 Subject: [llvm-commits] [llvm] r93369 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineAddSub.cpp test/Transforms/InstCombine/fsub-fadd.ll In-Reply-To: <201001132323.o0DNNIpO026876@zion.cs.uiuc.edu> References: <201001132323.o0DNNIpO026876@zion.cs.uiuc.edu> Message-ID: <6DE216F9-6246-4C21-A4D0-03E5FFB8D652@apple.com> On Jan 13, 2010, at 3:23 PM, Bill Wendling wrote: > Author: void > Date: Wed Jan 13 17:23:17 2010 > New Revision: 93369 > > URL: http://llvm.org/viewvc/llvm-project?rev=93369&view=rev > Log: > When the visitSub method was split into visitSub and visitFSub, this > xform was > added to the FSub version. However, the original version of this > xform guarded > against doing this for floating point (!Op0->getType()- > >isFPOrFPVector()). > > This is causing LLVM to perform incorrect xforms for code like: Hi Bill, The patch is fine, but please reduce the testcase to the minimum needed to repro the issue ("X-(X+Y) == -Y") and add it to an existing .ll file. -Chris From clattner at apple.com Fri Jan 15 13:58:14 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 11:58:14 -0800 Subject: [llvm-commits] [PATCH] Create Generic DOTGraphTraits Printer/Viewer In-Reply-To: References: Message-ID: <3BDA5D71-0D72-4BCD-9EE3-21576692B9A0@apple.com> On Jan 13, 2010, at 4:21 PM, Tobias Grosser wrote: > > Move the DOTGraphTraits dotty printer/viewer templates, that were > developed for > the dominance tree into their own header file. This will allow reuse > in future > passes. Ok with a couple changes: Please drop this in llvm/Analysis instead of llvm/Support. Also, please add enough forward declarations and #includes to make DOTGraphTraitsPass.h self contained. Thanks! -Chris > --- > include/llvm/Support/DOTGraphTraitsPass.h | 79 ++++++++++++++++++++ > +++++++++ > lib/Analysis/DomPrinter.cpp | 70 +++++ > +------------------- > 2 files changed, 96 insertions(+), 53 deletions(-) > create mode 100644 include/llvm/Support/DOTGraphTraitsPass.h > > <0001-Create-Generic-DOTGraphTraits-Printer- > Viewer.patch>_______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From stoklund at 2pi.dk Fri Jan 15 13:59:57 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 15 Jan 2010 19:59:57 -0000 Subject: [llvm-commits] [llvm] r93540 - /llvm/trunk/lib/CodeGen/TailDuplication.cpp Message-ID: <201001151959.o0FJxwxj029068@zion.cs.uiuc.edu> Author: stoklund Date: Fri Jan 15 13:59:57 2010 New Revision: 93540 URL: http://llvm.org/viewvc/llvm-project?rev=93540&view=rev Log: Simplify logic. Any functional change is unintended. Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=93540&r1=93539&r2=93540&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original) +++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Fri Jan 15 13:59:57 2010 @@ -108,12 +108,8 @@ MMI = getAnalysisIfAvailable(); bool MadeChange = false; - bool MadeChangeThisIteration = true; - while (MadeChangeThisIteration) { - MadeChangeThisIteration = false; - MadeChangeThisIteration |= TailDuplicateBlocks(MF); - MadeChange |= MadeChangeThisIteration; - } + while (TailDuplicateBlocks(MF)) + MadeChange = true; return MadeChange; } From stoklund at 2pi.dk Fri Jan 15 14:00:12 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 15 Jan 2010 20:00:12 -0000 Subject: [llvm-commits] [llvm] r93541 - /llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Message-ID: <201001152000.o0FK0CWf029102@zion.cs.uiuc.edu> Author: stoklund Date: Fri Jan 15 14:00:12 2010 New Revision: 93541 URL: http://llvm.org/viewvc/llvm-project?rev=93541&view=rev Log: Don't make changes to the MBB in MachineBasicBlock::canFallThrough(). This fixes the regression for -pre-regalloc-taildup in MultiSource/Applications/lambda-0.1.3. Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=93541&r1=93540&r2=93541&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Fri Jan 15 14:00:12 2010 @@ -378,7 +378,7 @@ MachineBasicBlock *TBB = 0, *FBB = 0; SmallVector Cond; const TargetInstrInfo *TII = getParent()->getTarget().getInstrInfo(); - if (TII->AnalyzeBranch(*this, TBB, FBB, Cond, true)) { + if (TII->AnalyzeBranch(*this, TBB, FBB, Cond)) { // If we couldn't analyze the branch, examine the last instruction. // If the block doesn't end in a known control barrier, assume fallthrough // is possible. The isPredicable check is needed because this code can be From asl at math.spbu.ru Fri Jan 15 15:17:13 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Fri, 15 Jan 2010 21:17:13 -0000 Subject: [llvm-commits] [llvm] r93550 - /llvm/trunk/lib/Target/MSP430/MSP430InstrFormats.td Message-ID: <201001152117.o0FLHE4i032159@zion.cs.uiuc.edu> Author: asl Date: Fri Jan 15 15:17:13 2010 New Revision: 93550 URL: http://llvm.org/viewvc/llvm-project?rev=93550&view=rev Log: Add instruction formats & support stuff Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrFormats.td Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrFormats.td?rev=93550&r1=93549&r2=93550&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrFormats.td (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrFormats.td Fri Jan 15 15:17:13 2010 @@ -11,8 +11,37 @@ // Describe MSP430 instructions format here // +// Format specifies the encoding used by the instruction. This is part of the +// ad-hoc solution used to emit machine instruction encodings by our machine +// code emitter. +class Format val> { + bits<2> Value = val; +} + +class SourceMode val> { + bits<2> Value = val; +} + +class DestMode { + bit Value = val; +} + +def PseudoFrm : Format<0>; +def SingleOpFrm : Format<1>; +def DoubleOpFrm : Format<2>; +def CondJumpFrm : Format<3>; + +def DstReg : DestMode<0>; +def DstMem : DestMode<1>; + +def SrcReg : SourceMode<0>; +def SrcMem : SourceMode<1>; +def SrcIndReg : SourceMode<2>; +def SrcPostInc : SourceMode<3>; +def SrcImm : SourceMode<3>; + // Generic MSP430 Format -class MSP430Inst : Instruction { +class MSP430Inst : Instruction { field bits<16> Inst; let Namespace = "MSP430"; @@ -20,38 +49,114 @@ dag OutOperandList = outs; dag InOperandList = ins; + Format Form = f; + bits<2> FormBits = Form.Value; + let AsmString = asmstr; } // FIXME: Create different classes for different addressing modes. // MSP430 Double Operand (Format I) Instructions -class IForm opcode, bit ad, bit bw, bits<2> as, +class IForm opcode, DestMode dest, bit bw, SourceMode src, dag outs, dag ins, string asmstr, list pattern> - : MSP430Inst { + : MSP430Inst { let Pattern = pattern; + + DestMode ad = dest; + SourceMode as = src; let Inst{12-15} = opcode; - let Inst{7} = ad; + let Inst{7} = ad.Value; let Inst{6} = bw; - let Inst{4-5} = as; + let Inst{4-5} = as.Value; } +// 8 bit IForm instructions +class IForm8 opcode, DestMode dest, SourceMode src, + dag outs, dag ins, string asmstr, list pattern> + : IForm; + +class I8rr opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm8; + +class I8ri opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm8; + +class I8rm opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm8; + +class I8mr opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm8; + +class I8mi opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm8; + +class I8mm opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm8; + +// 16 bit IForm instructions +class IForm16 opcode, DestMode dest, SourceMode src, + dag outs, dag ins, string asmstr, list pattern> + : IForm; + +class I16rr opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm16; + +class I16ri opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm16; + +class I16rm opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm16; + +class I16mr opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm16; + +class I16mi opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm16; + +class I16mm opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm16; + // MSP430 Single Operand (Format II) Instructions -class IIForm opcode, bit bw, bits<2> ad, +class IIForm opcode, bit bw, SourceMode src, dag outs, dag ins, string asmstr, list pattern> - : MSP430Inst { + : MSP430Inst { let Pattern = pattern; + SourceMode as = src; + let Inst{7-15} = opcode; let Inst{6} = bw; - let Inst{4-5} = ad; + let Inst{4-5} = as.Value; } +// 8 bit IIForm instructions +class IIForm8 opcode, SourceMode src, + dag outs, dag ins, string asmstr, list pattern> + : IIForm; + +// 16 bit IIForm instructions +class IIForm16 opcode, SourceMode src, + dag outs, dag ins, string asmstr, list pattern> + : IIForm; + // MSP430 Conditional Jumps Instructions class CJForm opcode, bits<3> cond, bit s, dag outs, dag ins, string asmstr, list pattern> - : MSP430Inst { + : MSP430Inst { let Pattern = pattern; let Inst{13-15} = opcode; @@ -61,7 +166,7 @@ // Pseudo instructions class Pseudo pattern> - : MSP430Inst { + : MSP430Inst { let Pattern = pattern; let Inst{15-0} = 0; } From asl at math.spbu.ru Fri Jan 15 15:18:02 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Fri, 15 Jan 2010 21:18:02 -0000 Subject: [llvm-commits] [llvm] r93551 - /llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Message-ID: <201001152118.o0FLI206032191@zion.cs.uiuc.edu> Author: asl Date: Fri Jan 15 15:18:02 2010 New Revision: 93551 URL: http://llvm.org/viewvc/llvm-project?rev=93551&view=rev Log: Add micro-optimization which allows us to fold imm into cmp. This allows us to save 1 word (sometimes) and reduce register pressure. Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=93551&r1=93550&r2=93551&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Fri Jan 15 15:18:02 2010 @@ -675,21 +675,53 @@ case ISD::SETULE: std::swap(LHS, RHS); // FALLTHROUGH case ISD::SETUGE: + // Turn lhs u>= rhs with lhs constant into rhs u< lhs+1, this allows us to + // fold constant into instruction. + if (const ConstantSDNode * C = dyn_cast(LHS)) { + LHS = RHS; + RHS = DAG.getConstant(C->getSExtValue() + 1, C->getValueType(0)); + TCC = MSP430CC::COND_LO; + break; + } TCC = MSP430CC::COND_HS; // aka COND_C break; case ISD::SETUGT: std::swap(LHS, RHS); // FALLTHROUGH case ISD::SETULT: + // Turn lhs u< rhs with lhs constant into rhs u>= lhs+1, this allows us to + // fold constant into instruction. + if (const ConstantSDNode * C = dyn_cast(LHS)) { + LHS = RHS; + RHS = DAG.getConstant(C->getSExtValue() + 1, C->getValueType(0)); + TCC = MSP430CC::COND_HS; + break; + } TCC = MSP430CC::COND_LO; // aka COND_NC break; case ISD::SETLE: std::swap(LHS, RHS); // FALLTHROUGH case ISD::SETGE: + // Turn lhs >= rhs with lhs constant into rhs < lhs+1, this allows us to + // fold constant into instruction. + if (const ConstantSDNode * C = dyn_cast(LHS)) { + LHS = RHS; + RHS = DAG.getConstant(C->getSExtValue() + 1, C->getValueType(0)); + TCC = MSP430CC::COND_L; + break; + } TCC = MSP430CC::COND_GE; break; case ISD::SETGT: std::swap(LHS, RHS); // FALLTHROUGH case ISD::SETLT: + // Turn lhs < rhs with lhs constant into rhs >= lhs+1, this allows us to + // fold constant into instruction. + if (const ConstantSDNode * C = dyn_cast(LHS)) { + LHS = RHS; + RHS = DAG.getConstant(C->getSExtValue() + 1, C->getValueType(0)); + TCC = MSP430CC::COND_GE; + break; + } TCC = MSP430CC::COND_L; break; } From asl at math.spbu.ru Fri Jan 15 15:18:18 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Fri, 15 Jan 2010 21:18:18 -0000 Subject: [llvm-commits] [llvm] r93552 - in /llvm/trunk/lib/Target/MSP430: MSP430ISelLowering.cpp MSP430InstrInfo.td Message-ID: <201001152118.o0FLIJLm032211@zion.cs.uiuc.edu> Author: asl Date: Fri Jan 15 15:18:18 2010 New Revision: 93552 URL: http://llvm.org/viewvc/llvm-project?rev=93552&view=rev Log: Enable bit tests and setcc stuff. Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=93552&r1=93551&r2=93552&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Fri Jan 15 15:18:18 2010 @@ -755,6 +755,8 @@ // If we are doing an AND and testing against zero, then the CMP // will not be generated. The AND (or BIT) will generate the condition codes, // but they are different from CMP. + // FIXME: since we're doing a post-processing, use a pseudoinstr here, so + // lowering & isel wouldn't diverge. bool andCC = false; if (ConstantSDNode *RHSC = dyn_cast(RHS)) { if (RHSC->isNullValue() && LHS.hasOneUse() && @@ -782,11 +784,11 @@ case MSP430CC::COND_HS: // Res = SRW & 1, no processing is required break; - case MSP430CC::COND_LO: + case MSP430CC::COND_LO: // Res = ~(SRW & 1) Invert = true; break; - case MSP430CC::COND_NE: + case MSP430CC::COND_NE: if (andCC) { // C = ~Z, thus Res = SRW & 1, no processing is required } else { @@ -794,7 +796,7 @@ Shift = true; } break; - case MSP430CC::COND_E: + case MSP430CC::COND_E: if (andCC) { // C = ~Z, thus Res = ~(SRW & 1) } else { @@ -808,7 +810,7 @@ SDValue One = DAG.getConstant(1, VT); if (Convert) { SDValue SR = DAG.getCopyFromReg(DAG.getEntryNode(), dl, MSP430::SRW, - MVT::i16, Flag); + MVT::i16, Flag); if (Shift) // FIXME: somewhere this is turned into a SRL, lower it MSP specific? SR = DAG.getNode(ISD::SRA, dl, MVT::i16, SR, One); Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td?rev=93552&r1=93551&r2=93552&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td Fri Jan 15 15:18:18 2010 @@ -861,58 +861,60 @@ let isCommutable = 1 in { def BIT8rr : Pseudo<(outs), (ins GR8:$src1, GR8:$src2), "bit.b\t{$src2, $src1}", - [(MSP430cmp 0, (and_su GR8:$src1, GR8:$src2)), + [(MSP430cmp (and_su GR8:$src1, GR8:$src2), 0), (implicit SRW)]>; def BIT16rr : Pseudo<(outs), (ins GR16:$src1, GR16:$src2), "bit.w\t{$src2, $src1}", - [(MSP430cmp 0, (and_su GR16:$src1, GR16:$src2)), + [(MSP430cmp (and_su GR16:$src1, GR16:$src2), 0), (implicit SRW)]>; } def BIT8ri : Pseudo<(outs), (ins GR8:$src1, i8imm:$src2), "bit.b\t{$src2, $src1}", - [(MSP430cmp 0, (and_su GR8:$src1, imm:$src2)), + [(MSP430cmp (and_su GR8:$src1, imm:$src2), 0), (implicit SRW)]>; def BIT16ri : Pseudo<(outs), (ins GR16:$src1, i16imm:$src2), "bit.w\t{$src2, $src1}", - [(MSP430cmp 0, (and_su GR16:$src1, imm:$src2)), + [(MSP430cmp (and_su GR16:$src1, imm:$src2), 0), (implicit SRW)]>; def BIT8rm : Pseudo<(outs), (ins GR8:$src1, memdst:$src2), "bit.b\t{$src2, $src1}", - [(MSP430cmp 0, (and_su GR8:$src1, (load addr:$src2))), + [(MSP430cmp (and_su GR8:$src1, (load addr:$src2)), 0), (implicit SRW)]>; def BIT16rm : Pseudo<(outs), (ins GR16:$src1, memdst:$src2), "bit.w\t{$src2, $src1}", - [(MSP430cmp 0, (and_su GR16:$src1, (load addr:$src2))), + [(MSP430cmp (and_su GR16:$src1, (load addr:$src2)), 0), (implicit SRW)]>; def BIT8mr : Pseudo<(outs), (ins memsrc:$src1, GR8:$src2), "bit.b\t{$src2, $src1}", - [(MSP430cmp 0, (and_su (load addr:$src1), GR8:$src2)), + [(MSP430cmp (and_su (load addr:$src1), GR8:$src2), 0), (implicit SRW)]>; def BIT16mr : Pseudo<(outs), (ins memsrc:$src1, GR16:$src2), "bit.w\t{$src2, $src1}", - [(MSP430cmp 0, (and_su (load addr:$src1), GR16:$src2)), + [(MSP430cmp (and_su (load addr:$src1), GR16:$src2), 0), (implicit SRW)]>; def BIT8mi : Pseudo<(outs), (ins memsrc:$src1, i8imm:$src2), "bit.b\t{$src2, $src1}", - [(MSP430cmp 0, (and_su (load addr:$src1), (i8 imm:$src2))), + [(MSP430cmp (and_su (load addr:$src1), (i8 imm:$src2)), 0), (implicit SRW)]>; def BIT16mi : Pseudo<(outs), (ins memsrc:$src1, i16imm:$src2), "bit.w\t{$src2, $src1}", - [(MSP430cmp 0, (and_su (load addr:$src1), (i16 imm:$src2))), + [(MSP430cmp (and_su (load addr:$src1), (i16 imm:$src2)), 0), (implicit SRW)]>; def BIT8mm : Pseudo<(outs), (ins memsrc:$src1, memsrc:$src2), "bit.b\t{$src2, $src1}", - [(MSP430cmp 0, (and_su (i8 (load addr:$src1)), - (load addr:$src2))), + [(MSP430cmp (and_su (i8 (load addr:$src1)), + (load addr:$src2)), + 0), (implicit SRW)]>; def BIT16mm : Pseudo<(outs), (ins memsrc:$src1, memsrc:$src2), "bit.w\t{$src2, $src1}", - [(MSP430cmp 0, (and_su (i16 (load addr:$src1)), - (load addr:$src2))), + [(MSP430cmp (and_su (i16 (load addr:$src1)), + (load addr:$src2)), + 0), (implicit SRW)]>; } // Defs = [SRW] @@ -923,7 +925,8 @@ def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>; // anyext -def : Pat<(anyext addr:$src), (MOVZX16rr8 GR8:$src)>; +def : Pat<(i16 (anyext GR8:$src)), + (SUBREG_TO_REG (i16 0), GR8:$src, subreg_8bit)>; // truncs def : Pat<(i8 (trunc GR16:$src)), @@ -996,6 +999,6 @@ // peephole patterns def : Pat<(and GR16:$src, 255), (ZEXT16r GR16:$src)>; -def : Pat<(MSP430cmp 0, (trunc (and_su GR16:$src1, GR16:$src2))), +def : Pat<(MSP430cmp (trunc (and_su GR16:$src1, GR16:$src2)), 0), (BIT8rr (EXTRACT_SUBREG GR16:$src1, subreg_8bit), (EXTRACT_SUBREG GR16:$src2, subreg_8bit))>; From asl at math.spbu.ru Fri Jan 15 15:18:40 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Fri, 15 Jan 2010 21:18:40 -0000 Subject: [llvm-commits] [llvm] r93553 - in /llvm/trunk/lib/Target/MSP430: MSP430.td MSP430InstrFormats.td MSP430InstrInfo.td Message-ID: <201001152118.o0FLIeWU032235@zion.cs.uiuc.edu> Author: asl Date: Fri Jan 15 15:18:39 2010 New Revision: 93553 URL: http://llvm.org/viewvc/llvm-project?rev=93553&view=rev Log: Provide instruction sizes & encoding. No opcodes yet (but not needed so far). Modified: llvm/trunk/lib/Target/MSP430/MSP430.td llvm/trunk/lib/Target/MSP430/MSP430InstrFormats.td llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td Modified: llvm/trunk/lib/Target/MSP430/MSP430.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430.td?rev=93553&r1=93552&r2=93553&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430.td (original) +++ llvm/trunk/lib/Target/MSP430/MSP430.td Fri Jan 15 15:18:39 2010 @@ -48,8 +48,14 @@ include "MSP430InstrInfo.td" -def MSP430InstrInfo : InstrInfo {} - +def MSP430InstrInfo : InstrInfo { + // Define how we want to layout our TargetSpecific information field... This + // should be kept up-to-date with the fields in the MSP430InstrInfo.h file. + let TSFlagsFields = ["FormBits", + "Size"]; + let TSFlagsShifts = [0, + 2]; +} def MSP430InstPrinter : AsmWriter { string AsmWriterClassName = "InstPrinter"; Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrFormats.td?rev=93553&r1=93552&r2=93553&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrFormats.td (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrFormats.td Fri Jan 15 15:18:39 2010 @@ -18,21 +18,14 @@ bits<2> Value = val; } -class SourceMode val> { - bits<2> Value = val; -} - -class DestMode { - bit Value = val; -} - def PseudoFrm : Format<0>; def SingleOpFrm : Format<1>; def DoubleOpFrm : Format<2>; def CondJumpFrm : Format<3>; -def DstReg : DestMode<0>; -def DstMem : DestMode<1>; +class SourceMode val> { + bits<2> Value = val; +} def SrcReg : SourceMode<0>; def SrcMem : SourceMode<1>; @@ -40,8 +33,26 @@ def SrcPostInc : SourceMode<3>; def SrcImm : SourceMode<3>; +class DestMode { + bit Value = val; +} + +def DstReg : DestMode<0>; +def DstMem : DestMode<1>; + +class SizeVal val> { + bits<3> Value = val; +} + +def SizeUnknown : SizeVal<0>; // Unknown / unset size +def SizeSpecial : SizeVal<1>; // Special instruction, e.g. pseudo +def Size2Bytes : SizeVal<2>; +def Size4Bytes : SizeVal<3>; +def Size6Bytes : SizeVal<4>; + // Generic MSP430 Format -class MSP430Inst : Instruction { +class MSP430Inst : Instruction { field bits<16> Inst; let Namespace = "MSP430"; @@ -52,19 +63,22 @@ Format Form = f; bits<2> FormBits = Form.Value; + SizeVal Sz = sz; + bits<3> Size = Sz.Value; + let AsmString = asmstr; } // FIXME: Create different classes for different addressing modes. // MSP430 Double Operand (Format I) Instructions -class IForm opcode, DestMode dest, bit bw, SourceMode src, +class IForm opcode, DestMode dest, bit bw, SourceMode src, SizeVal sz, dag outs, dag ins, string asmstr, list pattern> - : MSP430Inst { + : MSP430Inst { let Pattern = pattern; DestMode ad = dest; - SourceMode as = src; + SourceMode as = src; let Inst{12-15} = opcode; let Inst{7} = ad.Value; @@ -73,67 +87,67 @@ } // 8 bit IForm instructions -class IForm8 opcode, DestMode dest, SourceMode src, +class IForm8 opcode, DestMode dest, SourceMode src, SizeVal sz, dag outs, dag ins, string asmstr, list pattern> - : IForm; + : IForm; class I8rr opcode, dag outs, dag ins, string asmstr, list pattern> - : IForm8; + : IForm8; class I8ri opcode, dag outs, dag ins, string asmstr, list pattern> - : IForm8; + : IForm8; class I8rm opcode, dag outs, dag ins, string asmstr, list pattern> - : IForm8; + : IForm8; class I8mr opcode, dag outs, dag ins, string asmstr, list pattern> - : IForm8; + : IForm8; class I8mi opcode, dag outs, dag ins, string asmstr, list pattern> - : IForm8; + : IForm8; class I8mm opcode, dag outs, dag ins, string asmstr, list pattern> - : IForm8; + : IForm8; // 16 bit IForm instructions -class IForm16 opcode, DestMode dest, SourceMode src, +class IForm16 opcode, DestMode dest, SourceMode src, SizeVal sz, dag outs, dag ins, string asmstr, list pattern> - : IForm; + : IForm; class I16rr opcode, dag outs, dag ins, string asmstr, list pattern> - : IForm16; + : IForm16; class I16ri opcode, dag outs, dag ins, string asmstr, list pattern> - : IForm16; + : IForm16; class I16rm opcode, dag outs, dag ins, string asmstr, list pattern> - : IForm16; + : IForm16; class I16mr opcode, dag outs, dag ins, string asmstr, list pattern> - : IForm16; + : IForm16; class I16mi opcode, dag outs, dag ins, string asmstr, list pattern> - : IForm16; + : IForm16; class I16mm opcode, dag outs, dag ins, string asmstr, list pattern> - : IForm16; + : IForm16; // MSP430 Single Operand (Format II) Instructions -class IIForm opcode, bit bw, SourceMode src, +class IIForm opcode, bit bw, SourceMode src, SizeVal sz, dag outs, dag ins, string asmstr, list pattern> - : MSP430Inst { + : MSP430Inst { let Pattern = pattern; SourceMode as = src; @@ -144,29 +158,52 @@ } // 8 bit IIForm instructions -class IIForm8 opcode, SourceMode src, +class IIForm8 opcode, SourceMode src, SizeVal sz, dag outs, dag ins, string asmstr, list pattern> - : IIForm; + : IIForm; + +class II8r opcode, + dag outs, dag ins, string asmstr, list pattern> + : IIForm8; + +class II8m opcode, + dag outs, dag ins, string asmstr, list pattern> + : IIForm8; + +class II8i opcode, + dag outs, dag ins, string asmstr, list pattern> + : IIForm8; // 16 bit IIForm instructions -class IIForm16 opcode, SourceMode src, +class IIForm16 opcode, SourceMode src, SizeVal sz, dag outs, dag ins, string asmstr, list pattern> - : IIForm; + : IIForm; + +class II16r opcode, + dag outs, dag ins, string asmstr, list pattern> + : IIForm16; + +class II16m opcode, + dag outs, dag ins, string asmstr, list pattern> + : IIForm16; + +class II16i opcode, + dag outs, dag ins, string asmstr, list pattern> + : IIForm16; // MSP430 Conditional Jumps Instructions -class CJForm opcode, bits<3> cond, bit s, +class CJForm opcode, bits<3> cond, dag outs, dag ins, string asmstr, list pattern> - : MSP430Inst { + : MSP430Inst { let Pattern = pattern; let Inst{13-15} = opcode; let Inst{10-12} = cond; - let Inst{9} = s; } // Pseudo instructions class Pseudo pattern> - : MSP430Inst { + : MSP430Inst { let Pattern = pattern; let Inst{15-0} = 0; } Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td?rev=93553&r1=93552&r2=93553&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td Fri Jan 15 15:18:39 2010 @@ -157,23 +157,28 @@ // FIXME: Provide proper encoding! let isReturn = 1, isTerminator = 1, isBarrier = 1 in { - def RET : Pseudo<(outs), (ins), "ret", [(MSP430retflag)]>; - def RETI : Pseudo<(outs), (ins), "reti", [(MSP430retiflag)]>; + def RET : IForm16<0x0, DstReg, SrcPostInc, Size2Bytes, + (outs), (ins), "ret", [(MSP430retflag)]>; + def RETI : II16r<0x0, (outs), (ins), "reti", [(MSP430retiflag)]>; } let isBranch = 1, isTerminator = 1 in { +// FIXME: expand opcode & cond field for branches! + // Direct branch let isBarrier = 1 in - def JMP : Pseudo<(outs), (ins brtarget:$dst), + def JMP : CJForm<0, 0, + (outs), (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>; // Conditional branches let Uses = [SRW] in - def JCC : Pseudo<(outs), (ins brtarget:$dst, cc:$cc), - "j$cc\t$dst", - [(MSP430brcc bb:$dst, imm:$cc)]>; + def JCC : CJForm<0, 0, + (outs), (ins brtarget:$dst, cc:$cc), + "j$cc\t$dst", + [(MSP430brcc bb:$dst, imm:$cc)]>; } // isBranch, isTerminator //===----------------------------------------------------------------------===// @@ -186,12 +191,15 @@ // registers are added manually. let Defs = [R12W, R13W, R14W, R15W, SRW], Uses = [SPW] in { - def CALLi : Pseudo<(outs), (ins i16imm:$dst, variable_ops), - "call\t$dst", [(MSP430call imm:$dst)]>; - def CALLr : Pseudo<(outs), (ins GR16:$dst, variable_ops), - "call\t$dst", [(MSP430call GR16:$dst)]>; - def CALLm : Pseudo<(outs), (ins memsrc:$dst, variable_ops), - "call\t${dst:mem}", [(MSP430call (load addr:$dst))]>; + def CALLi : II16i<0x0, + (outs), (ins i16imm:$dst, variable_ops), + "call\t$dst", [(MSP430call imm:$dst)]>; + def CALLr : II16r<0x0, + (outs), (ins GR16:$dst, variable_ops), + "call\t$dst", [(MSP430call GR16:$dst)]>; + def CALLm : II16m<0x0, + (outs), (ins memsrc:$dst, variable_ops), + "call\t${dst:mem}", [(MSP430call (load addr:$dst))]>; } @@ -200,10 +208,12 @@ // let Defs = [SPW], Uses = [SPW], neverHasSideEffects=1 in { let mayLoad = 1 in -def POP16r : Pseudo<(outs GR16:$reg), (ins), "pop.w\t$reg", []>; +def POP16r : IForm16<0x0, DstReg, SrcPostInc, Size2Bytes, + (outs GR16:$reg), (ins), "pop.w\t$reg", []>; let mayStore = 1 in -def PUSH16r : Pseudo<(outs), (ins GR16:$reg), "push.w\t$reg",[]>; +def PUSH16r : II16r<0x0, + (outs), (ins GR16:$reg), "push.w\t$reg",[]>; } //===----------------------------------------------------------------------===// @@ -211,45 +221,55 @@ // FIXME: Provide proper encoding! let neverHasSideEffects = 1 in { -def MOV8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src), - "mov.b\t{$src, $dst}", - []>; -def MOV16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src), - "mov.w\t{$src, $dst}", - []>; +def MOV8rr : I8rr<0x0, + (outs GR8:$dst), (ins GR8:$src), + "mov.b\t{$src, $dst}", + []>; +def MOV16rr : I16rr<0x0, + (outs GR16:$dst), (ins GR16:$src), + "mov.w\t{$src, $dst}", + []>; } // FIXME: Provide proper encoding! let isReMaterializable = 1, isAsCheapAsAMove = 1 in { -def MOV8ri : Pseudo<(outs GR8:$dst), (ins i8imm:$src), - "mov.b\t{$src, $dst}", - [(set GR8:$dst, imm:$src)]>; -def MOV16ri : Pseudo<(outs GR16:$dst), (ins i16imm:$src), - "mov.w\t{$src, $dst}", - [(set GR16:$dst, imm:$src)]>; +def MOV8ri : I8ri<0x0, + (outs GR8:$dst), (ins i8imm:$src), + "mov.b\t{$src, $dst}", + [(set GR8:$dst, imm:$src)]>; +def MOV16ri : I16ri<0x0, + (outs GR16:$dst), (ins i16imm:$src), + "mov.w\t{$src, $dst}", + [(set GR16:$dst, imm:$src)]>; } let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in { -def MOV8rm : Pseudo<(outs GR8:$dst), (ins memsrc:$src), - "mov.b\t{$src, $dst}", - [(set GR8:$dst, (load addr:$src))]>; -def MOV16rm : Pseudo<(outs GR16:$dst), (ins memsrc:$src), - "mov.w\t{$src, $dst}", - [(set GR16:$dst, (load addr:$src))]>; -} - -def MOVZX16rr8 : Pseudo<(outs GR16:$dst), (ins GR8:$src), - "mov.b\t{$src, $dst}", - [(set GR16:$dst, (zext GR8:$src))]>; -def MOVZX16rm8 : Pseudo<(outs GR16:$dst), (ins memsrc:$src), - "mov.b\t{$src, $dst}", - [(set GR16:$dst, (zextloadi16i8 addr:$src))]>; +def MOV8rm : I8rm<0x0, + (outs GR8:$dst), (ins memsrc:$src), + "mov.b\t{$src, $dst}", + [(set GR8:$dst, (load addr:$src))]>; +def MOV16rm : I16rm<0x0, + (outs GR16:$dst), (ins memsrc:$src), + "mov.w\t{$src, $dst}", + [(set GR16:$dst, (load addr:$src))]>; +} + +def MOVZX16rr8 : I8rr<0x0, + (outs GR16:$dst), (ins GR8:$src), + "mov.b\t{$src, $dst}", + [(set GR16:$dst, (zext GR8:$src))]>; +def MOVZX16rm8 : I8rm<0x0, + (outs GR16:$dst), (ins memsrc:$src), + "mov.b\t{$src, $dst}", + [(set GR16:$dst, (zextloadi16i8 addr:$src))]>; let mayLoad = 1, hasExtraDefRegAllocReq = 1, Constraints = "$base = $base_wb" in { -def MOV8rm_POST : Pseudo<(outs GR8:$dst, GR16:$base_wb), (ins GR16:$base), - "mov.b\t{@$base+, $dst}", []>; -def MOV16rm_POST : Pseudo<(outs GR16:$dst, GR16:$base_wb), (ins GR16:$base), - "mov.w\t{@$base+, $dst}", []>; +def MOV8rm_POST : IForm8<0x0, DstReg, SrcPostInc, Size2Bytes, + (outs GR8:$dst, GR16:$base_wb), (ins GR16:$base), + "mov.b\t{@$base+, $dst}", []>; +def MOV16rm_POST : IForm16<0x0, DstReg, SrcPostInc, Size2Bytes, + (outs GR16:$dst, GR16:$base_wb), (ins GR16:$base), + "mov.w\t{@$base+, $dst}", []>; } // Any instruction that defines a 8-bit result leaves the high half of the @@ -267,27 +287,32 @@ def : Pat<(i16 (zext def8:$src)), (SUBREG_TO_REG (i16 0), GR8:$src, subreg_8bit)>; - -def MOV8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src), - "mov.b\t{$src, $dst}", - [(store (i8 imm:$src), addr:$dst)]>; -def MOV16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src), - "mov.w\t{$src, $dst}", - [(store (i16 imm:$src), addr:$dst)]>; - -def MOV8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src), - "mov.b\t{$src, $dst}", - [(store GR8:$src, addr:$dst)]>; -def MOV16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src), - "mov.w\t{$src, $dst}", - [(store GR16:$src, addr:$dst)]>; - -def MOV8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "mov.b\t{$src, $dst}", - [(store (i8 (load addr:$src)), addr:$dst)]>; -def MOV16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "mov.w\t{$src, $dst}", - [(store (i16 (load addr:$src)), addr:$dst)]>; +def MOV8mi : I8mi<0x0, + (outs), (ins memdst:$dst, i8imm:$src), + "mov.b\t{$src, $dst}", + [(store (i8 imm:$src), addr:$dst)]>; +def MOV16mi : I16mi<0x0, + (outs), (ins memdst:$dst, i16imm:$src), + "mov.w\t{$src, $dst}", + [(store (i16 imm:$src), addr:$dst)]>; + +def MOV8mr : I8mr<0x0, + (outs), (ins memdst:$dst, GR8:$src), + "mov.b\t{$src, $dst}", + [(store GR8:$src, addr:$dst)]>; +def MOV16mr : I16mr<0x0, + (outs), (ins memdst:$dst, GR16:$src), + "mov.w\t{$src, $dst}", + [(store GR16:$src, addr:$dst)]>; + +def MOV8mm : I8mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "mov.b\t{$src, $dst}", + [(store (i8 (load addr:$src)), addr:$dst)]>; +def MOV16mm : I16mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "mov.w\t{$src, $dst}", + [(store (i16 (load addr:$src)), addr:$dst)]>; //===----------------------------------------------------------------------===// // Arithmetic Instructions @@ -297,496 +322,624 @@ let Defs = [SRW] in { let isCommutable = 1 in { // X = ADD Y, Z == X = ADD Z, Y -// FIXME: Provide proper encoding! -def ADD8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2), - "add.b\t{$src2, $dst}", - [(set GR8:$dst, (add GR8:$src1, GR8:$src2)), - (implicit SRW)]>; -def ADD16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2), - "add.w\t{$src2, $dst}", - [(set GR16:$dst, (add GR16:$src1, GR16:$src2)), - (implicit SRW)]>; -} -def ADD8rm : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), - "add.b\t{$src2, $dst}", - [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))), - (implicit SRW)]>; -def ADD16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), - "add.w\t{$src2, $dst}", - [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))), - (implicit SRW)]>; +def ADD8rr : I8rr<0x0, + (outs GR8:$dst), (ins GR8:$src1, GR8:$src2), + "add.b\t{$src2, $dst}", + [(set GR8:$dst, (add GR8:$src1, GR8:$src2)), + (implicit SRW)]>; +def ADD16rr : I16rr<0x0, + (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), + "add.w\t{$src2, $dst}", + [(set GR16:$dst, (add GR16:$src1, GR16:$src2)), + (implicit SRW)]>; +} + +def ADD8rm : I8rm<0x0, + (outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), + "add.b\t{$src2, $dst}", + [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))), + (implicit SRW)]>; +def ADD16rm : I16rm<0x0, + (outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), + "add.w\t{$src2, $dst}", + [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))), + (implicit SRW)]>; let mayLoad = 1, hasExtraDefRegAllocReq = 1, Constraints = "$base = $base_wb, $src1 = $dst" in { -def ADD8rm_POST : Pseudo<(outs GR8:$dst, GR16:$base_wb), (ins GR8:$src1, GR16:$base), - "add.b\t{@$base+, $dst}", []>; -def ADD16rm_POST : Pseudo<(outs GR16:$dst, GR16:$base_wb), (ins GR16:$src1, GR16:$base), +def ADD8rm_POST : IForm8<0x0, DstReg, SrcPostInc, Size2Bytes, + (outs GR8:$dst, GR16:$base_wb), + (ins GR8:$src1, GR16:$base), + "add.b\t{@$base+, $dst}", []>; +def ADD16rm_POST : IForm16<0x0, DstReg, SrcPostInc, Size2Bytes, + (outs GR16:$dst, GR16:$base_wb), + (ins GR16:$src1, GR16:$base), "add.w\t{@$base+, $dst}", []>; } -def ADD8ri : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), - "add.b\t{$src2, $dst}", - [(set GR8:$dst, (add GR8:$src1, imm:$src2)), - (implicit SRW)]>; -def ADD16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), - "add.w\t{$src2, $dst}", - [(set GR16:$dst, (add GR16:$src1, imm:$src2)), - (implicit SRW)]>; +def ADD8ri : I8ri<0x0, + (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), + "add.b\t{$src2, $dst}", + [(set GR8:$dst, (add GR8:$src1, imm:$src2)), + (implicit SRW)]>; +def ADD16ri : I16ri<0x0, + (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), + "add.w\t{$src2, $dst}", + [(set GR16:$dst, (add GR16:$src1, imm:$src2)), + (implicit SRW)]>; let isTwoAddress = 0 in { -def ADD8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src), - "add.b\t{$src, $dst}", - [(store (add (load addr:$dst), GR8:$src), addr:$dst), - (implicit SRW)]>; -def ADD16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src), - "add.w\t{$src, $dst}", - [(store (add (load addr:$dst), GR16:$src), addr:$dst), - (implicit SRW)]>; - -def ADD8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src), - "add.b\t{$src, $dst}", - [(store (add (load addr:$dst), (i8 imm:$src)), addr:$dst), - (implicit SRW)]>; -def ADD16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src), - "add.w\t{$src, $dst}", - [(store (add (load addr:$dst), (i16 imm:$src)), addr:$dst), - (implicit SRW)]>; - -def ADD8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "add.b\t{$src, $dst}", - [(store (add (load addr:$dst), (i8 (load addr:$src))), addr:$dst), - (implicit SRW)]>; -def ADD16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "add.w\t{$src, $dst}", - [(store (add (load addr:$dst), (i16 (load addr:$src))), addr:$dst), - (implicit SRW)]>; +def ADD8mr : I8mr<0x0, + (outs), (ins memdst:$dst, GR8:$src), + "add.b\t{$src, $dst}", + [(store (add (load addr:$dst), GR8:$src), addr:$dst), + (implicit SRW)]>; +def ADD16mr : I16mr<0x0, + (outs), (ins memdst:$dst, GR16:$src), + "add.w\t{$src, $dst}", + [(store (add (load addr:$dst), GR16:$src), addr:$dst), + (implicit SRW)]>; + +def ADD8mi : I8mi<0x0, + (outs), (ins memdst:$dst, i8imm:$src), + "add.b\t{$src, $dst}", + [(store (add (load addr:$dst), (i8 imm:$src)), addr:$dst), + (implicit SRW)]>; +def ADD16mi : I16mi<0x0, + (outs), (ins memdst:$dst, i16imm:$src), + "add.w\t{$src, $dst}", + [(store (add (load addr:$dst), (i16 imm:$src)), addr:$dst), + (implicit SRW)]>; + +def ADD8mm : I8mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "add.b\t{$src, $dst}", + [(store (add (load addr:$dst), + (i8 (load addr:$src))), addr:$dst), + (implicit SRW)]>; +def ADD16mm : I16mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "add.w\t{$src, $dst}", + [(store (add (load addr:$dst), + (i16 (load addr:$src))), addr:$dst), + (implicit SRW)]>; } let Uses = [SRW] in { let isCommutable = 1 in { // X = ADDC Y, Z == X = ADDC Z, Y -def ADC8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2), - "addc.b\t{$src2, $dst}", - [(set GR8:$dst, (adde GR8:$src1, GR8:$src2)), - (implicit SRW)]>; -def ADC16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2), - "addc.w\t{$src2, $dst}", - [(set GR16:$dst, (adde GR16:$src1, GR16:$src2)), - (implicit SRW)]>; +def ADC8rr : I8rr<0x0, + (outs GR8:$dst), (ins GR8:$src1, GR8:$src2), + "addc.b\t{$src2, $dst}", + [(set GR8:$dst, (adde GR8:$src1, GR8:$src2)), + (implicit SRW)]>; +def ADC16rr : I16rr<0x0, + (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), + "addc.w\t{$src2, $dst}", + [(set GR16:$dst, (adde GR16:$src1, GR16:$src2)), + (implicit SRW)]>; } // isCommutable -def ADC8ri : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), - "addc.b\t{$src2, $dst}", - [(set GR8:$dst, (adde GR8:$src1, imm:$src2)), - (implicit SRW)]>; -def ADC16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), - "addc.w\t{$src2, $dst}", - [(set GR16:$dst, (adde GR16:$src1, imm:$src2)), - (implicit SRW)]>; - -def ADC8rm : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), - "addc.b\t{$src2, $dst}", - [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2))), - (implicit SRW)]>; -def ADC16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), - "addc.w\t{$src2, $dst}", - [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2))), - (implicit SRW)]>; +def ADC8ri : I8ri<0x0, + (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), + "addc.b\t{$src2, $dst}", + [(set GR8:$dst, (adde GR8:$src1, imm:$src2)), + (implicit SRW)]>; +def ADC16ri : I16ri<0x0, + (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), + "addc.w\t{$src2, $dst}", + [(set GR16:$dst, (adde GR16:$src1, imm:$src2)), + (implicit SRW)]>; + +def ADC8rm : I8rm<0x0, + (outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), + "addc.b\t{$src2, $dst}", + [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2))), + (implicit SRW)]>; +def ADC16rm : I16rm<0x0, + (outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), + "addc.w\t{$src2, $dst}", + [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2))), + (implicit SRW)]>; let isTwoAddress = 0 in { -def ADC8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src), - "addc.b\t{$src, $dst}", - [(store (adde (load addr:$dst), GR8:$src), addr:$dst), - (implicit SRW)]>; -def ADC16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src), - "addc.w\t{$src, $dst}", - [(store (adde (load addr:$dst), GR16:$src), addr:$dst), - (implicit SRW)]>; - -def ADC8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src), - "addc.b\t{$src, $dst}", - [(store (adde (load addr:$dst), (i8 imm:$src)), addr:$dst), - (implicit SRW)]>; -def ADC16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src), - "addc.w\t{$src, $dst}", - [(store (adde (load addr:$dst), (i16 imm:$src)), addr:$dst), - (implicit SRW)]>; - -def ADC8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "addc.b\t{$src, $dst}", - [(store (adde (load addr:$dst), (i8 (load addr:$src))), addr:$dst), - (implicit SRW)]>; -def ADC16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "addc.w\t{$src, $dst}", - [(store (adde (load addr:$dst), (i16 (load addr:$src))), addr:$dst), - (implicit SRW)]>; +def ADC8mr : I8mr<0x0, + (outs), (ins memdst:$dst, GR8:$src), + "addc.b\t{$src, $dst}", + [(store (adde (load addr:$dst), GR8:$src), addr:$dst), + (implicit SRW)]>; +def ADC16mr : I16mr<0x0, + (outs), (ins memdst:$dst, GR16:$src), + "addc.w\t{$src, $dst}", + [(store (adde (load addr:$dst), GR16:$src), addr:$dst), + (implicit SRW)]>; + +def ADC8mi : I8mi<0x0, + (outs), (ins memdst:$dst, i8imm:$src), + "addc.b\t{$src, $dst}", + [(store (adde (load addr:$dst), (i8 imm:$src)), addr:$dst), + (implicit SRW)]>; +def ADC16mi : I16mi<0x0, + (outs), (ins memdst:$dst, i16imm:$src), + "addc.w\t{$src, $dst}", + [(store (adde (load addr:$dst), (i16 imm:$src)), addr:$dst), + (implicit SRW)]>; + +def ADC8mm : I8mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "addc.b\t{$src, $dst}", + [(store (adde (load addr:$dst), + (i8 (load addr:$src))), addr:$dst), + (implicit SRW)]>; +def ADC16mm : I8mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "addc.w\t{$src, $dst}", + [(store (adde (load addr:$dst), + (i16 (load addr:$src))), addr:$dst), + (implicit SRW)]>; } } // Uses = [SRW] let isCommutable = 1 in { // X = AND Y, Z == X = AND Z, Y -def AND8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2), - "and.b\t{$src2, $dst}", - [(set GR8:$dst, (and GR8:$src1, GR8:$src2)), - (implicit SRW)]>; -def AND16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2), - "and.w\t{$src2, $dst}", - [(set GR16:$dst, (and GR16:$src1, GR16:$src2)), - (implicit SRW)]>; -} - -def AND8ri : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), - "and.b\t{$src2, $dst}", - [(set GR8:$dst, (and GR8:$src1, imm:$src2)), - (implicit SRW)]>; -def AND16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), - "and.w\t{$src2, $dst}", - [(set GR16:$dst, (and GR16:$src1, imm:$src2)), - (implicit SRW)]>; - -def AND8rm : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), - "and.b\t{$src2, $dst}", - [(set GR8:$dst, (and GR8:$src1, (load addr:$src2))), - (implicit SRW)]>; -def AND16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), - "and.w\t{$src2, $dst}", - [(set GR16:$dst, (and GR16:$src1, (load addr:$src2))), - (implicit SRW)]>; +def AND8rr : I8rr<0x0, + (outs GR8:$dst), (ins GR8:$src1, GR8:$src2), + "and.b\t{$src2, $dst}", + [(set GR8:$dst, (and GR8:$src1, GR8:$src2)), + (implicit SRW)]>; +def AND16rr : I16rr<0x0, + (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), + "and.w\t{$src2, $dst}", + [(set GR16:$dst, (and GR16:$src1, GR16:$src2)), + (implicit SRW)]>; +} + +def AND8ri : I8ri<0x0, + (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), + "and.b\t{$src2, $dst}", + [(set GR8:$dst, (and GR8:$src1, imm:$src2)), + (implicit SRW)]>; +def AND16ri : I16ri<0x0, + (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), + "and.w\t{$src2, $dst}", + [(set GR16:$dst, (and GR16:$src1, imm:$src2)), + (implicit SRW)]>; + +def AND8rm : I8rm<0x0, + (outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), + "and.b\t{$src2, $dst}", + [(set GR8:$dst, (and GR8:$src1, (load addr:$src2))), + (implicit SRW)]>; +def AND16rm : I16rm<0x0, + (outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), + "and.w\t{$src2, $dst}", + [(set GR16:$dst, (and GR16:$src1, (load addr:$src2))), + (implicit SRW)]>; let mayLoad = 1, hasExtraDefRegAllocReq = 1, Constraints = "$base = $base_wb, $src1 = $dst" in { -def AND8rm_POST : Pseudo<(outs GR8:$dst, GR16:$base_wb), (ins GR8:$src1, GR16:$base), - "and.b\t{@$base+, $dst}", []>; -def AND16rm_POST : Pseudo<(outs GR16:$dst, GR16:$base_wb), (ins GR16:$src1, GR16:$base), - "and.w\t{@$base+, $dst}", []>; +def AND8rm_POST : IForm8<0x0, DstReg, SrcPostInc, Size2Bytes, + (outs GR8:$dst, GR16:$base_wb), + (ins GR8:$src1, GR16:$base), + "and.b\t{@$base+, $dst}", []>; +def AND16rm_POST : IForm16<0x0, DstReg, SrcPostInc, Size2Bytes, + (outs GR16:$dst, GR16:$base_wb), + (ins GR16:$src1, GR16:$base), + "and.w\t{@$base+, $dst}", []>; } let isTwoAddress = 0 in { -def AND8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src), - "and.b\t{$src, $dst}", - [(store (and (load addr:$dst), GR8:$src), addr:$dst), - (implicit SRW)]>; -def AND16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src), - "and.w\t{$src, $dst}", - [(store (and (load addr:$dst), GR16:$src), addr:$dst), - (implicit SRW)]>; - -def AND8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src), - "and.b\t{$src, $dst}", - [(store (and (load addr:$dst), (i8 imm:$src)), addr:$dst), - (implicit SRW)]>; -def AND16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src), - "and.w\t{$src, $dst}", - [(store (and (load addr:$dst), (i16 imm:$src)), addr:$dst), - (implicit SRW)]>; - -def AND8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "and.b\t{$src, $dst}", - [(store (and (load addr:$dst), (i8 (load addr:$src))), addr:$dst), - (implicit SRW)]>; -def AND16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "and.w\t{$src, $dst}", - [(store (and (load addr:$dst), (i16 (load addr:$src))), addr:$dst), - (implicit SRW)]>; +def AND8mr : I8mr<0x0, + (outs), (ins memdst:$dst, GR8:$src), + "and.b\t{$src, $dst}", + [(store (and (load addr:$dst), GR8:$src), addr:$dst), + (implicit SRW)]>; +def AND16mr : I16mr<0x0, + (outs), (ins memdst:$dst, GR16:$src), + "and.w\t{$src, $dst}", + [(store (and (load addr:$dst), GR16:$src), addr:$dst), + (implicit SRW)]>; + +def AND8mi : I8mi<0x0, + (outs), (ins memdst:$dst, i8imm:$src), + "and.b\t{$src, $dst}", + [(store (and (load addr:$dst), (i8 imm:$src)), addr:$dst), + (implicit SRW)]>; +def AND16mi : I16mi<0x0, + (outs), (ins memdst:$dst, i16imm:$src), + "and.w\t{$src, $dst}", + [(store (and (load addr:$dst), (i16 imm:$src)), addr:$dst), + (implicit SRW)]>; + +def AND8mm : I8mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "and.b\t{$src, $dst}", + [(store (and (load addr:$dst), + (i8 (load addr:$src))), addr:$dst), + (implicit SRW)]>; +def AND16mm : I16mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "and.w\t{$src, $dst}", + [(store (and (load addr:$dst), + (i16 (load addr:$src))), addr:$dst), + (implicit SRW)]>; } let isCommutable = 1 in { // X = OR Y, Z == X = OR Z, Y -def OR8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2), - "bis.b\t{$src2, $dst}", - [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>; -def OR16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2), - "bis.w\t{$src2, $dst}", - [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>; -} - -def OR8ri : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), - "bis.b\t{$src2, $dst}", - [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>; -def OR16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), - "bis.w\t{$src2, $dst}", - [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>; - -def OR8rm : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), - "bis.b\t{$src2, $dst}", - [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>; -def OR16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), - "bis.w\t{$src2, $dst}", - [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>; +def OR8rr : I8rr<0x0, + (outs GR8:$dst), (ins GR8:$src1, GR8:$src2), + "bis.b\t{$src2, $dst}", + [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>; +def OR16rr : I16rr<0x0, + (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), + "bis.w\t{$src2, $dst}", + [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>; +} + +def OR8ri : I8ri<0x0, + (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), + "bis.b\t{$src2, $dst}", + [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>; +def OR16ri : I16ri<0x0, + (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), + "bis.w\t{$src2, $dst}", + [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>; + +def OR8rm : I8rm<0x0, + (outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), + "bis.b\t{$src2, $dst}", + [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>; +def OR16rm : I16rm<0x0, + (outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), + "bis.w\t{$src2, $dst}", + [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>; let mayLoad = 1, hasExtraDefRegAllocReq = 1, Constraints = "$base = $base_wb, $src1 = $dst" in { -def OR8rm_POST : Pseudo<(outs GR8:$dst, GR16:$base_wb), (ins GR8:$src1, GR16:$base), +def OR8rm_POST : IForm8<0x0, DstReg, SrcPostInc, Size2Bytes, + (outs GR8:$dst, GR16:$base_wb), + (ins GR8:$src1, GR16:$base), "bis.b\t{@$base+, $dst}", []>; -def OR16rm_POST : Pseudo<(outs GR16:$dst, GR16:$base_wb), (ins GR16:$src1, GR16:$base), - "bis.w\t{@$base+, $dst}", []>; +def OR16rm_POST : IForm16<0x0, DstReg, SrcPostInc, Size2Bytes, + (outs GR16:$dst, GR16:$base_wb), + (ins GR16:$src1, GR16:$base), + "bis.w\t{@$base+, $dst}", []>; } let isTwoAddress = 0 in { -def OR8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src), - "bis.b\t{$src, $dst}", - [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>; -def OR16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src), - "bis.w\t{$src, $dst}", - [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>; - -def OR8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src), - "bis.b\t{$src, $dst}", - [(store (or (load addr:$dst), (i8 imm:$src)), addr:$dst)]>; -def OR16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src), - "bis.w\t{$src, $dst}", - [(store (or (load addr:$dst), (i16 imm:$src)), addr:$dst)]>; - -def OR8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "bis.b\t{$src, $dst}", - [(store (or (i8 (load addr:$dst)), - (i8 (load addr:$src))), addr:$dst)]>; -def OR16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "bis.w\t{$src, $dst}", - [(store (or (i16 (load addr:$dst)), - (i16 (load addr:$src))), addr:$dst)]>; +def OR8mr : I8mr<0x0, + (outs), (ins memdst:$dst, GR8:$src), + "bis.b\t{$src, $dst}", + [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>; +def OR16mr : I16mr<0x0, + (outs), (ins memdst:$dst, GR16:$src), + "bis.w\t{$src, $dst}", + [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>; + +def OR8mi : I8mi<0x0, + (outs), (ins memdst:$dst, i8imm:$src), + "bis.b\t{$src, $dst}", + [(store (or (load addr:$dst), (i8 imm:$src)), addr:$dst)]>; +def OR16mi : I16mi<0x0, + (outs), (ins memdst:$dst, i16imm:$src), + "bis.w\t{$src, $dst}", + [(store (or (load addr:$dst), (i16 imm:$src)), addr:$dst)]>; + +def OR8mm : I8mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "bis.b\t{$src, $dst}", + [(store (or (i8 (load addr:$dst)), + (i8 (load addr:$src))), addr:$dst)]>; +def OR16mm : I16mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "bis.w\t{$src, $dst}", + [(store (or (i16 (load addr:$dst)), + (i16 (load addr:$src))), addr:$dst)]>; } // bic does not modify condition codes -def BIC8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2), - "bic.b\t{$src2, $dst}", - [(set GR8:$dst, (and GR8:$src1, (not GR8:$src2)))]>; -def BIC16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2), - "bic.w\t{$src2, $dst}", - [(set GR16:$dst, (and GR16:$src1, (not GR16:$src2)))]>; - -def BIC8rm : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), - "bic.b\t{$src2, $dst}", - [(set GR8:$dst, (and GR8:$src1, (not (i8 (load addr:$src2)))))]>; -def BIC16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), - "bic.w\t{$src2, $dst}", - [(set GR16:$dst, (and GR16:$src1, (not (i16 (load addr:$src2)))))]>; +def BIC8rr : I8rr<0x0, + (outs GR8:$dst), (ins GR8:$src1, GR8:$src2), + "bic.b\t{$src2, $dst}", + [(set GR8:$dst, (and GR8:$src1, (not GR8:$src2)))]>; +def BIC16rr : I16rr<0x0, + (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), + "bic.w\t{$src2, $dst}", + [(set GR16:$dst, (and GR16:$src1, (not GR16:$src2)))]>; + +def BIC8rm : I8rm<0x0, + (outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), + "bic.b\t{$src2, $dst}", + [(set GR8:$dst, (and GR8:$src1, (not (i8 (load addr:$src2)))))]>; +def BIC16rm : I16rm<0x0, + (outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), + "bic.w\t{$src2, $dst}", + [(set GR16:$dst, (and GR16:$src1, (not (i16 (load addr:$src2)))))]>; let isTwoAddress = 0 in { -def BIC8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src), - "bic.b\t{$src, $dst}", - [(store (and (load addr:$dst), (not GR8:$src)), addr:$dst)]>; -def BIC16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src), - "bic.w\t{$src, $dst}", - [(store (and (load addr:$dst), (not GR16:$src)), addr:$dst)]>; - -def BIC8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "bic.b\t{$src, $dst}", - [(store (and (load addr:$dst), (not (i8 (load addr:$src)))), addr:$dst)]>; -def BIC16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "bic.w\t{$src, $dst}", - [(store (and (load addr:$dst), (not (i16 (load addr:$src)))), addr:$dst)]>; +def BIC8mr : I8mr<0x0, + (outs), (ins memdst:$dst, GR8:$src), + "bic.b\t{$src, $dst}", + [(store (and (load addr:$dst), (not GR8:$src)), addr:$dst)]>; +def BIC16mr : I16mr<0x0, + (outs), (ins memdst:$dst, GR16:$src), + "bic.w\t{$src, $dst}", + [(store (and (load addr:$dst), (not GR16:$src)), addr:$dst)]>; + +def BIC8mm : I8mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "bic.b\t{$src, $dst}", + [(store (and (load addr:$dst), + (not (i8 (load addr:$src)))), addr:$dst)]>; +def BIC16mm : I16mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "bic.w\t{$src, $dst}", + [(store (and (load addr:$dst), + (not (i16 (load addr:$src)))), addr:$dst)]>; } let isCommutable = 1 in { // X = XOR Y, Z == X = XOR Z, Y -def XOR8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2), - "xor.b\t{$src2, $dst}", - [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)), - (implicit SRW)]>; -def XOR16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2), - "xor.w\t{$src2, $dst}", - [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)), - (implicit SRW)]>; -} - -def XOR8ri : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), - "xor.b\t{$src2, $dst}", - [(set GR8:$dst, (xor GR8:$src1, imm:$src2)), - (implicit SRW)]>; -def XOR16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), - "xor.w\t{$src2, $dst}", - [(set GR16:$dst, (xor GR16:$src1, imm:$src2)), - (implicit SRW)]>; - -def XOR8rm : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), - "xor.b\t{$src2, $dst}", - [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))), - (implicit SRW)]>; -def XOR16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), - "xor.w\t{$src2, $dst}", - [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))), - (implicit SRW)]>; +def XOR8rr : I8rr<0x0, + (outs GR8:$dst), (ins GR8:$src1, GR8:$src2), + "xor.b\t{$src2, $dst}", + [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)), + (implicit SRW)]>; +def XOR16rr : I16rr<0x0, + (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), + "xor.w\t{$src2, $dst}", + [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)), + (implicit SRW)]>; +} + +def XOR8ri : I8ri<0x0, + (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), + "xor.b\t{$src2, $dst}", + [(set GR8:$dst, (xor GR8:$src1, imm:$src2)), + (implicit SRW)]>; +def XOR16ri : I16ri<0x0, + (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), + "xor.w\t{$src2, $dst}", + [(set GR16:$dst, (xor GR16:$src1, imm:$src2)), + (implicit SRW)]>; + +def XOR8rm : I8rm<0x0, + (outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), + "xor.b\t{$src2, $dst}", + [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))), + (implicit SRW)]>; +def XOR16rm : I16rm<0x0, + (outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), + "xor.w\t{$src2, $dst}", + [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))), + (implicit SRW)]>; let mayLoad = 1, hasExtraDefRegAllocReq = 1, Constraints = "$base = $base_wb, $src1 = $dst" in { -def XOR8rm_POST : Pseudo<(outs GR8:$dst, GR16:$base_wb), (ins GR8:$src1, GR16:$base), - "xor.b\t{@$base+, $dst}", []>; -def XOR16rm_POST : Pseudo<(outs GR16:$dst, GR16:$base_wb), (ins GR16:$src1, GR16:$base), - "xor.w\t{@$base+, $dst}", []>; +def XOR8rm_POST : IForm8<0x0, DstReg, SrcPostInc, Size2Bytes, + (outs GR8:$dst, GR16:$base_wb), + (ins GR8:$src1, GR16:$base), + "xor.b\t{@$base+, $dst}", []>; +def XOR16rm_POST : IForm16<0x0, DstReg, SrcPostInc, Size2Bytes, + (outs GR16:$dst, GR16:$base_wb), + (ins GR16:$src1, GR16:$base), + "xor.w\t{@$base+, $dst}", []>; } let isTwoAddress = 0 in { -def XOR8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src), - "xor.b\t{$src, $dst}", - [(store (xor (load addr:$dst), GR8:$src), addr:$dst), - (implicit SRW)]>; -def XOR16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src), - "xor.w\t{$src, $dst}", - [(store (xor (load addr:$dst), GR16:$src), addr:$dst), - (implicit SRW)]>; - -def XOR8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src), - "xor.b\t{$src, $dst}", - [(store (xor (load addr:$dst), (i8 imm:$src)), addr:$dst), - (implicit SRW)]>; -def XOR16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src), - "xor.w\t{$src, $dst}", - [(store (xor (load addr:$dst), (i16 imm:$src)), addr:$dst), - (implicit SRW)]>; - -def XOR8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "xor.b\t{$src, $dst}", - [(store (xor (load addr:$dst), (i8 (load addr:$src))), addr:$dst), - (implicit SRW)]>; -def XOR16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "xor.w\t{$src, $dst}", - [(store (xor (load addr:$dst), (i16 (load addr:$src))), addr:$dst), - (implicit SRW)]>; -} - - -def SUB8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2), - "sub.b\t{$src2, $dst}", - [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)), - (implicit SRW)]>; -def SUB16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2), - "sub.w\t{$src2, $dst}", - [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)), - (implicit SRW)]>; - -def SUB8ri : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), - "sub.b\t{$src2, $dst}", - [(set GR8:$dst, (sub GR8:$src1, imm:$src2)), - (implicit SRW)]>; -def SUB16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), - "sub.w\t{$src2, $dst}", - [(set GR16:$dst, (sub GR16:$src1, imm:$src2)), - (implicit SRW)]>; - -def SUB8rm : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), - "sub.b\t{$src2, $dst}", - [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))), - (implicit SRW)]>; -def SUB16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), - "sub.w\t{$src2, $dst}", - [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))), - (implicit SRW)]>; +def XOR8mr : I8mr<0x0, + (outs), (ins memdst:$dst, GR8:$src), + "xor.b\t{$src, $dst}", + [(store (xor (load addr:$dst), GR8:$src), addr:$dst), + (implicit SRW)]>; +def XOR16mr : I16mr<0x0, + (outs), (ins memdst:$dst, GR16:$src), + "xor.w\t{$src, $dst}", + [(store (xor (load addr:$dst), GR16:$src), addr:$dst), + (implicit SRW)]>; + +def XOR8mi : I8mi<0x0, + (outs), (ins memdst:$dst, i8imm:$src), + "xor.b\t{$src, $dst}", + [(store (xor (load addr:$dst), (i8 imm:$src)), addr:$dst), + (implicit SRW)]>; +def XOR16mi : I16mi<0x0, + (outs), (ins memdst:$dst, i16imm:$src), + "xor.w\t{$src, $dst}", + [(store (xor (load addr:$dst), (i16 imm:$src)), addr:$dst), + (implicit SRW)]>; + +def XOR8mm : I8mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "xor.b\t{$src, $dst}", + [(store (xor (load addr:$dst), (i8 (load addr:$src))), addr:$dst), + (implicit SRW)]>; +def XOR16mm : I16mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "xor.w\t{$src, $dst}", + [(store (xor (load addr:$dst), (i16 (load addr:$src))), addr:$dst), + (implicit SRW)]>; +} + + +def SUB8rr : I8rr<0x0, + (outs GR8:$dst), (ins GR8:$src1, GR8:$src2), + "sub.b\t{$src2, $dst}", + [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)), + (implicit SRW)]>; +def SUB16rr : I16rr<0x0, + (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), + "sub.w\t{$src2, $dst}", + [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)), + (implicit SRW)]>; + +def SUB8ri : I8ri<0x0, + (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), + "sub.b\t{$src2, $dst}", + [(set GR8:$dst, (sub GR8:$src1, imm:$src2)), + (implicit SRW)]>; +def SUB16ri : I16ri<0x0, + (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), + "sub.w\t{$src2, $dst}", + [(set GR16:$dst, (sub GR16:$src1, imm:$src2)), + (implicit SRW)]>; + +def SUB8rm : I8rm<0x0, + (outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), + "sub.b\t{$src2, $dst}", + [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))), + (implicit SRW)]>; +def SUB16rm : I16rm<0x0, + (outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), + "sub.w\t{$src2, $dst}", + [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))), + (implicit SRW)]>; let mayLoad = 1, hasExtraDefRegAllocReq = 1, Constraints = "$base = $base_wb, $src1 = $dst" in { -def SUB8rm_POST : Pseudo<(outs GR8:$dst, GR16:$base_wb), (ins GR8:$src1, GR16:$base), - "sub.b\t{@$base+, $dst}", []>; -def SUB16rm_POST : Pseudo<(outs GR16:$dst, GR16:$base_wb), (ins GR16:$src1, GR16:$base), +def SUB8rm_POST : IForm8<0x0, DstReg, SrcPostInc, Size2Bytes, + (outs GR8:$dst, GR16:$base_wb), + (ins GR8:$src1, GR16:$base), + "sub.b\t{@$base+, $dst}", []>; +def SUB16rm_POST : IForm16<0x0, DstReg, SrcPostInc, Size2Bytes, + (outs GR16:$dst, GR16:$base_wb), + (ins GR16:$src1, GR16:$base), "sub.w\t{@$base+, $dst}", []>; } let isTwoAddress = 0 in { -def SUB8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src), - "sub.b\t{$src, $dst}", - [(store (sub (load addr:$dst), GR8:$src), addr:$dst), - (implicit SRW)]>; -def SUB16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src), - "sub.w\t{$src, $dst}", - [(store (sub (load addr:$dst), GR16:$src), addr:$dst), - (implicit SRW)]>; - -def SUB8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src), - "sub.b\t{$src, $dst}", - [(store (sub (load addr:$dst), (i8 imm:$src)), addr:$dst), - (implicit SRW)]>; -def SUB16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src), - "sub.w\t{$src, $dst}", - [(store (sub (load addr:$dst), (i16 imm:$src)), addr:$dst), - (implicit SRW)]>; - -def SUB8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "sub.b\t{$src, $dst}", - [(store (sub (load addr:$dst), (i8 (load addr:$src))), addr:$dst), - (implicit SRW)]>; -def SUB16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "sub.w\t{$src, $dst}", - [(store (sub (load addr:$dst), (i16 (load addr:$src))), addr:$dst), - (implicit SRW)]>; +def SUB8mr : I8mr<0x0, + (outs), (ins memdst:$dst, GR8:$src), + "sub.b\t{$src, $dst}", + [(store (sub (load addr:$dst), GR8:$src), addr:$dst), + (implicit SRW)]>; +def SUB16mr : I16mr<0x0, + (outs), (ins memdst:$dst, GR16:$src), + "sub.w\t{$src, $dst}", + [(store (sub (load addr:$dst), GR16:$src), addr:$dst), + (implicit SRW)]>; + +def SUB8mi : I8mi<0x0, + (outs), (ins memdst:$dst, i8imm:$src), + "sub.b\t{$src, $dst}", + [(store (sub (load addr:$dst), (i8 imm:$src)), addr:$dst), + (implicit SRW)]>; +def SUB16mi : I16mi<0x0, + (outs), (ins memdst:$dst, i16imm:$src), + "sub.w\t{$src, $dst}", + [(store (sub (load addr:$dst), (i16 imm:$src)), addr:$dst), + (implicit SRW)]>; + +def SUB8mm : I8mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "sub.b\t{$src, $dst}", + [(store (sub (load addr:$dst), + (i8 (load addr:$src))), addr:$dst), + (implicit SRW)]>; +def SUB16mm : I16mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "sub.w\t{$src, $dst}", + [(store (sub (load addr:$dst), + (i16 (load addr:$src))), addr:$dst), + (implicit SRW)]>; } let Uses = [SRW] in { -def SBC8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2), - "subc.b\t{$src2, $dst}", - [(set GR8:$dst, (sube GR8:$src1, GR8:$src2)), - (implicit SRW)]>; -def SBC16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2), - "subc.w\t{$src2, $dst}", - [(set GR16:$dst, (sube GR16:$src1, GR16:$src2)), - (implicit SRW)]>; - -def SBC8ri : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), - "subc.b\t{$src2, $dst}", - [(set GR8:$dst, (sube GR8:$src1, imm:$src2)), - (implicit SRW)]>; -def SBC16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), - "subc.w\t{$src2, $dst}", - [(set GR16:$dst, (sube GR16:$src1, imm:$src2)), - (implicit SRW)]>; - -def SBC8rm : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), - "subc.b\t{$src2, $dst}", - [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2))), - (implicit SRW)]>; -def SBC16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), - "subc.w\t{$src2, $dst}", - [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2))), - (implicit SRW)]>; +def SBC8rr : I8rr<0x0, + (outs GR8:$dst), (ins GR8:$src1, GR8:$src2), + "subc.b\t{$src2, $dst}", + [(set GR8:$dst, (sube GR8:$src1, GR8:$src2)), + (implicit SRW)]>; +def SBC16rr : I16rr<0x0, + (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), + "subc.w\t{$src2, $dst}", + [(set GR16:$dst, (sube GR16:$src1, GR16:$src2)), + (implicit SRW)]>; + +def SBC8ri : I8ri<0x0, + (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), + "subc.b\t{$src2, $dst}", + [(set GR8:$dst, (sube GR8:$src1, imm:$src2)), + (implicit SRW)]>; +def SBC16ri : I16ri<0x0, + (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), + "subc.w\t{$src2, $dst}", + [(set GR16:$dst, (sube GR16:$src1, imm:$src2)), + (implicit SRW)]>; + +def SBC8rm : I8rm<0x0, + (outs GR8:$dst), (ins GR8:$src1, memsrc:$src2), + "subc.b\t{$src2, $dst}", + [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2))), + (implicit SRW)]>; +def SBC16rm : I16rm<0x0, + (outs GR16:$dst), (ins GR16:$src1, memsrc:$src2), + "subc.w\t{$src2, $dst}", + [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2))), + (implicit SRW)]>; let isTwoAddress = 0 in { -def SBC8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src), - "subc.b\t{$src, $dst}", - [(store (sube (load addr:$dst), GR8:$src), addr:$dst), - (implicit SRW)]>; -def SBC16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src), - "subc.w\t{$src, $dst}", - [(store (sube (load addr:$dst), GR16:$src), addr:$dst), - (implicit SRW)]>; - -def SBC8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src), - "subc.b\t{$src, $dst}", - [(store (sube (load addr:$dst), (i8 imm:$src)), addr:$dst), - (implicit SRW)]>; -def SBC16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src), - "subc.w\t{$src, $dst}", - [(store (sube (load addr:$dst), (i16 imm:$src)), addr:$dst), - (implicit SRW)]>; - -def SBC8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "subc.b\t{$src, $dst}", - [(store (sube (load addr:$dst), (i8 (load addr:$src))), addr:$dst), - (implicit SRW)]>; -def SBC16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), - "subc.w\t{$src, $dst}", - [(store (sube (load addr:$dst), (i16 (load addr:$src))), addr:$dst), - (implicit SRW)]>; +def SBC8mr : I8mr<0x0, + (outs), (ins memdst:$dst, GR8:$src), + "subc.b\t{$src, $dst}", + [(store (sube (load addr:$dst), GR8:$src), addr:$dst), + (implicit SRW)]>; +def SBC16mr : I16mr<0x0, + (outs), (ins memdst:$dst, GR16:$src), + "subc.w\t{$src, $dst}", + [(store (sube (load addr:$dst), GR16:$src), addr:$dst), + (implicit SRW)]>; + +def SBC8mi : I8mi<0x0, + (outs), (ins memdst:$dst, i8imm:$src), + "subc.b\t{$src, $dst}", + [(store (sube (load addr:$dst), (i8 imm:$src)), addr:$dst), + (implicit SRW)]>; +def SBC16mi : I16mi<0x0, + (outs), (ins memdst:$dst, i16imm:$src), + "subc.w\t{$src, $dst}", + [(store (sube (load addr:$dst), (i16 imm:$src)), addr:$dst), + (implicit SRW)]>; + +def SBC8mm : I8mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "subc.b\t{$src, $dst}", + [(store (sube (load addr:$dst), + (i8 (load addr:$src))), addr:$dst), + (implicit SRW)]>; +def SBC16mm : I16mm<0x0, + (outs), (ins memdst:$dst, memsrc:$src), + "subc.w\t{$src, $dst}", + [(store (sube (load addr:$dst), + (i16 (load addr:$src))), addr:$dst), + (implicit SRW)]>; } } // Uses = [SRW] -// FIXME: Provide proper encoding! -def SAR8r1 : Pseudo<(outs GR8:$dst), (ins GR8:$src), - "rra.b\t$dst", - [(set GR8:$dst, (MSP430rra GR8:$src)), - (implicit SRW)]>; -def SAR16r1 : Pseudo<(outs GR16:$dst), (ins GR16:$src), - "rra.w\t$dst", - [(set GR16:$dst, (MSP430rra GR16:$src)), - (implicit SRW)]>; - -def SHL8r1 : Pseudo<(outs GR8:$dst), (ins GR8:$src), - "rla.b\t$dst", - [(set GR8:$dst, (MSP430rla GR8:$src)), - (implicit SRW)]>; -def SHL16r1 : Pseudo<(outs GR16:$dst), (ins GR16:$src), - "rla.w\t$dst", - [(set GR16:$dst, (MSP430rla GR16:$src)), - (implicit SRW)]>; +// FIXME: memory variant! +def SAR8r1 : II8r<0x0, + (outs GR8:$dst), (ins GR8:$src), + "rra.b\t$dst", + [(set GR8:$dst, (MSP430rra GR8:$src)), + (implicit SRW)]>; +def SAR16r1 : II16r<0x0, + (outs GR16:$dst), (ins GR16:$src), + "rra.w\t$dst", + [(set GR16:$dst, (MSP430rra GR16:$src)), + (implicit SRW)]>; + +def SHL8r1 : I8rr<0x0, + (outs GR8:$dst), (ins GR8:$src), + "rla.b\t$dst", + [(set GR8:$dst, (MSP430rla GR8:$src)), + (implicit SRW)]>; +def SHL16r1 : I16rr<0x0, + (outs GR16:$dst), (ins GR16:$src), + "rla.w\t$dst", + [(set GR16:$dst, (MSP430rla GR16:$src)), + (implicit SRW)]>; def SAR8r1c : Pseudo<(outs GR8:$dst), (ins GR8:$src), "clrc\n\t" @@ -799,123 +952,154 @@ [(set GR16:$dst, (MSP430rrc GR16:$src)), (implicit SRW)]>; -def SEXT16r : Pseudo<(outs GR16:$dst), (ins GR16:$src), - "sxt\t$dst", - [(set GR16:$dst, (sext_inreg GR16:$src, i8)), - (implicit SRW)]>; +// FIXME: Memory sext's ? +def SEXT16r : II16r<0x0, + (outs GR16:$dst), (ins GR16:$src), + "sxt\t$dst", + [(set GR16:$dst, (sext_inreg GR16:$src, i8)), + (implicit SRW)]>; } // Defs = [SRW] -def ZEXT16r : Pseudo<(outs GR16:$dst), (ins GR16:$src), - "mov.b\t{$src, $dst}", - [(set GR16:$dst, (zext (trunc GR16:$src)))]>; - -def SWPB16r : Pseudo<(outs GR16:$dst), (ins GR16:$src), - "swpb\t$dst", - [(set GR16:$dst, (bswap GR16:$src))]>; +def ZEXT16r : I8rr<0x0, + (outs GR16:$dst), (ins GR16:$src), + "mov.b\t{$src, $dst}", + [(set GR16:$dst, (zext (trunc GR16:$src)))]>; + +// FIXME: Memory bitswaps? +def SWPB16r : II16r<0x0, + (outs GR16:$dst), (ins GR16:$src), + "swpb\t$dst", + [(set GR16:$dst, (bswap GR16:$src))]>; } // isTwoAddress = 1 // Integer comparisons let Defs = [SRW] in { -def CMP8rr : Pseudo<(outs), (ins GR8:$src1, GR8:$src2), - "cmp.b\t{$src2, $src1}", - [(MSP430cmp GR8:$src1, GR8:$src2), (implicit SRW)]>; -def CMP16rr : Pseudo<(outs), (ins GR16:$src1, GR16:$src2), - "cmp.w\t{$src2, $src1}", - [(MSP430cmp GR16:$src1, GR16:$src2), (implicit SRW)]>; +def CMP8rr : I8rr<0x0, + (outs), (ins GR8:$src1, GR8:$src2), + "cmp.b\t{$src2, $src1}", + [(MSP430cmp GR8:$src1, GR8:$src2), (implicit SRW)]>; +def CMP16rr : I16rr<0x0, + (outs), (ins GR16:$src1, GR16:$src2), + "cmp.w\t{$src2, $src1}", + [(MSP430cmp GR16:$src1, GR16:$src2), (implicit SRW)]>; -def CMP8ri : Pseudo<(outs), (ins GR8:$src1, i8imm:$src2), +def CMP8ri : I8ri<0x0, + (outs), (ins GR8:$src1, i8imm:$src2), "cmp.b\t{$src2, $src1}", [(MSP430cmp GR8:$src1, imm:$src2), (implicit SRW)]>; -def CMP16ri : Pseudo<(outs), (ins GR16:$src1, i16imm:$src2), - "cmp.w\t{$src2, $src1}", - [(MSP430cmp GR16:$src1, imm:$src2), (implicit SRW)]>; - -def CMP8mi : Pseudo<(outs), (ins memsrc:$src1, i8imm:$src2), - "cmp.b\t{$src2, $src1}", - [(MSP430cmp (load addr:$src1), - (i8 imm:$src2)), (implicit SRW)]>; -def CMP16mi : Pseudo<(outs), (ins memsrc:$src1, i16imm:$src2), - "cmp.w\t{$src2, $src1}", - [(MSP430cmp (load addr:$src1), - (i16 imm:$src2)), (implicit SRW)]>; - -def CMP8rm : Pseudo<(outs), (ins GR8:$src1, memsrc:$src2), - "cmp.b\t{$src2, $src1}", - [(MSP430cmp GR8:$src1, (load addr:$src2)), (implicit SRW)]>; -def CMP16rm : Pseudo<(outs), (ins GR16:$src1, memsrc:$src2), - "cmp.w\t{$src2, $src1}", - [(MSP430cmp GR16:$src1, (load addr:$src2)), (implicit SRW)]>; - -def CMP8mr : Pseudo<(outs), (ins memsrc:$src1, GR8:$src2), - "cmp.b\t{$src2, $src1}", - [(MSP430cmp (load addr:$src1), GR8:$src2), (implicit SRW)]>; -def CMP16mr : Pseudo<(outs), (ins memsrc:$src1, GR16:$src2), - "cmp.w\t{$src2, $src1}", - [(MSP430cmp (load addr:$src1), GR16:$src2), (implicit SRW)]>; - +def CMP16ri : I16ri<0x0, + (outs), (ins GR16:$src1, i16imm:$src2), + "cmp.w\t{$src2, $src1}", + [(MSP430cmp GR16:$src1, imm:$src2), (implicit SRW)]>; -// BIT TESTS, just sets condition codes -// Note that the C condition is set differently than when using CMP. -let isCommutable = 1 in { -def BIT8rr : Pseudo<(outs), (ins GR8:$src1, GR8:$src2), - "bit.b\t{$src2, $src1}", - [(MSP430cmp (and_su GR8:$src1, GR8:$src2), 0), - (implicit SRW)]>; -def BIT16rr : Pseudo<(outs), (ins GR16:$src1, GR16:$src2), - "bit.w\t{$src2, $src1}", - [(MSP430cmp (and_su GR16:$src1, GR16:$src2), 0), - (implicit SRW)]>; -} -def BIT8ri : Pseudo<(outs), (ins GR8:$src1, i8imm:$src2), - "bit.b\t{$src2, $src1}", - [(MSP430cmp (and_su GR8:$src1, imm:$src2), 0), - (implicit SRW)]>; -def BIT16ri : Pseudo<(outs), (ins GR16:$src1, i16imm:$src2), - "bit.w\t{$src2, $src1}", - [(MSP430cmp (and_su GR16:$src1, imm:$src2), 0), - (implicit SRW)]>; +def CMP8mi : I8mi<0x0, + (outs), (ins memsrc:$src1, i8imm:$src2), + "cmp.b\t{$src2, $src1}", + [(MSP430cmp (load addr:$src1), + (i8 imm:$src2)), (implicit SRW)]>; +def CMP16mi : I16mi<0x0, + (outs), (ins memsrc:$src1, i16imm:$src2), + "cmp.w\t{$src2, $src1}", + [(MSP430cmp (load addr:$src1), + (i16 imm:$src2)), (implicit SRW)]>; -def BIT8rm : Pseudo<(outs), (ins GR8:$src1, memdst:$src2), - "bit.b\t{$src2, $src1}", - [(MSP430cmp (and_su GR8:$src1, (load addr:$src2)), 0), - (implicit SRW)]>; -def BIT16rm : Pseudo<(outs), (ins GR16:$src1, memdst:$src2), - "bit.w\t{$src2, $src1}", - [(MSP430cmp (and_su GR16:$src1, (load addr:$src2)), 0), - (implicit SRW)]>; +def CMP8rm : I8rm<0x0, + (outs), (ins GR8:$src1, memsrc:$src2), + "cmp.b\t{$src2, $src1}", + [(MSP430cmp GR8:$src1, (load addr:$src2)), + (implicit SRW)]>; +def CMP16rm : I16rm<0x0, + (outs), (ins GR16:$src1, memsrc:$src2), + "cmp.w\t{$src2, $src1}", + [(MSP430cmp GR16:$src1, (load addr:$src2)), + (implicit SRW)]>; -def BIT8mr : Pseudo<(outs), (ins memsrc:$src1, GR8:$src2), - "bit.b\t{$src2, $src1}", - [(MSP430cmp (and_su (load addr:$src1), GR8:$src2), 0), - (implicit SRW)]>; -def BIT16mr : Pseudo<(outs), (ins memsrc:$src1, GR16:$src2), - "bit.w\t{$src2, $src1}", - [(MSP430cmp (and_su (load addr:$src1), GR16:$src2), 0), - (implicit SRW)]>; +def CMP8mr : I8mr<0x0, + (outs), (ins memsrc:$src1, GR8:$src2), + "cmp.b\t{$src2, $src1}", + [(MSP430cmp (load addr:$src1), GR8:$src2), + (implicit SRW)]>; +def CMP16mr : I16mr<0x0, + (outs), (ins memsrc:$src1, GR16:$src2), + "cmp.w\t{$src2, $src1}", + [(MSP430cmp (load addr:$src1), GR16:$src2), + (implicit SRW)]>; -def BIT8mi : Pseudo<(outs), (ins memsrc:$src1, i8imm:$src2), - "bit.b\t{$src2, $src1}", - [(MSP430cmp (and_su (load addr:$src1), (i8 imm:$src2)), 0), - (implicit SRW)]>; -def BIT16mi : Pseudo<(outs), (ins memsrc:$src1, i16imm:$src2), - "bit.w\t{$src2, $src1}", - [(MSP430cmp (and_su (load addr:$src1), (i16 imm:$src2)), 0), - (implicit SRW)]>; -def BIT8mm : Pseudo<(outs), (ins memsrc:$src1, memsrc:$src2), - "bit.b\t{$src2, $src1}", - [(MSP430cmp (and_su (i8 (load addr:$src1)), - (load addr:$src2)), +// BIT TESTS, just sets condition codes +// Note that the C condition is set differently than when using CMP. +let isCommutable = 1 in { +def BIT8rr : I8rr<0x0, + (outs), (ins GR8:$src1, GR8:$src2), + "bit.b\t{$src2, $src1}", + [(MSP430cmp (and_su GR8:$src1, GR8:$src2), 0), + (implicit SRW)]>; +def BIT16rr : I16rr<0x0, + (outs), (ins GR16:$src1, GR16:$src2), + "bit.w\t{$src2, $src1}", + [(MSP430cmp (and_su GR16:$src1, GR16:$src2), 0), + (implicit SRW)]>; +} +def BIT8ri : I8ri<0x0, + (outs), (ins GR8:$src1, i8imm:$src2), + "bit.b\t{$src2, $src1}", + [(MSP430cmp (and_su GR8:$src1, imm:$src2), 0), + (implicit SRW)]>; +def BIT16ri : I16ri<0x0, + (outs), (ins GR16:$src1, i16imm:$src2), + "bit.w\t{$src2, $src1}", + [(MSP430cmp (and_su GR16:$src1, imm:$src2), 0), + (implicit SRW)]>; + +def BIT8rm : I8rm<0x0, + (outs), (ins GR8:$src1, memdst:$src2), + "bit.b\t{$src2, $src1}", + [(MSP430cmp (and_su GR8:$src1, (load addr:$src2)), 0), + (implicit SRW)]>; +def BIT16rm : I16rm<0x0, + (outs), (ins GR16:$src1, memdst:$src2), + "bit.w\t{$src2, $src1}", + [(MSP430cmp (and_su GR16:$src1, (load addr:$src2)), 0), + (implicit SRW)]>; + +def BIT8mr : I8mr<0x0, + (outs), (ins memsrc:$src1, GR8:$src2), + "bit.b\t{$src2, $src1}", + [(MSP430cmp (and_su (load addr:$src1), GR8:$src2), 0), + (implicit SRW)]>; +def BIT16mr : I16mr<0x0, + (outs), (ins memsrc:$src1, GR16:$src2), + "bit.w\t{$src2, $src1}", + [(MSP430cmp (and_su (load addr:$src1), GR16:$src2), 0), + (implicit SRW)]>; + +def BIT8mi : I8mi<0x0, + (outs), (ins memsrc:$src1, i8imm:$src2), + "bit.b\t{$src2, $src1}", + [(MSP430cmp (and_su (load addr:$src1), (i8 imm:$src2)), 0), + (implicit SRW)]>; +def BIT16mi : I16mi<0x0, + (outs), (ins memsrc:$src1, i16imm:$src2), + "bit.w\t{$src2, $src1}", + [(MSP430cmp (and_su (load addr:$src1), (i16 imm:$src2)), 0), + (implicit SRW)]>; + +def BIT8mm : I8mm<0x0, + (outs), (ins memsrc:$src1, memsrc:$src2), + "bit.b\t{$src2, $src1}", + [(MSP430cmp (and_su (i8 (load addr:$src1)), + (load addr:$src2)), 0), (implicit SRW)]>; -def BIT16mm : Pseudo<(outs), (ins memsrc:$src1, memsrc:$src2), - "bit.w\t{$src2, $src1}", - [(MSP430cmp (and_su (i16 (load addr:$src1)), - (load addr:$src2)), +def BIT16mm : I16mm<0x0, + (outs), (ins memsrc:$src1, memsrc:$src2), + "bit.w\t{$src2, $src1}", + [(MSP430cmp (and_su (i16 (load addr:$src1)), + (load addr:$src2)), 0), - (implicit SRW)]>; + (implicit SRW)]>; } // Defs = [SRW] //===----------------------------------------------------------------------===// From asl at math.spbu.ru Fri Jan 15 15:19:05 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Fri, 15 Jan 2010 21:19:05 -0000 Subject: [llvm-commits] [llvm] r93554 - in /llvm/trunk/lib/Target/MSP430: MSP430.h MSP430BranchSelector.cpp MSP430InstrInfo.cpp MSP430InstrInfo.h MSP430InstrInfo.td MSP430TargetMachine.cpp MSP430TargetMachine.h Message-ID: <201001152119.o0FLJ6TU032265@zion.cs.uiuc.edu> Author: asl Date: Fri Jan 15 15:19:05 2010 New Revision: 93554 URL: http://llvm.org/viewvc/llvm-project?rev=93554&view=rev Log: Add branch relaxation pass (shamelessly stolen from PPC). Added: llvm/trunk/lib/Target/MSP430/MSP430BranchSelector.cpp Modified: llvm/trunk/lib/Target/MSP430/MSP430.h llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.h llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.h Modified: llvm/trunk/lib/Target/MSP430/MSP430.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430.h?rev=93554&r1=93553&r2=93554&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430.h (original) +++ llvm/trunk/lib/Target/MSP430/MSP430.h Fri Jan 15 15:19:05 2010 @@ -39,6 +39,8 @@ FunctionPass *createMSP430ISelDag(MSP430TargetMachine &TM, CodeGenOpt::Level OptLevel); + FunctionPass *createMSP430BranchSelectionPass(); + extern Target TheMSP430Target; } // end namespace llvm; Added: llvm/trunk/lib/Target/MSP430/MSP430BranchSelector.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430BranchSelector.cpp?rev=93554&view=auto ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430BranchSelector.cpp (added) +++ llvm/trunk/lib/Target/MSP430/MSP430BranchSelector.cpp Fri Jan 15 15:19:05 2010 @@ -0,0 +1,179 @@ +//===-- MSP430BranchSelector.cpp - Emit long conditional branches--*- C++ -*-=// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains a pass that scans a machine function to determine which +// conditional branches need more than 10 bits of displacement to reach their +// target basic block. It does this in two passes; a calculation of basic block +// positions pass, and a branch psuedo op to machine branch opcode pass. This +// pass should be run last, just before the assembly printer. +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "msp430-branch-select" +#include "MSP430.h" +#include "MSP430InstrInfo.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/Target/TargetMachine.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Support/MathExtras.h" +using namespace llvm; + +STATISTIC(NumExpanded, "Number of branches expanded to long format"); + +namespace { + struct MSP430BSel : public MachineFunctionPass { + static char ID; + MSP430BSel() : MachineFunctionPass(&ID) {} + + /// BlockSizes - The sizes of the basic blocks in the function. + std::vector BlockSizes; + + virtual bool runOnMachineFunction(MachineFunction &Fn); + + virtual const char *getPassName() const { + return "MSP430 Branch Selector"; + } + }; + char MSP430BSel::ID = 0; +} + +/// createMSP430BranchSelectionPass - returns an instance of the Branch +/// Selection Pass +/// +FunctionPass *llvm::createMSP430BranchSelectionPass() { + return new MSP430BSel(); +} + +bool MSP430BSel::runOnMachineFunction(MachineFunction &Fn) { + const TargetInstrInfo *TII = Fn.getTarget().getInstrInfo(); + // Give the blocks of the function a dense, in-order, numbering. + Fn.RenumberBlocks(); + BlockSizes.resize(Fn.getNumBlockIDs()); + + // Measure each MBB and compute a size for the entire function. + unsigned FuncSize = 0; + for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; + ++MFI) { + MachineBasicBlock *MBB = MFI; + + unsigned BlockSize = 0; + for (MachineBasicBlock::iterator MBBI = MBB->begin(), EE = MBB->end(); + MBBI != EE; ++MBBI) + BlockSize += TII->GetInstSizeInBytes(MBBI); + + BlockSizes[MBB->getNumber()] = BlockSize; + FuncSize += BlockSize; + } + + // If the entire function is smaller than the displacement of a branch field, + // we know we don't need to shrink any branches in this function. This is a + // common case. + if (FuncSize < (1 << 9)) { + BlockSizes.clear(); + return false; + } + + // For each conditional branch, if the offset to its destination is larger + // than the offset field allows, transform it into a long branch sequence + // like this: + // short branch: + // bCC MBB + // long branch: + // b!CC $PC+6 + // b MBB + // + bool MadeChange = true; + bool EverMadeChange = false; + while (MadeChange) { + // Iteratively expand branches until we reach a fixed point. + MadeChange = false; + + for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; + ++MFI) { + MachineBasicBlock &MBB = *MFI; + unsigned MBBStartOffset = 0; + for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); + I != E; ++I) { + if ((I->getOpcode() != MSP430::JCC || I->getOperand(0).isImm()) && + I->getOpcode() != MSP430::JMP) { + MBBStartOffset += TII->GetInstSizeInBytes(I); + continue; + } + + // Determine the offset from the current branch to the destination + // block. + MachineBasicBlock *Dest = I->getOperand(0).getMBB(); + + int BranchSize; + if (Dest->getNumber() <= MBB.getNumber()) { + // If this is a backwards branch, the delta is the offset from the + // start of this block to this branch, plus the sizes of all blocks + // from this block to the dest. + BranchSize = MBBStartOffset; + + for (unsigned i = Dest->getNumber(), e = MBB.getNumber(); i != e; ++i) + BranchSize += BlockSizes[i]; + } else { + // Otherwise, add the size of the blocks between this block and the + // dest to the number of bytes left in this block. + BranchSize = -MBBStartOffset; + + for (unsigned i = MBB.getNumber(), e = Dest->getNumber(); i != e; ++i) + BranchSize += BlockSizes[i]; + } + + // If this branch is in range, ignore it. + if (isInt<10>(BranchSize)) { + MBBStartOffset += 2; + continue; + } + + // Otherwise, we have to expand it to a long branch. + unsigned NewSize; + MachineInstr *OldBranch = I; + DebugLoc dl = OldBranch->getDebugLoc(); + + if (I->getOpcode() == MSP430::JMP) { + NewSize = 4; + } else { + // The BCC operands are: + // 0. MSP430 branch predicate + // 1. Target MBB + SmallVector Cond; + Cond.push_back(I->getOperand(1)); + + // Jump over the uncond branch inst (i.e. $+6) on opposite condition. + TII->ReverseBranchCondition(Cond); + BuildMI(MBB, I, dl, TII->get(MSP430::JCC)) + .addImm(4).addOperand(Cond[0]); + + NewSize = 6; + } + // Uncond branch to the real destination. + I = BuildMI(MBB, I, dl, TII->get(MSP430::B)).addMBB(Dest); + + // Remove the old branch from the function. + OldBranch->eraseFromParent(); + + // Remember that this instruction is NewSize bytes, increase the size of the + // block by NewSize-2, remember to iterate. + BlockSizes[MBB.getNumber()] += NewSize-2; + MBBStartOffset += NewSize; + + ++NumExpanded; + MadeChange = true; + } + } + EverMadeChange |= MadeChange; + } + + BlockSizes.clear(); + return true; +} Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp?rev=93554&r1=93553&r2=93554&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp Fri Jan 15 15:19:05 2010 @@ -344,3 +344,45 @@ } return Count; } + +/// GetInstSize - Return the number of bytes of code the specified +/// instruction may be. This returns the maximum number of bytes. +/// +unsigned MSP430InstrInfo::GetInstSizeInBytes(const MachineInstr *MI) const { + const TargetInstrDesc &Desc = MI->getDesc(); + + switch (Desc.TSFlags & MSP430II::SizeMask) { + default: + switch (Desc.getOpcode()) { + default: + assert(0 && "Unknown instruction size!"); + case TargetInstrInfo::DBG_LABEL: + case TargetInstrInfo::EH_LABEL: + case TargetInstrInfo::IMPLICIT_DEF: + case TargetInstrInfo::KILL: + return 0; + case TargetInstrInfo::INLINEASM: { + const MachineFunction *MF = MI->getParent()->getParent(); + const TargetInstrInfo &TII = *MF->getTarget().getInstrInfo(); + return TII.getInlineAsmLength(MI->getOperand(0).getSymbolName(), + *MF->getTarget().getMCAsmInfo()); + } + } + case MSP430II::SizeSpecial: + switch (MI->getOpcode()) { + default: + assert(0 && "Unknown instruction size!"); + case MSP430::SAR8r1c: + case MSP430::SAR16r1c: + return 4; + } + case MSP430II::Size2Bytes: + return 2; + case MSP430II::Size4Bytes: + return 4; + case MSP430II::Size6Bytes: + return 6; + } + + return 6; +} Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.h?rev=93554&r1=93553&r2=93554&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.h (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.h Fri Jan 15 15:19:05 2010 @@ -21,6 +21,22 @@ class MSP430TargetMachine; +/// MSP430II - This namespace holds all of the target specific flags that +/// instruction info tracks. +/// +namespace MSP430II { + enum { + SizeShift = 2, + SizeMask = 7 << SizeShift, + + SizeUnknown = 0 << SizeShift, + SizeSpecial = 1 << SizeShift, + Size2Bytes = 2 << SizeShift, + Size4Bytes = 3 << SizeShift, + Size6Bytes = 4 << SizeShift + }; +} + class MSP430InstrInfo : public TargetInstrInfoImpl { const MSP430RegisterInfo RI; MSP430TargetMachine &TM; @@ -59,6 +75,8 @@ MachineBasicBlock::iterator MI, const std::vector &CSI) const; + unsigned GetInstSizeInBytes(const MachineInstr *MI) const; + // Branch folding goodness bool ReverseBranchCondition(SmallVectorImpl &Cond) const; bool isUnpredicatedTerminator(const MachineInstr *MI) const; Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td?rev=93554&r1=93553&r2=93554&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td Fri Jan 15 15:19:05 2010 @@ -167,11 +167,18 @@ // FIXME: expand opcode & cond field for branches! // Direct branch -let isBarrier = 1 in +let isBarrier = 1 in { + // Short branch def JMP : CJForm<0, 0, (outs), (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>; + // Long branch + def B : I16ri<0, + (outs), (ins brtarget:$dst), + "br\t$dst", + []>; +} // Conditional branches let Uses = [SRW] in Modified: llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp?rev=93554&r1=93553&r2=93554&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp Fri Jan 15 15:19:05 2010 @@ -44,3 +44,9 @@ return false; } +bool MSP430TargetMachine::addPreEmitPass(PassManagerBase &PM, + CodeGenOpt::Level OptLevel) { + // Must run branch selection immediately preceding the asm printer. + PM.add(createMSP430BranchSelectionPass()); + return false; +} Modified: llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.h?rev=93554&r1=93553&r2=93554&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.h (original) +++ llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.h Fri Jan 15 15:19:05 2010 @@ -55,6 +55,7 @@ } virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel); + virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel); }; // MSP430TargetMachine. } // end namespace llvm From asl at math.spbu.ru Fri Jan 15 15:19:26 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Fri, 15 Jan 2010 21:19:26 -0000 Subject: [llvm-commits] [llvm] r93555 - in /llvm/trunk/test/CodeGen/MSP430: bit.ll setcc.ll Message-ID: <201001152119.o0FLJQt6032289@zion.cs.uiuc.edu> Author: asl Date: Fri Jan 15 15:19:26 2010 New Revision: 93555 URL: http://llvm.org/viewvc/llvm-project?rev=93555&view=rev Log: Reenable tests Modified: llvm/trunk/test/CodeGen/MSP430/bit.ll llvm/trunk/test/CodeGen/MSP430/setcc.ll Modified: llvm/trunk/test/CodeGen/MSP430/bit.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/bit.ll?rev=93555&r1=93554&r2=93555&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/bit.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/bit.ll Fri Jan 15 15:19:26 2010 @@ -1,5 +1,4 @@ ; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s -; XFAIL: * target datalayout = "e-p:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:16:32" target triple = "msp430-generic-generic" Modified: llvm/trunk/test/CodeGen/MSP430/setcc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/setcc.ll?rev=93555&r1=93554&r2=93555&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/setcc.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/setcc.ll Fri Jan 15 15:19:26 2010 @@ -1,5 +1,4 @@ ; RUN: llc -march=msp430 < %s | FileCheck %s -; XFAIL: * target datalayout = "e-p:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:16:32" target triple = "msp430-generic-generic" @@ -32,7 +31,7 @@ ret i16 %t2 } ; CHECK:sccwne: -; CHECK: cmp.w r15, r14 +; CHECK: cmp.w r14, r15 ; CHECK-NEXT: mov.w r2, r15 ; CHECK-NEXT: rra.w r15 ; CHECK-NEXT: and.w #1, r15 @@ -43,7 +42,7 @@ ret i16 %t2 } ; CHECK:sccweq: -; CHECK: cmp.w r15, r14 +; CHECK: cmp.w r14, r15 ; CHECK-NEXT: mov.w r2, r15 ; CHECK-NEXT: rra.w r15 ; CHECK-NEXT: and.w #1, r15 @@ -55,7 +54,7 @@ ret i16 %t2 } ; CHECK:sccwugt: -; CHECK: cmp.w r14, r15 +; CHECK: cmp.w r15, r14 ; CHECK-NEXT: mov.w r2, r15 ; CHECK-NEXT: and.w #1, r15 ; CHECK-NEXT: xor.w #1, r15 @@ -66,7 +65,7 @@ ret i16 %t2 } ; CHECK:sccwuge: -; CHECK: cmp.w r15, r14 +; CHECK: cmp.w r14, r15 ; CHECK-NEXT: mov.w r2, r15 ; CHECK-NEXT: and.w #1, r15 @@ -76,7 +75,7 @@ ret i16 %t2 } ; CHECK:sccwult: -; CHECK: cmp.w r15, r14 +; CHECK: cmp.w r14, r15 ; CHECK-NEXT: mov.w r2, r15 ; CHECK-NEXT: and.w #1, r15 ; CHECK-NEXT: xor.w #1, r15 @@ -87,7 +86,7 @@ ret i16 %t2 } ; CHECK:sccwule: -; CHECK: cmp.w r14, r15 +; CHECK: cmp.w r15, r14 ; CHECK-NEXT: mov.w r2, r15 ; CHECK-NEXT: and.w #1, r15 From asl at math.spbu.ru Fri Jan 15 15:19:43 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Fri, 15 Jan 2010 21:19:43 -0000 Subject: [llvm-commits] [llvm] r93556 - in /llvm/trunk/lib/Target/MSP430: MSP430ISelLowering.cpp MSP430ISelLowering.h Message-ID: <201001152119.o0FLJh4K032307@zion.cs.uiuc.edu> Author: asl Date: Fri Jan 15 15:19:43 2010 New Revision: 93556 URL: http://llvm.org/viewvc/llvm-project?rev=93556&view=rev Log: zext / truncate is free on msp430. Inform codegen about this. Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=93556&r1=93555&r2=93556&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Fri Jan 15 15:19:43 2010 @@ -967,6 +967,31 @@ } } +bool MSP430TargetLowering::isTruncateFree(const Type *Ty1, + const Type *Ty2) const { + if (!Ty1->isInteger() || !Ty2->isInteger()) + return false; + + return (Ty1->getPrimitiveSizeInBits() > Ty2->getPrimitiveSizeInBits()); +} + +bool MSP430TargetLowering::isTruncateFree(EVT VT1, EVT VT2) const { + if (!VT1.isInteger() || !VT2.isInteger()) + return false; + + return (VT1.getSizeInBits() > VT2.getSizeInBits()); +} + +bool MSP430TargetLowering::isZExtFree(const Type *Ty1, const Type *Ty2) const { + // MSP430 implicitly zero-extends 8-bit results in 16-bit registers. + return 0 && Ty1->isInteger(8) && Ty2->isInteger(16); +} + +bool MSP430TargetLowering::isZExtFree(EVT VT1, EVT VT2) const { + // MSP430 implicitly zero-extends 8-bit results in 16-bit registers. + return 0 && VT1 == MVT::i8 && VT2 == MVT::i16; +} + //===----------------------------------------------------------------------===// // Other Lowering Code //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h?rev=93556&r1=93555&r2=93556&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h Fri Jan 15 15:19:43 2010 @@ -99,6 +99,23 @@ std::pair getRegForInlineAsmConstraint(const std::string &Constraint, EVT VT) const; + /// isTruncateFree - Return true if it's free to truncate a value of type + /// Ty1 to type Ty2. e.g. On msp430 it's free to truncate a i16 value in + /// register R15W to i8 by referencing its sub-register R15B. + virtual bool isTruncateFree(const Type *Ty1, const Type *Ty2) const; + virtual bool isTruncateFree(EVT VT1, EVT VT2) const; + + /// isZExtFree - Return true if any actual instruction that defines a value + /// of type Ty1 implicit zero-extends the value to Ty2 in the result + /// register. This does not necessarily include registers defined in unknown + /// ways, such as incoming arguments, or copies from unknown virtual + /// registers. Also, if isTruncateFree(Ty2, Ty1) is true, this does not + /// necessarily apply to truncate instructions. e.g. on msp430, all + /// instructions that define 8-bit values implicit zero-extend the result + /// out to 16 bits. + virtual bool isZExtFree(const Type *Ty1, const Type *Ty2) const; + virtual bool isZExtFree(EVT VT1, EVT VT2) const; + MachineBasicBlock* EmitInstrWithCustomInserter(MachineInstr *MI, MachineBasicBlock *BB, DenseMap *EM) const; From echristo at apple.com Fri Jan 15 15:36:32 2010 From: echristo at apple.com (Eric Christopher) Date: Fri, 15 Jan 2010 21:36:32 -0000 Subject: [llvm-commits] [llvm] r93558 - in /llvm/trunk: bindings/ocaml/llvm/llvm.ml bindings/ocaml/llvm/llvm.mli docs/LangRef.html include/llvm-c/Core.h include/llvm/Attributes.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Target/CppBackend/CPPBackend.cpp lib/VMCore/Attributes.cpp utils/llvm.grm utils/vim/llvm.vim Message-ID: <201001152136.o0FLaXXk000699@zion.cs.uiuc.edu> Author: echristo Date: Fri Jan 15 15:36:30 2010 New Revision: 93558 URL: http://llvm.org/viewvc/llvm-project?rev=93558&view=rev Log: Remove the InlineHint attribute. There are no current or planned users. Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml llvm/trunk/bindings/ocaml/llvm/llvm.mli llvm/trunk/docs/LangRef.html llvm/trunk/include/llvm-c/Core.h llvm/trunk/include/llvm/Attributes.h llvm/trunk/lib/AsmParser/LLLexer.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLToken.h llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp llvm/trunk/lib/VMCore/Attributes.cpp llvm/trunk/utils/llvm.grm llvm/trunk/utils/vim/llvm.vim Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.ml?rev=93558&r1=93557&r2=93558&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm.ml (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm.ml Fri Jan 15 15:36:30 2010 @@ -93,7 +93,6 @@ | Noredzone | Noimplicitfloat | Naked - | Inlinehint end module Icmp = struct @@ -848,7 +847,7 @@ = "LLVMCreateModuleProviderForExistingModule" external dispose : llmoduleprovider -> unit = "llvm_dispose_module_provider" end - + (*===-- Memory buffers ----------------------------------------------------===*) Modified: llvm/trunk/bindings/ocaml/llvm/llvm.mli URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.mli?rev=93558&r1=93557&r2=93558&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm.mli (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm.mli Fri Jan 15 15:36:30 2010 @@ -143,7 +143,6 @@ | Noredzone | Noimplicitfloat | Naked - | Inlinehint end (** The predicate for an integer comparison ([icmp]) instruction. Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=93558&r1=93557&r2=93558&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Fri Jan 15 15:36:30 2010 @@ -1083,11 +1083,6 @@ function into callers whenever possible, ignoring any active inlining size threshold for this caller. -
    inlinehint
    -
    This attribute indicates that the source code contained a hint that inlining - this function is desirable (such as the "inline" keyword in C/C++). It - is just a hint; it imposes no requirements on the inliner.
    -
    noinline
    This attribute indicates that the inliner should never inline this function in any situation. This attribute may not be used together with Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=93558&r1=93557&r2=93558&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Fri Jan 15 15:36:30 2010 @@ -117,8 +117,7 @@ LLVMNoCaptureAttribute = 1<<21, LLVMNoRedZoneAttribute = 1<<22, LLVMNoImplicitFloatAttribute = 1<<23, - LLVMNakedAttribute = 1<<24, - LLVMInlineHintAttribute = 1<<25 + LLVMNakedAttribute = 1<<24 } LLVMAttribute; typedef enum { Modified: llvm/trunk/include/llvm/Attributes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Attributes.h?rev=93558&r1=93557&r2=93558&view=diff ============================================================================== --- llvm/trunk/include/llvm/Attributes.h (original) +++ llvm/trunk/include/llvm/Attributes.h Fri Jan 15 15:36:30 2010 @@ -58,8 +58,6 @@ const Attributes NoImplicitFloat = 1<<23; /// disable implicit floating point /// instructions. const Attributes Naked = 1<<24; ///< Naked function -const Attributes InlineHint = 1<<25; ///< source said inlining was - ///desirable /// @brief Attributes that only apply to function parameters. const Attributes ParameterOnly = ByVal | Nest | StructRet | NoCapture; @@ -68,7 +66,7 @@ /// be used on return values or function parameters. const Attributes FunctionOnly = NoReturn | NoUnwind | ReadNone | ReadOnly | NoInline | AlwaysInline | OptimizeForSize | StackProtect | StackProtectReq | - NoRedZone | NoImplicitFloat | Naked | InlineHint; + NoRedZone | NoImplicitFloat | Naked; /// @brief Parameter attributes that do not apply to vararg call arguments. const Attributes VarArgsIncompatible = StructRet; Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=93558&r1=93557&r2=93558&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLLexer.cpp (original) +++ llvm/trunk/lib/AsmParser/LLLexer.cpp Fri Jan 15 15:36:30 2010 @@ -558,7 +558,6 @@ KEYWORD(readnone); KEYWORD(readonly); - KEYWORD(inlinehint); KEYWORD(noinline); KEYWORD(alwaysinline); KEYWORD(optsize); Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=93558&r1=93557&r2=93558&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Fri Jan 15 15:36:30 2010 @@ -947,7 +947,6 @@ case lltok::kw_noinline: Attrs |= Attribute::NoInline; break; case lltok::kw_readnone: Attrs |= Attribute::ReadNone; break; case lltok::kw_readonly: Attrs |= Attribute::ReadOnly; break; - case lltok::kw_inlinehint: Attrs |= Attribute::InlineHint; break; case lltok::kw_alwaysinline: Attrs |= Attribute::AlwaysInline; break; case lltok::kw_optsize: Attrs |= Attribute::OptimizeForSize; break; case lltok::kw_ssp: Attrs |= Attribute::StackProtect; break; Modified: llvm/trunk/lib/AsmParser/LLToken.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=93558&r1=93557&r2=93558&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLToken.h (original) +++ llvm/trunk/lib/AsmParser/LLToken.h Fri Jan 15 15:36:30 2010 @@ -85,7 +85,6 @@ kw_readnone, kw_readonly, - kw_inlinehint, kw_noinline, kw_alwaysinline, kw_optsize, Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=93558&r1=93557&r2=93558&view=diff ============================================================================== --- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original) +++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Fri Jan 15 15:36:30 2010 @@ -472,7 +472,6 @@ HANDLE_ATTR(Nest); HANDLE_ATTR(ReadNone); HANDLE_ATTR(ReadOnly); - HANDLE_ATTR(InlineHint); HANDLE_ATTR(NoInline); HANDLE_ATTR(AlwaysInline); HANDLE_ATTR(OptimizeForSize); Modified: llvm/trunk/lib/VMCore/Attributes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Attributes.cpp?rev=93558&r1=93557&r2=93558&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Attributes.cpp (original) +++ llvm/trunk/lib/VMCore/Attributes.cpp Fri Jan 15 15:36:30 2010 @@ -56,8 +56,6 @@ Result += "optsize "; if (Attrs & Attribute::NoInline) Result += "noinline "; - if (Attrs & Attribute::InlineHint) - Result += "inlinehint "; if (Attrs & Attribute::AlwaysInline) Result += "alwaysinline "; if (Attrs & Attribute::StackProtect) Modified: llvm/trunk/utils/llvm.grm URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/llvm.grm?rev=93558&r1=93557&r2=93558&view=diff ============================================================================== --- llvm/trunk/utils/llvm.grm (original) +++ llvm/trunk/utils/llvm.grm Fri Jan 15 15:36:30 2010 @@ -161,7 +161,6 @@ | signext | readnone | readonly - | inlinehint | noinline | alwaysinline | optsize Modified: llvm/trunk/utils/vim/llvm.vim URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/vim/llvm.vim?rev=93558&r1=93557&r2=93558&view=diff ============================================================================== --- llvm/trunk/utils/vim/llvm.vim (original) +++ llvm/trunk/utils/vim/llvm.vim Fri Jan 15 15:36:30 2010 @@ -51,7 +51,7 @@ syn keyword llvmKeyword x86_stdcallcc x86_fastcallcc syn keyword llvmKeyword signext zeroext inreg sret nounwind noreturn syn keyword llvmKeyword nocapture byval nest readnone readonly noalias -syn keyword llvmKeyword inlinehint noinline alwaysinline optsize ssp sspreq +syn keyword llvmKeyword noinline alwaysinline optsize ssp sspreq syn keyword llvmKeyword noredzone noimplicitfloat naked syn keyword llvmKeyword module asm align tail to syn keyword llvmKeyword addrspace section alias sideeffect c gc From clattner at apple.com Fri Jan 15 15:36:55 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 13:36:55 -0800 Subject: [llvm-commits] [Patch] Patch for llvm-config In-Reply-To: References: <13E01678D13D43229821E721E2F1C4A8@nvidia.com> Message-ID: <2E24F4CA-7094-4F4F-9059-4FBD807B94B1@apple.com> On Jan 12, 2010, at 12:28 PM, Michael Beck wrote: > Hi all, > >> Applying this patch breaks llvm-config for me. I don't know >> anything about it, but maybe this will help: >> Bareword found where operator expected at /Users/sabre/llvm/Debug/ >> bin/ llvm-config line 133, near "--src > > Yep, this patch was broken. Attached is the correct one. Remind me what this patch does? -Chris > > best regards, > -- > Michael Beck From clattner at apple.com Fri Jan 15 15:38:46 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 13:38:46 -0800 Subject: [llvm-commits] [llvm] r93220 - /llvm/trunk/include/llvm/CodeGen/MachineOperand.h In-Reply-To: <201001120201.o0C21sAH023798@zion.cs.uiuc.edu> References: <201001120201.o0C21sAH023798@zion.cs.uiuc.edu> Message-ID: <7B3C303C-2842-40CA-9ED4-9DE2EC9F5E78@apple.com> On Jan 11, 2010, at 6:01 PM, Dale Johannesen wrote: > Author: johannes > Date: Mon Jan 11 20:01:53 2010 > New Revision: 93220 > > URL: http://llvm.org/viewvc/llvm-project?rev=93220&view=rev > Log: > Add MO_Metadata as an operand kind. Not used yet. Hey Dale, All of this work looks great, one minor thing: > + static MachineOperand CreateMetadata(MDNode *Meta, > + unsigned char TargetFlags = > 0) { > + MachineOperand Op(MachineOperand::MO_Metadata); > + Op.Contents.MD = Meta; > + Op.setTargetFlags(TargetFlags); > + return Op; > + } You don't need the TargetFlags argument here. -Chris From sabre at nondot.org Fri Jan 15 15:50:19 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 21:50:19 -0000 Subject: [llvm-commits] [llvm] r93559 - /llvm/trunk/docs/LangRef.html Message-ID: <201001152150.o0FLoKZf001124@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 15:50:19 2010 New Revision: 93559 URL: http://llvm.org/viewvc/llvm-project?rev=93559&view=rev Log: move "Metadata Nodes and Metadata Strings" section to the right place in the document and edit it. 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=93559&r1=93558&r2=93559&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Fri Jan 15 15:50:19 2010 @@ -924,9 +924,9 @@
    -

    Named metadata is a collection of metadata. Metadata - node and null are the only valid named metadata operands. - Metadata strings are not allowed as an named metadata operand.

    +

    Named metadata is a collection of metadata. Metadata + nodes (but not metadata strings) and null are the only valid operands for + a named metadata.

    Syntax:
    @@ -2335,41 +2335,6 @@
    - - - -
    - -

    Metadata provides a way to attach arbitrary data to the instruction - stream without affecting the behaviour of the program. There are two - metadata primitives, strings and nodes. All metadata has the - metadata type and is identified in syntax by a preceding exclamation - point ('!').

    - -

    A metadata string is a string surrounded by double quotes. It can contain - any character by escaping non-printable characters with "\xx" where "xx" is - the two digit hex code. For example: "!"test\00"".

    - -

    Metadata nodes are represented with notation similar to structure constants - (a comma separated list of elements, surrounded by braces and preceded by an - exclamation point). For example: "!{ metadata !"test\00", i32 - 10}".

    - -

    A metadata node will attempt to track changes to the values it holds. In the - event that a value is deleted, it will be replaced with a typeless - "null", such as "metadata !{null, i32 10}".

    - -

    A named metadata is a collection of - metadata nodes. For example: "!foo = metadata !{!4, !3}". - -

    Optimizations may rely on metadata to provide additional information about - the program that isn't available in the instructions, or that isn't easily - computable. Similarly, the code generator may expect a certain metadata - format to be used to express debugging information.

    - -
    - @@ -2439,6 +2404,35 @@
    + + + +
    + +

    LLVM IR allows metadata to be attached to instructions in the program that + can convey extra information about the code to the optimizers and code + generator. One example application of metadata is source-level debug + information. There are two metadata primitives: strings and nodes. All + metadata has the metadata type and is identified in syntax by a + preceding exclamation point ('!').

    + +

    A metadata string is a string surrounded by double quotes. It can contain + any character by escaping non-printable characters with "\xx" where "xx" is + the two digit hex code. For example: "!"test\00"".

    + +

    Metadata nodes are represented with notation similar to structure constants + (a comma separated list of elements, surrounded by braces and preceded by an + exclamation point). For example: "!{ metadata !"test\00", i32 + 10}". Metadata nodes can have any values as their operand.

    + +

    A named metadata is a collection of + metadata nodes, which can be looked up in the module symbol table. For + example: "!foo = metadata !{!4, !3}". + +

    +
    From dag at cray.com Fri Jan 15 15:52:46 2010 From: dag at cray.com (David Greene) Date: Fri, 15 Jan 2010 15:52:46 -0600 Subject: [llvm-commits] [llvm] r93538 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp In-Reply-To: <6BCA97EE-3764-4705-B60B-2788C3B8E998@apple.com> References: <201001151943.o0FJhO34028333@zion.cs.uiuc.edu> <6BCA97EE-3764-4705-B60B-2788C3B8E998@apple.com> Message-ID: <201001151552.47541.dag@cray.com> On Friday 15 January 2010 13:47, Chris Lattner wrote: > On Jan 15, 2010, at 11:43 AM, David Greene wrote: > > Add some debug routines to SelectionDAG to dump full DAGs. > > print/dumpWithDepth allows one to dump a DAG up to N levels deep. > > dump/printWithFullDepth prints the whole DAG, subject to a depth limit > > on 100 in the default case (to prevent infinite recursion). > > > > Have CannotYetSelect to a dumpWithFullDepth so it is clearer exactly > > what the non-matching DAG looks like. > > As Dan requested, please remove limit. Ok. > > +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Jan 15 > > 13:43:23 2010 > > @@ -5893,6 +5893,49 @@ > > print_details(OS, G); > > } > > > > +void SDNode::printWithDepth(raw_ostream &OS, const SelectionDAG *G, > > + unsigned depth, unsigned indent, > > What is the relation here between depth and indent? why not always > print the message and remove limit? They're essentially inverses. I'll create a helper to track indent and clean up the interface visible to the user. We could compute indent if we tracked the original depth presented to the routine, but that wouldn't be any less complicated. > > + while (myindent--) { > > + OS << ' '; > > + } > > O.indent(indent). Cool, didn't know that existed. > > + > > + print(OS, G); > > + > > + if (depth > 1) { > > Please use early exit here. Ok. > > +void SDNode::dumpWithFullDepth(const SelectionDAG *G, unsigned > > indent) const { > > + // Don't print impossibly deep things. > > + dumpWithDepth(G, 100, indent, true); > > +} > > It would be nice to eliminate some of these unless they are all truly > useful. After removing limit, we definitely want both for the case of buggy DAGs that cause infinite recursion. -Dave From clattner at apple.com Fri Jan 15 15:52:57 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 13:52:57 -0800 Subject: [llvm-commits] [llvm] r84134 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h In-Reply-To: References: <200910142108.n9EL89PR023324@zion.cs.uiuc.edu> <1103E7BC-53DE-49F4-9DC1-A335327EA2A1@apple.com> Message-ID: <8265AAD1-9EDA-47AC-B3DA-A22F99378C4F@apple.com> ping? On Jan 4, 2010, at 11:00 AM, Chris Lattner wrote: > > On Jan 4, 2010, at 8:48 AM, Devang Patel wrote: > >> >> On Jan 3, 2010, at 9:12 PM, Chris Lattner wrote: >> >>> On Oct 14, 2009, at 2:08 PM, Devang Patel wrote: >>>> Author: dpatel >>>> Date: Wed Oct 14 16:08:09 2009 >>>> New Revision: 84134 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=84134&view=rev >>>> Log: >>>> Add support to record DbgScope as inlined scope. >>> >>> Devang, why does InlinedAt need to be a WeakVH here? WeakVH is >>> much more expensive than it looks. >> >> InlinedAt is a MDNode which can be replaced by another MDNode. >> WeakVH ensures that DbgScope still points to expected MDNode. > > AsmPrinter is changing MDNodes? Per my previous email/bugzilla, there > is no use of MDNode::replaceAllUsesWith that is actually valid anyway. > > -Chris > >> - >> Devang >>> >>> -Chris >>> >>>> >>>> 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=84134&r1=84133&r2=84134&view=diff >>>> >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> =================================================================== >>>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) >>>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Oct 14 >>>> 16:08:09 2009 >>>> @@ -145,7 +145,10 @@ >>>> class VISIBILITY_HIDDEN DbgScope { >>>> DbgScope *Parent; // Parent to this scope. >>>> DIDescriptor Desc; // Debug info descriptor for >>>> scope. >>>> - // Either subprogram or >>>> block. >>>> + // FIXME use WeakVH for >>>> Desc. >>>> + WeakVH InlinedAt; // If this scope represents >>>> inlined >>>> + // function body then this >>>> is the location >>>> + // where this body is >>>> inlined. >>>> unsigned StartLabelID; // Label ID of the beginning >>>> of scope. >>>> unsigned EndLabelID; // Label ID of the end of >>>> scope. >>>> const MachineInstr *LastInsn; // Last instruction of this >>>> scope. >>>> @@ -157,14 +160,17 @@ >>>> // Private state for dump() >>>> mutable unsigned IndentLevel; >>>> public: >>>> - DbgScope(DbgScope *P, DIDescriptor D) >>>> - : Parent(P), Desc(D), StartLabelID(0), EndLabelID(0), >>>> LastInsn(0), >>>> - FirstInsn(0), IndentLevel(0) {} >>>> + DbgScope(DbgScope *P, DIDescriptor D, MDNode *I = 0) >>>> + : Parent(P), Desc(D), InlinedAt(I), StartLabelID(0), >>>> EndLabelID(0), >>>> + LastInsn(0), FirstInsn(0), IndentLevel(0) {} >>>> virtual ~DbgScope(); >>>> >>>> // Accessors. >>>> DbgScope *getParent() const { return Parent; } >>>> DIDescriptor getDesc() const { return Desc; } >>>> + MDNode *getInlinedAt() const { >>>> + return dyn_cast_or_null(InlinedAt); >>>> + } >>>> unsigned getStartLabelID() const { return StartLabelID; } >>>> unsigned getEndLabelID() const { return EndLabelID; } >>>> SmallVector &getScopes() { return Scopes; } >>>> @@ -1296,29 +1302,39 @@ >>>> >>>> /// getOrCreateScope - Returns the scope associated with the given >>>> descriptor. >>>> /// >>>> -DbgScope *DwarfDebug::getDbgScope(MDNode *N, const MachineInstr >>>> *MI) { >>>> +DbgScope *DwarfDebug::getDbgScope(MDNode *N, const MachineInstr >>>> *MI, >>>> + MDNode *InlinedAt) { >>>> DbgScope *&Slot = DbgScopeMap[N]; >>>> if (Slot) return Slot; >>>> >>>> DbgScope *Parent = NULL; >>>> >>>> - DIDescriptor Scope(N); >>>> - if (Scope.isCompileUnit()) { >>>> - return NULL; >>>> - } else if (Scope.isSubprogram()) { >>>> - DISubprogram SP(N); >>>> - DIDescriptor ParentDesc = SP.getContext(); >>>> - if (!ParentDesc.isNull() && !ParentDesc.isCompileUnit()) >>>> - Parent = getDbgScope(ParentDesc.getNode(), MI); >>>> - } else if (Scope.isLexicalBlock()) { >>>> - DILexicalBlock DB(N); >>>> - DIDescriptor ParentDesc = DB.getContext(); >>>> - if (!ParentDesc.isNull()) >>>> - Parent = getDbgScope(ParentDesc.getNode(), MI); >>>> - } else >>>> - assert (0 && "Unexpected scope info"); >>>> + if (InlinedAt) { >>>> + DILocation IL(InlinedAt); >>>> + assert (!IL.isNull() && "Invalid InlindAt location!"); >>>> + DenseMap::iterator DSI = >>>> + DbgScopeMap.find(IL.getScope().getNode()); >>>> + assert (DSI != DbgScopeMap.end() && "Unable to find InlineAt >>>> scope!"); >>>> + Parent = DSI->second; >>>> + } else { >>>> + DIDescriptor Scope(N); >>>> + if (Scope.isCompileUnit()) { >>>> + return NULL; >>>> + } else if (Scope.isSubprogram()) { >>>> + DISubprogram SP(N); >>>> + DIDescriptor ParentDesc = SP.getContext(); >>>> + if (!ParentDesc.isNull() && !ParentDesc.isCompileUnit()) >>>> + Parent = getDbgScope(ParentDesc.getNode(), MI, InlinedAt); >>>> + } else if (Scope.isLexicalBlock()) { >>>> + DILexicalBlock DB(N); >>>> + DIDescriptor ParentDesc = DB.getContext(); >>>> + if (!ParentDesc.isNull()) >>>> + Parent = getDbgScope(ParentDesc.getNode(), MI, InlinedAt); >>>> + } else >>>> + assert (0 && "Unexpected scope info"); >>>> + } >>>> >>>> - Slot = new DbgScope(Parent, DIDescriptor(N)); >>>> + Slot = new DbgScope(Parent, DIDescriptor(N), InlinedAt); >>>> Slot->setFirstInsn(MI); >>>> >>>> if (Parent) >>>> @@ -1795,7 +1811,10 @@ >>>> DIVariable DV (Var); >>>> if (DV.isNull()) continue; >>>> unsigned VSlot = VI->second; >>>> - DbgScope *Scope = getDbgScope(DV.getContext().getNode(), >>>> NULL); >>>> + DenseMap::iterator DSI = >>>> + DbgScopeMap.find(DV.getContext().getNode()); >>>> + assert (DSI != DbgScopeMap.end() && "Unable to find variable >>>> scope!"); >>>> + DbgScope *Scope = DSI->second; >>>> Scope->AddVariable(new DbgVariable(DV, VSlot, false)); >>>> } >>>> } >>>> @@ -1849,7 +1868,7 @@ >>>> // into a scope DIE at the end. >>>> DIDescriptor D(DLT.Scope); >>>> if (!D.isCompileUnit()) { >>>> - DbgScope *Scope = getDbgScope(DLT.Scope, MInsn); >>>> + DbgScope *Scope = getDbgScope(DLT.Scope, MInsn, >>>> DLT.InlinedAtLoc); >>>> Scope->setLastInsn(MInsn); >>>> } >>>> } >>>> >>>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h >>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=84134&r1=84133&r2=84134&view=diff >>>> >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> =================================================================== >>>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) >>>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Oct 14 >>>> 16:08:09 2009 >>>> @@ -364,7 +364,7 @@ >>>> /// getDbgScope - Returns the scope associated with the given >>>> descriptor. >>>> /// >>>> DbgScope *getOrCreateScope(MDNode *N); >>>> - DbgScope *getDbgScope(MDNode *N, const MachineInstr *MI); >>>> + DbgScope *getDbgScope(MDNode *N, const MachineInstr *MI, MDNode >>>> *InlinedAt); >>>> >>>> /// ConstructDbgScope - Construct the components of a scope. >>>> /// >>>> >>>> >>>> _______________________________________________ >>>> 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 bob.wilson at apple.com Fri Jan 15 15:55:02 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 15 Jan 2010 21:55:02 -0000 Subject: [llvm-commits] [llvm] r93560 - /llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Message-ID: <201001152155.o0FLt2VW001288@zion.cs.uiuc.edu> Author: bwilson Date: Fri Jan 15 15:55:02 2010 New Revision: 93560 URL: http://llvm.org/viewvc/llvm-project?rev=93560&view=rev Log: Fix a comment typo. Modified: llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Modified: llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp?rev=93560&r1=93559&r2=93560&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Fri Jan 15 15:55:02 2010 @@ -232,7 +232,7 @@ PN->eraseFromParent(); } - // If this loop has muliple exits and the exits all go to the same + // If this loop has multiple exits and the exits all go to the same // block, attempt to merge the exits. This helps several passes, such // as LoopRotation, which do not support loops with multiple exits. // SimplifyCFG also does this (and this code uses the same utility From clattner at apple.com Fri Jan 15 15:55:24 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 13:55:24 -0800 Subject: [llvm-commits] [llvm] r93247 - in /llvm/trunk: include/llvm/Metadata.h include/llvm/Module.h include/llvm/ValueSymbolTable.h lib/VMCore/Metadata.cpp lib/VMCore/Module.cpp In-Reply-To: <201001121834.o0CIY6j5010460@zion.cs.uiuc.edu> References: <201001121834.o0CIY6j5010460@zion.cs.uiuc.edu> Message-ID: <3ADAAB40-7862-4157-A22A-812890C4D332@apple.com> On Jan 12, 2010, at 10:34 AM, Devang Patel wrote: > Author: dpatel > Date: Tue Jan 12 12:34:06 2010 > New Revision: 93247 > > URL: http://llvm.org/viewvc/llvm-project?rev=93247&view=rev > Log: > Use ilist_tratis to autoinsert and remove NamedMDNode from > MDSymbolTable. Great, > +++ llvm/trunk/include/llvm/ValueSymbolTable.h Tue Jan 12 12:34:06 > 2010 > @@ -17,6 +17,7 @@ > #include "llvm/Value.h" > #include "llvm/ADT/StringMap.h" > #include "llvm/System/DataTypes.h" > +#include "llvm/ADT/ilist_node.h" You shouldn't need this #include. > +++ llvm/trunk/lib/VMCore/Metadata.cpp Tue Jan 12 12:34:06 2010 > > /// setName - Set the name of this named metadata. > void NamedMDNode::setName(StringRef N) { > + assert (!N.empty() && "Invalid named metadata name!"); > + Name = N.str(); > + if (Parent) > + Parent->getMDSymbolTable().insert(N, this); > } Doesn't this need to remove the old name from the symbol table before setting the new name? -Chris From dpatel at apple.com Fri Jan 15 16:06:00 2010 From: dpatel at apple.com (Devang Patel) Date: Fri, 15 Jan 2010 14:06:00 -0800 Subject: [llvm-commits] [llvm] r84134 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h In-Reply-To: <8265AAD1-9EDA-47AC-B3DA-A22F99378C4F@apple.com> References: <200910142108.n9EL89PR023324@zion.cs.uiuc.edu> <1103E7BC-53DE-49F4-9DC1-A335327EA2A1@apple.com> <8265AAD1-9EDA-47AC-B3DA-A22F99378C4F@apple.com> Message-ID: <267B3E40-B81C-48D4-A180-E92F14BE90B6@apple.com> On Jan 15, 2010, at 1:52 PM, Chris Lattner wrote: > ping? Right now, FE relies on MDNode::replaceAllUsesWith. We need to come up of another way to handle recursive constructs in FE. Plus, MDNode's replaceOperand may also trigger MDNode::replaceAllUsesWith. So, Between beginFunction() and endFunction(), if metadata changes (Dale is introducing new machine instruction with a metadata operand, which may change during codegen pipeline) then we need WeakVH to track MDNode. I have not had a chance to measure DbgScope's impact on performance. I'll do the measurement then update it, if required, appropriately. Meanwhile, I am adding FIXME now. - Devang > > On Jan 4, 2010, at 11:00 AM, Chris Lattner wrote: > >> >> On Jan 4, 2010, at 8:48 AM, Devang Patel wrote: >> >>> >>> On Jan 3, 2010, at 9:12 PM, Chris Lattner wrote: >>> >>>> On Oct 14, 2009, at 2:08 PM, Devang Patel wrote: >>>>> Author: dpatel >>>>> Date: Wed Oct 14 16:08:09 2009 >>>>> New Revision: 84134 >>>>> >>>>> URL: http://llvm.org/viewvc/llvm-project?rev=84134&view=rev >>>>> Log: >>>>> Add support to record DbgScope as inlined scope. >>>> >>>> Devang, why does InlinedAt need to be a WeakVH here? WeakVH is >>>> much more expensive than it looks. >>> >>> InlinedAt is a MDNode which can be replaced by another MDNode. >>> WeakVH ensures that DbgScope still points to expected MDNode. >> >> AsmPrinter is changing MDNodes? Per my previous email/bugzilla, there >> is no use of MDNode::replaceAllUsesWith that is actually valid anyway. >> >> -Chris >> >>> - >>> Devang >>>> >>>> -Chris >>>> >>>>> >>>>> 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=84134&r1=84133&r2=84134&view=diff >>>>> >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> =================================================================== >>>>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) >>>>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Oct 14 >>>>> 16:08:09 2009 >>>>> @@ -145,7 +145,10 @@ >>>>> class VISIBILITY_HIDDEN DbgScope { >>>>> DbgScope *Parent; // Parent to this scope. >>>>> DIDescriptor Desc; // Debug info descriptor for >>>>> scope. >>>>> - // Either subprogram or >>>>> block. >>>>> + // FIXME use WeakVH for Desc. >>>>> + WeakVH InlinedAt; // If this scope represents >>>>> inlined >>>>> + // function body then this >>>>> is the location >>>>> + // where this body is >>>>> inlined. >>>>> unsigned StartLabelID; // Label ID of the beginning >>>>> of scope. >>>>> unsigned EndLabelID; // Label ID of the end of scope. >>>>> const MachineInstr *LastInsn; // Last instruction of this >>>>> scope. >>>>> @@ -157,14 +160,17 @@ >>>>> // Private state for dump() >>>>> mutable unsigned IndentLevel; >>>>> public: >>>>> - DbgScope(DbgScope *P, DIDescriptor D) >>>>> - : Parent(P), Desc(D), StartLabelID(0), EndLabelID(0), >>>>> LastInsn(0), >>>>> - FirstInsn(0), IndentLevel(0) {} >>>>> + DbgScope(DbgScope *P, DIDescriptor D, MDNode *I = 0) >>>>> + : Parent(P), Desc(D), InlinedAt(I), StartLabelID(0), >>>>> EndLabelID(0), >>>>> + LastInsn(0), FirstInsn(0), IndentLevel(0) {} >>>>> virtual ~DbgScope(); >>>>> >>>>> // Accessors. >>>>> DbgScope *getParent() const { return Parent; } >>>>> DIDescriptor getDesc() const { return Desc; } >>>>> + MDNode *getInlinedAt() const { >>>>> + return dyn_cast_or_null(InlinedAt); >>>>> + } >>>>> unsigned getStartLabelID() const { return StartLabelID; } >>>>> unsigned getEndLabelID() const { return EndLabelID; } >>>>> SmallVector &getScopes() { return Scopes; } >>>>> @@ -1296,29 +1302,39 @@ >>>>> >>>>> /// getOrCreateScope - Returns the scope associated with the given >>>>> descriptor. >>>>> /// >>>>> -DbgScope *DwarfDebug::getDbgScope(MDNode *N, const MachineInstr >>>>> *MI) { >>>>> +DbgScope *DwarfDebug::getDbgScope(MDNode *N, const MachineInstr >>>>> *MI, >>>>> + MDNode *InlinedAt) { >>>>> DbgScope *&Slot = DbgScopeMap[N]; >>>>> if (Slot) return Slot; >>>>> >>>>> DbgScope *Parent = NULL; >>>>> >>>>> - DIDescriptor Scope(N); >>>>> - if (Scope.isCompileUnit()) { >>>>> - return NULL; >>>>> - } else if (Scope.isSubprogram()) { >>>>> - DISubprogram SP(N); >>>>> - DIDescriptor ParentDesc = SP.getContext(); >>>>> - if (!ParentDesc.isNull() && !ParentDesc.isCompileUnit()) >>>>> - Parent = getDbgScope(ParentDesc.getNode(), MI); >>>>> - } else if (Scope.isLexicalBlock()) { >>>>> - DILexicalBlock DB(N); >>>>> - DIDescriptor ParentDesc = DB.getContext(); >>>>> - if (!ParentDesc.isNull()) >>>>> - Parent = getDbgScope(ParentDesc.getNode(), MI); >>>>> - } else >>>>> - assert (0 && "Unexpected scope info"); >>>>> + if (InlinedAt) { >>>>> + DILocation IL(InlinedAt); >>>>> + assert (!IL.isNull() && "Invalid InlindAt location!"); >>>>> + DenseMap::iterator DSI = >>>>> + DbgScopeMap.find(IL.getScope().getNode()); >>>>> + assert (DSI != DbgScopeMap.end() && "Unable to find InlineAt >>>>> scope!"); >>>>> + Parent = DSI->second; >>>>> + } else { >>>>> + DIDescriptor Scope(N); >>>>> + if (Scope.isCompileUnit()) { >>>>> + return NULL; >>>>> + } else if (Scope.isSubprogram()) { >>>>> + DISubprogram SP(N); >>>>> + DIDescriptor ParentDesc = SP.getContext(); >>>>> + if (!ParentDesc.isNull() && !ParentDesc.isCompileUnit()) >>>>> + Parent = getDbgScope(ParentDesc.getNode(), MI, InlinedAt); >>>>> + } else if (Scope.isLexicalBlock()) { >>>>> + DILexicalBlock DB(N); >>>>> + DIDescriptor ParentDesc = DB.getContext(); >>>>> + if (!ParentDesc.isNull()) >>>>> + Parent = getDbgScope(ParentDesc.getNode(), MI, InlinedAt); >>>>> + } else >>>>> + assert (0 && "Unexpected scope info"); >>>>> + } >>>>> >>>>> - Slot = new DbgScope(Parent, DIDescriptor(N)); >>>>> + Slot = new DbgScope(Parent, DIDescriptor(N), InlinedAt); >>>>> Slot->setFirstInsn(MI); >>>>> >>>>> if (Parent) >>>>> @@ -1795,7 +1811,10 @@ >>>>> DIVariable DV (Var); >>>>> if (DV.isNull()) continue; >>>>> unsigned VSlot = VI->second; >>>>> - DbgScope *Scope = getDbgScope(DV.getContext().getNode(), >>>>> NULL); >>>>> + DenseMap::iterator DSI = >>>>> + DbgScopeMap.find(DV.getContext().getNode()); >>>>> + assert (DSI != DbgScopeMap.end() && "Unable to find variable >>>>> scope!"); >>>>> + DbgScope *Scope = DSI->second; >>>>> Scope->AddVariable(new DbgVariable(DV, VSlot, false)); >>>>> } >>>>> } >>>>> @@ -1849,7 +1868,7 @@ >>>>> // into a scope DIE at the end. >>>>> DIDescriptor D(DLT.Scope); >>>>> if (!D.isCompileUnit()) { >>>>> - DbgScope *Scope = getDbgScope(DLT.Scope, MInsn); >>>>> + DbgScope *Scope = getDbgScope(DLT.Scope, MInsn, >>>>> DLT.InlinedAtLoc); >>>>> Scope->setLastInsn(MInsn); >>>>> } >>>>> } >>>>> >>>>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h >>>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=84134&r1=84133&r2=84134&view=diff >>>>> >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> = >>>>> ==================================================================== >>>>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) >>>>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Oct 14 >>>>> 16:08:09 2009 >>>>> @@ -364,7 +364,7 @@ >>>>> /// getDbgScope - Returns the scope associated with the given >>>>> descriptor. >>>>> /// >>>>> DbgScope *getOrCreateScope(MDNode *N); >>>>> - DbgScope *getDbgScope(MDNode *N, const MachineInstr *MI); >>>>> + DbgScope *getDbgScope(MDNode *N, const MachineInstr *MI, MDNode >>>>> *InlinedAt); >>>>> >>>>> /// ConstructDbgScope - Construct the components of a scope. >>>>> /// >>>>> >>>>> >>>>> _______________________________________________ >>>>> llvm-commits mailing list >>>>> llvm-commits at cs.uiuc.edu >>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>>> >>> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From dpatel at apple.com Fri Jan 15 16:08:16 2010 From: dpatel at apple.com (Devang Patel) Date: Fri, 15 Jan 2010 22:08:16 -0000 Subject: [llvm-commits] [llvm] r93562 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <201001152208.o0FM8GQY001861@zion.cs.uiuc.edu> Author: dpatel Date: Fri Jan 15 16:08:16 2010 New Revision: 93562 URL: http://llvm.org/viewvc/llvm-project?rev=93562&view=rev Log: Add FIXME. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=93562&r1=93561&r2=93562&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Jan 15 16:08:16 2010 @@ -165,6 +165,7 @@ class DbgScope { DbgScope *Parent; // Parent to this scope. DIDescriptor Desc; // Debug info descriptor for scope. + // FIXME : Use of WeakVH may be expensive here. WeakVH InlinedAtLocation; // Location at which scope is inlined. bool AbstractScope; // Abstract Scope unsigned StartLabelID; // Label ID of the beginning of scope. From gohman at apple.com Fri Jan 15 16:18:16 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 15 Jan 2010 22:18:16 -0000 Subject: [llvm-commits] [llvm] r93563 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Message-ID: <201001152218.o0FMIG2J002252@zion.cs.uiuc.edu> Author: djg Date: Fri Jan 15 16:18:15 2010 New Revision: 93563 URL: http://llvm.org/viewvc/llvm-project?rev=93563&view=rev Log: Fix a typo that Anton noticed. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=93563&r1=93562&r2=93563&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Jan 15 16:18:15 2010 @@ -7579,7 +7579,7 @@ bool X86TargetLowering::isZExtFree(const Type *Ty1, const Type *Ty2) const { // x86-64 implicitly zero-extends 32-bit results in 64-bit registers. - return Ty1->isInteger(64) && Ty2->isInteger(64) && Subtarget->is64Bit(); + return Ty1->isInteger(32) && Ty2->isInteger(64) && Subtarget->is64Bit(); } bool X86TargetLowering::isZExtFree(EVT VT1, EVT VT2) const { From grosbach at apple.com Fri Jan 15 16:21:03 2010 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 15 Jan 2010 22:21:03 -0000 Subject: [llvm-commits] [llvm] r93564 - /llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp Message-ID: <201001152221.o0FML3EN002352@zion.cs.uiuc.edu> Author: grosbach Date: Fri Jan 15 16:21:03 2010 New Revision: 93564 URL: http://llvm.org/viewvc/llvm-project?rev=93564&view=rev Log: Update Thumb1 storeRegToStackSlot() and loadRegFromStackSlot() to properly handle physical registers R0-R7 when described as having a non-tGPR register class. Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp?rev=93564&r1=93563&r2=93564&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp Fri Jan 15 16:21:03 2010 @@ -105,7 +105,9 @@ (TargetRegisterInfo::isPhysicalRegister(SrcReg) && isARMLowRegister(SrcReg))) && "Unknown regclass!"); - if (RC == ARM::tGPRRegisterClass) { + if (RC == ARM::tGPRRegisterClass || + (TargetRegisterInfo::isPhysicalRegister(SrcReg) && + isARMLowRegister(SrcReg))) { MachineFunction &MF = *MBB.getParent(); MachineFrameInfo &MFI = *MF.getFrameInfo(); MachineMemOperand *MMO = @@ -130,7 +132,9 @@ (TargetRegisterInfo::isPhysicalRegister(DestReg) && isARMLowRegister(DestReg))) && "Unknown regclass!"); - if (RC == ARM::tGPRRegisterClass) { + if (RC == ARM::tGPRRegisterClass || + (TargetRegisterInfo::isPhysicalRegister(DestReg) && + isARMLowRegister(DestReg))) { MachineFunction &MF = *MBB.getParent(); MachineFrameInfo &MFI = *MF.getFrameInfo(); MachineMemOperand *MMO = From dalej at apple.com Fri Jan 15 16:22:36 2010 From: dalej at apple.com (Dale Johannesen) Date: Fri, 15 Jan 2010 22:22:36 -0000 Subject: [llvm-commits] [llvm] r93565 - in /llvm/trunk: include/llvm/Target/Target.td lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Message-ID: <201001152222.o0FMMajF002417@zion.cs.uiuc.edu> Author: johannes Date: Fri Jan 15 16:22:35 2010 New Revision: 93565 URL: http://llvm.org/viewvc/llvm-project?rev=93565&view=rev Log: DEBUG_VALUE is now variable sized, as it has a target-dependent memory address representation in it. Restore X86 printing of DEBUG_VALUE; lowering is done in X86RegisterInfo using the normal algorithm. Modified: llvm/trunk/include/llvm/Target/Target.td llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Modified: llvm/trunk/include/llvm/Target/Target.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/Target.td?rev=93565&r1=93564&r2=93565&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/Target.td (original) +++ llvm/trunk/include/llvm/Target/Target.td Fri Jan 15 16:22:35 2010 @@ -479,7 +479,7 @@ } def DEBUG_VALUE : Instruction { let OutOperandList = (ops); - let InOperandList = (ops unknown:$value, i64imm:$offset, unknown:$meta); + let InOperandList = (ops variable_ops); let AsmString = "DEBUG_VALUE"; let Namespace = "TargetInstrInfo"; let isAsCheapAsAMove = 1; Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=93565&r1=93564&r2=93565&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Fri Jan 15 16:22:35 2010 @@ -25,6 +25,7 @@ #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Mangler.h" #include "llvm/ADT/SmallString.h" +#include "llvm/Analysis/DebugInfo.h" using namespace llvm; @@ -420,6 +421,29 @@ case TargetInstrInfo::GC_LABEL: printLabel(MI); return; + case TargetInstrInfo::DEBUG_VALUE: { + if (!VerboseAsm) + return; + O << '\t' << MAI->getCommentString() << "DEBUG_VALUE: "; + unsigned NOps = MI->getNumOperands(); + // cast away const; DIetc do not take const operands for some reason + DIVariable V((MDNode*)(MI->getOperand(NOps-1).getMetadata())); + O << V.getName(); + O << " <- "; + if (NOps==3) { + // Variable is in register + assert(MI->getOperand(0).getType()==MachineOperand::MO_Register); + printOperand(MI, 0); + } else { + // Frame address. Currently handles ESP or ESP + offset only + assert(MI->getOperand(0).getType()==MachineOperand::MO_Register); + assert(MI->getOperand(3).getType()==MachineOperand::MO_Immediate); + O << '['; printOperand(MI, 0); O << '+'; printOperand(MI, 3); O << ']'; + } + O << "+"; + printOperand(MI, NOps-2); + return; + } case TargetInstrInfo::INLINEASM: printInlineAsm(MI); return; From gohman at apple.com Fri Jan 15 16:22:58 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 15 Jan 2010 22:22:58 -0000 Subject: [llvm-commits] [llvm] r93566 - /llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Message-ID: <201001152222.o0FMMxRX002442@zion.cs.uiuc.edu> Author: djg Date: Fri Jan 15 16:22:58 2010 New Revision: 93566 URL: http://llvm.org/viewvc/llvm-project?rev=93566&view=rev Log: Add comments to the dump() and dumpr() routines. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=93566&r1=93565&r2=93566&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Fri Jan 15 16:22:58 2010 @@ -1297,9 +1297,17 @@ /// void printWithFullDepth(raw_ostream &O, const SelectionDAG *G = 0, unsigned indent = 0) const; + /// dump - Dump this node, for debugging. void dump() const; + /// dumpr - Dump (recursively) this node and its use-def subgraph. void dumpr() const; + /// dump - Dump this node, for debugging. + /// The given SelectionDAG allows target-specific nodes to be printed + /// in human-readable form. void dump(const SelectionDAG *G) const; + /// dumpr - Dump (recursively) this node and its use-def subgraph. + /// The given SelectionDAG allows target-specific nodes to be printed + /// in human-readable form. void dumpr(const SelectionDAG *G) const; /// dumpWithDepth - printWithDepth to dbgs(). /// From grosbach at apple.com Fri Jan 15 16:27:38 2010 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 15 Jan 2010 22:27:38 -0000 Subject: [llvm-commits] [llvm] r93567 - /llvm/trunk/test/CodeGen/Thumb/2010-01-15-local-alloc-spill-physical.ll Message-ID: <201001152227.o0FMRcjR002598@zion.cs.uiuc.edu> Author: grosbach Date: Fri Jan 15 16:27:37 2010 New Revision: 93567 URL: http://llvm.org/viewvc/llvm-project?rev=93567&view=rev Log: add testcase for r93564 Added: llvm/trunk/test/CodeGen/Thumb/2010-01-15-local-alloc-spill-physical.ll Added: llvm/trunk/test/CodeGen/Thumb/2010-01-15-local-alloc-spill-physical.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/2010-01-15-local-alloc-spill-physical.ll?rev=93567&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/2010-01-15-local-alloc-spill-physical.ll (added) +++ llvm/trunk/test/CodeGen/Thumb/2010-01-15-local-alloc-spill-physical.ll Fri Jan 15 16:27:37 2010 @@ -0,0 +1,20 @@ +; RUN: llc < %s -regalloc=local -relocation-model=pic | FileCheck %s + +target triple = "thumbv6-apple-darwin10" + + at fred = internal global i32 0 ; [#uses=1] + +define arm_apcscc void @foo() nounwind { +entry: +; CHECK: str r0, [sp] + %0 = call arm_apcscc i32 (...)* @bar() nounwind ; [#uses=1] +; CHECK: blx _bar +; CHECK: ldr r1, [sp] + store i32 %0, i32* @fred, align 4 + br label %return + +return: ; preds = %entry + ret void +} + +declare arm_apcscc i32 @bar(...) From clattner at apple.com Fri Jan 15 16:28:52 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 14:28:52 -0800 Subject: [llvm-commits] [llvm] r93531 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/VMCore/AutoUpgrade.cpp lib/VMCore/IntrinsicInst.cpp lib/VMCore/Verifier.cpp test/Assembler/functionlocal-metadata.ll test/DebugInfo/2009-10-16-Scope.ll test/DebugInfo/printdbginfo2.ll In-Reply-To: <201001151904.o0FJ4AkT026653@zion.cs.uiuc.edu> References: <201001151904.o0FJ4AkT026653@zion.cs.uiuc.edu> Message-ID: On Jan 15, 2010, at 11:04 AM, Victor Hernandez wrote: > Author: hernande > Date: Fri Jan 15 13:04:09 2010 > New Revision: 93531 > > URL: http://llvm.org/viewvc/llvm-project?rev=93531&view=rev > Log: > Improve llvm.dbg.declare intrinsic by referring directly to the > storage in its first argument, via function-local metadata (instead > of via a bitcast). > This patch also cleans up code that expects there to be a bitcast in > the first argument and testcases that call llvm.dbg.declare. > It also strips old llvm.dbg.declare intrinsics that did not pass > metadata as the first argument. Great! Please remove OnlyUsedByDbgInfoIntrinsics and its callers, since it is now dead with this change. Also InstCombiner::hasOneUsePlusDeclare and probably other stuff can be removed. > +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Fri Jan 15 13:04:09 2010 > @@ -1034,26 +1032,22 @@ > /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. > Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, > Instruction *InsertBefore) { > if (!DeclareFn) > DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); > > + Value *Elts[] = { Storage }; > + Value *Args[] = { MDNode::get(Storage->getContext(), Elts, 1), > D.getNode() }; You can just pass in &Storage to eliminate the Elts array. > 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) { > if (!DeclareFn) > DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); > > + Value *Elts[] = { Storage }; > + Value *Args[] = { MDNode::get(Storage->getContext(), Elts, 1), > D.getNode() }; > return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd); Likewise. > @@ -1258,25 +1252,24 @@ > > +const DbgDeclareInst *llvm::findDbgDeclare(const Value *V) { This function needs comments, and should be static within the function since it is only used by getLocationInfo. findDbgGlobalDeclare should similarly be local to the file. The bigger issue is that findDbgDeclare is linear time with the size of a function (aka, really really slow). Because it is O(n), DbgInfoPrinter is O(n^2). findDbgGlobalDeclare is also O(n) in # global variables with debug information. I think that the answer here is to remove getLocationInfo and replace it with a more efficient interface, what do you think? > +++ llvm/trunk/lib/VMCore/Verifier.cpp Fri Jan 15 13:04:09 2010 > @@ -1590,9 +1590,10 @@ > default: > break; > case Intrinsic::dbg_declare: // llvm.dbg.declare > - if (Constant *C = dyn_cast(CI.getOperand(1))) > - Assert1(C && !isa(C), > - "invalid llvm.dbg.declare intrinsic call", &CI); > + if (MDNode *MD = dyn_cast(CI.getOperand(1))) this should use cast_or_null. > + if (Constant *C = dyn_cast(MD->getOperand(0))) > + Assert1(C && !isa(C), > + "invalid llvm.dbg.declare intrinsic call", &CI); This assert is not checking for C being null correctly, nor is it checking for Op#1 not being MD correctly. -Chris From clattner at apple.com Fri Jan 15 16:30:14 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 14:30:14 -0800 Subject: [llvm-commits] [llvm] r84134 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h In-Reply-To: <267B3E40-B81C-48D4-A180-E92F14BE90B6@apple.com> References: <200910142108.n9EL89PR023324@zion.cs.uiuc.edu> <1103E7BC-53DE-49F4-9DC1-A335327EA2A1@apple.com> <8265AAD1-9EDA-47AC-B3DA-A22F99378C4F@apple.com> <267B3E40-B81C-48D4-A180-E92F14BE90B6@apple.com> Message-ID: <4C66E3E1-3386-4656-98F7-1D66FBD077A2@apple.com> On Jan 15, 2010, at 2:06 PM, Devang Patel wrote: > > On Jan 15, 2010, at 1:52 PM, Chris Lattner wrote: > >> ping? > > Right now, FE relies on MDNode::replaceAllUsesWith. We need to come > up of another way to handle recursive constructs in FE. This code is in the code generator's asmwriter, not in the frontend. The frontend should be done by the time these are created. > Plus, > MDNode's replaceOperand may also trigger MDNode::replaceAllUsesWith. > So, Between beginFunction() and endFunction(), if metadata changes > (Dale is introducing new machine instruction with a metadata > operand, which may change during codegen pipeline) then we need > WeakVH to track MDNode. > > I have not had a chance to measure DbgScope's impact on performance. > I'll do the measurement then update it, if required, appropriately. > Meanwhile, I am adding FIXME now. The code generator should only be run when the metadata is all done, I don't see how it can change here. -Chris From dag at cray.com Fri Jan 15 16:38:01 2010 From: dag at cray.com (David Greene) Date: Fri, 15 Jan 2010 16:38:01 -0600 Subject: [llvm-commits] [llvm] r93566 - /llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h In-Reply-To: <201001152222.o0FMMxRX002442@zion.cs.uiuc.edu> References: <201001152222.o0FMMxRX002442@zion.cs.uiuc.edu> Message-ID: <201001151638.01373.dag@cray.com> On Friday 15 January 2010 16:22, Dan Gohman wrote: > + /// dump - Dump this node, for debugging. > void dump() const; > + /// dump - Dump this node, for debugging. > + /// The given SelectionDAG allows target-specific nodes to be printed > + /// in human-readable form. > void dump(const SelectionDAG *G) const; Why not use default parameters? Usually I don't like them but in this case it makes sense. I can clean this up as I work through the other changes. -Dave From arplynn at gmail.com Fri Jan 15 16:39:25 2010 From: arplynn at gmail.com (Alastair Lynn) Date: Fri, 15 Jan 2010 22:39:25 +0000 Subject: [llvm-commits] [llvm] r93556 - in /llvm/trunk/lib/Target/MSP430: MSP430ISelLowering.cpp MSP430ISelLowering.h In-Reply-To: <201001152119.o0FLJh4K032307@zion.cs.uiuc.edu> References: <201001152119.o0FLJh4K032307@zion.cs.uiuc.edu> Message-ID: Hi Anton- > +bool MSP430TargetLowering::isZExtFree(const Type *Ty1, const Type *Ty2) const { > + // MSP430 implicitly zero-extends 8-bit results in 16-bit registers. > + return 0 && Ty1->isInteger(8) && Ty2->isInteger(16); > +} > + > +bool MSP430TargetLowering::isZExtFree(EVT VT1, EVT VT2) const { > + // MSP430 implicitly zero-extends 8-bit results in 16-bit registers. > + return 0 && VT1 == MVT::i8 && VT2 == MVT::i16; > +} Forgive my possible lack of understanding, but surely these shouldn't have the 0 && at the start? Alastair From anton at korobeynikov.info Fri Jan 15 16:44:25 2010 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Sat, 16 Jan 2010 01:44:25 +0300 Subject: [llvm-commits] [llvm] r93556 - in /llvm/trunk/lib/Target/MSP430: MSP430ISelLowering.cpp MSP430ISelLowering.h In-Reply-To: References: <201001152119.o0FLJh4K032307@zion.cs.uiuc.edu> Message-ID: Hello, Alastair > Forgive my possible lack of understanding, but surely these shouldn't have the 0 && at the start? For now - they should. :) I wanted to show Dan code pessimization. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From clattner at apple.com Fri Jan 15 16:46:29 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 14:46:29 -0800 Subject: [llvm-commits] [llvm] r93565 - in /llvm/trunk: include/llvm/Target/Target.td lib/Target/X86/AsmPrinter/X86MCInstLower.cpp In-Reply-To: <201001152222.o0FMMajF002417@zion.cs.uiuc.edu> References: <201001152222.o0FMMajF002417@zion.cs.uiuc.edu> Message-ID: On Jan 15, 2010, at 2:22 PM, Dale Johannesen wrote: > Author: johannes > Date: Fri Jan 15 16:22:35 2010 > New Revision: 93565 > > URL: http://llvm.org/viewvc/llvm-project?rev=93565&view=rev > Log: > DEBUG_VALUE is now variable sized, as it has a > target-dependent memory address representation in it. > Restore X86 printing of DEBUG_VALUE; lowering is > done in X86RegisterInfo using the normal algorithm. Ok. > + case TargetInstrInfo::DEBUG_VALUE: { > + if (!VerboseAsm) > + return; > + O << '\t' << MAI->getCommentString() << "DEBUG_VALUE: "; > + unsigned NOps = MI->getNumOperands(); Do you plan to move this into the target-independent AsmPrinter code? > + // cast away const; DIetc do not take const operands for some > reason > + DIVariable V((MDNode*)(MI->getOperand(NOps-1).getMetadata())); This shouldn't need a cast. > + O << V.getName(); > + O << " <- "; > + if (NOps==3) { > + // Variable is in register > + assert(MI- > >getOperand(0).getType()==MachineOperand::MO_Register); > + printOperand(MI, 0); > + } else { > + // Frame address. Currently handles ESP or ESP + offset only > + assert(MI- > >getOperand(0).getType()==MachineOperand::MO_Register); > + assert(MI- > >getOperand(3).getType()==MachineOperand::MO_Immediate); What about EBP? -Chris From clattner at apple.com Fri Jan 15 16:51:24 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 14:51:24 -0800 Subject: [llvm-commits] [llvm] r83207 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp In-Reply-To: <97442F43-BD5F-4BF2-8BFE-B472838B1A34@apple.com> References: <200910011825.n91IPNZF028439@zion.cs.uiuc.edu> <0C06FEC3-55F5-477E-A885-3D9EE47AD5AD@apple.com> <4764FB07-DE5E-457B-91C7-25E07D0297A9@apple.com> <3BE3E47E-F850-47A6-A28B-163A7C01A34E@apple.com> <97442F43-BD5F-4BF2-8BFE-B472838B1A34@apple.com> Message-ID: ping? On Jan 4, 2010, at 10:59 AM, Chris Lattner wrote: > > On Jan 4, 2010, at 8:55 AM, Devang Patel wrote: > >> >> On Jan 3, 2010, at 9:22 PM, Chris Lattner wrote: >> >>> On Oct 1, 2009, at 2:35 PM, Evan Cheng wrote: >>>> Can't we compute these on demand so codegen passes don't have to >>>> change these? >>> >>> Devang, I never saw an answer to this. >> >> Now, we compute this just before asmprint. > > DbgScope still maintains these as instance variables. I see that it > is now an asmprinter local data structure, so we can't have pointer > invalidation issues. However, we still have memory use to consider. > >>> I have serious concerns about DbgScope and the presence of two >>> MachineInstr*'s that can dangle seems very dubious. >> >> DbgScope is representing lexical scopes for debug info. > > How many DbgScopes are created? > > -Chris > >> This info is collected based on debug info attached with >> MachineInstr. DbgScope keeps MachineInstr so >> that we can avoid printing labels until the instruction is printed. >> >> - >> Devang >>> >>> -Chris >>> >>>> >>>> Evan >>>> >>>> On Oct 1, 2009, at 2:25 PM, Devang Patel wrote: >>>> >>>>> >>>>> On Oct 1, 2009, at 1:38 PM, Dan Gohman wrote: >>>>> >>>>>> >>>>>> On Oct 1, 2009, at 11:25 AM, Devang Patel wrote: >>>>>> >>>>>>> Author: dpatel >>>>>>> Date: Thu Oct 1 13:25:23 2009 >>>>>>> New Revision: 83207 >>>>>>> >>>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=83207&view=rev >>>>>>> Log: >>>>>>> Record first and last instruction of a scope in DbgScope. >>>>>> >>>>>> How does this interact with Post-RA scheduling, MachineLICM, >>>>>> and MachineHoist? >>>>> >>>>> It depends on when we run this DwarfDebug pass. Today, at iSel >>>>> time we put the stake in the ground and emit label node (or >>>>> instruction) to mark scope boundaries. In future, this will be >>>>> divided into three steps >>>>> >>>>> 1 - Just before AsmPrinter, the DwarfDebug will note down scope >>>>> boundaries in DbgScope based on info attached with an machine >>>>> instruction. >>>>> 2 - @processDebugLoc() in AsmPrinter the labels will be emitted >>>>> to mark scope boundaries and DW will be updated according. >>>>> 3 - At the end, the scope DIEs will be created based on DbgScope >>>>> entries. >>>>> >>>>> So MachineLICM will have as much freedom as standard LICM. >>>>> >>>>> - >>>>> Devang >>>>> _______________________________________________ >>>>> llvm-commits mailing list >>>>> llvm-commits at cs.uiuc.edu >>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>>> >>>> _______________________________________________ >>>> llvm-commits mailing list >>>> llvm-commits at cs.uiuc.edu >>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> >> > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100115/5120c8f0/attachment.html From clattner at apple.com Fri Jan 15 16:56:51 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 14:56:51 -0800 Subject: [llvm-commits] [llvm] r93400 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp In-Reply-To: References: <201001140145.o0E1jEDi032182@zion.cs.uiuc.edu> <352a1fb21001140939k4f8055e0i90ee37ca4540e7eb@mail.gmail.com> <3AEBD80F-B03B-41F8-BD98-F6758DA36F85@apple.com> Message-ID: <8732090F-2F56-48F8-A446-6A3FCB80F60F@apple.com> On Jan 14, 2010, at 12:15 PM, Victor Hernandez wrote: > > On Jan 14, 2010, at 10:20 AM, Victor Hernandez wrote: > >> >> On Jan 14, 2010, at 9:39 AM, Devang Patel wrote: >> >>> On Wed, Jan 13, 2010 at 5:45 PM, Victor Hernandez >> > wrote: >>>> Author: hernande >>>> Date: Wed Jan 13 19:45:14 2010 >>>> New Revision: 93400 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=93400&view=rev >>>> Log: >>>> Add MDNode::getFunction(), which figures out the metadata's >>>> function, if it has function that it is local to. >>> >>> so will this replace isFunctionLocal() ? >> >> No, I don't think it should replace isFunctionLocal(). >> getFunction() is an expensive operation that should not be used in >> performance-critical tasks (currently it is only used when printing >> out ll files). isFunctionLocal() is fast and will very rarely give >> a false positive (when a metadata is created function-local, but >> then the operands are modified later). > > After our discussion, I am more amenable to replacing > isFunctionLocal() with getFunction(). I just committed a debug > version of getFunction() that asserts that function-local metadata > has only 1 parent function. Can you elaborate on why? Your description before (isfunctionlocal is trivial and fast, nothing important should call getFunction) makes perfect sense to me. Please add a comment on getFunction() indicating that it is slow and should not be used for performance critical code. -Chris From clattner at apple.com Fri Jan 15 16:58:45 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 14:58:45 -0800 Subject: [llvm-commits] [llvm] r93400 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp In-Reply-To: <201001140145.o0E1jEDi032182@zion.cs.uiuc.edu> References: <201001140145.o0E1jEDi032182@zion.cs.uiuc.edu> Message-ID: On Jan 13, 2010, at 5:45 PM, Victor Hernandez wrote: > Author: hernande > Date: Wed Jan 13 19:45:14 2010 > New Revision: 93400 > > URL: http://llvm.org/viewvc/llvm-project?rev=93400&view=rev > Log: > Add MDNode::getFunction(), which figures out the metadata's > function, if it has function that it is local to. Ok. > +++ llvm/trunk/lib/VMCore/Metadata.cpp Wed Jan 13 19:45:14 2010 > @@ -121,6 +121,40 @@ > Op->~MDNodeOperand(); > } > > +static Function *getFunctionHelper(const MDNode *N, > + SmallPtrSet > &Visited) { > + assert(N->isFunctionLocal() && "Should only be called on function- > local MD"); > + Function *F = NULL; You don't need F here except in the MDNode case. All the other cases should just "return BB->getParent();" for example. This allows you to unnest the "else if"s into a series of "if"s. Also, function mdnodes can never be cyclic, why do you need the smallptrset? -Chris > + // Only visit each MDNode once. > + if (!Visited.insert(N)) return F; > + > + for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { > + Value *V = N->getOperand(i); > + if (!V) continue; > + if (Instruction *I = dyn_cast(V)) > + F = I->getParent()->getParent(); > + else if (BasicBlock *BB = dyn_cast(V)) > + F = BB->getParent(); > + else if (Argument *A = dyn_cast(V)) > + F = A->getParent(); > + else if (MDNode *MD = dyn_cast(V)) > + if (MD->isFunctionLocal()) > + F = getFunctionHelper(MD, Visited); > + if (F) break; > + } > + > + return F; > +} > + > +// getFunction - If this metadata is function-local and recursively > has a > +// function-local operand, return the first such operand's parent > function. > +// Otherwise, return null. > +Function *MDNode::getFunction() const { > + if (!isFunctionLocal()) return NULL; > + SmallPtrSet Visited; > + return getFunctionHelper(this, Visited); > +} > + > // destroy - Delete this node. Only when there are no uses. > void MDNode::destroy() { > setValueSubclassData(getSubclassDataFromValue() | DestroyFlag); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From kremenek at apple.com Fri Jan 15 16:59:13 2010 From: kremenek at apple.com (Ted Kremenek) Date: Fri, 15 Jan 2010 22:59:13 -0000 Subject: [llvm-commits] [llvm] r93570 - /llvm/trunk/lib/Target/MSP430/CMakeLists.txt Message-ID: <201001152259.o0FMxDu9003847@zion.cs.uiuc.edu> Author: kremenek Date: Fri Jan 15 16:59:11 2010 New Revision: 93570 URL: http://llvm.org/viewvc/llvm-project?rev=93570&view=rev Log: Update CMake build. Modified: llvm/trunk/lib/Target/MSP430/CMakeLists.txt Modified: llvm/trunk/lib/Target/MSP430/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/CMakeLists.txt?rev=93570&r1=93569&r2=93570&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/MSP430/CMakeLists.txt Fri Jan 15 16:59:11 2010 @@ -11,9 +11,10 @@ tablegen(MSP430GenSubtarget.inc -gen-subtarget) add_llvm_target(MSP430CodeGen - MSP430InstrInfo.cpp + MSP430BranchSelector.cpp MSP430ISelDAGToDAG.cpp MSP430ISelLowering.cpp + MSP430InstrInfo.cpp MSP430MCAsmInfo.cpp MSP430RegisterInfo.cpp MSP430Subtarget.cpp From kremenek at apple.com Fri Jan 15 16:59:47 2010 From: kremenek at apple.com (Ted Kremenek) Date: Fri, 15 Jan 2010 22:59:47 -0000 Subject: [llvm-commits] [llvm] r93571 - /llvm/trunk/lib/CodeGen/CMakeLists.txt Message-ID: <201001152259.o0FMxl3Z003877@zion.cs.uiuc.edu> Author: kremenek Date: Fri Jan 15 16:59:46 2010 New Revision: 93571 URL: http://llvm.org/viewvc/llvm-project?rev=93571&view=rev Log: Update CMake build. Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=93571&r1=93570&r2=93571&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/CMakeLists.txt Fri Jan 15 16:59:46 2010 @@ -21,7 +21,6 @@ LiveStackAnalysis.cpp LiveVariables.cpp LowerSubregs.cpp - MachOCodeEmitter.cpp MachOWriter.cpp MachineBasicBlock.cpp MachineDominators.cpp From dalej at apple.com Fri Jan 15 16:59:55 2010 From: dalej at apple.com (Dale Johannesen) Date: Fri, 15 Jan 2010 14:59:55 -0800 Subject: [llvm-commits] [llvm] r93565 - in /llvm/trunk: include/llvm/Target/Target.td lib/Target/X86/AsmPrinter/X86MCInstLower.cpp In-Reply-To: References: <201001152222.o0FMMajF002417@zion.cs.uiuc.edu> Message-ID: <5E413AC0-70C5-4441-A39C-B17811DA8370@apple.com> On Jan 15, 2010, at 2:46 PMPST, Chris Lattner wrote: > On Jan 15, 2010, at 2:22 PM, Dale Johannesen wrote: >> Author: johannes >> Date: Fri Jan 15 16:22:35 2010 >> New Revision: 93565 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=93565&view=rev >> Log: >> DEBUG_VALUE is now variable sized, as it has a >> target-dependent memory address representation in it. >> Restore X86 printing of DEBUG_VALUE; lowering is >> done in X86RegisterInfo using the normal algorithm. > > Ok. > >> + case TargetInstrInfo::DEBUG_VALUE: { >> + if (!VerboseAsm) >> + return; >> + O << '\t' << MAI->getCommentString() << "DEBUG_VALUE: "; >> + unsigned NOps = MI->getNumOperands(); > > Do you plan to move this into the target-independent AsmPrinter code? I can move part of it if you feel strongly; part of it is target dependent. The whole printing-as-comment thing is temporary anyway. My expectation is that that will go away before we move on to another target, but that could be wrong. >> + // cast away const; DIetc do not take const operands for some >> reason >> + DIVariable V((MDNode*)(MI->getOperand(NOps-1).getMetadata())); > > This shouldn't need a cast. Well, I could "fix" it by changing getMetadata not to return a const*, but I'd rather not; metadata is read-only at this point, so it *should* return a const*. The DI* constructors do not take const MDNode*. IMO they ought to, but that's a big change (doing it consistently throughout and patching all the uses, I mean). >> + O << V.getName(); >> + O << " <- "; >> + if (NOps==3) { >> + // Variable is in register >> + assert(MI- >> >getOperand(0).getType()==MachineOperand::MO_Register); >> + printOperand(MI, 0); >> + } else { >> + // Frame address. Currently handles ESP or ESP + offset only >> + assert(MI- >> >getOperand(0).getType()==MachineOperand::MO_Register); >> + assert(MI- >> >getOperand(3).getType()==MachineOperand::MO_Immediate); > > What about EBP? I'll fix the comment. From aaronngray.lists at googlemail.com Fri Jan 15 17:00:47 2010 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Fri, 15 Jan 2010 23:00:47 +0000 Subject: [llvm-commits] [Cygwin] No runtime lib profile patch In-Reply-To: <9719867c1001130834h6ec68c3fldb62470f37262f4e@mail.gmail.com> References: <9719867c1001130834h6ec68c3fldb62470f37262f4e@mail.gmail.com> Message-ID: <9719867c1001151500l655c2311pf440893aa1fef193@mail.gmail.com> 2010/1/13 Aaron Gray > Hi, > > I am getting the following build error on doing a full build on LLVM > on Cygwin :- > > make[2]: Entering directory `/home/ang/build/llvm/runtime/libprofile' > llvm[2]: Linking Debug Loadable Module profile_rt.dll > /usr/bin/ld: warning: cannot find entry symbol __cygwin_dll_entry at 12; > defaulting > to 67941000 > /home/ang/build/llvm/runtime/libprofile/Debug/BasicBlockTracing.o: In > function ` > BBTraceAtExitHandler': > Index: runtime/Makefile > =================================================================== > --- runtime/Makefile (revision 93262) > +++ runtime/Makefile (working copy) > @@ -20,8 +20,12 @@ > PARALLEL_DIRS := $(filter-out libprofile, $(PARALLEL_DIRS)) > endif > > +ifeq ($(OS), Cygwin) > +PARALLEL_DIRS := $(filter-out libprofile, $(PARALLEL_DIRS)) > +endif > + > endif > > include $(LEVEL)/Makefile.common > > install:: > > Could someone commit this patch. Dynamic libraries are not supported on Cygwin. And unless someone needs profiling on Cygwin it can wait till its actually needed. Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100115/17d1977e/attachment.html From clattner at apple.com Fri Jan 15 17:02:28 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 15 Jan 2010 15:02:28 -0800 Subject: [llvm-commits] [llvm] r93565 - in /llvm/trunk: include/llvm/Target/Target.td lib/Target/X86/AsmPrinter/X86MCInstLower.cpp In-Reply-To: <5E413AC0-70C5-4441-A39C-B17811DA8370@apple.com> References: <201001152222.o0FMMajF002417@zion.cs.uiuc.edu> <5E413AC0-70C5-4441-A39C-B17811DA8370@apple.com> Message-ID: On Jan 15, 2010, at 2:59 PM, Dale Johannesen wrote: >>> + case TargetInstrInfo::DEBUG_VALUE: { >>> + if (!VerboseAsm) >>> + return; >>> + O << '\t' << MAI->getCommentString() << "DEBUG_VALUE: "; >>> + unsigned NOps = MI->getNumOperands(); >> >> Do you plan to move this into the target-independent AsmPrinter code? > > I can move part of it if you feel strongly; part of it is target > dependent. The whole printing-as-comment thing is temporary > anyway. My expectation is that that will go away before we move on > to another target, but that could be wrong. Ok, if it grows much or we add another target, we'll need to commonize it. I'm ok with leaving it here for now. The target hook will be needed when we actually start emitting dwarf, but we can design it lazily when we know more. >>> + // cast away const; DIetc do not take const operands for some >>> reason >>> + DIVariable V((MDNode*)(MI->getOperand(NOps-1).getMetadata())); >> >> This shouldn't need a cast. > > Well, I could "fix" it by changing getMetadata not to return a > const*, but I'd rather not; metadata is read-only at this point, so > it *should* return a const*. The DI* constructors do not take > const MDNode*. IMO they ought to, but that's a big change (doing it > consistently throughout and patching all the uses, I mean). Sigh, you're right, the DI* constructors should take a const pointer. Please file a bugzilla about this, thanks Dale. -Chris From gohman at apple.com Fri Jan 15 17:14:06 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 15 Jan 2010 15:14:06 -0800 Subject: [llvm-commits] [llvm] r93566 - /llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h In-Reply-To: <201001151638.01373.dag@cray.com> References: <201001152222.o0FMMxRX002442@zion.cs.uiuc.edu> <201001151638.01373.dag@cray.com> Message-ID: <318C52CA-93AC-46AF-8FD6-E5625CB2B1B8@apple.com> On Jan 15, 2010, at 2:38 PM, David Greene wrote: > On Friday 15 January 2010 16:22, Dan Gohman wrote: > >> + /// dump - Dump this node, for debugging. >> void dump() const; >> + /// dump - Dump this node, for debugging. >> + /// The given SelectionDAG allows target-specific nodes to be printed >> + /// in human-readable form. >> void dump(const SelectionDAG *G) const; > > Why not use default parameters? Usually I don't like them but in this case > it makes sense. I can clean this up as I work through the other changes. Default parameters are not debugger-friendly, with popular compilers and debuggers. Dan From sabre at nondot.org Fri Jan 15 17:18:18 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 23:18:18 -0000 Subject: [llvm-commits] [llvm] r93575 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Message-ID: <201001152318.o0FNIIhT004621@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 17:18:17 2010 New Revision: 93575 URL: http://llvm.org/viewvc/llvm-project?rev=93575&view=rev Log: add a AsmPrinter::GetGlobalValueSymbol and GetExternalSymbolSymbol helper method, use it to simplify some code. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=93575&r1=93574&r2=93575&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Fri Jan 15 17:18:17 2010 @@ -339,6 +339,14 @@ /// EmitComments - Pretty-print comments for basic blocks void EmitComments(const MachineBasicBlock &MBB) const; + /// GetGlobalValueSymbol - Return the MCSymbol for the specified global + /// value. + MCSymbol *GetGlobalValueSymbol(const GlobalValue *GV) const; + + /// GetExternalSymbolSymbol - Return the MCSymbol for the specified + /// ExternalSymbol. + MCSymbol *GetExternalSymbolSymbol(StringRef Sym) const; + /// GetMBBSymbol - Return the MCSymbol corresponding to the specified basic /// block label. MCSymbol *GetMBBSymbol(unsigned MBBID) const; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93575&r1=93574&r2=93575&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Jan 15 17:18:17 2010 @@ -1698,6 +1698,22 @@ return OutContext.GetOrCreateSymbol(Name.str()); } +/// GetGlobalValueSymbol - Return the MCSymbol for the specified global +/// value. +MCSymbol *AsmPrinter::GetGlobalValueSymbol(const GlobalValue *GV) const { + SmallString<60> NameStr; + Mang->getNameWithPrefix(NameStr, GV, false); + return OutContext.GetOrCreateSymbol(NameStr.str()); +} + +/// GetExternalSymbolSymbol - Return the MCSymbol for the specified +/// ExternalSymbol. +MCSymbol *AsmPrinter::GetExternalSymbolSymbol(StringRef Sym) const { + SmallString<60> NameStr; + Mang->getNameWithPrefix(NameStr, Sym); + return OutContext.GetOrCreateSymbol(NameStr.str()); +} + /// EmitBasicBlockStart - This method prints the label for the specified /// MachineBasicBlock, an alignment (if present) and a comment describing Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=93575&r1=93574&r2=93575&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Fri Jan 15 17:18:17 2010 @@ -201,15 +201,13 @@ GV->hasHiddenVisibility() ? MMIMachO.getHiddenGVStubEntry(Sym) : MMIMachO.getGVStubEntry(Sym); if (StubSym == 0) { - Mang->getNameWithPrefix(TmpNameStr, GV, false); - StubSym = OutContext.GetOrCreateSymbol(TmpNameStr.str()); + StubSym = GetGlobalValueSymbol(GV); } } O << Name; } else { assert(ACPV->isExtSymbol() && "unrecognized constant pool value"); - Mang->getNameWithPrefix(TmpNameStr, ACPV->getSymbol()); - OutContext.GetOrCreateSymbol(TmpNameStr.str())->print(O, MAI); + GetExternalSymbolSymbol(ACPV->getSymbol())->print(O, MAI); } if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")"; Modified: llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp?rev=93575&r1=93574&r2=93575&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp Fri Jan 15 17:18:17 2010 @@ -181,12 +181,9 @@ O << Mang->getMangledName(MO.getGlobal()); printOffset(MO.getOffset()); break; - case MachineOperand::MO_ExternalSymbol: { - SmallString<60> NameStr; - Mang->getNameWithPrefix(NameStr, MO.getSymbolName()); - OutContext.GetOrCreateSymbol(NameStr.str())->print(O, MAI); + case MachineOperand::MO_ExternalSymbol: + GetExternalSymbolSymbol(MO.getSymbolName())->print(O, MAI); break; - } case MachineOperand::MO_ConstantPoolIndex: O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_" << MO.getIndex(); Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=93575&r1=93574&r2=93575&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Fri Jan 15 17:18:17 2010 @@ -198,7 +198,7 @@ GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); return; case MachineOperand::MO_GlobalAddress: - O << Mang->getMangledName(MO.getGlobal()); + GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); break; case MachineOperand::MO_ExternalSymbol: O << MO.getSymbolName(); From greened at obbligato.org Fri Jan 15 17:23:41 2010 From: greened at obbligato.org (David Greene) Date: Fri, 15 Jan 2010 23:23:41 -0000 Subject: [llvm-commits] [llvm] r93576 - in /llvm/trunk: lib/Target/X86/X86ISelDAGToDAG.cpp test/CodeGen/X86/2010-01-15-SelectionDAGCycle.ll Message-ID: <201001152323.o0FNNfvN004858@zion.cs.uiuc.edu> Author: greened Date: Fri Jan 15 17:23:41 2010 New Revision: 93576 URL: http://llvm.org/viewvc/llvm-project?rev=93576&view=rev Log: Fix PR6019. A load has more than one use if it feeds a bitconvert that has more than one use. Added: llvm/trunk/test/CodeGen/X86/2010-01-15-SelectionDAGCycle.ll Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=93576&r1=93575&r2=93576&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Fri Jan 15 17:23:41 2010 @@ -384,8 +384,11 @@ /// static bool isRMWLoad(SDValue N, SDValue Chain, SDValue Address, SDValue &Load) { - if (N.getOpcode() == ISD::BIT_CONVERT) + if (N.getOpcode() == ISD::BIT_CONVERT) { + if (!N.hasOneUse()) + return false; N = N.getOperand(0); + } LoadSDNode *LD = dyn_cast(N); if (!LD || LD->isVolatile()) Added: llvm/trunk/test/CodeGen/X86/2010-01-15-SelectionDAGCycle.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-01-15-SelectionDAGCycle.ll?rev=93576&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-01-15-SelectionDAGCycle.ll (added) +++ llvm/trunk/test/CodeGen/X86/2010-01-15-SelectionDAGCycle.ll Fri Jan 15 17:23:41 2010 @@ -0,0 +1,28 @@ +; RUN: llc < %s -march=x86-64 +; ModuleID = 'bugpoint-reduced-simplified.bc' +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 @numvec_(i32* noalias %ncelet, i32* noalias %ncel, i32* noalias %nfac, i32* noalias %nfabor, i32* noalias %lregis, i32* noalias %irveci, i32* noalias %irvecb, [0 x [2 x i32]]* noalias %ifacel, [0 x i32]* noalias %ifabor, [0 x i32]* noalias %inumfi, [0 x i32]* noalias %inumfb, [1 x i32]* noalias %iworkf, [0 x i32]* noalias %ismbs) { +"file bug754399.f90, line 1, bb1": + %r1037 = bitcast <2 x double> zeroinitializer to <4 x i32> ; <<4 x i32>> [#uses=1] + br label %"file bug754399.f90, line 184, in inner vector loop at depth 0, bb164" + +"file bug754399.f90, line 184, in inner vector loop at depth 0, bb164": ; preds = %"file bug754399.f90, line 184, in inner vector loop at depth 0, bb164", %"file bug754399.f90, line 1, bb1" + %tmp641 = add i64 0, 48 ; [#uses=1] + %tmp641642 = inttoptr i64 %tmp641 to <4 x i32>* ; <<4 x i32>*> [#uses=1] + %r1258 = load <4 x i32>* %tmp641642, align 4 ; <<4 x i32>> [#uses=2] + %r1295 = extractelement <4 x i32> %r1258, i32 3 ; [#uses=1] + %r1296 = sext i32 %r1295 to i64 ; [#uses=1] + %r1297 = add i64 %r1296, -1 ; [#uses=1] + %r1298183 = getelementptr [0 x i32]* %ismbs, i64 0, i64 %r1297 ; [#uses=1] + %r1298184 = load i32* %r1298183, align 4 ; [#uses=1] + %r1301 = extractelement <4 x i32> %r1037, i32 3 ; [#uses=1] + %r1302 = mul i32 %r1298184, %r1301 ; [#uses=1] + %r1306 = insertelement <4 x i32> zeroinitializer, i32 %r1302, i32 3 ; <<4 x i32>> [#uses=1] + %r1321 = add <4 x i32> %r1306, %r1258 ; <<4 x i32>> [#uses=1] + %tmp643 = add i64 0, 48 ; [#uses=1] + %tmp643644 = inttoptr i64 %tmp643 to <4 x i32>* ; <<4 x i32>*> [#uses=1] + store <4 x i32> %r1321, <4 x i32>* %tmp643644, align 4 + br label %"file bug754399.f90, line 184, in inner vector loop at depth 0, bb164" +} From sabre at nondot.org Fri Jan 15 17:25:11 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 23:25:11 -0000 Subject: [llvm-commits] [llvm] r93577 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <201001152325.o0FNPBn6004948@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 17:25:11 2010 New Revision: 93577 URL: http://llvm.org/viewvc/llvm-project?rev=93577&view=rev Log: add another helper Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=93577&r1=93576&r2=93577&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Fri Jan 15 17:25:11 2010 @@ -343,6 +343,12 @@ /// value. MCSymbol *GetGlobalValueSymbol(const GlobalValue *GV) const; + /// GetPrivateGlobalValueSymbolStub - Return the MCSymbol for a symbol with + /// global value name as its base, with the specified suffix, and where the + /// symbol is forced to have private linkage. + MCSymbol *GetPrivateGlobalValueSymbolStub(const GlobalValue *GV, + StringRef Suffix) const; + /// GetExternalSymbolSymbol - Return the MCSymbol for the specified /// ExternalSymbol. MCSymbol *GetExternalSymbolSymbol(StringRef Sym) const; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93577&r1=93576&r2=93577&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Jan 15 17:25:11 2010 @@ -1706,6 +1706,17 @@ return OutContext.GetOrCreateSymbol(NameStr.str()); } +/// GetPrivateGlobalValueSymbolStub - Return the MCSymbol for a symbol with +/// global value name as its base, with the specified suffix, and where the +/// symbol is forced to have private linkage. +MCSymbol *AsmPrinter::GetPrivateGlobalValueSymbolStub(const GlobalValue *GV, + StringRef Suffix) const { + SmallString<60> NameStr; + Mang->getNameWithPrefix(NameStr, GV, true); + NameStr.append(Suffix.begin(), Suffix.end()); + return OutContext.GetOrCreateSymbol(NameStr.str()); +} + /// GetExternalSymbolSymbol - Return the MCSymbol for the specified /// ExternalSymbol. MCSymbol *AsmPrinter::GetExternalSymbolSymbol(StringRef Sym) const { From sabre at nondot.org Fri Jan 15 17:26:49 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 23:26:49 -0000 Subject: [llvm-commits] [llvm] r93578 - /llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Message-ID: <201001152326.o0FNQo1l005009@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 17:26:49 2010 New Revision: 93578 URL: http://llvm.org/viewvc/llvm-project?rev=93578&view=rev Log: mc'ize a bunch of symbol stuff, eliminating std::strings. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=93578&r1=93577&r2=93578&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Fri Jan 15 17:26:49 2010 @@ -184,27 +184,24 @@ } else if (ACPV->isBlockAddress()) { O << GetBlockAddressSymbol(ACPV->getBlockAddress())->getName(); } else if (ACPV->isGlobalValue()) { - std::string Name; GlobalValue *GV = ACPV->getGV(); bool isIndirect = Subtarget->isTargetDarwin() && Subtarget->GVIsIndirectSymbol(GV, TM.getRelocationModel()); if (!isIndirect) - Name = Mang->getMangledName(GV); + GetGlobalValueSymbol(GV)->print(O, MAI); else { // FIXME: Remove this when Darwin transition to @GOT like syntax. - Name = Mang->getMangledName(GV, "$non_lazy_ptr", true); - MCSymbol *Sym = OutContext.GetOrCreateSymbol(StringRef(Name)); + MCSymbol *Sym = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr"); + Sym->print(O, MAI); MachineModuleInfoMachO &MMIMachO = MMI->getObjFileInfo(); const MCSymbol *&StubSym = GV->hasHiddenVisibility() ? MMIMachO.getHiddenGVStubEntry(Sym) : MMIMachO.getGVStubEntry(Sym); - if (StubSym == 0) { + if (StubSym == 0) StubSym = GetGlobalValueSymbol(GV); - } } - O << Name; } else { assert(ACPV->isExtSymbol() && "unrecognized constant pool value"); GetExternalSymbolSymbol(ACPV->getSymbol())->print(O, MAI); @@ -217,9 +214,9 @@ << "+" << (unsigned)ACPV->getPCAdjustment(); if (ACPV->mustAddCurrentAddress()) O << "-."; - O << ")"; + O << ')'; } - O << "\n"; + O << '\n'; } void getAnalysisUsage(AnalysisUsage &AU) const { @@ -379,7 +376,7 @@ else if ((Modifier && strcmp(Modifier, "hi16") == 0) || (TF & ARMII::MO_HI16)) O << ":upper16:"; - O << Mang->getMangledName(GV); + GetGlobalValueSymbol(GV)->print(O, MAI); printOffset(MO.getOffset()); @@ -1225,10 +1222,10 @@ if (isDarwin) { if (GVar->hasLocalLinkage()) { - O << MAI->getLCOMMDirective() << name << "," << Size + O << MAI->getLCOMMDirective() << name << ',' << Size << ',' << Align; } else if (GVar->hasCommonLinkage()) { - O << MAI->getCOMMDirective() << name << "," << Size + O << MAI->getCOMMDirective() << name << ',' << Size << ',' << Align; } else { OutStreamer.SwitchSection(TheSection); From dalej at apple.com Fri Jan 15 17:28:50 2010 From: dalej at apple.com (Dale Johannesen) Date: Fri, 15 Jan 2010 23:28:50 -0000 Subject: [llvm-commits] [llvm] r93579 - /llvm/trunk/include/llvm/CodeGen/MachineOperand.h Message-ID: <201001152328.o0FNSoLC005084@zion.cs.uiuc.edu> Author: johannes Date: Fri Jan 15 17:28:49 2010 New Revision: 93579 URL: http://llvm.org/viewvc/llvm-project?rev=93579&view=rev Log: Remove unneeded argument per review. Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineOperand.h?rev=93579&r1=93578&r2=93579&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineOperand.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineOperand.h Fri Jan 15 17:28:49 2010 @@ -453,11 +453,9 @@ Op.setTargetFlags(TargetFlags); return Op; } - static MachineOperand CreateMetadata(MDNode *Meta, - unsigned char TargetFlags = 0) { + static MachineOperand CreateMetadata(MDNode *Meta) { MachineOperand Op(MachineOperand::MO_Metadata); Op.Contents.MD = Meta; - Op.setTargetFlags(TargetFlags); return Op; } From dalej at apple.com Fri Jan 15 17:29:29 2010 From: dalej at apple.com (Dale Johannesen) Date: Fri, 15 Jan 2010 23:29:29 -0000 Subject: [llvm-commits] [llvm] r93580 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Message-ID: <201001152329.o0FNTTO7005117@zion.cs.uiuc.edu> Author: johannes Date: Fri Jan 15 17:29:29 2010 New Revision: 93580 URL: http://llvm.org/viewvc/llvm-project?rev=93580&view=rev Log: Adjust some comments per review. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=93580&r1=93579&r2=93580&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Fri Jan 15 17:29:29 2010 @@ -422,11 +422,13 @@ printLabel(MI); return; case TargetInstrInfo::DEBUG_VALUE: { + // FIXME: if this is implemented for another target before it goes + // away completely, the common part should be moved into AsmPrinter. if (!VerboseAsm) return; O << '\t' << MAI->getCommentString() << "DEBUG_VALUE: "; unsigned NOps = MI->getNumOperands(); - // cast away const; DIetc do not take const operands for some reason + // cast away const; DIetc do not take const operands for some reason. DIVariable V((MDNode*)(MI->getOperand(NOps-1).getMetadata())); O << V.getName(); O << " <- "; @@ -435,7 +437,7 @@ assert(MI->getOperand(0).getType()==MachineOperand::MO_Register); printOperand(MI, 0); } else { - // Frame address. Currently handles ESP or ESP + offset only + // Frame address. Currently handles register +- offset only. assert(MI->getOperand(0).getType()==MachineOperand::MO_Register); assert(MI->getOperand(3).getType()==MachineOperand::MO_Immediate); O << '['; printOperand(MI, 0); O << '+'; printOperand(MI, 3); O << ']'; From kremenek at apple.com Fri Jan 15 17:29:34 2010 From: kremenek at apple.com (Ted Kremenek) Date: Fri, 15 Jan 2010 23:29:34 -0000 Subject: [llvm-commits] [llvm] r93581 - in /llvm/trunk: include/llvm/Support/Allocator.h lib/Support/Allocator.cpp Message-ID: <201001152329.o0FNTY2I005137@zion.cs.uiuc.edu> Author: kremenek Date: Fri Jan 15 17:29:34 2010 New Revision: 93581 URL: http://llvm.org/viewvc/llvm-project?rev=93581&view=rev Log: BumpPtrAllocator: Have the DefaultSlabAllocator created at runtime, not initialization time. This removes one of the 'init_constructors' reported in . Modified: llvm/trunk/include/llvm/Support/Allocator.h llvm/trunk/lib/Support/Allocator.cpp Modified: llvm/trunk/include/llvm/Support/Allocator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=93581&r1=93580&r2=93581&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Allocator.h (original) +++ llvm/trunk/include/llvm/Support/Allocator.h Fri Jan 15 17:29:34 2010 @@ -128,11 +128,11 @@ /// one. void DeallocateSlabs(MemSlab *Slab); - static MallocSlabAllocator DefaultSlabAllocator; + static MallocSlabAllocator &GetDefaultSlabAllocator(); public: BumpPtrAllocator(size_t size = 4096, size_t threshold = 4096, - SlabAllocator &allocator = DefaultSlabAllocator); + SlabAllocator &allocator = GetDefaultSlabAllocator()); ~BumpPtrAllocator(); /// Reset - Deallocate all but the current slab and reset the current pointer Modified: llvm/trunk/lib/Support/Allocator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=93581&r1=93580&r2=93581&view=diff ============================================================================== --- llvm/trunk/lib/Support/Allocator.cpp (original) +++ llvm/trunk/lib/Support/Allocator.cpp Fri Jan 15 17:29:34 2010 @@ -142,8 +142,10 @@ << " (includes alignment, etc)\n"; } -MallocSlabAllocator BumpPtrAllocator::DefaultSlabAllocator = - MallocSlabAllocator(); +MallocSlabAllocator &BumpPtrAllocator::GetDefaultSlabAllocator() { + static MallocSlabAllocator DefaultSlabAllocator; + return DefaultSlabAllocator; +} SlabAllocator::~SlabAllocator() { } From sabre at nondot.org Fri Jan 15 17:31:55 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 23:31:55 -0000 Subject: [llvm-commits] [llvm] r93582 - /llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Message-ID: <201001152331.o0FNVtHs005238@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 17:31:55 2010 New Revision: 93582 URL: http://llvm.org/viewvc/llvm-project?rev=93582&view=rev Log: use MCSymbol instead of getMangledName() in all cases except one. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=93582&r1=93581&r2=93582&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Fri Jan 15 17:31:55 2010 @@ -387,9 +387,7 @@ } case MachineOperand::MO_ExternalSymbol: { bool isCallOp = Modifier && !strcmp(Modifier, "call"); - SmallString<128> NameStr; - Mang->getNameWithPrefix(NameStr, MO.getSymbolName()); - OutContext.GetOrCreateSymbol(NameStr.str())->print(O, MAI); + GetExternalSymbolSymbol(MO.getSymbolName())->print(O, MAI); if (isCallOp && Subtarget->isTargetELF() && TM.getRelocationModel() == Reloc::PIC_) @@ -1188,17 +1186,23 @@ return; } - std::string name = Mang->getMangledName(GVar); + std::string Name = Mang->getMangledName(GVar); + MCSymbol *GVarSym = GetGlobalValueSymbol(GVar); + + Constant *C = GVar->getInitializer(); const Type *Type = C->getType(); unsigned Size = TD->getTypeAllocSize(Type); unsigned Align = TD->getPreferredAlignmentLog(GVar); bool isDarwin = Subtarget->isTargetDarwin(); - printVisibility(name, GVar->getVisibility()); + printVisibility(Name, GVar->getVisibility()); - if (Subtarget->isTargetELF()) - O << "\t.type " << name << ",%object\n"; + if (Subtarget->isTargetELF()) { + O << "\t.type "; + GVarSym->print(O, MAI); + O << ",%object\n"; + } const MCSection *TheSection = getObjFileLowering().SectionForGlobal(GVar, Mang, TM); @@ -1210,9 +1214,12 @@ !TheSection->getKind().isMergeableCString()) { if (GVar->hasExternalLinkage()) { if (const char *Directive = MAI->getZeroFillDirective()) { - O << "\t.globl\t" << name << "\n"; - O << Directive << "__DATA, __common, " << name << ", " - << Size << ", " << Align << "\n"; + O << "\t.globl\t"; + GVarSym->print(O, MAI); + O << "\n"; + O << Directive << "__DATA, __common, "; + GVarSym->print(O, MAI); + O << ", " << Size << ", " << Align << "\n"; return; } } @@ -1222,17 +1229,23 @@ if (isDarwin) { if (GVar->hasLocalLinkage()) { - O << MAI->getLCOMMDirective() << name << ',' << Size - << ',' << Align; + O << MAI->getLCOMMDirective(); + GVarSym->print(O, MAI); + O << ',' << Size << ',' << Align; } else if (GVar->hasCommonLinkage()) { - O << MAI->getCOMMDirective() << name << ',' << Size - << ',' << Align; + O << MAI->getCOMMDirective(); + GVarSym->print(O, MAI); + O << ',' << Size << ',' << Align; } else { OutStreamer.SwitchSection(TheSection); - O << "\t.globl " << name << '\n' - << MAI->getWeakDefDirective() << name << '\n'; + O << "\t.globl "; + GVarSym->print(O, MAI); + O << '\n' << MAI->getWeakDefDirective(); + GVarSym->print(O, MAI); + O << '\n'; EmitAlignment(Align, GVar); - O << name << ":"; + GVarSym->print(O, MAI); + O << ":"; if (VerboseAsm) { O.PadToColumn(MAI->getCommentColumn()); O << MAI->getCommentString() << ' '; @@ -1244,16 +1257,25 @@ } } else if (MAI->getLCOMMDirective() != NULL) { if (GVar->hasLocalLinkage()) { - O << MAI->getLCOMMDirective() << name << "," << Size; + O << MAI->getLCOMMDirective(); + GVarSym->print(O, MAI); + O << "," << Size; } else { - O << MAI->getCOMMDirective() << name << "," << Size; + O << MAI->getCOMMDirective(); + GVarSym->print(O, MAI); + O << "," << Size; if (MAI->getCOMMDirectiveTakesAlignment()) O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); } } else { - if (GVar->hasLocalLinkage()) - O << "\t.local\t" << name << "\n"; - O << MAI->getCOMMDirective() << name << "," << Size; + if (GVar->hasLocalLinkage()) { + O << "\t.local\t"; + GVarSym->print(O, MAI); + O << '\n'; + } + O << MAI->getCOMMDirective(); + GVarSym->print(O, MAI); + O << "," << Size; if (MAI->getCOMMDirectiveTakesAlignment()) O << "," << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); } @@ -1275,17 +1297,24 @@ case GlobalValue::WeakODRLinkage: case GlobalValue::LinkerPrivateLinkage: if (isDarwin) { - O << "\t.globl " << name << "\n" - << "\t.weak_definition " << name << "\n"; + O << "\t.globl "; + GVarSym->print(O, MAI); + O << "\n\t.weak_definition "; + GVarSym->print(O, MAI); + O << "\n"; } else { - O << "\t.weak " << name << "\n"; + O << "\t.weak "; + GVarSym->print(O, MAI); + O << "\n"; } break; case GlobalValue::AppendingLinkage: // FIXME: appending linkage variables should go into a section of // their name or something. For now, just emit them as external. case GlobalValue::ExternalLinkage: - O << "\t.globl " << name << "\n"; + O << "\t.globl "; + GVarSym->print(O, MAI); + O << "\n"; break; case GlobalValue::PrivateLinkage: case GlobalValue::InternalLinkage: @@ -1295,15 +1324,19 @@ } EmitAlignment(Align, GVar); - O << name << ":"; + GVarSym->print(O, MAI); + O << ":"; if (VerboseAsm) { O.PadToColumn(MAI->getCommentColumn()); O << MAI->getCommentString() << ' '; WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); } O << "\n"; - if (MAI->hasDotTypeDotSizeDirective()) - O << "\t.size " << name << ", " << Size << "\n"; + if (MAI->hasDotTypeDotSizeDirective()) { + O << "\t.size "; + GVarSym->print(O, MAI); + O << ", " << Size << "\n"; + } EmitGlobalConstant(C); O << '\n'; From sabre at nondot.org Fri Jan 15 17:38:51 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 23:38:51 -0000 Subject: [llvm-commits] [llvm] r93587 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Message-ID: <201001152338.o0FNcplP005518@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 17:38:51 2010 New Revision: 93587 URL: http://llvm.org/viewvc/llvm-project?rev=93587&view=rev Log: add a version of AsmPrinter::printVisibility that takes an MCSymbol. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=93587&r1=93586&r2=93587&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Fri Jan 15 17:38:51 2010 @@ -418,6 +418,9 @@ /// printVisibility - This prints visibility information about symbol, if /// this is suported by the target. + void printVisibility(const MCSymbol *Sym, unsigned Visibility) const; + + // FIXME: This is deprecated and should be removed. void printVisibility(const std::string& Name, unsigned Visibility) const; /// printOffset - This is just convenient handler for printing offsets. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93587&r1=93586&r2=93587&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Jan 15 17:38:51 2010 @@ -1856,6 +1856,23 @@ } } +void AsmPrinter::printVisibility(const MCSymbol *Sym, + unsigned Visibility) const { + if (Visibility == GlobalValue::HiddenVisibility) { + if (const char *Directive = MAI->getHiddenDirective()) { + O << Directive; + Sym->print(O, MAI); + O << '\n'; + } + } else if (Visibility == GlobalValue::ProtectedVisibility) { + if (const char *Directive = MAI->getProtectedDirective()) { + O << Directive; + Sym->print(O, MAI); + O << '\n'; + } + } +} + void AsmPrinter::printOffset(int64_t Offset) const { if (Offset > 0) O << '+' << Offset; Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=93587&r1=93586&r2=93587&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Fri Jan 15 17:38:51 2010 @@ -49,7 +49,6 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/MathExtras.h" #include using namespace llvm; @@ -1186,9 +1185,7 @@ return; } - std::string Name = Mang->getMangledName(GVar); MCSymbol *GVarSym = GetGlobalValueSymbol(GVar); - Constant *C = GVar->getInitializer(); const Type *Type = C->getType(); @@ -1196,7 +1193,7 @@ unsigned Align = TD->getPreferredAlignmentLog(GVar); bool isDarwin = Subtarget->isTargetDarwin(); - printVisibility(Name, GVar->getVisibility()); + printVisibility(GVarSym, GVar->getVisibility()); if (Subtarget->isTargetELF()) { O << "\t.type "; From idadesub at users.sourceforge.net Fri Jan 15 17:49:17 2010 From: idadesub at users.sourceforge.net (Erick Tryzelaar) Date: Fri, 15 Jan 2010 23:49:17 -0000 Subject: [llvm-commits] [llvm] r93588 - /llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Message-ID: <201001152349.o0FNnH9j005819@zion.cs.uiuc.edu> Author: erickt Date: Fri Jan 15 17:49:16 2010 New Revision: 93588 URL: http://llvm.org/viewvc/llvm-project?rev=93588&view=rev Log: Fix bug 5992: O'Caml's llvm_create_module was treating the context as a string. Thanks Andy Ray for catching this! Modified: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Modified: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c?rev=93588&r1=93587&r2=93588&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Fri Jan 15 17:49:16 2010 @@ -112,9 +112,9 @@ /*===-- Modules -----------------------------------------------------------===*/ -/* string -> llmodule */ -CAMLprim LLVMModuleRef llvm_create_module(value ModuleID) { - return LLVMModuleCreateWithName(String_val(ModuleID)); +/* llcontext -> string -> llmodule */ +CAMLprim LLVMModuleRef llvm_create_module(LLVMContextRef C, value ModuleID) { + return LLVMModuleCreateWithNameInContext(String_val(ModuleID), C); } /* llmodule -> unit */ From sabre at nondot.org Fri Jan 15 17:55:17 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 23:55:17 -0000 Subject: [llvm-commits] [llvm] r93589 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Message-ID: <201001152355.o0FNtHNf006096@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 17:55:16 2010 New Revision: 93589 URL: http://llvm.org/viewvc/llvm-project?rev=93589&view=rev Log: supplement CurrentFnName with CurrentFnSym, which will eventually replace it. Upgrade Alpha, Blackfin, and part of CellSPU to not use mangler anymore. CellSPU needs more invasive surgery. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=93589&r1=93588&r2=93589&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Fri Jan 15 17:55:16 2010 @@ -134,7 +134,8 @@ /// Cache of mangled name for current function. This is recalculated at the /// beginning of each call to runOnMachineFunction(). /// - std::string CurrentFnName; + std::string CurrentFnName; // FIXME: REMOVE. + const MCSymbol *CurrentFnSym; /// getCurrentSection() - Return the current section we are emitting to. const MCSection *getCurrentSection() const; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93589&r1=93588&r2=93589&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Jan 15 17:55:16 2010 @@ -224,6 +224,7 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) { // What's my mangled name? CurrentFnName = Mang->getMangledName(MF.getFunction()); + CurrentFnSym = GetGlobalValueSymbol(MF.getFunction()); IncrementFunctionNumber(); if (VerboseAsm) Modified: llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp?rev=93589&r1=93588&r2=93589&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp Fri Jan 15 17:55:16 2010 @@ -28,7 +28,6 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/FormattedStream.h" #include "llvm/ADT/Statistic.h" using namespace llvm; @@ -108,7 +107,7 @@ return; case MachineOperand::MO_GlobalAddress: - O << Mang->getMangledName(MO.getGlobal()); + GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); return; case MachineOperand::MO_JumpTableIndex: @@ -208,7 +207,7 @@ if (EmitSpecialLLVMGlobal(GVar)) return; - std::string name = Mang->getMangledName(GVar); + MCSymbol *GVarSym = GetGlobalValueSymbol(GVar); Constant *C = GVar->getInitializer(); unsigned Size = TD->getTypeAllocSize(C->getType()); unsigned Align = TD->getPreferredAlignmentLog(GVar); @@ -218,38 +217,47 @@ TM)); // 1: Check visibility - printVisibility(name, GVar->getVisibility()); + printVisibility(GVarSym, GVar->getVisibility()); // 2: Kind switch (GVar->getLinkage()) { - case GlobalValue::LinkOnceAnyLinkage: - case GlobalValue::LinkOnceODRLinkage: - case GlobalValue::WeakAnyLinkage: - case GlobalValue::WeakODRLinkage: - case GlobalValue::CommonLinkage: - O << MAI->getWeakRefDirective() << name << '\n'; + case GlobalValue::LinkOnceAnyLinkage: + case GlobalValue::LinkOnceODRLinkage: + case GlobalValue::WeakAnyLinkage: + case GlobalValue::WeakODRLinkage: + case GlobalValue::CommonLinkage: + O << MAI->getWeakRefDirective(); + GVarSym->print(O, MAI); + O << '\n'; break; - case GlobalValue::AppendingLinkage: - case GlobalValue::ExternalLinkage: - O << MAI->getGlobalDirective() << name << "\n"; - break; - case GlobalValue::InternalLinkage: - case GlobalValue::PrivateLinkage: - case GlobalValue::LinkerPrivateLinkage: - break; - default: - llvm_unreachable("Unknown linkage type!"); - } + case GlobalValue::AppendingLinkage: + case GlobalValue::ExternalLinkage: + O << MAI->getGlobalDirective(); + GVarSym->print(O, MAI); + O << '\n'; + break; + case GlobalValue::InternalLinkage: + case GlobalValue::PrivateLinkage: + case GlobalValue::LinkerPrivateLinkage: + break; + default: + llvm_unreachable("Unknown linkage type!"); + } // 3: Type, Size, Align if (MAI->hasDotTypeDotSizeDirective()) { - O << "\t.type\t" << name << ", @object\n"; - O << "\t.size\t" << name << ", " << Size << "\n"; + O << "\t.type\t"; + GVarSym->print(O, MAI); + O << ", @object\n"; + O << "\t.size\t"; + GVarSym->print(O, MAI); + O << ", " << Size << "\n"; } EmitAlignment(Align, GVar); - - O << name << ":\n"; + + GVarSym->print(O, MAI); + O << ":\n"; EmitGlobalConstant(C); O << '\n'; Modified: llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp?rev=93589&r1=93588&r2=93589&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp Fri Jan 15 17:55:16 2010 @@ -30,7 +30,6 @@ #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetRegistry.h" -#include "llvm/Support/Mangler.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/ErrorHandling.h" @@ -55,7 +54,7 @@ void printInstruction(const MachineInstr *MI); // autogenerated. static const char *getRegisterName(unsigned RegNo); - void emitLinkage(const std::string &n, GlobalValue::LinkageTypes l); + void emitLinkage(const MCSymbol *GVSym, GlobalValue::LinkageTypes l); bool runOnMachineFunction(MachineFunction &F); bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode); @@ -71,23 +70,29 @@ RegisterAsmPrinter X(TheBlackfinTarget); } -void BlackfinAsmPrinter::emitLinkage(const std::string &name, - GlobalValue::LinkageTypes l) { - switch (l) { +void BlackfinAsmPrinter::emitLinkage(const MCSymbol *GVSym, + GlobalValue::LinkageTypes L) { + switch (L) { default: llvm_unreachable("Unknown linkage type!"); case GlobalValue::InternalLinkage: // Symbols default to internal. case GlobalValue::PrivateLinkage: case GlobalValue::LinkerPrivateLinkage: break; case GlobalValue::ExternalLinkage: - O << MAI->getGlobalDirective() << name << "\n"; + O << MAI->getGlobalDirective(); + GVSym->print(O, MAI); + O << "\n"; break; case GlobalValue::LinkOnceAnyLinkage: case GlobalValue::LinkOnceODRLinkage: case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakODRLinkage: - O << MAI->getGlobalDirective() << name << "\n"; - O << MAI->getWeakDefDirective() << name << "\n"; + O << MAI->getGlobalDirective(); + GVSym->print(O, MAI); + O << "\n"; + O << MAI->getWeakDefDirective(); + GVSym->print(O, MAI); + O << "\n"; break; } } @@ -98,18 +103,24 @@ if (!GV->hasInitializer() || EmitSpecialLLVMGlobal(GV)) return; - std::string name = Mang->getMangledName(GV); + MCSymbol *GVSym = GetGlobalValueSymbol(GV); Constant *C = GV->getInitializer(); OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GV, Mang, TM)); - emitLinkage(name, GV->getLinkage()); + emitLinkage(GVSym, GV->getLinkage()); EmitAlignment(TD->getPreferredAlignmentLog(GV), GV); - printVisibility(name, GV->getVisibility()); + printVisibility(GVSym, GV->getVisibility()); - O << "\t.type " << name << ", STT_OBJECT\n"; - O << "\t.size " << name << ',' << TD->getTypeAllocSize(C->getType()) << '\n'; - O << name << ":\n"; + O << "\t.type "; + GVSym->print(O, MAI); + O << ", STT_OBJECT\n"; + O << "\t.size "; + GVSym->print(O, MAI); + O << "\n"; + O << ',' << TD->getTypeAllocSize(C->getType()) << '\n'; + GVSym->print(O, MAI); + O << ":\n"; EmitGlobalConstant(C); } @@ -124,11 +135,14 @@ const Function *F = MF.getFunction(); OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM)); EmitAlignment(2, F); - emitLinkage(CurrentFnName, F->getLinkage()); - printVisibility(CurrentFnName, F->getVisibility()); + emitLinkage(CurrentFnSym, F->getLinkage()); + printVisibility(CurrentFnSym, F->getVisibility()); - O << "\t.type\t" << CurrentFnName << ", STT_FUNC\n" - << CurrentFnName << ":\n"; + O << "\t.type\t"; + CurrentFnSym->print(O, MAI); + O << ", STT_FUNC\n"; + CurrentFnSym->print(O, MAI); + O << ":\n"; if (DW) DW->BeginFunction(&MF); @@ -154,7 +168,11 @@ } } - O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n"; + O << "\t.size "; + CurrentFnSym->print(O, MAI); + O << ", .-"; + CurrentFnSym->print(O, MAI); + O << "\n"; if (DW) DW->EndFunction(&MF); @@ -178,7 +196,7 @@ GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); return; case MachineOperand::MO_GlobalAddress: - O << Mang->getMangledName(MO.getGlobal()); + GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); printOffset(MO.getOffset()); break; case MachineOperand::MO_ExternalSymbol: Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp?rev=93589&r1=93588&r2=93589&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Fri Jan 15 17:55:16 2010 @@ -437,18 +437,27 @@ case Function::InternalLinkage: // Symbols default to internal. break; case Function::ExternalLinkage: - O << "\t.global\t" << CurrentFnName << "\n" - << "\t.type\t" << CurrentFnName << ", @function\n"; + O << "\t.global\t"; + CurrentFnSym->print(O, MAI); + O << "\n" << "\t.type\t"; + CurrentFnSym->print(O, MAI); + O << ", @function\n"; break; case Function::WeakAnyLinkage: case Function::WeakODRLinkage: case Function::LinkOnceAnyLinkage: case Function::LinkOnceODRLinkage: - O << "\t.global\t" << CurrentFnName << "\n"; - O << "\t.weak_definition\t" << CurrentFnName << "\n"; + O << "\t.global\t"; + CurrentFnSym->print(O, MAI); + O << "\n"; + O << "\t.weak_definition\t"; + CurrentFnSym->print(O, MAI); + O << "\n"; break; } - O << CurrentFnName << ":\n"; + + CurrentFnSym->print(O, MAI); + O << ":\n"; // Emit pre-function debug information. DW->BeginFunction(&MF); @@ -467,7 +476,11 @@ } } - O << "\t.size\t" << CurrentFnName << ",.-" << CurrentFnName << "\n"; + O << "\t.size\t"; + CurrentFnSym->print(O, MAI); + O << ",.-"; + CurrentFnSym->print(O, MAI); + O << "\n"; // Print out jump tables referenced by the function. EmitJumpTableInfo(MF.getJumpTableInfo(), MF); From sabre at nondot.org Fri Jan 15 17:56:04 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 15 Jan 2010 23:56:04 -0000 Subject: [llvm-commits] [llvm] r93590 - /llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Message-ID: <201001152356.o0FNu40W006127@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 17:56:03 2010 New Revision: 93590 URL: http://llvm.org/viewvc/llvm-project?rev=93590&view=rev Log: remove two write-only sets. Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp?rev=93590&r1=93589&r2=93590&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Fri Jan 15 17:56:03 2010 @@ -41,7 +41,6 @@ #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/MathExtras.h" -#include using namespace llvm; namespace { @@ -50,7 +49,6 @@ const std::string bss_section(".bss"); class SPUAsmPrinter : public AsmPrinter { - std::set FnStubs, GVStubs; public: explicit SPUAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, const MCAsmInfo *T, bool V) : @@ -332,7 +330,6 @@ // Computing the address of an external symbol, not calling it. if (TM.getRelocationModel() != Reloc::Static) { std::string Name(MAI->getGlobalPrefix()); Name += MO.getSymbolName(); - GVStubs.insert(Name); O << "L" << Name << "$non_lazy_ptr"; return; } @@ -348,7 +345,6 @@ if (TM.getRelocationModel() != Reloc::Static) { if (((GV->isDeclaration() || GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()))) { - GVStubs.insert(Name); O << "L" << Name << "$non_lazy_ptr"; return; } From daniel at zuster.org Fri Jan 15 18:00:21 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 16 Jan 2010 00:00:21 -0000 Subject: [llvm-commits] [llvm] r93591 - /llvm/trunk/test/lit.cfg Message-ID: <201001160000.o0G00LA8006293@zion.cs.uiuc.edu> Author: ddunbar Date: Fri Jan 15 18:00:20 2010 New Revision: 93591 URL: http://llvm.org/viewvc/llvm-project?rev=93591&view=rev Log: Fix llvm_supports_binding for lit, problem noticed by Bob! Modified: llvm/trunk/test/lit.cfg Modified: llvm/trunk/test/lit.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.cfg?rev=93591&r1=93590&r2=93591&view=diff ============================================================================== --- llvm/trunk/test/lit.cfg (original) +++ llvm/trunk/test/lit.cfg Fri Jan 15 18:00:20 2010 @@ -133,7 +133,7 @@ bindings = set(site_exp['llvm_bindings'].split(',')) def llvm_supports_binding(name): - return name in langs + return name in bindings # Provide on_clone hook for reading 'dg.exp'. import os From sabre at nondot.org Fri Jan 15 18:21:18 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 00:21:18 -0000 Subject: [llvm-commits] [llvm] r93594 - in /llvm/trunk/lib/Target: ARM/AsmPrinter/ARMAsmPrinter.cpp Alpha/AsmPrinter/AlphaAsmPrinter.cpp CellSPU/AsmPrinter/SPUAsmPrinter.cpp MSP430/AsmPrinter/MSP430AsmPrinter.cpp Mips/AsmPrinter/MipsAsmPrinter.cpp PowerPC/AsmPrinter/PPCAsmPrinter.cpp Sparc/AsmPrinter/SparcAsmPrinter.cpp SystemZ/AsmPrinter/SystemZAsmPrinter.cpp X86/AsmPrinter/X86AsmPrinter.cpp XCore/AsmPrinter/XCoreAsmPrinter.cpp Message-ID: <201001160021.o0G0LJw8007014@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 18:21:18 2010 New Revision: 93594 URL: http://llvm.org/viewvc/llvm-project?rev=93594&view=rev Log: MCize a bunch more stuff, eliminating a lot of uses of the mangler and CurrentFnName. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Fri Jan 15 18:21:18 2010 @@ -256,7 +256,9 @@ case Function::InternalLinkage: break; case Function::ExternalLinkage: - O << "\t.globl\t" << CurrentFnName << "\n"; + O << "\t.globl\t"; + CurrentFnSym->print(O, MAI); + O << "\n"; break; case Function::LinkerPrivateLinkage: case Function::WeakAnyLinkage: @@ -264,29 +266,38 @@ case Function::LinkOnceAnyLinkage: case Function::LinkOnceODRLinkage: if (Subtarget->isTargetDarwin()) { - O << "\t.globl\t" << CurrentFnName << "\n"; - O << "\t.weak_definition\t" << CurrentFnName << "\n"; + O << "\t.globl\t"; + CurrentFnSym->print(O, MAI); + O << "\n"; + O << "\t.weak_definition\t"; + CurrentFnSym->print(O, MAI); + O << "\n"; } else { - O << MAI->getWeakRefDirective() << CurrentFnName << "\n"; + O << MAI->getWeakRefDirective(); + CurrentFnSym->print(O, MAI); + O << "\n"; } break; } - printVisibility(CurrentFnName, F->getVisibility()); + printVisibility(CurrentFnSym, F->getVisibility()); unsigned FnAlign = 1 << MF.getAlignment(); // MF alignment is log2. if (AFI->isThumbFunction()) { EmitAlignment(FnAlign, F, AFI->getAlign()); O << "\t.code\t16\n"; O << "\t.thumb_func"; - if (Subtarget->isTargetDarwin()) - O << "\t" << CurrentFnName; + if (Subtarget->isTargetDarwin()) { + O << "\t"; + CurrentFnSym->print(O, MAI); + } O << "\n"; } else { EmitAlignment(FnAlign, F); } - O << CurrentFnName << ":\n"; + CurrentFnSym->print(O, MAI); + O << ":\n"; // Emit pre-function debug information. DW->BeginFunction(&MF); @@ -313,8 +324,13 @@ printMachineInstruction(II); } - if (MAI->hasDotTypeDotSizeDirective()) - O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n"; + if (MAI->hasDotTypeDotSizeDirective()) { + O << "\t.size "; + CurrentFnSym->print(O, MAI); + O << ", .-"; + CurrentFnSym->print(O, MAI); + O << "\n"; + } // Emit post-function debug information. DW->EndFunction(&MF); Modified: llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp Fri Jan 15 18:21:18 2010 @@ -147,22 +147,29 @@ case Function::PrivateLinkage: case Function::LinkerPrivateLinkage: break; - case Function::ExternalLinkage: - O << "\t.globl " << CurrentFnName << "\n"; - break; + case Function::ExternalLinkage: + O << "\t.globl "; + CurrentFnSym->print(O, MAI); + O << "\n"; + break; case Function::WeakAnyLinkage: case Function::WeakODRLinkage: case Function::LinkOnceAnyLinkage: case Function::LinkOnceODRLinkage: - O << MAI->getWeakRefDirective() << CurrentFnName << "\n"; + O << MAI->getWeakRefDirective(); + CurrentFnSym->print(O, MAI); + O << "\n"; break; } - printVisibility(CurrentFnName, F->getVisibility()); + printVisibility(CurrentFnSym, F->getVisibility()); - O << "\t.ent " << CurrentFnName << "\n"; + O << "\t.ent "; + CurrentFnSym->print(O, MAI); + O << "\n"; - O << CurrentFnName << ":\n"; + CurrentFnSym->print(O, MAI); + O << ":\n"; // Print out code for the function. for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); @@ -184,7 +191,9 @@ } } - O << "\t.end " << CurrentFnName << "\n"; + O << "\t.end "; + CurrentFnSym->print(O, MAI); + O << "\n"; // We didn't modify anything. return false; Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Fri Jan 15 18:21:18 2010 @@ -39,7 +39,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/MathExtras.h" using namespace llvm; @@ -329,30 +328,25 @@ case MachineOperand::MO_ExternalSymbol: // Computing the address of an external symbol, not calling it. if (TM.getRelocationModel() != Reloc::Static) { - std::string Name(MAI->getGlobalPrefix()); Name += MO.getSymbolName(); - O << "L" << Name << "$non_lazy_ptr"; + O << "L" << MAI->getGlobalPrefix() << MO.getSymbolName() + << "$non_lazy_ptr"; return; } - O << MAI->getGlobalPrefix() << MO.getSymbolName(); + GetExternalSymbolSymbol(MO.getSymbolName())->print(O, MAI); return; - case MachineOperand::MO_GlobalAddress: { - // Computing the address of a global symbol, not calling it. - GlobalValue *GV = MO.getGlobal(); - std::string Name = Mang->getMangledName(GV); - + case MachineOperand::MO_GlobalAddress: // External or weakly linked global variables need non-lazily-resolved // stubs if (TM.getRelocationModel() != Reloc::Static) { + GlobalValue *GV = MO.getGlobal(); if (((GV->isDeclaration() || GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()))) { - O << "L" << Name << "$non_lazy_ptr"; + GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr")->print(O, MAI); return; } } - O << Name; + GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); return; - } - default: O << ""; return; @@ -505,9 +499,9 @@ if (EmitSpecialLLVMGlobal(GVar)) return; - std::string name = Mang->getMangledName(GVar); + MCSymbol *GVarSym = GetGlobalValueSymbol(GVar); - printVisibility(name, GVar->getVisibility()); + printVisibility(GVarSym, GVar->getVisibility()); Constant *C = GVar->getInitializer(); const Type *Type = C->getType(); @@ -524,14 +518,23 @@ if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. if (GVar->hasExternalLinkage()) { - O << "\t.global " << name << '\n'; - O << "\t.type " << name << ", @object\n"; - O << name << ":\n"; + O << "\t.global "; + GVarSym->print(O, MAI); + O << '\n'; + O << "\t.type "; + GVarSym->print(O, MAI); + O << ", @object\n"; + GVarSym->print(O, MAI); + O << ":\n"; O << "\t.zero " << Size << '\n'; } else if (GVar->hasLocalLinkage()) { - O << MAI->getLCOMMDirective() << name << ',' << Size; + O << MAI->getLCOMMDirective(); + GVarSym->print(O, MAI); + O << ',' << Size; } else { - O << ".comm " << name << ',' << Size; + O << ".comm "; + GVarSym->print(O, MAI); + O << ',' << Size; } O << "\t\t" << MAI->getCommentString() << " '"; WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); @@ -540,34 +543,42 @@ } switch (GVar->getLinkage()) { - // Should never be seen for the CellSPU platform... - case GlobalValue::LinkOnceAnyLinkage: - case GlobalValue::LinkOnceODRLinkage: - case GlobalValue::WeakAnyLinkage: - case GlobalValue::WeakODRLinkage: - case GlobalValue::CommonLinkage: - O << "\t.global " << name << '\n' - << "\t.type " << name << ", @object\n" - << "\t.weak " << name << '\n'; + // Should never be seen for the CellSPU platform... + case GlobalValue::LinkOnceAnyLinkage: + case GlobalValue::LinkOnceODRLinkage: + case GlobalValue::WeakAnyLinkage: + case GlobalValue::WeakODRLinkage: + case GlobalValue::CommonLinkage: + O << "\t.global "; + GVarSym->print(O, MAI); + O << "\n\t.type "; + GVarSym->print(O, MAI); + O << ", @object\n" << "\t.weak "; + GVarSym->print(O, MAI); + O << '\n'; break; - case GlobalValue::AppendingLinkage: + case GlobalValue::AppendingLinkage: // FIXME: appending linkage variables should go into a section of // their name or something. For now, just emit them as external. - case GlobalValue::ExternalLinkage: + case GlobalValue::ExternalLinkage: // If external or appending, declare as a global symbol - O << "\t.global " << name << '\n' - << "\t.type " << name << ", @object\n"; - // FALL THROUGH - case GlobalValue::PrivateLinkage: - case GlobalValue::LinkerPrivateLinkage: - case GlobalValue::InternalLinkage: + O << "\t.global "; + GVarSym->print(O, MAI); + O << "\n\t.type "; + GVarSym->print(O, MAI); + O << ", @object\n"; break; - default: + case GlobalValue::PrivateLinkage: + case GlobalValue::LinkerPrivateLinkage: + case GlobalValue::InternalLinkage: + break; + default: llvm_report_error("Unknown linkage type!"); } EmitAlignment(Align, GVar); - O << name << ":\t\t\t\t" << MAI->getCommentString() << " '"; + GVarSym->print(O, MAI); + O << ":\t\t\t\t" << MAI->getCommentString() << " '"; WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); O << "'\n"; Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp Fri Jan 15 18:21:18 2010 @@ -38,9 +38,7 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/ErrorHandling.h" - using namespace llvm; STATISTIC(EmittedInsts, "Number of machine instrs printed"); @@ -101,14 +99,16 @@ const TargetData *TD = TM.getTargetData(); - std::string name = Mang->getMangledName(GVar); + MCSymbol *GVarSym = GetGlobalValueSymbol(GVar); Constant *C = GVar->getInitializer(); unsigned Size = TD->getTypeAllocSize(C->getType()); unsigned Align = TD->getPreferredAlignmentLog(GVar); - printVisibility(name, GVar->getVisibility()); + printVisibility(GVarSym, GVar->getVisibility()); - O << "\t.type\t" << name << ", at object\n"; + O << "\t.type\t"; + GVarSym->print(O, MAI); + O << ", at object\n"; OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang, TM)); @@ -119,10 +119,15 @@ if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. - if (GVar->hasLocalLinkage()) - O << "\t.local\t" << name << '\n'; + if (GVar->hasLocalLinkage()) { + O << "\t.local\t"; + GVarSym->print(O, MAI); + O << '\n'; + } - O << MAI->getCOMMDirective() << name << ',' << Size; + O << MAI->getCOMMDirective(); + GVarSym->print(O, MAI); + O << ',' << Size; if (MAI->getCOMMDirectiveTakesAlignment()) O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); @@ -141,7 +146,9 @@ case GlobalValue::LinkOnceODRLinkage: case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakODRLinkage: - O << "\t.weak\t" << name << '\n'; + O << "\t.weak\t"; + GVarSym->print(O, MAI); + O << '\n'; break; case GlobalValue::DLLExportLinkage: case GlobalValue::AppendingLinkage: @@ -149,7 +156,9 @@ // their name or something. For now, just emit them as external. case GlobalValue::ExternalLinkage: // If external or appending, declare as a global symbol - O << "\t.globl " << name << '\n'; + O << "\t.globl "; + GVarSym->print(O, MAI); + O << '\n'; // FALL THROUGH case GlobalValue::PrivateLinkage: case GlobalValue::LinkerPrivateLinkage: @@ -161,7 +170,8 @@ // Use 16-bit alignment by default to simplify bunch of stuff EmitAlignment(Align, GVar); - O << name << ":"; + GVarSym->print(O, MAI); + O << ":"; if (VerboseAsm) { O.PadToColumn(MAI->getCommentColumn()); O << MAI->getCommentString() << ' '; @@ -171,8 +181,11 @@ EmitGlobalConstant(C); - if (MAI->hasDotTypeDotSizeDirective()) - O << "\t.size\t" << name << ", " << Size << '\n'; + if (MAI->hasDotTypeDotSizeDirective()) { + O << "\t.size\t"; + GVarSym->print(O, MAI); + O << ", " << Size << '\n'; + } } void MSP430AsmPrinter::emitFunctionHeader(const MachineFunction &MF) { @@ -190,20 +203,27 @@ case Function::LinkerPrivateLinkage: break; case Function::ExternalLinkage: - O << "\t.globl\t" << CurrentFnName << '\n'; + O << "\t.globl\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; break; case Function::LinkOnceAnyLinkage: case Function::LinkOnceODRLinkage: case Function::WeakAnyLinkage: case Function::WeakODRLinkage: - O << "\t.weak\t" << CurrentFnName << '\n'; + O << "\t.weak\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; break; } - printVisibility(CurrentFnName, F->getVisibility()); + printVisibility(CurrentFnSym, F->getVisibility()); - O << "\t.type\t" << CurrentFnName << ", at function\n" - << CurrentFnName << ":\n"; + O << "\t.type\t"; + CurrentFnSym->print(O, MAI); + O << ", at function\n"; + CurrentFnSym->print(O, MAI); + O << ":\n"; } bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) { @@ -225,8 +245,13 @@ printMachineInstruction(II); } - if (MAI->hasDotTypeDotSizeDirective()) - O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n'; + if (MAI->hasDotTypeDotSizeDirective()) { + O << "\t.size\t"; + CurrentFnSym->print(O, MAI); + O << ", .-"; + CurrentFnSym->print(O, MAI); + O << '\n'; + } // We didn't modify anything return false; @@ -263,14 +288,14 @@ return; case MachineOperand::MO_GlobalAddress: { bool isMemOp = Modifier && !strcmp(Modifier, "mem"); - std::string Name = Mang->getMangledName(MO.getGlobal()); uint64_t Offset = MO.getOffset(); O << (isMemOp ? '&' : '#'); if (Offset) O << '(' << Offset << '+'; - O << Name; + GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); + if (Offset) O << ')'; @@ -278,11 +303,8 @@ } case MachineOperand::MO_ExternalSymbol: { bool isMemOp = Modifier && !strcmp(Modifier, "mem"); - std::string Name(MAI->getGlobalPrefix()); - Name += MO.getSymbolName(); - - O << (isMemOp ? '&' : '#') << Name; - + O << (isMemOp ? '&' : '#'); + O << MAI->getGlobalPrefix() << MO.getSymbolName(); return; } default: Modified: llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp Fri Jan 15 18:21:18 2010 @@ -37,7 +37,6 @@ #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/Mangler.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Debug.h" @@ -45,7 +44,6 @@ #include "llvm/Support/FormattedStream.h" #include "llvm/Support/MathExtras.h" #include - using namespace llvm; STATISTIC(EmittedInsts, "Number of machine instrs printed"); @@ -219,15 +217,23 @@ // 2 bits aligned EmitAlignment(MF.getAlignment(), F); - O << "\t.globl\t" << CurrentFnName << '\n'; - O << "\t.ent\t" << CurrentFnName << '\n'; + O << "\t.globl\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; + O << "\t.ent\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; - printVisibility(CurrentFnName, F->getVisibility()); + printVisibility(CurrentFnSym, F->getVisibility()); - if ((MAI->hasDotTypeDotSizeDirective()) && Subtarget->isLinux()) - O << "\t.type\t" << CurrentFnName << ", @function\n"; + if ((MAI->hasDotTypeDotSizeDirective()) && Subtarget->isLinux()) { + O << "\t.type\t"; + CurrentFnSym->print(O, MAI); + O << ", @function\n"; + } - O << CurrentFnName << ":\n"; + CurrentFnSym->print(O, MAI); + O << ":\n"; emitFrameDirective(MF); printSavedRegsBitmask(MF); @@ -243,9 +249,16 @@ O << "\t.set\tmacro\n"; O << "\t.set\treorder\n"; - O << "\t.end\t" << CurrentFnName << '\n'; - if (MAI->hasDotTypeDotSizeDirective() && !Subtarget->isLinux()) - O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n'; + O << "\t.end\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; + if (MAI->hasDotTypeDotSizeDirective() && !Subtarget->isLinux()) { + O << "\t.size\t"; + CurrentFnSym->print(O, MAI); + O << ", .-"; + CurrentFnSym->print(O, MAI); + O << '\n'; + } } /// runOnMachineFunction - This uses the printMachineInstruction() @@ -350,16 +363,16 @@ return; case MachineOperand::MO_GlobalAddress: - O << Mang->getMangledName(MO.getGlobal()); + GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); break; case MachineOperand::MO_ExternalSymbol: - O << MO.getSymbolName(); + GetExternalSymbolSymbol(MO.getSymbolName())->print(O, MAI); break; case MachineOperand::MO_JumpTableIndex: O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() - << '_' << MO.getIndex(); + << '_' << MO.getIndex(); break; case MachineOperand::MO_ConstantPoolIndex: @@ -436,7 +449,7 @@ return; O << "\n\n"; - std::string name = Mang->getMangledName(GVar); + MCSymbol *GVarSym = GetGlobalValueSymbol(GVar); Constant *C = GVar->getInitializer(); const Type *CTy = C->getType(); unsigned Size = TD->getTypeAllocSize(CTy); @@ -455,7 +468,7 @@ } else Align = TD->getPreferredTypeAlignmentShift(CTy); - printVisibility(name, GVar->getVisibility()); + printVisibility(GVarSym, GVar->getVisibility()); OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang, TM)); @@ -465,10 +478,15 @@ (GVar->hasLocalLinkage() || GVar->isWeakForLinker())) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. - if (GVar->hasLocalLinkage()) - O << "\t.local\t" << name << '\n'; - - O << MAI->getCOMMDirective() << name << ',' << Size; + if (GVar->hasLocalLinkage()) { + O << "\t.local\t"; + GVarSym->print(O, MAI); + O << '\n'; + } + + O << MAI->getCOMMDirective(); + GVarSym->print(O, MAI); + O << ',' << Size; if (MAI->getCOMMDirectiveTakesAlignment()) O << ',' << (1 << Align); @@ -484,14 +502,18 @@ case GlobalValue::WeakODRLinkage: // FIXME: Verify correct for weak. // Nonnull linkonce -> weak - O << "\t.weak " << name << '\n'; + O << "\t.weak "; + GVarSym->print(O, MAI); + O << '\n'; break; case GlobalValue::AppendingLinkage: // FIXME: appending linkage variables should go into a section of their name // or something. For now, just emit them as external. case GlobalValue::ExternalLinkage: // If external or appending, declare as a global symbol - O << MAI->getGlobalDirective() << name << '\n'; + O << MAI->getGlobalDirective(); + GVarSym->print(O, MAI); + O << '\n'; // Fall Through case GlobalValue::PrivateLinkage: case GlobalValue::LinkerPrivateLinkage: @@ -512,11 +534,16 @@ EmitAlignment(Align, GVar); if (MAI->hasDotTypeDotSizeDirective() && printSizeAndType) { - O << "\t.type " << name << ", at object\n"; - O << "\t.size " << name << ',' << Size << '\n'; + O << "\t.type "; + GVarSym->print(O, MAI); + O << ", at object\n"; + O << "\t.size "; + GVarSym->print(O, MAI); + O << ',' << Size << '\n'; } - O << name << ":\n"; + GVarSym->print(O, MAI); + O << ":\n"; EmitGlobalConstant(C); } Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Fri Jan 15 18:21:18 2010 @@ -641,34 +641,47 @@ case Function::InternalLinkage: // Symbols default to internal. break; case Function::ExternalLinkage: - O << "\t.global\t" << CurrentFnName << '\n' - << "\t.type\t" << CurrentFnName << ", @function\n"; + O << "\t.global\t"; + CurrentFnSym->print(O, MAI); + O << '\n' << "\t.type\t"; + CurrentFnSym->print(O, MAI); + O << ", @function\n"; break; case Function::LinkerPrivateLinkage: case Function::WeakAnyLinkage: case Function::WeakODRLinkage: case Function::LinkOnceAnyLinkage: case Function::LinkOnceODRLinkage: - O << "\t.global\t" << CurrentFnName << '\n'; - O << "\t.weak\t" << CurrentFnName << '\n'; + O << "\t.global\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; + O << "\t.weak\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; break; } - printVisibility(CurrentFnName, F->getVisibility()); + printVisibility(CurrentFnSym, F->getVisibility()); EmitAlignment(MF.getAlignment(), F); if (Subtarget.isPPC64()) { // Emit an official procedure descriptor. - // FIXME 64-bit SVR4: Use MCSection here? + // FIXME 64-bit SVR4: Use MCSection here! O << "\t.section\t\".opd\",\"aw\"\n"; O << "\t.align 3\n"; - O << CurrentFnName << ":\n"; - O << "\t.quad .L." << CurrentFnName << ",.TOC. at tocbase\n"; + CurrentFnSym->print(O, MAI); + O << ":\n"; + O << "\t.quad .L."; + CurrentFnSym->print(O, MAI); + O << ",.TOC. at tocbase\n"; O << "\t.previous\n"; - O << ".L." << CurrentFnName << ":\n"; + O << ".L."; + CurrentFnSym->print(O, MAI); + O << ":\n"; } else { - O << CurrentFnName << ":\n"; + CurrentFnSym->print(O, MAI); + O << ":\n"; } // Emit pre-function debug information. @@ -688,7 +701,11 @@ } } - O << "\t.size\t" << CurrentFnName << ",.-" << CurrentFnName << '\n'; + O << "\t.size\t"; + CurrentFnSym->print(O, MAI); + O << ",.-"; + CurrentFnSym->print(O, MAI); + O << '\n'; OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM)); @@ -829,22 +846,29 @@ case Function::InternalLinkage: // Symbols default to internal. break; case Function::ExternalLinkage: - O << "\t.globl\t" << CurrentFnName << '\n'; + O << "\t.globl\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; break; case Function::WeakAnyLinkage: case Function::WeakODRLinkage: case Function::LinkOnceAnyLinkage: case Function::LinkOnceODRLinkage: case Function::LinkerPrivateLinkage: - O << "\t.globl\t" << CurrentFnName << '\n'; - O << "\t.weak_definition\t" << CurrentFnName << '\n'; + O << "\t.globl\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; + O << "\t.weak_definition\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; break; } - printVisibility(CurrentFnName, F->getVisibility()); + printVisibility(CurrentFnSym, F->getVisibility()); EmitAlignment(MF.getAlignment(), F); - O << CurrentFnName << ":\n"; + CurrentFnSym->print(O, MAI); + O << ":\n"; // Emit pre-function debug information. DW->BeginFunction(&MF); Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Fri Jan 15 18:21:18 2010 @@ -138,7 +138,11 @@ DW->EndFunction(&MF); // We didn't modify anything. - O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n'; + O << "\t.size\t"; + CurrentFnSym->print(O, MAI); + O << ", .-"; + CurrentFnSym->print(O, MAI); + O << '\n'; return false; } @@ -156,7 +160,9 @@ case Function::DLLExportLinkage: case Function::ExternalLinkage: // Function is externally visible - O << "\t.global\t" << CurrentFnName << '\n'; + O << "\t.global\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; break; case Function::LinkerPrivateLinkage: case Function::LinkOnceAnyLinkage: @@ -164,14 +170,18 @@ case Function::WeakAnyLinkage: case Function::WeakODRLinkage: // Function is weak - O << "\t.weak\t" << CurrentFnName << '\n' ; + O << "\t.weak\t";CurrentFnSym->print(O, MAI); + O << '\n' ; break; } - printVisibility(CurrentFnName, F->getVisibility()); + printVisibility(CurrentFnSym, F->getVisibility()); - O << "\t.type\t" << CurrentFnName << ", #function\n"; - O << CurrentFnName << ":\n"; + O << "\t.type\t"; + CurrentFnSym->print(O, MAI); + O << ", #function\n"; + CurrentFnSym->print(O, MAI); + O << ":\n"; } Modified: llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp Fri Jan 15 18:21:18 2010 @@ -99,20 +99,27 @@ case Function::LinkerPrivateLinkage: break; case Function::ExternalLinkage: - O << "\t.globl\t" << CurrentFnName << '\n'; + O << "\t.globl\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; break; case Function::LinkOnceAnyLinkage: case Function::LinkOnceODRLinkage: case Function::WeakAnyLinkage: case Function::WeakODRLinkage: - O << "\t.weak\t" << CurrentFnName << '\n'; + O << "\t.weak\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; break; } - printVisibility(CurrentFnName, F->getVisibility()); + printVisibility(CurrentFnSym, F->getVisibility()); - O << "\t.type\t" << CurrentFnName << ", at function\n" - << CurrentFnName << ":\n"; + O << "\t.type\t"; + CurrentFnSym->print(O, MAI); + O << ", at function\n"; + CurrentFnSym->print(O, MAI); + O << ":\n"; } bool SystemZAsmPrinter::runOnMachineFunction(MachineFunction &MF) { @@ -137,8 +144,13 @@ printMachineInstruction(II); } - if (MAI->hasDotTypeDotSizeDirective()) - O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n'; + if (MAI->hasDotTypeDotSizeDirective()) { + O << "\t.size\t"; + CurrentFnSym->print(O, MAI); + O << ", .-"; + CurrentFnSym->print(O, MAI); + O << '\n'; + } // Print out jump tables referenced by the function. EmitJumpTableInfo(MF.getJumpTableInfo(), MF); Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Fri Jan 15 18:21:18 2010 @@ -84,7 +84,9 @@ break; case Function::DLLExportLinkage: case Function::ExternalLinkage: - O << "\t.globl\t" << CurrentFnName << '\n'; + O << "\t.globl\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; break; case Function::LinkerPrivateLinkage: case Function::LinkOnceAnyLinkage: @@ -92,30 +94,41 @@ case Function::WeakAnyLinkage: case Function::WeakODRLinkage: if (Subtarget->isTargetDarwin()) { - O << "\t.globl\t" << CurrentFnName << '\n'; - O << MAI->getWeakDefDirective() << CurrentFnName << '\n'; + O << "\t.globl\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; + O << MAI->getWeakDefDirective(); + CurrentFnSym->print(O, MAI); + O << '\n'; } else if (Subtarget->isTargetCygMing()) { - O << "\t.globl\t" << CurrentFnName << "\n" - "\t.linkonce discard\n"; + O << "\t.globl\t"; + CurrentFnSym->print(O, MAI); + O << "\n\t.linkonce discard\n"; } else { - O << "\t.weak\t" << CurrentFnName << '\n'; + O << "\t.weak\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; } break; } - printVisibility(CurrentFnName, F->getVisibility()); + printVisibility(CurrentFnSym, F->getVisibility()); - if (Subtarget->isTargetELF()) - O << "\t.type\t" << CurrentFnName << ", at function\n"; - else if (Subtarget->isTargetCygMing()) { - O << "\t.def\t " << CurrentFnName - << ";\t.scl\t" << + if (Subtarget->isTargetELF()) { + O << "\t.type\t"; + CurrentFnSym->print(O, MAI); + O << ", at function\n"; + } else if (Subtarget->isTargetCygMing()) { + O << "\t.def\t "; + CurrentFnSym->print(O, MAI); + O << ";\t.scl\t" << (F->hasInternalLinkage() ? COFF::C_STAT : COFF::C_EXT) << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT) << ";\t.endef\n"; } - O << CurrentFnName << ':'; + CurrentFnSym->print(O, MAI); + O << ':'; if (VerboseAsm) { O.PadToColumn(MAI->getCommentColumn()); O << MAI->getCommentString() << ' '; @@ -125,8 +138,11 @@ // Add some workaround for linkonce linkage on Cygwin\MinGW if (Subtarget->isTargetCygMing() && - (F->hasLinkOnceLinkage() || F->hasWeakLinkage())) - O << "Lllvm$workaround$fake$stub$" << CurrentFnName << ":\n"; + (F->hasLinkOnceLinkage() || F->hasWeakLinkage())) { + O << "Lllvm$workaround$fake$stub$"; + CurrentFnSym->print(O, MAI); + O << ":\n"; + } } /// runOnMachineFunction - This uses the printMachineInstruction() @@ -183,8 +199,13 @@ O << "\tnop\n"; } - if (MAI->hasDotTypeDotSizeDirective()) - O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n'; + if (MAI->hasDotTypeDotSizeDirective()) { + O << "\t.size\t"; + CurrentFnSym->print(O, MAI); + O << ", .-"; + CurrentFnSym->print(O, MAI); + O << '\n'; + } // Emit post-function debug information. if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling()) Modified: llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp Fri Jan 15 18:21:18 2010 @@ -69,10 +69,9 @@ bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode); - void emitGlobalDirective(const std::string &name); - void emitExternDirective(const std::string &name); + void emitGlobalDirective(const MCSymbol *Sym); - void emitArrayBound(const std::string &name, const GlobalVariable *GV); + void emitArrayBound(const MCSymbol *Sym, const GlobalVariable *GV); virtual void PrintGlobalVariable(const GlobalVariable *GV); void emitFunctionStart(MachineFunction &MF); @@ -95,35 +94,31 @@ #include "XCoreGenAsmWriter.inc" -void XCoreAsmPrinter:: -emitGlobalDirective(const std::string &name) -{ - O << MAI->getGlobalDirective() << name; +void XCoreAsmPrinter::emitGlobalDirective(const MCSymbol *Sym) { + O << MAI->getGlobalDirective(); + Sym->print(O, MAI); O << "\n"; } -void XCoreAsmPrinter:: -emitExternDirective(const std::string &name) -{ - O << "\t.extern\t" << name; - O << '\n'; -} - -void XCoreAsmPrinter:: -emitArrayBound(const std::string &name, const GlobalVariable *GV) -{ +void XCoreAsmPrinter::emitArrayBound(const MCSymbol *Sym, + const GlobalVariable *GV) { assert(((GV->hasExternalLinkage() || GV->hasWeakLinkage()) || GV->hasLinkOnceLinkage()) && "Unexpected linkage"); if (const ArrayType *ATy = dyn_cast( - cast(GV->getType())->getElementType())) - { - O << MAI->getGlobalDirective() << name << ".globound" << "\n"; - O << MAI->getSetDirective() << name << ".globound" << "," + cast(GV->getType())->getElementType())) { + O << MAI->getGlobalDirective(); + Sym->print(O, MAI); + O << ".globound" << "\n"; + O << MAI->getSetDirective(); + Sym->print(O, MAI); + O << ".globound" << "," << ATy->getNumElements() << "\n"; if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()) { // TODO Use COMDAT groups for LinkOnceLinkage - O << MAI->getWeakDefDirective() << name << ".globound" << "\n"; + O << MAI->getWeakDefDirective(); + Sym->print(O, MAI); + O << ".globound" << "\n"; } } } @@ -135,15 +130,19 @@ return; const TargetData *TD = TM.getTargetData(); - OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GV, Mang,TM)); + - std::string name = Mang->getMangledName(GV); + MCSymbol *GVSym = GetGlobalValueSymbol(GV); Constant *C = GV->getInitializer(); unsigned Align = (unsigned)TD->getPreferredTypeAlignmentShift(C->getType()); // Mark the start of the global - O << "\t.cc_top " << name << ".data," << name << "\n"; + O << "\t.cc_top "; + GVSym->print(O, MAI); + O << ".data,"; + GVSym->print(O, MAI); + O << "\n"; switch (GV->getLinkage()) { case GlobalValue::AppendingLinkage: @@ -153,11 +152,13 @@ case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakODRLinkage: case GlobalValue::ExternalLinkage: - emitArrayBound(name, GV); - emitGlobalDirective(name); + emitArrayBound(GVSym, GV); + emitGlobalDirective(GVSym); // TODO Use COMDAT groups for LinkOnceLinkage if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()) { - O << MAI->getWeakDefDirective() << name << "\n"; + O << MAI->getWeakDefDirective(); + GVSym->print(O, MAI); + O << "\n"; } // FALL THROUGH case GlobalValue::InternalLinkage: @@ -181,10 +182,15 @@ Size *= MaxThreads; } if (MAI->hasDotTypeDotSizeDirective()) { - O << "\t.type " << name << ", at object\n"; - O << "\t.size " << name << "," << Size << "\n"; + O << "\t.type "; + GVSym->print(O, MAI); + O << ", at object\n"; + O << "\t.size "; + GVSym->print(O, MAI); + O << "," << Size << "\n"; } - O << name << ":\n"; + GVSym->print(O, MAI); + O << ":\n"; EmitGlobalConstant(C); if (GV->isThreadLocal()) { @@ -199,7 +205,9 @@ } // Mark the end of the global - O << "\t.cc_bottom " << name << ".data\n"; + O << "\t.cc_bottom "; + GVSym->print(O, MAI); + O << ".data\n"; } /// Emit the directives on the start of functions @@ -210,7 +218,11 @@ OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM)); // Mark the start of the function - O << "\t.cc_top " << CurrentFnName << ".function," << CurrentFnName << "\n"; + O << "\t.cc_top "; + CurrentFnSym->print(O, MAI); + O << ".function,"; + CurrentFnSym->print(O, MAI); + O << "\n"; switch (F->getLinkage()) { default: llvm_unreachable("Unknown linkage type!"); @@ -219,31 +231,38 @@ case Function::LinkerPrivateLinkage: break; case Function::ExternalLinkage: - emitGlobalDirective(CurrentFnName); + emitGlobalDirective(CurrentFnSym); break; case Function::LinkOnceAnyLinkage: case Function::LinkOnceODRLinkage: case Function::WeakAnyLinkage: case Function::WeakODRLinkage: // TODO Use COMDAT groups for LinkOnceLinkage - O << MAI->getGlobalDirective() << CurrentFnName << "\n"; - O << MAI->getWeakDefDirective() << CurrentFnName << "\n"; + O << MAI->getGlobalDirective(); + CurrentFnSym->print(O, MAI); + O << "\n"; + O << MAI->getWeakDefDirective(); + CurrentFnSym->print(O, MAI); + O << "\n"; break; } // (1 << 1) byte aligned EmitAlignment(MF.getAlignment(), F, 1); if (MAI->hasDotTypeDotSizeDirective()) { - O << "\t.type " << CurrentFnName << ", at function\n"; + O << "\t.type "; + CurrentFnSym->print(O, MAI); + O << ", at function\n"; } - O << CurrentFnName << ":\n"; + CurrentFnSym->print(O, MAI); + O << ":\n"; } /// Emit the directives on the end of functions -void XCoreAsmPrinter:: -emitFunctionEnd(MachineFunction &MF) -{ +void XCoreAsmPrinter::emitFunctionEnd(MachineFunction &MF) { // Mark the end of the function - O << "\t.cc_bottom " << CurrentFnName << ".function\n"; + O << "\t.cc_bottom "; + CurrentFnSym->print(O, MAI); + O << ".function\n"; } /// runOnMachineFunction - This uses the printMachineInstruction() From sabre at nondot.org Fri Jan 15 18:24:20 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 00:24:20 -0000 Subject: [llvm-commits] [llvm] r93595 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Message-ID: <201001160024.o0G0OKfn007142@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 18:24:20 2010 New Revision: 93595 URL: http://llvm.org/viewvc/llvm-project?rev=93595&view=rev Log: revert the x86 part of my last patch, cygwin is mutating CurrentFnName! Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=93595&r1=93594&r2=93595&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Fri Jan 15 18:24:20 2010 @@ -84,9 +84,7 @@ break; case Function::DLLExportLinkage: case Function::ExternalLinkage: - O << "\t.globl\t"; - CurrentFnSym->print(O, MAI); - O << '\n'; + O << "\t.globl\t" << CurrentFnName << '\n'; break; case Function::LinkerPrivateLinkage: case Function::LinkOnceAnyLinkage: @@ -94,41 +92,30 @@ case Function::WeakAnyLinkage: case Function::WeakODRLinkage: if (Subtarget->isTargetDarwin()) { - O << "\t.globl\t"; - CurrentFnSym->print(O, MAI); - O << '\n'; - O << MAI->getWeakDefDirective(); - CurrentFnSym->print(O, MAI); - O << '\n'; + O << "\t.globl\t" << CurrentFnName << '\n'; + O << MAI->getWeakDefDirective() << CurrentFnName << '\n'; } else if (Subtarget->isTargetCygMing()) { - O << "\t.globl\t"; - CurrentFnSym->print(O, MAI); - O << "\n\t.linkonce discard\n"; + O << "\t.globl\t" << CurrentFnName << "\n" + "\t.linkonce discard\n"; } else { - O << "\t.weak\t"; - CurrentFnSym->print(O, MAI); - O << '\n'; + O << "\t.weak\t" << CurrentFnName << '\n'; } break; } - printVisibility(CurrentFnSym, F->getVisibility()); + printVisibility(CurrentFnName, F->getVisibility()); - if (Subtarget->isTargetELF()) { - O << "\t.type\t"; - CurrentFnSym->print(O, MAI); - O << ", at function\n"; - } else if (Subtarget->isTargetCygMing()) { - O << "\t.def\t "; - CurrentFnSym->print(O, MAI); - O << ";\t.scl\t" << + if (Subtarget->isTargetELF()) + O << "\t.type\t" << CurrentFnName << ", at function\n"; + else if (Subtarget->isTargetCygMing()) { + O << "\t.def\t " << CurrentFnName + << ";\t.scl\t" << (F->hasInternalLinkage() ? COFF::C_STAT : COFF::C_EXT) << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT) << ";\t.endef\n"; } - CurrentFnSym->print(O, MAI); - O << ':'; + O << CurrentFnName << ':'; if (VerboseAsm) { O.PadToColumn(MAI->getCommentColumn()); O << MAI->getCommentString() << ' '; @@ -138,11 +125,8 @@ // Add some workaround for linkonce linkage on Cygwin\MinGW if (Subtarget->isTargetCygMing() && - (F->hasLinkOnceLinkage() || F->hasWeakLinkage())) { - O << "Lllvm$workaround$fake$stub$"; - CurrentFnSym->print(O, MAI); - O << ":\n"; - } + (F->hasLinkOnceLinkage() || F->hasWeakLinkage())) + O << "Lllvm$workaround$fake$stub$" << CurrentFnName << ":\n"; } /// runOnMachineFunction - This uses the printMachineInstruction() @@ -199,13 +183,8 @@ O << "\tnop\n"; } - if (MAI->hasDotTypeDotSizeDirective()) { - O << "\t.size\t"; - CurrentFnSym->print(O, MAI); - O << ", .-"; - CurrentFnSym->print(O, MAI); - O << '\n'; - } + if (MAI->hasDotTypeDotSizeDirective()) + O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n'; // Emit post-function debug information. if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling()) From bob.wilson at apple.com Fri Jan 15 18:27:50 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Sat, 16 Jan 2010 00:27:50 -0000 Subject: [llvm-commits] [test-suite] r93596 - /test-suite/trunk/Makefile.programs Message-ID: <201001160027.o0G0Ro0G007261@zion.cs.uiuc.edu> Author: bwilson Date: Fri Jan 15 18:27:50 2010 New Revision: 93596 URL: http://llvm.org/viewvc/llvm-project?rev=93596&view=rev Log: Remove -pre-regalloc-taildup option for llcbeta testing. Modified: test-suite/trunk/Makefile.programs Modified: test-suite/trunk/Makefile.programs URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.programs?rev=93596&r1=93595&r2=93596&view=diff ============================================================================== --- test-suite/trunk/Makefile.programs (original) +++ test-suite/trunk/Makefile.programs Fri Jan 15 18:27:50 2010 @@ -232,19 +232,19 @@ LLCBETAOPTION := -sched=simple endif ifeq ($(ARCH),x86_64) -LLCBETAOPTION := -pre-regalloc-taildup +LLCBETAOPTION := endif ifeq ($(ARCH),x86) -LLCBETAOPTION := -pre-regalloc-taildup +LLCBETAOPTION := endif ifeq ($(ARCH),Sparc) LLCBETAOPTION := -enable-sparc-v9-insts endif ifeq ($(ARCH),ARM) -LLCBETAOPTION := -pre-regalloc-taildup +LLCBETAOPTION := endif ifeq ($(ARCH),THUMB) -LLCBETAOPTION := -pre-regalloc-taildup +LLCBETAOPTION := endif print-llcbeta-option: From bob.wilson at apple.com Fri Jan 15 18:29:51 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Sat, 16 Jan 2010 00:29:51 -0000 Subject: [llvm-commits] [llvm] r93597 - in /llvm/trunk: lib/CodeGen/LLVMTargetMachine.cpp test/CodeGen/ARM/indirectbr.ll test/CodeGen/Thumb/2009-12-17-pre-regalloc-taildup.ll test/CodeGen/Thumb2/2010-01-06-TailDuplicateLabels.ll Message-ID: <201001160029.o0G0TpN2007327@zion.cs.uiuc.edu> Author: bwilson Date: Fri Jan 15 18:29:50 2010 New Revision: 93597 URL: http://llvm.org/viewvc/llvm-project?rev=93597&view=rev Log: Run the pre-register allocation tail duplication pass by default. Remove the -pre-regalloc-taildup command-line option, and add a new -disable-early-taildup option. Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp llvm/trunk/test/CodeGen/ARM/indirectbr.ll llvm/trunk/test/CodeGen/Thumb/2009-12-17-pre-regalloc-taildup.ll llvm/trunk/test/CodeGen/Thumb2/2010-01-06-TailDuplicateLabels.ll Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=93597&r1=93596&r2=93597&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Fri Jan 15 18:29:50 2010 @@ -39,6 +39,8 @@ cl::desc("Disable branch folding")); static cl::opt DisableTailDuplicate("disable-tail-duplicate", cl::Hidden, cl::desc("Disable tail duplication")); +static cl::opt DisableEarlyTailDup("disable-early-taildup", cl::Hidden, + cl::desc("Disable pre-register allocation tail duplication")); static cl::opt DisableCodePlace("disable-code-place", cl::Hidden, cl::desc("Disable code placement")); static cl::opt DisableSSC("disable-ssc", cl::Hidden, @@ -77,9 +79,6 @@ static cl::opt EnableSplitGEPGVN("split-gep-gvn", cl::Hidden, cl::desc("Split GEPs and run no-load GVN")); -static cl::opt PreAllocTailDup("pre-regalloc-taildup", cl::Hidden, - cl::desc("Pre-register allocation tail duplication")); - LLVMTargetMachine::LLVMTargetMachine(const Target &T, const std::string &TargetTriple) : TargetMachine(T) { @@ -351,8 +350,7 @@ } // Pre-ra tail duplication. - if (OptLevel != CodeGenOpt::None && - !DisableTailDuplicate && PreAllocTailDup) { + if (OptLevel != CodeGenOpt::None && !DisableEarlyTailDup) { PM.add(createTailDuplicatePass(true)); printAndVerify(PM, "After Pre-RegAlloc TailDuplicate", /* allowDoubleDefs= */ true); Modified: llvm/trunk/test/CodeGen/ARM/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/indirectbr.ll?rev=93597&r1=93596&r2=93597&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/indirectbr.ll (original) +++ llvm/trunk/test/CodeGen/ARM/indirectbr.ll Fri Jan 15 18:29:50 2010 @@ -12,6 +12,10 @@ entry: %0 = load i8** @nextaddr, align 4 ; [#uses=2] %1 = icmp eq i8* %0, null ; [#uses=1] +; indirect branch gets duplicated here +; ARM: bx +; THUMB: mov pc, r1 +; THUMB2: mov pc, r1 br i1 %1, label %bb3, label %bb2 bb2: ; preds = %entry, %bb3 Modified: llvm/trunk/test/CodeGen/Thumb/2009-12-17-pre-regalloc-taildup.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/2009-12-17-pre-regalloc-taildup.ll?rev=93597&r1=93596&r2=93597&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/2009-12-17-pre-regalloc-taildup.ll (original) +++ llvm/trunk/test/CodeGen/Thumb/2009-12-17-pre-regalloc-taildup.ll Fri Jan 15 18:29:50 2010 @@ -1,4 +1,4 @@ -; RUN: llc -O3 -pre-regalloc-taildup < %s | FileCheck %s +; RUN: llc -O3 < %s | FileCheck %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-n32" target triple = "thumbv7-apple-darwin10" Modified: llvm/trunk/test/CodeGen/Thumb2/2010-01-06-TailDuplicateLabels.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2010-01-06-TailDuplicateLabels.ll?rev=93597&r1=93596&r2=93597&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2010-01-06-TailDuplicateLabels.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/2010-01-06-TailDuplicateLabels.ll Fri Jan 15 18:29:50 2010 @@ -1,4 +1,4 @@ -; RUN: llc -relocation-model=pic -pre-regalloc-taildup < %s | grep {:$} | sort | uniq -d | count 0 +; RUN: llc -relocation-model=pic < %s | grep {:$} | sort | uniq -d | count 0 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-n32" target triple = "thumbv7-apple-darwin10" From sabre at nondot.org Fri Jan 15 18:32:38 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 00:32:38 -0000 Subject: [llvm-commits] [llvm] r93598 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Message-ID: <201001160032.o0G0WcJc007424@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 18:32:38 2010 New Revision: 93598 URL: http://llvm.org/viewvc/llvm-project?rev=93598&view=rev Log: MCize tis, and make it keep CurrentFnSym up to date with CurrentFnName. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=93598&r1=93597&r2=93598&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Fri Jan 15 18:32:38 2010 @@ -72,6 +72,7 @@ X86COFFMachineModuleInfo &COFFMMI = MMI->getObjFileInfo(); COFFMMI.DecorateCygMingName(CurrentFnName, F, *TM.getTargetData()); + CurrentFnSym = OutContext.GetOrCreateSymbol(StringRef(CurrentFnName)); } OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM)); @@ -84,7 +85,9 @@ break; case Function::DLLExportLinkage: case Function::ExternalLinkage: - O << "\t.globl\t" << CurrentFnName << '\n'; + O << "\t.globl\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; break; case Function::LinkerPrivateLinkage: case Function::LinkOnceAnyLinkage: @@ -92,30 +95,41 @@ case Function::WeakAnyLinkage: case Function::WeakODRLinkage: if (Subtarget->isTargetDarwin()) { - O << "\t.globl\t" << CurrentFnName << '\n'; - O << MAI->getWeakDefDirective() << CurrentFnName << '\n'; + O << "\t.globl\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; + O << MAI->getWeakDefDirective(); + CurrentFnSym->print(O, MAI); + O << '\n'; } else if (Subtarget->isTargetCygMing()) { - O << "\t.globl\t" << CurrentFnName << "\n" - "\t.linkonce discard\n"; + O << "\t.globl\t"; + CurrentFnSym->print(O, MAI); + O << "\n\t.linkonce discard\n"; } else { - O << "\t.weak\t" << CurrentFnName << '\n'; + O << "\t.weak\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; } break; } - printVisibility(CurrentFnName, F->getVisibility()); + printVisibility(CurrentFnSym, F->getVisibility()); - if (Subtarget->isTargetELF()) - O << "\t.type\t" << CurrentFnName << ", at function\n"; - else if (Subtarget->isTargetCygMing()) { - O << "\t.def\t " << CurrentFnName - << ";\t.scl\t" << + if (Subtarget->isTargetELF()) { + O << "\t.type\t"; + CurrentFnSym->print(O, MAI); + O << ", at function\n"; + } else if (Subtarget->isTargetCygMing()) { + O << "\t.def\t "; + CurrentFnSym->print(O, MAI); + O << ";\t.scl\t" << (F->hasInternalLinkage() ? COFF::C_STAT : COFF::C_EXT) << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT) << ";\t.endef\n"; } - O << CurrentFnName << ':'; + CurrentFnSym->print(O, MAI); + O << ':'; if (VerboseAsm) { O.PadToColumn(MAI->getCommentColumn()); O << MAI->getCommentString() << ' '; @@ -125,8 +139,11 @@ // Add some workaround for linkonce linkage on Cygwin\MinGW if (Subtarget->isTargetCygMing() && - (F->hasLinkOnceLinkage() || F->hasWeakLinkage())) - O << "Lllvm$workaround$fake$stub$" << CurrentFnName << ":\n"; + (F->hasLinkOnceLinkage() || F->hasWeakLinkage())) { + O << "Lllvm$workaround$fake$stub$"; + CurrentFnSym->print(O, MAI); + O << ":\n"; + } } /// runOnMachineFunction - This uses the printMachineInstruction() @@ -183,8 +200,13 @@ O << "\tnop\n"; } - if (MAI->hasDotTypeDotSizeDirective()) - O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n'; + if (MAI->hasDotTypeDotSizeDirective()) { + O << "\t.size\t"; + CurrentFnSym->print(O, MAI); + O << ", .-"; + CurrentFnSym->print(O, MAI); + O << '\n'; + } // Emit post-function debug information. if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling()) From bob.wilson at apple.com Fri Jan 15 18:42:26 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Sat, 16 Jan 2010 00:42:26 -0000 Subject: [llvm-commits] [llvm] r93600 - /llvm/trunk/lib/CodeGen/TailDuplication.cpp Message-ID: <201001160042.o0G0gQBR007801@zion.cs.uiuc.edu> Author: bwilson Date: Fri Jan 15 18:42:25 2010 New Revision: 93600 URL: http://llvm.org/viewvc/llvm-project?rev=93600&view=rev Log: Treat indirect branches specially only during pre-regalloc tail duplication, not during the later post-alloc tail duplication. Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=93600&r1=93599&r2=93600&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original) +++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Fri Jan 15 18:42:25 2010 @@ -433,28 +433,28 @@ TailDuplicatePass::TailDuplicate(MachineBasicBlock *TailBB, MachineFunction &MF, SmallVector &TDBBs, SmallVector &Copies) { - // Pre-regalloc tail duplication hurts compile time and doesn't help - // much except for indirect branches. - bool hasIndirectBranch = (!TailBB->empty() && - TailBB->back().getDesc().isIndirectBranch()); - if (PreRegAlloc && !hasIndirectBranch) - return false; - // Set the limit on the number of instructions to duplicate, with a default // of one less than the tail-merge threshold. When optimizing for size, // duplicate only one, because one branch instruction can be eliminated to // compensate for the duplication. unsigned MaxDuplicateCount; - if (hasIndirectBranch) + if (MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize)) + MaxDuplicateCount = 1; + else + MaxDuplicateCount = TailDuplicateSize; + + if (PreRegAlloc) { + // Pre-regalloc tail duplication hurts compile time and doesn't help + // much except for indirect branches. + if (TailBB->empty() || !TailBB->back().getDesc().isIndirectBranch()) + return false; // If the target has hardware branch prediction that can handle indirect // branches, duplicating them can often make them predictable when there // are common paths through the code. The limit needs to be high enough - // to allow undoing the effects of tail merging. + // to allow undoing the effects of tail merging and other optimizations + // that rearrange the predecessors of the indirect branch. MaxDuplicateCount = 20; - else if (MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize)) - MaxDuplicateCount = 1; - else - MaxDuplicateCount = TailDuplicateSize; + } // Don't try to tail-duplicate single-block loops. if (TailBB->isSuccessor(TailBB)) From sabre at nondot.org Fri Jan 15 18:51:39 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 00:51:39 -0000 Subject: [llvm-commits] [llvm] r93603 - in /llvm/trunk/lib/Target: Sparc/AsmPrinter/SparcAsmPrinter.cpp X86/AsmPrinter/X86AsmPrinter.cpp X86/X86COFFMachineModuleInfo.cpp X86/X86COFFMachineModuleInfo.h Message-ID: <201001160051.o0G0peRb008121@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 18:51:39 2010 New Revision: 93603 URL: http://llvm.org/viewvc/llvm-project?rev=93603&view=rev Log: switch X86 target off CurFunctionName and MCIze more. Note that the code wasn't calling DecorateCygMingName when emitting the ".ascii -export" stuff at the end of file for DLLExported functions. I don't know if it should or not, but I'm preserving behavior. Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.cpp llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=93603&r1=93602&r2=93603&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Fri Jan 15 18:51:39 2010 @@ -170,8 +170,9 @@ case Function::WeakAnyLinkage: case Function::WeakODRLinkage: // Function is weak - O << "\t.weak\t";CurrentFnSym->print(O, MAI); - O << '\n' ; + O << "\t.weak\t"; + CurrentFnSym->print(O, MAI); + O << '\n'; break; } Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=93603&r1=93602&r2=93603&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Fri Jan 15 18:51:39 2010 @@ -71,8 +71,8 @@ if (Subtarget->isTargetCygMing()) { X86COFFMachineModuleInfo &COFFMMI = MMI->getObjFileInfo(); - COFFMMI.DecorateCygMingName(CurrentFnName, F, *TM.getTargetData()); - CurrentFnSym = OutContext.GetOrCreateSymbol(StringRef(CurrentFnName)); + COFFMMI.DecorateCygMingName(CurrentFnSym, OutContext, F, + *TM.getTargetData()); } OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM)); @@ -238,24 +238,25 @@ case MachineOperand::MO_GlobalAddress: { const GlobalValue *GV = MO.getGlobal(); - const char *Suffix = ""; + const MCSymbol *GVSym; if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) - Suffix = "$stub"; + GVSym = GetPrivateGlobalValueSymbolStub(GV, "$stub"); else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY || MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE || MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE) - Suffix = "$non_lazy_ptr"; - - std::string Name = Mang->getMangledName(GV, Suffix, Suffix[0] != '\0'); + GVSym = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr"); + else + GVSym = GetGlobalValueSymbol(GV); + if (Subtarget->isTargetCygMing()) { X86COFFMachineModuleInfo &COFFMMI = MMI->getObjFileInfo(); - COFFMMI.DecorateCygMingName(Name, GV, *TM.getTargetData()); + COFFMMI.DecorateCygMingName(GVSym, OutContext, GV, *TM.getTargetData()); } // Handle dllimport linkage. if (MO.getTargetFlags() == X86II::MO_DLLIMPORT) - Name = "__imp_" + Name; + GVSym = OutContext.GetOrCreateSymbol(Twine("__imp_") + GVSym->getName()); if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY || MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) { @@ -296,11 +297,13 @@ // If the name begins with a dollar-sign, enclose it in parens. We do this // to avoid having it look like an integer immediate to the assembler. - if (Name[0] == '$') - O << '(' << Name << ')'; - else - O << Name; - + if (GVSym->getName()[0] != '$') + GVSym->print(O, MAI); + else { + O << '('; + GVSym->print(O, MAI); + O << ')'; + } printOffset(MO.getOffset()); break; } @@ -916,36 +919,39 @@ if (Subtarget->isTargetCygMing()) { // Necessary for dllexport support - std::vector DLLExportedFns, DLLExportedGlobals; + std::vector DLLExportedFns, DLLExportedGlobals; TargetLoweringObjectFileCOFF &TLOFCOFF = static_cast(getObjFileLowering()); for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I) if (I->hasDLLExportLinkage()) { - std::string Name = Mang->getMangledName(I); - COFFMMI.DecorateCygMingName(Name, I, *TM.getTargetData()); - DLLExportedFns.push_back(Name); + const MCSymbol *Sym = GetGlobalValueSymbol(I); + COFFMMI.DecorateCygMingName(Sym, OutContext, I, *TM.getTargetData()); + DLLExportedFns.push_back(Sym); } for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) - if (I->hasDLLExportLinkage()) { - std::string Name = Mang->getMangledName(I); - COFFMMI.DecorateCygMingName(Name, I, *TM.getTargetData()); - DLLExportedGlobals.push_back(Mang->getMangledName(I)); - } + if (I->hasDLLExportLinkage()) + DLLExportedGlobals.push_back(GetGlobalValueSymbol(I)); // Output linker support code for dllexported globals on windows. if (!DLLExportedGlobals.empty() || !DLLExportedFns.empty()) { OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve", true, SectionKind::getMetadata())); - for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i) - O << "\t.ascii \" -export:" << DLLExportedGlobals[i] << ",data\"\n"; + for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i) { + O << "\t.ascii \" -export:"; + DLLExportedGlobals[i]->print(O, MAI); + O << ",data\"\n"; + } - for (unsigned i = 0, e = DLLExportedFns.size(); i != e; ++i) - O << "\t.ascii \" -export:" << DLLExportedFns[i] << "\"\n"; + for (unsigned i = 0, e = DLLExportedFns.size(); i != e; ++i) { + O << "\t.ascii \" -export:"; + DLLExportedFns[i]->print(O, MAI); + O << "\"\n"; + } } } } Modified: llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.cpp?rev=93603&r1=93602&r2=93603&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.cpp Fri Jan 15 18:51:39 2010 @@ -15,6 +15,8 @@ #include "X86MachineFunctionInfo.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCSymbol.h" #include "llvm/Target/TargetData.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/raw_ostream.h" @@ -23,7 +25,6 @@ X86COFFMachineModuleInfo::X86COFFMachineModuleInfo(const MachineModuleInfo &) { } X86COFFMachineModuleInfo::~X86COFFMachineModuleInfo() { - } void X86COFFMachineModuleInfo::AddFunctionInfo(const Function *F, @@ -114,10 +115,12 @@ /// DecorateCygMingName - Query FunctionInfoMap and use this information for /// various name decorations for Cygwin and MingW. -void X86COFFMachineModuleInfo::DecorateCygMingName(std::string &Name, +void X86COFFMachineModuleInfo::DecorateCygMingName(const MCSymbol *&Name, + MCContext &Ctx, const GlobalValue *GV, const TargetData &TD) { - SmallString<128> NameStr(Name.begin(), Name.end()); + SmallString<128> NameStr(Name->getName().begin(), Name->getName().end()); DecorateCygMingName(NameStr, GV, TD); - Name.assign(NameStr.begin(), NameStr.end()); + + Name = Ctx.GetOrCreateSymbol(NameStr.str()); } Modified: llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h?rev=93603&r1=93602&r2=93603&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h Fri Jan 15 18:51:39 2010 @@ -46,8 +46,8 @@ ~X86COFFMachineModuleInfo(); - void DecorateCygMingName(std::string &Name, const GlobalValue *GV, - const TargetData &TD); + void DecorateCygMingName(const MCSymbol* &Name, MCContext &Ctx, + const GlobalValue *GV, const TargetData &TD); void DecorateCygMingName(SmallVectorImpl &Name, const GlobalValue *GV, const TargetData &TD); From sabre at nondot.org Fri Jan 15 18:53:23 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 00:53:23 -0000 Subject: [llvm-commits] [llvm] r93604 - /llvm/trunk/test/CodeGen/X86/illegal-asm.ll Message-ID: <201001160053.o0G0rNTw008193@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 18:53:22 2010 New Revision: 93604 URL: http://llvm.org/viewvc/llvm-project?rev=93604&view=rev Log: this teestcase takes a long time to crash, remove it. If someone cares about this, they should file a bug, it's not doing any good as an xfail. Removed: llvm/trunk/test/CodeGen/X86/illegal-asm.ll Removed: llvm/trunk/test/CodeGen/X86/illegal-asm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/illegal-asm.ll?rev=93603&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/illegal-asm.ll (original) +++ llvm/trunk/test/CodeGen/X86/illegal-asm.ll (removed) @@ -1,34 +0,0 @@ -; RUN: llc < %s -mtriple=i386-apple-darwin -disable-fp-elim -; RUN: llc < %s -mtriple=i386-linux -disable-fp-elim -; XFAIL: * -; Expected to run out of registers during allocation. -; PR3864 -; rdar://6251720 - - %struct.CABACContext = type { i32, i32, i8* } - %struct.H264Context = type { %struct.CABACContext, [460 x i8] } - at coeff_abs_level_m1_offset = common global [6 x i32] zeroinitializer ; <[6 x i32]*> [#uses=1] - at coeff_abs_level1_ctx = common global [8 x i8] zeroinitializer ; <[8 x i8]*> [#uses=1] - -define i32 @decode_cabac_residual(%struct.H264Context* %h, i32 %cat) nounwind { -entry: - %0 = getelementptr [6 x i32]* @coeff_abs_level_m1_offset, i32 0, i32 %cat ; [#uses=1] - %1 = load i32* %0, align 4 ; [#uses=1] - %2 = load i8* getelementptr ([8 x i8]* @coeff_abs_level1_ctx, i32 0, i32 0), align 1 ; [#uses=1] - %3 = zext i8 %2 to i32 ; [#uses=1] - %.sum = add i32 %3, %1 ; [#uses=1] - %4 = getelementptr %struct.H264Context* %h, i32 0, i32 1, i32 %.sum ; [#uses=2] - %5 = getelementptr %struct.H264Context* %h, i32 0, i32 0, i32 0 ; [#uses=2] - %6 = getelementptr %struct.H264Context* %h, i32 0, i32 0, i32 1 ; [#uses=2] - %7 = getelementptr %struct.H264Context* %h, i32 0, i32 0, i32 2 ; [#uses=2] - %8 = load i32* %5, align 4 ; [#uses=1] - %9 = load i32* %6, align 4 ; [#uses=1] - %10 = load i8* %4, align 4 ; [#uses=1] - %asmtmp = tail call { i32, i32, i32, i32 } asm sideeffect "#$0 $1 $2 $3 $4 $5", "=&{di},=r,=r,=*m,=&q,=*imr,1,2,*m,5,~{dirflag},~{fpsr},~{flags},~{cx}"(i8** %7, i8* %4, i32 %8, i32 %9, i8** %7, i8 %10) nounwind ; <{ i32, i32, i32, i32 }> [#uses=3] - %asmresult = extractvalue { i32, i32, i32, i32 } %asmtmp, 0 ; [#uses=1] - %asmresult1 = extractvalue { i32, i32, i32, i32 } %asmtmp, 1 ; [#uses=1] - store i32 %asmresult1, i32* %5 - %asmresult2 = extractvalue { i32, i32, i32, i32 } %asmtmp, 2 ; [#uses=1] - store i32 %asmresult2, i32* %6 - ret i32 %asmresult -} From sabre at nondot.org Fri Jan 15 19:00:27 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 01:00:27 -0000 Subject: [llvm-commits] [llvm] r93605 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Message-ID: <201001160100.o0G10SZl008565@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 19:00:27 2010 New Revision: 93605 URL: http://llvm.org/viewvc/llvm-project?rev=93605&view=rev Log: eliminate uses of deprecated mangler apis Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=93605&r1=93604&r2=93605&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Fri Jan 15 19:00:27 2010 @@ -223,7 +223,6 @@ /// jump tables, constant pools, global address and external symbols, all of /// which print to a label with various suffixes for relocation types etc. void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) { - SmallString<128> TempNameStr; switch (MO.getType()) { default: llvm_unreachable("unknown symbol type!"); case MachineOperand::MO_JumpTableIndex: @@ -260,39 +259,25 @@ if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY || MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) { - Mang->getNameWithPrefix(TempNameStr, GV, true); - TempNameStr += "$non_lazy_ptr"; - MCSymbol *Sym = OutContext.GetOrCreateSymbol(TempNameStr.str()); + MCSymbol *Sym = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr"); const MCSymbol *&StubSym = MMI->getObjFileInfo().getGVStubEntry(Sym); - if (StubSym == 0) { - TempNameStr.clear(); - Mang->getNameWithPrefix(TempNameStr, GV, false); - StubSym = OutContext.GetOrCreateSymbol(TempNameStr.str()); - } + if (StubSym == 0) + StubSym = GetGlobalValueSymbol(GV); + } else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){ - Mang->getNameWithPrefix(TempNameStr, GV, true); - TempNameStr += "$non_lazy_ptr"; - MCSymbol *Sym = OutContext.GetOrCreateSymbol(TempNameStr.str()); + MCSymbol *Sym = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr"); const MCSymbol *&StubSym = MMI->getObjFileInfo().getHiddenGVStubEntry(Sym); - if (StubSym == 0) { - TempNameStr.clear(); - Mang->getNameWithPrefix(TempNameStr, GV, false); - StubSym = OutContext.GetOrCreateSymbol(TempNameStr.str()); - } + if (StubSym == 0) + StubSym = GetGlobalValueSymbol(GV); } else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) { - Mang->getNameWithPrefix(TempNameStr, GV, true); - TempNameStr += "$stub"; - MCSymbol *Sym = OutContext.GetOrCreateSymbol(TempNameStr.str()); + MCSymbol *Sym = GetPrivateGlobalValueSymbolStub(GV, "$stub"); const MCSymbol *&StubSym = MMI->getObjFileInfo().getFnStubEntry(Sym); - if (StubSym == 0) { - TempNameStr.clear(); - Mang->getNameWithPrefix(TempNameStr, GV, false); - StubSym = OutContext.GetOrCreateSymbol(TempNameStr.str()); - } + if (StubSym == 0) + StubSym = GetGlobalValueSymbol(GV); } // If the name begins with a dollar-sign, enclose it in parens. We do this @@ -310,9 +295,11 @@ case MachineOperand::MO_ExternalSymbol: { const MCSymbol *SymToPrint; if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) { - Mang->getNameWithPrefix(TempNameStr, - StringRef(MO.getSymbolName())+"$stub"); - const MCSymbol *Sym = OutContext.GetOrCreateSymbol(TempNameStr.str()); + SmallString<128> TempNameStr; + TempNameStr += StringRef(MO.getSymbolName()); + TempNameStr += StringRef("$stub"); + + const MCSymbol *Sym = GetExternalSymbolSymbol(TempNameStr.str()); const MCSymbol *&StubSym = MMI->getObjFileInfo().getFnStubEntry(Sym); if (StubSym == 0) { @@ -321,8 +308,7 @@ } SymToPrint = StubSym; } else { - Mang->getNameWithPrefix(TempNameStr, MO.getSymbolName()); - SymToPrint = OutContext.GetOrCreateSymbol(TempNameStr.str()); + SymToPrint = GetExternalSymbolSymbol(MO.getSymbolName()); } // If the name begins with a dollar-sign, enclose it in parens. We do this @@ -707,16 +693,19 @@ const TargetData *TD = TM.getTargetData(); - std::string name = Mang->getMangledName(GVar); + MCSymbol *GVSym = GetGlobalValueSymbol(GVar); Constant *C = GVar->getInitializer(); const Type *Type = C->getType(); unsigned Size = TD->getTypeAllocSize(Type); unsigned Align = TD->getPreferredAlignmentLog(GVar); - printVisibility(name, GVar->getVisibility()); + printVisibility(GVSym, GVar->getVisibility()); - if (Subtarget->isTargetELF()) - O << "\t.type\t" << name << ", at object\n"; + if (Subtarget->isTargetELF()) { + O << "\t.type\t"; + GVSym->print(O, MAI); + O << ", at object\n"; + } SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM); @@ -730,9 +719,12 @@ !TheSection->getKind().isMergeableCString()) { if (GVar->hasExternalLinkage()) { if (const char *Directive = MAI->getZeroFillDirective()) { - O << "\t.globl " << name << '\n'; - O << Directive << "__DATA, __common, " << name << ", " - << Size << ", " << Align << '\n'; + O << "\t.globl "; + GVSym->print(O, MAI); + O << '\n'; + O << Directive << "__DATA, __common, "; + GVSym->print(O, MAI); + O << ", " << Size << ", " << Align << '\n'; return; } } @@ -743,14 +735,20 @@ if (MAI->getLCOMMDirective() != NULL) { if (GVar->hasLocalLinkage()) { - O << MAI->getLCOMMDirective() << name << ',' << Size; + O << MAI->getLCOMMDirective(); + GVSym->print(O, MAI); + O << ',' << Size; if (Subtarget->isTargetDarwin()) O << ',' << Align; } else if (Subtarget->isTargetDarwin() && !GVar->hasCommonLinkage()) { - O << "\t.globl " << name << '\n' - << MAI->getWeakDefDirective() << name << '\n'; + O << "\t.globl "; + GVSym->print(O, MAI); + O << '\n' << MAI->getWeakDefDirective(); + GVSym->print(O, MAI); + O << '\n'; EmitAlignment(Align, GVar); - O << name << ":"; + GVSym->print(O, MAI); + O << ":"; if (VerboseAsm) { O.PadToColumn(MAI->getCommentColumn()); O << MAI->getCommentString() << ' '; @@ -760,16 +758,23 @@ EmitGlobalConstant(C); return; } else { - O << MAI->getCOMMDirective() << name << ',' << Size; + O << MAI->getCOMMDirective(); + GVSym->print(O, MAI); + O << ',' << Size; if (MAI->getCOMMDirectiveTakesAlignment()) O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); } } else { if (!Subtarget->isTargetCygMing()) { - if (GVar->hasLocalLinkage()) - O << "\t.local\t" << name << '\n'; + if (GVar->hasLocalLinkage()) { + O << "\t.local\t"; + GVSym->print(O, MAI); + O << '\n'; + } } - O << MAI->getCOMMDirective() << name << ',' << Size; + O << MAI->getCOMMDirective(); + GVSym->print(O, MAI); + O << ',' << Size; if (MAI->getCOMMDirectiveTakesAlignment()) O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); } @@ -791,13 +796,19 @@ case GlobalValue::WeakODRLinkage: case GlobalValue::LinkerPrivateLinkage: if (Subtarget->isTargetDarwin()) { - O << "\t.globl " << name << '\n' - << MAI->getWeakDefDirective() << name << '\n'; + O << "\t.globl "; + GVSym->print(O, MAI); + O << '\n' << MAI->getWeakDefDirective(); + GVSym->print(O, MAI); + O << '\n'; } else if (Subtarget->isTargetCygMing()) { - O << "\t.globl\t" << name << "\n" - "\t.linkonce same_size\n"; + O << "\t.globl\t"; + GVSym->print(O, MAI); + O << "\n\t.linkonce same_size\n"; } else { - O << "\t.weak\t" << name << '\n'; + O << "\t.weak\t"; + GVSym->print(O, MAI); + O << '\n'; } break; case GlobalValue::DLLExportLinkage: @@ -806,7 +817,9 @@ // their name or something. For now, just emit them as external. case GlobalValue::ExternalLinkage: // If external or appending, declare as a global symbol - O << "\t.globl " << name << '\n'; + O << "\t.globl "; + GVSym->print(O, MAI); + O << '\n'; // FALL THROUGH case GlobalValue::PrivateLinkage: case GlobalValue::InternalLinkage: @@ -816,7 +829,8 @@ } EmitAlignment(Align, GVar); - O << name << ":"; + GVSym->print(O, MAI); + O << ":"; if (VerboseAsm){ O.PadToColumn(MAI->getCommentColumn()); O << MAI->getCommentString() << ' '; @@ -826,8 +840,11 @@ EmitGlobalConstant(C); - if (MAI->hasDotTypeDotSizeDirective()) - O << "\t.size\t" << name << ", " << Size << '\n'; + if (MAI->hasDotTypeDotSizeDirective()) { + O << "\t.size\t"; + GVSym->print(O, MAI); + O << ", " << Size << '\n'; + } } void X86AsmPrinter::EmitEndOfAsmFile(Module &M) { From isanbard at gmail.com Fri Jan 15 19:06:59 2010 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 16 Jan 2010 01:06:59 -0000 Subject: [llvm-commits] [llvm] r93606 - in /llvm/trunk: include/llvm/Support/Allocator.h lib/Support/Allocator.cpp Message-ID: <201001160106.o0G16xEE008797@zion.cs.uiuc.edu> Author: void Date: Fri Jan 15 19:06:58 2010 New Revision: 93606 URL: http://llvm.org/viewvc/llvm-project?rev=93606&view=rev Log: Temporarily revert r93581. It was causing failures in the ExecutionEngine tests on the build bots. Modified: llvm/trunk/include/llvm/Support/Allocator.h llvm/trunk/lib/Support/Allocator.cpp Modified: llvm/trunk/include/llvm/Support/Allocator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=93606&r1=93605&r2=93606&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Allocator.h (original) +++ llvm/trunk/include/llvm/Support/Allocator.h Fri Jan 15 19:06:58 2010 @@ -128,11 +128,11 @@ /// one. void DeallocateSlabs(MemSlab *Slab); - static MallocSlabAllocator &GetDefaultSlabAllocator(); + static MallocSlabAllocator DefaultSlabAllocator; public: BumpPtrAllocator(size_t size = 4096, size_t threshold = 4096, - SlabAllocator &allocator = GetDefaultSlabAllocator()); + SlabAllocator &allocator = DefaultSlabAllocator); ~BumpPtrAllocator(); /// Reset - Deallocate all but the current slab and reset the current pointer Modified: llvm/trunk/lib/Support/Allocator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=93606&r1=93605&r2=93606&view=diff ============================================================================== --- llvm/trunk/lib/Support/Allocator.cpp (original) +++ llvm/trunk/lib/Support/Allocator.cpp Fri Jan 15 19:06:58 2010 @@ -142,10 +142,8 @@ << " (includes alignment, etc)\n"; } -MallocSlabAllocator &BumpPtrAllocator::GetDefaultSlabAllocator() { - static MallocSlabAllocator DefaultSlabAllocator; - return DefaultSlabAllocator; -} +MallocSlabAllocator BumpPtrAllocator::DefaultSlabAllocator = + MallocSlabAllocator(); SlabAllocator::~SlabAllocator() { } From sabre at nondot.org Fri Jan 15 19:12:02 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 01:12:02 -0000 Subject: [llvm-commits] [llvm] r93608 - in /llvm/trunk/lib/Target: PowerPC/AsmPrinter/PPCAsmPrinter.cpp Sparc/AsmPrinter/SparcAsmPrinter.cpp SystemZ/AsmPrinter/SystemZAsmPrinter.cpp Message-ID: <201001160112.o0G1C2dW008980@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 19:12:01 2010 New Revision: 93608 URL: http://llvm.org/viewvc/llvm-project?rev=93608&view=rev Log: switch more stuff onto MCSymbols Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=93608&r1=93607&r2=93608&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Fri Jan 15 19:12:01 2010 @@ -729,9 +729,9 @@ if (EmitSpecialLLVMGlobal(GVar)) return; - std::string name = Mang->getMangledName(GVar); + MCSymbol *GVarSym = GetGlobalValueSymbol(GVar); - printVisibility(name, GVar->getVisibility()); + printVisibility(GVarSym, GVar->getVisibility()); Constant *C = GVar->getInitializer(); const Type *Type = C->getType(); @@ -748,14 +748,23 @@ if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. if (GVar->hasExternalLinkage()) { - O << "\t.global " << name << '\n'; - O << "\t.type " << name << ", @object\n"; - O << name << ":\n"; + O << "\t.global "; + GVarSym->print(O, MAI); + O << '\n'; + O << "\t.type "; + GVarSym->print(O, MAI); + O << ", @object\n"; + GVarSym->print(O, MAI); + O << ":\n"; O << "\t.zero " << Size << '\n'; } else if (GVar->hasLocalLinkage()) { - O << MAI->getLCOMMDirective() << name << ',' << Size; + O << MAI->getLCOMMDirective(); + GVarSym->print(O, MAI); + O << ',' << Size; } else { - O << ".comm " << name << ',' << Size; + O << ".comm "; + GVarSym->print(O, MAI); + O << ',' << Size; } if (VerboseAsm) { O << "\t\t" << MAI->getCommentString() << " '"; @@ -773,17 +782,24 @@ case GlobalValue::WeakODRLinkage: case GlobalValue::CommonLinkage: case GlobalValue::LinkerPrivateLinkage: - O << "\t.global " << name << '\n' - << "\t.type " << name << ", @object\n" - << "\t.weak " << name << '\n'; + O << "\t.global "; + GVarSym->print(O, MAI); + O << "\n\t.type "; + GVarSym->print(O, MAI); + O << ", @object\n\t.weak "; + GVarSym->print(O, MAI); + O << '\n'; break; case GlobalValue::AppendingLinkage: // FIXME: appending linkage variables should go into a section of // their name or something. For now, just emit them as external. case GlobalValue::ExternalLinkage: // If external or appending, declare as a global symbol - O << "\t.global " << name << '\n' - << "\t.type " << name << ", @object\n"; + O << "\t.global "; + GVarSym->print(O, MAI); + O << "\n\t.type "; + GVarSym->print(O, MAI); + O << ", @object\n"; // FALL THROUGH case GlobalValue::InternalLinkage: case GlobalValue::PrivateLinkage: @@ -793,7 +809,8 @@ } EmitAlignment(Align, GVar); - O << name << ":"; + GVarSym->print(O, MAI); + O << ":"; if (VerboseAsm) { O << "\t\t\t\t" << MAI->getCommentString() << " '"; WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); @@ -967,8 +984,8 @@ return; } - std::string name = Mang->getMangledName(GVar); - printVisibility(name, GVar->getVisibility()); + MCSymbol *GVarSym = GetGlobalValueSymbol(GVar); + printVisibility(GVarSym, GVar->getVisibility()); Constant *C = GVar->getInitializer(); const Type *Type = C->getType(); @@ -989,16 +1006,25 @@ if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. if (GVar->hasExternalLinkage()) { - O << "\t.globl " << name << '\n'; - O << "\t.zerofill __DATA, __common, " << name << ", " - << Size << ", " << Align; + O << "\t.globl "; + GVarSym->print(O, MAI); + O << '\n'; + O << "\t.zerofill __DATA, __common, "; + GVarSym->print(O, MAI); + O << ", " << Size << ", " << Align; } else if (GVar->hasLocalLinkage()) { - O << MAI->getLCOMMDirective() << name << ',' << Size << ',' << Align; + O << MAI->getLCOMMDirective(); + GVarSym->print(O, MAI); + O << ',' << Size << ',' << Align; } else if (!GVar->hasCommonLinkage()) { - O << "\t.globl " << name << '\n' - << MAI->getWeakDefDirective() << name << '\n'; + O << "\t.globl "; + GVarSym->print(O, MAI); + O << '\n' << MAI->getWeakDefDirective(); + GVarSym->print(O, MAI); + O << '\n'; EmitAlignment(Align, GVar); - O << name << ":"; + GVarSym->print(O, MAI); + O << ":"; if (VerboseAsm) { O << "\t\t\t\t" << MAI->getCommentString() << " "; WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); @@ -1007,7 +1033,9 @@ EmitGlobalConstant(C); return; } else { - O << ".comm " << name << ',' << Size; + O << ".comm "; + GVarSym->print(O, MAI); + O << ',' << Size; // Darwin 9 and above support aligned common data. if (Subtarget.isDarwin9()) O << ',' << Align; @@ -1022,31 +1050,37 @@ } switch (GVar->getLinkage()) { - case GlobalValue::LinkOnceAnyLinkage: - case GlobalValue::LinkOnceODRLinkage: - case GlobalValue::WeakAnyLinkage: - case GlobalValue::WeakODRLinkage: - case GlobalValue::CommonLinkage: - case GlobalValue::LinkerPrivateLinkage: - O << "\t.globl " << name << '\n' - << "\t.weak_definition " << name << '\n'; + case GlobalValue::LinkOnceAnyLinkage: + case GlobalValue::LinkOnceODRLinkage: + case GlobalValue::WeakAnyLinkage: + case GlobalValue::WeakODRLinkage: + case GlobalValue::CommonLinkage: + case GlobalValue::LinkerPrivateLinkage: + O << "\t.globl "; + GVarSym->print(O, MAI); + O << "\n\t.weak_definition "; + GVarSym->print(O, MAI); + O << '\n'; break; - case GlobalValue::AppendingLinkage: + case GlobalValue::AppendingLinkage: // FIXME: appending linkage variables should go into a section of // their name or something. For now, just emit them as external. - case GlobalValue::ExternalLinkage: + case GlobalValue::ExternalLinkage: // If external or appending, declare as a global symbol - O << "\t.globl " << name << '\n'; + O << "\t.globl "; + GVarSym->print(O, MAI); + O << '\n'; // FALL THROUGH - case GlobalValue::InternalLinkage: - case GlobalValue::PrivateLinkage: + case GlobalValue::InternalLinkage: + case GlobalValue::PrivateLinkage: break; - default: + default: llvm_unreachable("Unknown linkage type!"); } EmitAlignment(Align, GVar); - O << name << ":"; + GVarSym->print(O, MAI); + O << ":"; if (VerboseAsm) { O << "\t\t\t\t" << MAI->getCommentString() << " '"; WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=93608&r1=93607&r2=93608&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Fri Jan 15 19:12:01 2010 @@ -34,7 +34,6 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/MathExtras.h" #include #include @@ -299,12 +298,12 @@ return; O << "\n\n"; - std::string name = Mang->getMangledName(GVar); + MCSymbol *GVarSym = GetGlobalValueSymbol(GVar); Constant *C = GVar->getInitializer(); unsigned Size = TD->getTypeAllocSize(C->getType()); unsigned Align = TD->getPreferredAlignment(GVar); - printVisibility(name, GVar->getVisibility()); + printVisibility(GVarSym, GVar->getVisibility()); OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang, TM)); @@ -314,10 +313,15 @@ (GVar->hasLocalLinkage() || GVar->isWeakForLinker())) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. - if (GVar->hasLocalLinkage()) - O << "\t.local " << name << '\n'; - - O << MAI->getCOMMDirective() << name << ',' << Size; + if (GVar->hasLocalLinkage()) { + O << "\t.local "; + GVarSym->print(O, MAI); + O << '\n'; + } + + O << MAI->getCOMMDirective(); + GVarSym->print(O, MAI); + O << ',' << Size; if (MAI->getCOMMDirectiveTakesAlignment()) O << ',' << (1 << Align); @@ -333,14 +337,18 @@ case GlobalValue::WeakAnyLinkage: // FIXME: Verify correct for weak. case GlobalValue::WeakODRLinkage: // FIXME: Verify correct for weak. // Nonnull linkonce -> weak - O << "\t.weak " << name << '\n'; + O << "\t.weak "; + GVarSym->print(O, MAI); + O << '\n'; break; case GlobalValue::AppendingLinkage: // FIXME: appending linkage variables should go into a section of // their name or something. For now, just emit them as external. case GlobalValue::ExternalLinkage: // If external or appending, declare as a global symbol - O << MAI->getGlobalDirective() << name << '\n'; + O << MAI->getGlobalDirective(); + GVarSym->print(O, MAI); + O << '\n'; // FALL THROUGH case GlobalValue::PrivateLinkage: case GlobalValue::LinkerPrivateLinkage: @@ -359,11 +367,16 @@ EmitAlignment(Align, GVar); if (MAI->hasDotTypeDotSizeDirective()) { - O << "\t.type " << name << ",#object\n"; - O << "\t.size " << name << ',' << Size << '\n'; + O << "\t.type "; + GVarSym->print(O, MAI); + O << ",#object\n"; + O << "\t.size "; + GVarSym->print(O, MAI); + O << ',' << Size << '\n'; } - O << name << ":\n"; + GVarSym->print(O, MAI); + O << ":\n"; EmitGlobalConstant(C); } Modified: llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp?rev=93608&r1=93607&r2=93608&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp Fri Jan 15 19:12:01 2010 @@ -36,7 +36,6 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Mangler.h" - using namespace llvm; STATISTIC(EmittedInsts, "Number of machine instrs printed"); @@ -326,14 +325,16 @@ if (EmitSpecialLLVMGlobal(GVar)) return; - std::string name = Mang->getMangledName(GVar); + MCSymbol *GVarSym = GetGlobalValueSymbol(GVar); Constant *C = GVar->getInitializer(); unsigned Size = TD->getTypeAllocSize(C->getType()); unsigned Align = std::max(1U, TD->getPreferredAlignmentLog(GVar)); - printVisibility(name, GVar->getVisibility()); + printVisibility(GVarSym, GVar->getVisibility()); - O << "\t.type\t" << name << ", at object\n"; + O << "\t.type\t"; + GVarSym->print(O, MAI); + O << ", at object\n"; OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang, TM)); @@ -344,10 +345,15 @@ if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. - if (GVar->hasLocalLinkage()) - O << "\t.local\t" << name << '\n'; + if (GVar->hasLocalLinkage()) { + O << "\t.local\t"; + GVarSym->print(O, MAI); + O << '\n'; + } - O << MAI->getCOMMDirective() << name << ',' << Size; + O << MAI->getCOMMDirective(); + GVarSym->print(O, MAI); + O << ',' << Size; if (MAI->getCOMMDirectiveTakesAlignment()) O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); @@ -365,7 +371,9 @@ case GlobalValue::LinkOnceODRLinkage: case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakODRLinkage: - O << "\t.weak\t" << name << '\n'; + O << "\t.weak\t"; + GVarSym->print(O, MAI); + O << '\n'; break; case GlobalValue::DLLExportLinkage: case GlobalValue::AppendingLinkage: @@ -373,7 +381,9 @@ // their name or something. For now, just emit them as external. case GlobalValue::ExternalLinkage: // If external or appending, declare as a global symbol - O << "\t.globl " << name << '\n'; + O << "\t.globl "; + GVarSym->print(O, MAI); + O << '\n'; // FALL THROUGH case GlobalValue::PrivateLinkage: case GlobalValue::LinkerPrivateLinkage: @@ -385,14 +395,18 @@ // Use 16-bit alignment by default to simplify bunch of stuff EmitAlignment(Align, GVar, 1); - O << name << ":"; + GVarSym->print(O, MAI); + O << ":"; if (VerboseAsm) { O << "\t\t\t\t" << MAI->getCommentString() << ' '; WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); } O << '\n'; - if (MAI->hasDotTypeDotSizeDirective()) - O << "\t.size\t" << name << ", " << Size << '\n'; + if (MAI->hasDotTypeDotSizeDirective()) { + O << "\t.size\t"; + GVarSym->print(O, MAI); + O << ", " << Size << '\n'; + } EmitGlobalConstant(C); } From sabre at nondot.org Fri Jan 15 19:17:26 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 01:17:26 -0000 Subject: [llvm-commits] [llvm] r93609 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp Message-ID: <201001160117.o0G1HQwG009179@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 19:17:26 2010 New Revision: 93609 URL: http://llvm.org/viewvc/llvm-project?rev=93609&view=rev Log: remove the string form of printVisibility. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=93609&r1=93608&r2=93609&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Fri Jan 15 19:17:26 2010 @@ -421,9 +421,6 @@ /// this is suported by the target. void printVisibility(const MCSymbol *Sym, unsigned Visibility) const; - // FIXME: This is deprecated and should be removed. - void printVisibility(const std::string& Name, unsigned Visibility) const; - /// printOffset - This is just convenient handler for printing offsets. void printOffset(int64_t Offset) const; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93609&r1=93608&r2=93609&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Jan 15 19:17:26 2010 @@ -178,21 +178,30 @@ O << '\n'; for (Module::const_alias_iterator I = M.alias_begin(), E = M.alias_end(); I != E; ++I) { - std::string Name = Mang->getMangledName(I); + MCSymbol *Name = GetGlobalValueSymbol(I); const GlobalValue *GV = cast(I->getAliasedGlobal()); - std::string Target = Mang->getMangledName(GV); + MCSymbol *Target = GetGlobalValueSymbol(GV); - if (I->hasExternalLinkage() || !MAI->getWeakRefDirective()) - O << "\t.globl\t" << Name << '\n'; - else if (I->hasWeakLinkage()) - O << MAI->getWeakRefDirective() << Name << '\n'; - else if (!I->hasLocalLinkage()) - llvm_unreachable("Invalid alias linkage"); + if (I->hasExternalLinkage() || !MAI->getWeakRefDirective()) { + O << "\t.globl\t"; + Name->print(O, MAI); + O << '\n'; + } else if (I->hasWeakLinkage()) { + O << MAI->getWeakRefDirective(); + Name->print(O, MAI); + O << '\n'; + } else { + assert(!I->hasLocalLinkage() && "Invalid alias linkage"); + } printVisibility(Name, I->getVisibility()); - O << MAI->getSetDirective() << ' ' << Name << ", " << Target << '\n'; + O << MAI->getSetDirective() << ' '; + Name->print(O, MAI); + O << ", "; + Target->print(O, MAI); + O << '\n'; } } @@ -1846,17 +1855,6 @@ } } -void AsmPrinter::printVisibility(const std::string& Name, - unsigned Visibility) const { - if (Visibility == GlobalValue::HiddenVisibility) { - if (const char *Directive = MAI->getHiddenDirective()) - O << Directive << Name << '\n'; - } else if (Visibility == GlobalValue::ProtectedVisibility) { - if (const char *Directive = MAI->getProtectedDirective()) - O << Directive << Name << '\n'; - } -} - void AsmPrinter::printVisibility(const MCSymbol *Sym, unsigned Visibility) const { if (Visibility == GlobalValue::HiddenVisibility) { Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp?rev=93609&r1=93608&r2=93609&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp Fri Jan 15 19:17:26 2010 @@ -128,7 +128,8 @@ O << "\tretlw high(" << PAN::getFrameLabel(CurrentFnName) << ")\n"; // Emit function start label. - O << CurrentFnName << ":\n"; + CurrentFnSym->print(O, MAI); + O << ":\n"; DebugLoc CurDL; O << "\n"; @@ -399,7 +400,8 @@ // Emit the data section name. O << "\n"; - PIC16Section *fPDataSection = const_cast(getObjFileLowering(). + PIC16Section *fPDataSection = + const_cast(getObjFileLowering(). SectionForFrame(CurrentFnName)); fPDataSection->setColor(getFunctionColor(F)); Modified: llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp?rev=93609&r1=93608&r2=93609&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp Fri Jan 15 19:17:26 2010 @@ -35,7 +35,6 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Mangler.h" using namespace llvm; STATISTIC(EmittedInsts, "Number of machine instrs printed"); @@ -184,9 +183,7 @@ return; case MachineOperand::MO_GlobalAddress: { const GlobalValue *GV = MO.getGlobal(); - std::string Name = Mang->getMangledName(GV); - - O << Name; + GetGlobalValueSymbol(GV)->print(O, MAI); // Assemble calls via PLT for externally visible symbols if PIC. if (TM.getRelocationModel() == Reloc::PIC_ && @@ -250,17 +247,11 @@ printOffset(MO.getOffset()); break; - case MachineOperand::MO_GlobalAddress: { - const GlobalValue *GV = MO.getGlobal(); - std::string Name = Mang->getMangledName(GV); - - O << Name; + case MachineOperand::MO_GlobalAddress: + GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); break; - } case MachineOperand::MO_ExternalSymbol: { - std::string Name(MAI->getGlobalPrefix()); - Name += MO.getSymbolName(); - O << Name; + GetExternalSymbolSymbol(MO.getSymbolName())->print(O, MAI); break; } default: From sabre at nondot.org Fri Jan 15 19:21:04 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 01:21:04 -0000 Subject: [llvm-commits] [llvm] r93610 - /llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp Message-ID: <201001160121.o0G1L47q009297@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 19:21:04 2010 New Revision: 93610 URL: http://llvm.org/viewvc/llvm-project?rev=93610&view=rev Log: get pic16 off CurrentFnName Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp?rev=93610&r1=93609&r2=93610&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp Fri Jan 15 19:21:04 2010 @@ -82,7 +82,7 @@ // Color the Auto section of the given function. void PIC16AsmPrinter::ColorAutoSection(const Function *F) { - std::string SectionName = PAN::getAutosSectionName(CurrentFnName); + std::string SectionName = PAN::getAutosSectionName(CurrentFnSym->getName()); PIC16Section* Section = PTOF->findPIC16Section(SectionName); if (Section != NULL) { int Color = getFunctionColor(F); @@ -103,11 +103,8 @@ // of runOnMachineFunction. SetupMachineFunction(MF); - // Get the mangled name. - const Function *F = MF.getFunction(); - CurrentFnName = Mang->getMangledName(F); - // Put the color information from function to its auto section. + const Function *F = MF.getFunction(); ColorAutoSection(F); // Emit the function frame (args and temps). @@ -117,15 +114,15 @@ // Now emit the instructions of function in its code section. const MCSection *fCodeSection - = getObjFileLowering().SectionForCode(CurrentFnName); + = getObjFileLowering().SectionForCode(CurrentFnSym->getName()); // Start the Code Section. O << "\n"; OutStreamer.SwitchSection(fCodeSection); // Emit the frame address of the function at the beginning of code. - O << "\tretlw low(" << PAN::getFrameLabel(CurrentFnName) << ")\n"; - O << "\tretlw high(" << PAN::getFrameLabel(CurrentFnName) << ")\n"; + O << "\tretlw low(" << PAN::getFrameLabel(CurrentFnSym->getName()) << ")\n"; + O << "\tretlw high(" << PAN::getFrameLabel(CurrentFnSym->getName()) << ")\n"; // Emit function start label. CurrentFnSym->print(O, MAI); @@ -402,13 +399,13 @@ PIC16Section *fPDataSection = const_cast(getObjFileLowering(). - SectionForFrame(CurrentFnName)); + SectionForFrame(CurrentFnSym->getName())); fPDataSection->setColor(getFunctionColor(F)); OutStreamer.SwitchSection(fPDataSection); // Emit function frame label - O << PAN::getFrameLabel(CurrentFnName) << ":\n"; + O << PAN::getFrameLabel(CurrentFnSym->getName()) << ":\n"; const Type *RetType = F->getReturnType(); unsigned RetSize = 0; @@ -420,9 +417,10 @@ // we will need to avoid printing a global directive for Retval label // in emitExternandGloblas. if(RetSize > 0) - O << PAN::getRetvalLabel(CurrentFnName) << " RES " << RetSize << "\n"; + O << PAN::getRetvalLabel(CurrentFnSym->getName()) + << " RES " << RetSize << "\n"; else - O << PAN::getRetvalLabel(CurrentFnName) << ": \n"; + O << PAN::getRetvalLabel(CurrentFnSym->getName()) << ": \n"; // Emit variable to hold the space for function arguments unsigned ArgSize = 0; @@ -432,12 +430,13 @@ ArgSize += TD->getTypeAllocSize(Ty); } - O << PAN::getArgsLabel(CurrentFnName) << " RES " << ArgSize << "\n"; + O << PAN::getArgsLabel(CurrentFnSym->getName()) << " RES " << ArgSize << "\n"; // Emit temporary space int TempSize = PTLI->GetTmpSize(); if (TempSize > 0) - O << PAN::getTempdataLabel(CurrentFnName) << " RES " << TempSize << '\n'; + O << PAN::getTempdataLabel(CurrentFnSym->getName()) << " RES " + << TempSize << '\n'; } From sabre at nondot.org Fri Jan 15 19:24:10 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 01:24:10 -0000 Subject: [llvm-commits] [llvm] r93612 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <201001160124.o0G1OAas009428@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 19:24:10 2010 New Revision: 93612 URL: http://llvm.org/viewvc/llvm-project?rev=93612&view=rev Log: CurrentFnName is now dead, remove it. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=93612&r1=93611&r2=93612&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Fri Jan 15 19:24:10 2010 @@ -131,10 +131,9 @@ /// Mangler *Mang; - /// Cache of mangled name for current function. This is recalculated at the + /// The symbol for the current function. This is recalculated at the /// beginning of each call to runOnMachineFunction(). /// - std::string CurrentFnName; // FIXME: REMOVE. const MCSymbol *CurrentFnSym; /// getCurrentSection() - Return the current section we are emitting to. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93612&r1=93611&r2=93612&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Jan 15 19:24:10 2010 @@ -231,8 +231,7 @@ } void AsmPrinter::SetupMachineFunction(MachineFunction &MF) { - // What's my mangled name? - CurrentFnName = Mang->getMangledName(MF.getFunction()); + // Get the function symbol. CurrentFnSym = GetGlobalValueSymbol(MF.getFunction()); IncrementFunctionNumber(); From rafael.espindola at gmail.com Fri Jan 15 19:27:37 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sat, 16 Jan 2010 01:27:37 -0000 Subject: [llvm-commits] [test-suite] r93613 - in /test-suite/trunk: RunSafely.sh TimedExec.sh Message-ID: <201001160127.o0G1RbaB009561@zion.cs.uiuc.edu> Author: rafael Date: Fri Jan 15 19:27:36 2010 New Revision: 93613 URL: http://llvm.org/viewvc/llvm-project?rev=93613&view=rev Log: Make TimedExec.sh work on Linux. Use TimedExec.sh in every system. Modified: test-suite/trunk/RunSafely.sh test-suite/trunk/TimedExec.sh Modified: test-suite/trunk/RunSafely.sh URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/RunSafely.sh?rev=93613&r1=93612&r2=93613&view=diff ============================================================================== --- test-suite/trunk/RunSafely.sh (original) +++ test-suite/trunk/RunSafely.sh Fri Jan 15 19:27:36 2010 @@ -129,9 +129,7 @@ # PWD=`pwd` COMMAND="$RUN_UNDER $PROGRAM $*" -if [ "$SYSTEM" = "Darwin" ]; then - COMMAND="${DIR}TimedExec.sh $ULIMIT $PWD $COMMAND" -fi +COMMAND="${DIR}TimedExec.sh $ULIMIT $PWD $COMMAND" if [ "x$RHOST" = x ] ; then ( sh -c "$ULIMITCMD time -p sh -c '$COMMAND >$OUTFILE 2>&1 < $INFILE; echo exit \$?'" ) 2>&1 \ Modified: test-suite/trunk/TimedExec.sh URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/TimedExec.sh?rev=93613&r1=93612&r2=93613&view=diff ============================================================================== --- test-suite/trunk/TimedExec.sh (original) +++ test-suite/trunk/TimedExec.sh Fri Jan 15 19:27:36 2010 @@ -33,7 +33,7 @@ while [ $SEC -lt $TIMEOUT ]; do sleep 1 # Check if parent has completed. - kill -s INFO $PARENT 2>/dev/null + kill -0 $PARENT 2>/dev/null if [ $? -eq 1 ]; then exit 0 fi From sabre at nondot.org Fri Jan 15 19:37:15 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 01:37:15 -0000 Subject: [llvm-commits] [llvm] r93614 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <201001160137.o0G1bFRa009932@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 19:37:14 2010 New Revision: 93614 URL: http://llvm.org/viewvc/llvm-project?rev=93614&view=rev Log: fix inverted conditional Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93614&r1=93613&r2=93614&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Jan 15 19:37:14 2010 @@ -192,7 +192,7 @@ Name->print(O, MAI); O << '\n'; } else { - assert(!I->hasLocalLinkage() && "Invalid alias linkage"); + assert(I->hasLocalLinkage() && "Invalid alias linkage"); } printVisibility(Name, I->getVisibility()); From sabre at nondot.org Fri Jan 15 19:40:08 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 01:40:08 -0000 Subject: [llvm-commits] [llvm] r93615 - in /llvm/trunk/lib/Target: ARM/AsmPrinter/ARMMCInstLower.cpp MSP430/AsmPrinter/MSP430MCInstLower.cpp PIC16/AsmPrinter/PIC16AsmPrinter.cpp X86/AsmPrinter/X86AsmPrinter.cpp X86/AsmPrinter/X86MCInstLower.cpp XCore/AsmPrinter/XCoreAsmPrinter.cpp Message-ID: <201001160140.o0G1e8cq010031@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 19:40:07 2010 New Revision: 93615 URL: http://llvm.org/viewvc/llvm-project?rev=93615&view=rev Log: eliminate uses of mangler and simplify code. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp?rev=93615&r1=93614&r2=93615&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp Fri Jan 15 19:40:07 2010 @@ -22,7 +22,6 @@ #include "llvm/MC/MCInst.h" //#include "llvm/MC/MCStreamer.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Support/Mangler.h" #include "llvm/ADT/SmallString.h" using namespace llvm; @@ -40,33 +39,24 @@ MCSymbol *ARMMCInstLower:: GetGlobalAddressSymbol(const MachineOperand &MO) const { - const GlobalValue *GV = MO.getGlobal(); - - SmallString<128> Name; - Mang.getNameWithPrefix(Name, GV, false); - // FIXME: HANDLE PLT references how?? switch (MO.getTargetFlags()) { default: assert(0 && "Unknown target flag on GV operand"); case 0: break; } - return Ctx.GetOrCreateSymbol(Name.str()); + return Printer.GetGlobalValueSymbol(MO.getGlobal()); } MCSymbol *ARMMCInstLower:: GetExternalSymbolSymbol(const MachineOperand &MO) const { - SmallString<128> Name; - Name += Printer.MAI->getGlobalPrefix(); - Name += MO.getSymbolName(); - // FIXME: HANDLE PLT references how?? switch (MO.getTargetFlags()) { default: assert(0 && "Unknown target flag on GV operand"); case 0: break; } - return Ctx.GetOrCreateSymbol(Name.str()); + return Printer.GetExternalSymbolSymbol(MO.getSymbolName()); } Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp?rev=93615&r1=93614&r2=93615&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp Fri Jan 15 19:40:07 2010 @@ -22,37 +22,27 @@ #include "llvm/MC/MCInst.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/Mangler.h" #include "llvm/ADT/SmallString.h" using namespace llvm; MCSymbol *MSP430MCInstLower:: GetGlobalAddressSymbol(const MachineOperand &MO) const { - const GlobalValue *GV = MO.getGlobal(); - - SmallString<128> Name; - Mang.getNameWithPrefix(Name, GV, false); - switch (MO.getTargetFlags()) { default: llvm_unreachable("Unknown target flag on GV operand"); case 0: break; } - return Ctx.GetOrCreateSymbol(Name.str()); + return Printer.GetGlobalValueSymbol(MO.getGlobal()); } MCSymbol *MSP430MCInstLower:: GetExternalSymbolSymbol(const MachineOperand &MO) const { - SmallString<128> Name; - Name += Printer.MAI->getGlobalPrefix(); - Name += MO.getSymbolName(); - switch (MO.getTargetFlags()) { default: assert(0 && "Unknown target flag on GV operand"); case 0: break; } - return Ctx.GetOrCreateSymbol(Name.str()); + return Printer.GetExternalSymbolSymbol(MO.getSymbolName()); } MCSymbol *MSP430MCInstLower:: Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp?rev=93615&r1=93614&r2=93615&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp Fri Jan 15 19:40:07 2010 @@ -29,7 +29,6 @@ #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Mangler.h" #include using namespace llvm; @@ -185,24 +184,22 @@ return; case MachineOperand::MO_GlobalAddress: { - std::string Sname = Mang->getMangledName(MO.getGlobal()); + MCSymbol *Sym = GetGlobalValueSymbol(MO.getGlobal()); // FIXME: currently we do not have a memcpy def coming in the module // by any chance, as we do not link in those as .bc lib. So these calls // are always external and it is safe to emit an extern. - if (PAN::isMemIntrinsic(Sname)) { - LibcallDecls.push_back(createESName(Sname)); - } + if (PAN::isMemIntrinsic(Sym->getName())) + LibcallDecls.push_back(createESName(Sym->getName())); - O << Sname; + Sym->print(O, MAI); break; } case MachineOperand::MO_ExternalSymbol: { const char *Sname = MO.getSymbolName(); // If its a libcall name, record it to decls section. - if (PAN::getSymbolTag(Sname) == PAN::LIBCALL) { + if (PAN::getSymbolTag(Sname) == PAN::LIBCALL) LibcallDecls.push_back(Sname); - } // Record a call to intrinsic to print the extern declaration for it. std::string Sym = Sname; @@ -211,7 +208,7 @@ LibcallDecls.push_back(createESName(Sym)); } - O << Sym; + O << Sym; break; } case MachineOperand::MO_MachineBasicBlock: @@ -317,16 +314,14 @@ // Emit declarations for external functions. O <<"\n"<getCommentString() << "Function Declarations - BEGIN." <<"\n"; for (Module::iterator I = M.begin(), E = M.end(); I != E; I++) { - if (I->isIntrinsic()) - continue; - - std::string Name = Mang->getMangledName(I); - if (Name.compare("@abort") == 0) + if (I->isIntrinsic() || I->getName() == "@abort") continue; if (!I->isDeclaration() && !I->hasExternalLinkage()) continue; + MCSymbol *Sym = GetGlobalValueSymbol(I); + // Do not emit memcpy, memset, and memmove here. // Calls to these routines can be generated in two ways, // 1. User calling the standard lib function @@ -335,14 +330,14 @@ // second case the call is via and externalsym and the prototype is missing. // So declarations for these are currently always getting printing by // tracking both kind of references in printInstrunction. - if (I->isDeclaration() && PAN::isMemIntrinsic(Name)) continue; + if (I->isDeclaration() && PAN::isMemIntrinsic(Sym->getName())) continue; const char *directive = I->isDeclaration() ? MAI->getExternDirective() : MAI->getGlobalDirective(); - O << directive << Name << "\n"; - O << directive << PAN::getRetvalLabel(Name) << "\n"; - O << directive << PAN::getArgsLabel(Name) << "\n"; + O << directive << Sym->getName() << "\n"; + O << directive << PAN::getRetvalLabel(Sym->getName()) << "\n"; + O << directive << PAN::getArgsLabel(Sym->getName()) << "\n"; } O << MAI->getCommentString() << "Function Declarations - END." <<"\n"; @@ -355,7 +350,9 @@ O << "\n" << MAI->getCommentString() << "Imported Variables - BEGIN" << "\n"; for (unsigned j = 0; j < Items.size(); j++) { - O << MAI->getExternDirective() << Mang->getMangledName(Items[j]) << "\n"; + O << MAI->getExternDirective(); + GetGlobalValueSymbol(Items[j])->print(O, MAI); + O << "\n"; } O << MAI->getCommentString() << "Imported Variables - END" << "\n"; } @@ -367,7 +364,9 @@ O << "\n" << MAI->getCommentString() << "Exported Variables - BEGIN" << "\n"; for (unsigned j = 0; j < Items.size(); j++) { - O << MAI->getGlobalDirective() << Mang->getMangledName(Items[j]) << "\n"; + O << MAI->getGlobalDirective(); + GetGlobalValueSymbol(Items[j])->print(O, MAI); + O << "\n"; } O << MAI->getCommentString() << "Exported Variables - END" << "\n"; } @@ -392,7 +391,6 @@ void PIC16AsmPrinter::EmitFunctionFrame(MachineFunction &MF) { const Function *F = MF.getFunction(); - std::string FuncName = Mang->getMangledName(F); const TargetData *TD = TM.getTargetData(); // Emit the data section name. O << "\n"; @@ -446,10 +444,9 @@ std::vector Items = S->Items; for (unsigned j = 0; j < Items.size(); j++) { - std::string Name = Mang->getMangledName(Items[j]); Constant *C = Items[j]->getInitializer(); int AddrSpace = Items[j]->getType()->getAddressSpace(); - O << Name; + GetGlobalValueSymbol(Items[j])->print(O, MAI); EmitGlobalConstant(C, AddrSpace); } } @@ -465,11 +462,11 @@ OutStreamer.SwitchSection(S); std::vector Items = S->Items; for (unsigned j = 0; j < Items.size(); j++) { - std::string Name = Mang->getMangledName(Items[j]); Constant *C = Items[j]->getInitializer(); const Type *Ty = C->getType(); unsigned Size = TD->getTypeAllocSize(Ty); - O << Name << " RES " << Size << "\n"; + GetGlobalValueSymbol(Items[j])->print(O, MAI); + O << " RES " << Size << "\n"; } } Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=93615&r1=93614&r2=93615&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Fri Jan 15 19:40:07 2010 @@ -36,7 +36,6 @@ #include "llvm/CodeGen/MachineModuleInfoImpls.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Mangler.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetOptions.h" Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=93615&r1=93614&r2=93615&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Fri Jan 15 19:40:07 2010 @@ -83,33 +83,24 @@ MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str()); const MCSymbol *&StubSym = getMachOMMI().getGVStubEntry(Sym); - if (StubSym == 0) { - Name.clear(); - Mang->getNameWithPrefix(Name, GV, false); - StubSym = Ctx.GetOrCreateSymbol(Name.str()); - } + if (StubSym == 0) + StubSym = AsmPrinter.GetGlobalValueSymbol(GV); return Sym; } case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: { Name += "$non_lazy_ptr"; MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str()); const MCSymbol *&StubSym = getMachOMMI().getHiddenGVStubEntry(Sym); - if (StubSym == 0) { - Name.clear(); - Mang->getNameWithPrefix(Name, GV, false); - StubSym = Ctx.GetOrCreateSymbol(Name.str()); - } + if (StubSym == 0) + StubSym = AsmPrinter.GetGlobalValueSymbol(GV); return Sym; } case X86II::MO_DARWIN_STUB: { Name += "$stub"; MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str()); const MCSymbol *&StubSym = getMachOMMI().getFnStubEntry(Sym); - if (StubSym == 0) { - Name.clear(); - Mang->getNameWithPrefix(Name, GV, false); - StubSym = Ctx.GetOrCreateSymbol(Name.str()); - } + if (StubSym == 0) + StubSym = AsmPrinter.GetGlobalValueSymbol(GV); return Sym; } // FIXME: These probably should be a modifier on the symbol or something?? Modified: llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp?rev=93615&r1=93614&r2=93615&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp Fri Jan 15 19:40:07 2010 @@ -37,7 +37,6 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/MathExtras.h" #include #include @@ -340,7 +339,7 @@ GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); break; case MachineOperand::MO_GlobalAddress: - O << Mang->getMangledName(MO.getGlobal()); + GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); break; case MachineOperand::MO_ExternalSymbol: O << MO.getSymbolName(); From isanbard at gmail.com Fri Jan 15 19:40:55 2010 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 16 Jan 2010 01:40:55 -0000 Subject: [llvm-commits] [llvm] r93616 - in /llvm/trunk: include/llvm/Target/TargetMachine.h lib/CodeGen/AsmPrinter/DwarfException.cpp lib/Target/X86/X86TargetMachine.cpp lib/Target/X86/X86TargetMachine.h Message-ID: <201001160140.o0G1etuu010066@zion.cs.uiuc.edu> Author: void Date: Fri Jan 15 19:40:55 2010 New Revision: 93616 URL: http://llvm.org/viewvc/llvm-project?rev=93616&view=rev Log: Retrying r91337: The CIE says that the LSDA point in the FDE section is an "sdata4". That's fine, but we need it to actually be 4-bytes in the FDE for some platforms. Allow individual platforms to decide for themselves. Modified: llvm/trunk/include/llvm/Target/TargetMachine.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp llvm/trunk/lib/Target/X86/X86TargetMachine.cpp llvm/trunk/lib/Target/X86/X86TargetMachine.h Modified: llvm/trunk/include/llvm/Target/TargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=93616&r1=93615&r2=93616&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetMachine.h (original) +++ llvm/trunk/include/llvm/Target/TargetMachine.h Fri Jan 15 19:40:55 2010 @@ -81,6 +81,14 @@ }; } +// Specify if we should encode the LSDA pointer in the FDE as 4- or 8-bytes. +namespace DwarfLSDAEncoding { + enum Encoding { + Default, + FourByte, + EightByte + }; +} //===----------------------------------------------------------------------===// /// @@ -192,6 +200,12 @@ /// is false. static void setAsmVerbosityDefault(bool); + /// getLSDAEncoding - Returns the LSDA pointer encoding. The choices are + /// 4-byte, 8-byte, and target default. + virtual DwarfLSDAEncoding::Encoding getLSDAEncoding() const { + return DwarfLSDAEncoding::Default; + } + /// CodeGenFileType - These enums are meant to be passed into /// addPassesToEmitFile to indicate what type of file to emit. enum CodeGenFileType { Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=93616&r1=93615&r2=93616&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Fri Jan 15 19:40:55 2010 @@ -283,17 +283,28 @@ if (MMI->getPersonalities()[0] != NULL) { bool is4Byte = TD->getPointerSize() == sizeof(int32_t); - Asm->EmitULEB128Bytes(is4Byte ? 4 : 8); - Asm->EOL("Augmentation size"); + if (Asm->TM.getLSDAEncoding() == DwarfLSDAEncoding::FourByte) { + Asm->EmitULEB128Bytes(4); + Asm->EOL("Augmentation size"); - if (EHFrameInfo.hasLandingPads) - EmitReference("exception", EHFrameInfo.Number, true, false); - else { - if (is4Byte) - Asm->EmitInt32((int)0); + if (EHFrameInfo.hasLandingPads) + EmitReference("exception", EHFrameInfo.Number, true, true); else - Asm->EmitInt64((int)0); + Asm->EmitInt32((int)0); + } else { + Asm->EmitULEB128Bytes(is4Byte ? 4 : 8); + Asm->EOL("Augmentation size"); + + if (EHFrameInfo.hasLandingPads) { + EmitReference("exception", EHFrameInfo.Number, true, false); + } else { + if (is4Byte) + Asm->EmitInt32((int)0); + else + Asm->EmitInt64((int)0); + } } + Asm->EOL("Language Specific Data Area"); } else { Asm->EmitULEB128Bytes(0); Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=93616&r1=93615&r2=93616&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Fri Jan 15 19:40:55 2010 @@ -249,3 +249,10 @@ else setCodeModel(CodeModel::Small); } + +DwarfLSDAEncoding::Encoding X86TargetMachine::getLSDAEncoding() const { + if (Subtarget.isTargetDarwin() && Subtarget.getDarwinVers() > 10) + return DwarfLSDAEncoding::FourByte; + + return DwarfLSDAEncoding::Default; +} Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.h?rev=93616&r1=93615&r2=93616&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.h (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.h Fri Jan 15 19:40:55 2010 @@ -62,6 +62,8 @@ return Subtarget.isTargetELF() ? &ELFWriterInfo : 0; } + virtual DwarfLSDAEncoding::Encoding getLSDAEncoding() const; + // Set up the pass pipeline. virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel); virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel); From sabre at nondot.org Fri Jan 15 19:45:48 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 01:45:48 -0000 Subject: [llvm-commits] [llvm] r93619 - /llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Message-ID: <201001160145.o0G1jmnO010267@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 19:45:47 2010 New Revision: 93619 URL: http://llvm.org/viewvc/llvm-project?rev=93619&view=rev Log: simplify some code. Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=93619&r1=93618&r2=93619&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Fri Jan 15 19:45:47 2010 @@ -65,14 +65,14 @@ Stub = LazyPtr = AnonSymbol = 0; } - void Init(const GlobalValue *GV, Mangler *Mang, MCContext &Ctx) { + void Init(const GlobalValue *GV, AsmPrinter *Printer) { // Already initialized. if (Stub != 0) return; // Get the names. - SmallString<128> TmpStr; - Mang->getNameWithPrefix(TmpStr, GV, true); - MakeSymbols(TmpStr, Ctx); + Stub = Printer->GetPrivateGlobalValueSymbolStub(GV, "$stub"); + LazyPtr = Printer->GetPrivateGlobalValueSymbolStub(GV, "$lazy_ptr"); + AnonSymbol = Printer->GetPrivateGlobalValueSymbolStub(GV, "$stub$tmp"); } void Init(StringRef GVName, Mangler *Mang, MCContext &Ctx) { @@ -81,10 +81,6 @@ // Get the names for the external symbol name. SmallString<128> TmpStr; Mang->getNameWithPrefix(TmpStr, GVName, Mangler::Private); - MakeSymbols(TmpStr, Ctx); - } - - void MakeSymbols(SmallString<128> &TmpStr, MCContext &Ctx) { TmpStr += "$stub"; Stub = Ctx.GetOrCreateSymbol(TmpStr.str()); TmpStr.erase(TmpStr.end()-5, TmpStr.end()); // Remove $stub @@ -241,7 +237,7 @@ if (GV->isDeclaration() || GV->isWeakForLinker()) { // Dynamically-resolved functions need a stub for the function. FnStubInfo &FnInfo = FnStubs[Mang->getMangledName(GV)]; - FnInfo.Init(GV, Mang, OutContext); + FnInfo.Init(GV, this); FnInfo.Stub->print(O, MAI); return; } From dpatel at apple.com Fri Jan 15 19:53:44 2010 From: dpatel at apple.com (Devang Patel) Date: Sat, 16 Jan 2010 01:53:44 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93620 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Message-ID: <201001160153.o0G1riXw010530@zion.cs.uiuc.edu> Author: dpatel Date: Fri Jan 15 19:53:43 2010 New Revision: 93620 URL: http://llvm.org/viewvc/llvm-project?rev=93620&view=rev Log: - There is not any reason to skip function name if its debug info is emitted. - Update code to match comment. Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.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=93620&r1=93619&r2=93620&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Fri Jan 15 19:53:43 2010 @@ -263,20 +263,21 @@ Virtuality = dwarf::DW_VIRTUALITY_virtual; ContainingType = getOrCreateType(DECL_CONTEXT (FnDecl)); } - bool UseModuleContext = false; + + bool ArtificialFnWithAbstractOrigin = false; // If this artificial function has abstract origin then put this function // at module scope. The abstract copy will be placed in appropriate region. - if (DECL_ABSTRACT_ORIGIN (FnDecl) != FnDecl - && DECL_ARTIFICIAL(FnDecl)) - UseModuleContext = true; - + if (DECL_ARTIFICIAL (FnDecl) + && DECL_ABSTRACT_ORIGIN (FnDecl) + && DECL_ABSTRACT_ORIGIN (FnDecl) != FnDecl) + ArtificialFnWithAbstractOrigin = true; + const char *FnName = lang_hooks.dwarf_name(FnDecl, 0); DISubprogram SP = - DebugFactory.CreateSubprogram((UseModuleContext ? - getOrCreateCompileUnit(main_input_filename) : - findRegion(DECL_CONTEXT(FnDecl))), - (UseModuleContext ? FnName : StringRef()), - (UseModuleContext ? FnName : StringRef()), + DebugFactory.CreateSubprogram(ArtificialFnWithAbstractOrigin ? + getOrCreateCompileUnit(main_input_filename) : + findRegion (DECL_CONTEXT(FnDecl)), + FnName, FnName, LinkageName, getOrCreateCompileUnit(Loc.file), lineno, FNType, From sabre at nondot.org Fri Jan 15 20:00:23 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 02:00:23 -0000 Subject: [llvm-commits] [llvm] r93621 - /llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Message-ID: <201001160200.o0G20NYv010764@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 20:00:23 2010 New Revision: 93621 URL: http://llvm.org/viewvc/llvm-project?rev=93621&view=rev Log: use symbols instead of strings, eliminating a bunch of getMangledName calls. Add FIXMEs about a bunch of nondeterminism in stub output. Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=93621&r1=93620&r2=93621&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Fri Jan 15 20:00:23 2010 @@ -94,8 +94,8 @@ } }; - StringMap FnStubs; - StringMap GVStubs, HiddenGVStubs, TOC; + DenseMap FnStubs; + StringMap GVStubs, HiddenGVStubs, TOC; const PPCSubtarget &Subtarget; uint64_t LabelID; public: @@ -236,16 +236,15 @@ GlobalValue *GV = MO.getGlobal(); if (GV->isDeclaration() || GV->isWeakForLinker()) { // Dynamically-resolved functions need a stub for the function. - FnStubInfo &FnInfo = FnStubs[Mang->getMangledName(GV)]; + FnStubInfo &FnInfo = FnStubs[GetGlobalValueSymbol(GV)]; FnInfo.Init(GV, this); FnInfo.Stub->print(O, MAI); return; } } if (MO.getType() == MachineOperand::MO_ExternalSymbol) { - SmallString<128> MangledName; - Mang->getNameWithPrefix(MangledName, MO.getSymbolName()); - FnStubInfo &FnInfo = FnStubs[MangledName.str()]; + FnStubInfo &FnInfo = + FnStubs[GetExternalSymbolSymbol(MO.getSymbolName())]; FnInfo.Init(MO.getSymbolName(), Mang, OutContext); FnInfo.Stub->print(O, MAI); return; @@ -339,16 +338,13 @@ std::string Name = Mang->getMangledName(GV); // Map symbol -> label of TOC entry. - if (TOC.count(Name) == 0) { - std::string Label; - Label += MAI->getPrivateGlobalPrefix(); - Label += "C"; - Label += utostr(LabelID++); + if (TOC.count(Name) == 0) + TOC[Name] = OutContext. + GetOrCreateSymbol(StringRef(MAI->getPrivateGlobalPrefix()) + "C" + + Twine(LabelID++)); - TOC[Name] = Label; - } - - O << TOC[Name] << "@toc"; + TOC[Name]->print(O, MAI); + O << "@toc"; } void printPredicateOperand(const MachineInstr *MI, unsigned OpNo, @@ -438,7 +434,9 @@ Name += MO.getSymbolName(); if (TM.getRelocationModel() != Reloc::Static) { - GVStubs[Name] = Name+"$non_lazy_ptr"; + GVStubs[Name] = + OutContext.GetOrCreateSymbol(StringRef(MAI->getGlobalPrefix())+ + MO.getSymbolName()+"$non_lazy_ptr"); Name += "$non_lazy_ptr"; } O << Name; @@ -447,25 +445,27 @@ case MachineOperand::MO_GlobalAddress: { // Computing the address of a global symbol, not calling it. GlobalValue *GV = MO.getGlobal(); - std::string Name; + MCSymbol *SymToPrint; // External or weakly linked global variables need non-lazily-resolved stubs if (TM.getRelocationModel() != Reloc::Static && (GV->isDeclaration() || GV->isWeakForLinker())) { if (!GV->hasHiddenVisibility()) { - Name = Mang->getMangledName(GV, "$non_lazy_ptr", true); - GVStubs[Mang->getMangledName(GV)] = Name; + SymToPrint = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr"); + GVStubs[Mang->getMangledName(GV)] = SymToPrint; } else if (GV->isDeclaration() || GV->hasCommonLinkage() || GV->hasAvailableExternallyLinkage()) { - Name = Mang->getMangledName(GV, "$non_lazy_ptr", true); - HiddenGVStubs[Mang->getMangledName(GV)] = Name; + SymToPrint = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr"); + HiddenGVStubs[Mang->getMangledName(GV)] = SymToPrint; + GetGlobalValueSymbol(GV)->print(O, MAI); } else { - Name = Mang->getMangledName(GV); + SymToPrint = GetGlobalValueSymbol(GV); } } else { - Name = Mang->getMangledName(GV); + SymToPrint = GetGlobalValueSymbol(GV); } - O << Name; + + SymToPrint->print(O, MAI); printOffset(MO.getOffset()); return; @@ -827,9 +827,11 @@ // FIXME 64-bit SVR4: Use MCSection here? O << "\t.section\t\".toc\",\"aw\"\n"; - for (StringMap::iterator I = TOC.begin(), E = TOC.end(); + // FIXME: This is nondeterminstic! + for (StringMap::iterator I = TOC.begin(), E = TOC.end(); I != E; ++I) { - O << I->second << ":\n"; + I->second->print(O, MAI); + O << ":\n"; O << "\t.tc " << I->getKeyData() << "[TC]," << I->getKeyData() << '\n'; } } @@ -1110,14 +1112,17 @@ MCSectionMachO::S_SYMBOL_STUBS | MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, 32, SectionKind::getText()); - for (StringMap::iterator I = FnStubs.begin(), E = FnStubs.end(); - I != E; ++I) { + // FIXME: This is emitting in nondeterminstic order! + for (DenseMap::iterator I = + FnStubs.begin(), E = FnStubs.end(); I != E; ++I) { OutStreamer.SwitchSection(StubSection); EmitAlignment(4); const FnStubInfo &Info = I->second; Info.Stub->print(O, MAI); O << ":\n"; - O << "\t.indirect_symbol " << I->getKeyData() << '\n'; + O << "\t.indirect_symbol "; + I->first->print(O, MAI); + O << '\n'; O << "\tmflr r0\n"; O << "\tbcl 20,31,"; Info.AnonSymbol->print(O, MAI); @@ -1142,7 +1147,9 @@ OutStreamer.SwitchSection(LSPSection); Info.LazyPtr->print(O, MAI); O << ":\n"; - O << "\t.indirect_symbol " << I->getKeyData() << '\n'; + O << "\t.indirect_symbol "; + I->first->print(O, MAI); + O << '\n'; O << (isPPC64 ? "\t.quad" : "\t.long") << " dyld_stub_binding_helper\n"; } } else if (!FnStubs.empty()) { @@ -1152,14 +1159,17 @@ MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, 16, SectionKind::getText()); - for (StringMap::iterator I = FnStubs.begin(), E = FnStubs.end(); - I != E; ++I) { + // FIXME: This is emitting in nondeterminstic order! + for (DenseMap::iterator I = FnStubs.begin(), + E = FnStubs.end(); I != E; ++I) { OutStreamer.SwitchSection(StubSection); EmitAlignment(4); const FnStubInfo &Info = I->second; Info.Stub->print(O, MAI); O << ":\n"; - O << "\t.indirect_symbol " << I->getKeyData() << '\n'; + O << "\t.indirect_symbol "; + I->first->print(O, MAI); + O << '\n'; O << "\tlis r11,ha16("; Info.LazyPtr->print(O, MAI); O << ")\n"; @@ -1171,7 +1181,9 @@ OutStreamer.SwitchSection(LSPSection); Info.LazyPtr->print(O, MAI); O << ":\n"; - O << "\t.indirect_symbol " << I->getKeyData() << '\n'; + O << "\t.indirect_symbol "; + I->first->print(O, MAI); + O << '\n'; O << (isPPC64 ? "\t.quad" : "\t.long") << " dyld_stub_binding_helper\n"; } } @@ -1186,7 +1198,7 @@ E = Personalities.end(); I != E; ++I) { if (*I) GVStubs[Mang->getMangledName(*I)] = - Mang->getMangledName(*I, "$non_lazy_ptr", true); + GetPrivateGlobalValueSymbolStub(*I, "$non_lazy_ptr"); } } @@ -1196,9 +1208,11 @@ OutStreamer.SwitchSection(TLOFMacho.getNonLazySymbolPointerSection()); EmitAlignment(isPPC64 ? 3 : 2); - for (StringMap::iterator I = GVStubs.begin(), + // FIXME: This is nondeterminstic. + for (StringMap::iterator I = GVStubs.begin(), E = GVStubs.end(); I != E; ++I) { - O << I->second << ":\n"; + I->second->print(O, MAI); + O << ":\n"; O << "\t.indirect_symbol " << I->getKeyData() << '\n'; O << (isPPC64 ? "\t.quad\t0\n" : "\t.long\t0\n"); } @@ -1207,9 +1221,11 @@ if (!HiddenGVStubs.empty()) { OutStreamer.SwitchSection(getObjFileLowering().getDataSection()); EmitAlignment(isPPC64 ? 3 : 2); - for (StringMap::iterator I = HiddenGVStubs.begin(), + // FIXME: This is nondeterminstic. + for (StringMap::iterator I = HiddenGVStubs.begin(), E = HiddenGVStubs.end(); I != E; ++I) { - O << I->second << ":\n"; + I->second->print(O, MAI); + O << ":\n"; O << (isPPC64 ? "\t.quad\t" : "\t.long\t") << I->getKeyData() << '\n'; } } From sabre at nondot.org Fri Jan 15 20:09:06 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 02:09:06 -0000 Subject: [llvm-commits] [llvm] r93624 - /llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Message-ID: <201001160209.o0G296KK011190@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 20:09:06 2010 New Revision: 93624 URL: http://llvm.org/viewvc/llvm-project?rev=93624&view=rev Log: more string -> sym, getMangledName is now gone from this file. Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=93624&r1=93623&r2=93624&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Fri Jan 15 20:09:06 2010 @@ -95,7 +95,7 @@ }; DenseMap FnStubs; - StringMap GVStubs, HiddenGVStubs, TOC; + DenseMap GVStubs, HiddenGVStubs, TOC; const PPCSubtarget &Subtarget; uint64_t LabelID; public: @@ -333,17 +333,16 @@ assert(MO.getType() == MachineOperand::MO_GlobalAddress); - GlobalValue *GV = MO.getGlobal(); - - std::string Name = Mang->getMangledName(GV); + const MCSymbol *Sym = GetGlobalValueSymbol(MO.getGlobal()); // Map symbol -> label of TOC entry. - if (TOC.count(Name) == 0) - TOC[Name] = OutContext. + const MCSymbol *&TOCEntry = TOC[Sym]; + if (TOCEntry == 0) + TOCEntry = OutContext. GetOrCreateSymbol(StringRef(MAI->getPrivateGlobalPrefix()) + "C" + Twine(LabelID++)); - TOC[Name]->print(O, MAI); + TOCEntry->print(O, MAI); O << "@toc"; } @@ -430,16 +429,16 @@ return; case MachineOperand::MO_ExternalSymbol: { // Computing the address of an external symbol, not calling it. - std::string Name(MAI->getGlobalPrefix()); - Name += MO.getSymbolName(); - - if (TM.getRelocationModel() != Reloc::Static) { - GVStubs[Name] = - OutContext.GetOrCreateSymbol(StringRef(MAI->getGlobalPrefix())+ - MO.getSymbolName()+"$non_lazy_ptr"); - Name += "$non_lazy_ptr"; + const MCSymbol *SymName = GetExternalSymbolSymbol(MO.getSymbolName()); + if (TM.getRelocationModel() == Reloc::Static) { + SymName->print(O, MAI); + return; } - O << Name; + const MCSymbol *NLPSym = + OutContext.GetOrCreateSymbol(StringRef(MAI->getGlobalPrefix())+ + MO.getSymbolName()+"$non_lazy_ptr"); + GVStubs[SymName] = NLPSym; + NLPSym->print(O, MAI); return; } case MachineOperand::MO_GlobalAddress: { @@ -452,12 +451,11 @@ (GV->isDeclaration() || GV->isWeakForLinker())) { if (!GV->hasHiddenVisibility()) { SymToPrint = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr"); - GVStubs[Mang->getMangledName(GV)] = SymToPrint; + GVStubs[GetGlobalValueSymbol(GV)] = SymToPrint; } else if (GV->isDeclaration() || GV->hasCommonLinkage() || GV->hasAvailableExternallyLinkage()) { SymToPrint = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr"); - HiddenGVStubs[Mang->getMangledName(GV)] = SymToPrint; - GetGlobalValueSymbol(GV)->print(O, MAI); + HiddenGVStubs[GetGlobalValueSymbol(GV)] = SymToPrint; } else { SymToPrint = GetGlobalValueSymbol(GV); } @@ -828,11 +826,15 @@ O << "\t.section\t\".toc\",\"aw\"\n"; // FIXME: This is nondeterminstic! - for (StringMap::iterator I = TOC.begin(), E = TOC.end(); - I != E; ++I) { + for (DenseMap::iterator I = TOC.begin(), + E = TOC.end(); I != E; ++I) { I->second->print(O, MAI); O << ":\n"; - O << "\t.tc " << I->getKeyData() << "[TC]," << I->getKeyData() << '\n'; + O << "\t.tc "; + I->first->print(O, MAI); + O << "[TC],"; + I->first->print(O, MAI); + O << '\n'; } } @@ -1197,7 +1199,7 @@ for (std::vector::const_iterator I = Personalities.begin(), E = Personalities.end(); I != E; ++I) { if (*I) - GVStubs[Mang->getMangledName(*I)] = + GVStubs[GetGlobalValueSymbol(*I)] = GetPrivateGlobalValueSymbolStub(*I, "$non_lazy_ptr"); } } @@ -1209,11 +1211,13 @@ EmitAlignment(isPPC64 ? 3 : 2); // FIXME: This is nondeterminstic. - for (StringMap::iterator I = GVStubs.begin(), - E = GVStubs.end(); I != E; ++I) { + for (DenseMap::iterator + I = GVStubs.begin(), E = GVStubs.end(); I != E; ++I) { I->second->print(O, MAI); O << ":\n"; - O << "\t.indirect_symbol " << I->getKeyData() << '\n'; + O << "\t.indirect_symbol "; + I->first->print(O, MAI); + O << '\n'; O << (isPPC64 ? "\t.quad\t0\n" : "\t.long\t0\n"); } } @@ -1222,11 +1226,13 @@ OutStreamer.SwitchSection(getObjFileLowering().getDataSection()); EmitAlignment(isPPC64 ? 3 : 2); // FIXME: This is nondeterminstic. - for (StringMap::iterator I = HiddenGVStubs.begin(), - E = HiddenGVStubs.end(); I != E; ++I) { + for (DenseMap::iterator + I = HiddenGVStubs.begin(), E = HiddenGVStubs.end(); I != E; ++I) { I->second->print(O, MAI); O << ":\n"; - O << (isPPC64 ? "\t.quad\t" : "\t.long\t") << I->getKeyData() << '\n'; + O << (isPPC64 ? "\t.quad\t" : "\t.long\t"); + I->first->print(O, MAI); + O << '\n'; } } From isanbard at gmail.com Fri Jan 15 20:10:13 2010 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 16 Jan 2010 02:10:13 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93625 - in /llvm-gcc-4.2/trunk/gcc: config/arm/arm.c config/bfin/bfin.c config/i386/i386.c llvm-backend.cpp Message-ID: <201001160210.o0G2ADPf011238@zion.cs.uiuc.edu> Author: void Date: Fri Jan 15 20:10:12 2010 New Revision: 93625 URL: http://llvm.org/viewvc/llvm-project?rev=93625&view=rev Log: Make the "-fno-schedule-insns" invoke the "--disable-scheduling" flag in LLVM. The scheduler is turned off in GCC for many many things. Ignore it when it turns these things off. We'll let LLVM determine what's the best strategy here. Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.c llvm-gcc-4.2/trunk/gcc/config/bfin/bfin.c llvm-gcc-4.2/trunk/gcc/config/i386/i386.c llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.c?rev=93625&r1=93624&r2=93625&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.c Fri Jan 15 20:10:12 2010 @@ -1716,11 +1716,15 @@ /* For arm2/3 there is no need to do any scheduling if there is only a floating point emulator, or we are doing software floating-point. */ + /* LLVM LOCAL begin */ +#ifndef ENABLE_LLVM if ((TARGET_SOFT_FLOAT || arm_fpu_tune == FPUTYPE_FPA_EMU2 || arm_fpu_tune == FPUTYPE_FPA_EMU3) && (tune_flags & FL_MODE32) == 0) flag_schedule_insns = flag_schedule_insns_after_reload = 0; +#endif + /* LLVM LOCAL end */ if (target_thread_switch) { @@ -1783,11 +1787,15 @@ /* APPLE LOCAL v7 support. Merge from mainline */ /* ??? We might want scheduling for thumb2. */ + /* LLVM LOCAL begin */ +#ifndef ENABLE_LLVM if (TARGET_THUMB && flag_schedule_insns) { /* Don't warn since it's on by default in -O2. */ flag_schedule_insns = 0; } +#endif + /* LLVM LOCAL end */ if (optimize_size) { @@ -23725,10 +23733,14 @@ /* For -O2 and beyond, turn off -fschedule-insns by default. It tends to make the problem with not enough registers even worse. */ + /* LLVM LOCAL begin */ +#ifndef ENABLE_LLVM #ifdef INSN_SCHEDULING if (level > 1) flag_schedule_insns = 0; #endif +#endif + /* LLVM LOCAL end */ /* radar 4094534. */ /* The Darwin libraries never set errno, so we might as well Modified: llvm-gcc-4.2/trunk/gcc/config/bfin/bfin.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/bfin/bfin.c?rev=93625&r1=93624&r2=93625&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/bfin/bfin.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/bfin/bfin.c Fri Jan 15 20:10:12 2010 @@ -2004,7 +2004,11 @@ if (flag_pic && !TARGET_FDPIC && !TARGET_ID_SHARED_LIBRARY) flag_pic = 0; + /* LLVM LOCAL begin */ +#ifndef ENABLE_LLVM flag_schedule_insns = 0; +#endif + /* LLVM LOCAL end */ init_machine_status = bfin_init_machine_status; } Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/i386.c?rev=93625&r1=93624&r2=93625&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/i386.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/i386.c Fri Jan 15 20:10:12 2010 @@ -2226,8 +2226,12 @@ /* When scheduling description is not available, disable scheduler pass so it won't slow down the compilation and make x87 code slower. */ /* APPLE LOCAL 5591571 */ + /* LLVM LOCAL begin */ +#ifndef ENABLE_LLVM if (1 || !TARGET_SCHEDULE) flag_schedule_insns_after_reload = flag_schedule_insns = 0; +#endif + /* LLVM LOCAL end */ /* APPLE LOCAL begin dynamic-no-pic */ #if TARGET_MACHO @@ -2449,10 +2453,14 @@ /* APPLE LOCAL end disable strict aliasing; breaks too much existing code. */ /* For -O2 and beyond, turn off -fschedule-insns by default. It tends to make the problem with not enough registers even worse. */ + /* LLVM LOCAL begin */ +#ifndef ENABLE_LLVM #ifdef INSN_SCHEDULING if (level > 1) flag_schedule_insns = 0; #endif +#endif + /* LLVM LOCAL end */ /* APPLE LOCAL begin pragma fenv */ /* Trapping math is not needed by many users, and is expensive. @@ -2505,10 +2513,14 @@ { /* For -O2 and beyond, turn off -fschedule-insns by default. It tends to make the problem with not enough registers even worse. */ + /* LLVM LOCAL begin */ +#ifndef ENABLE_LLVM #ifdef INSN_SCHEDULING if (level > 1) flag_schedule_insns = 0; #endif +#endif + /* LLVM LOCAL end */ /* APPLE LOCAL begin pragma fenv */ /* Trapping math is not needed by many users, and is expensive. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=93625&r1=93624&r2=93625&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Fri Jan 15 20:10:12 2010 @@ -406,6 +406,8 @@ Args.push_back("--debug-pass=Arguments"); if (flag_unwind_tables) Args.push_back("--unwind-tables"); + if (!flag_schedule_insns) + Args.push_back("--disable-scheduling"); // If there are options that should be passed through to the LLVM backend // directly from the command line, do so now. This is mainly for debugging From sabre at nondot.org Fri Jan 15 20:15:39 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 02:15:39 -0000 Subject: [llvm-commits] [llvm] r93626 - in /llvm/trunk/lib/Target/MSIL: MSILWriter.cpp MSILWriter.h Message-ID: <201001160215.o0G2Fdde011406@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 20:15:38 2010 New Revision: 93626 URL: http://llvm.org/viewvc/llvm-project?rev=93626&view=rev Log: this doesn't need the mangler. Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.cpp llvm/trunk/lib/Target/MSIL/MSILWriter.h Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.cpp?rev=93626&r1=93625&r2=93626&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSIL/MSILWriter.cpp (original) +++ llvm/trunk/lib/Target/MSIL/MSILWriter.cpp Fri Jan 15 20:15:38 2010 @@ -102,7 +102,6 @@ bool MSILWriter::doInitialization(Module &M) { ModulePtr = &M; - Mang = new Mangler(M); Out << ".assembly extern mscorlib {}\n"; Out << ".assembly MSIL {}\n\n"; Out << "// External\n"; @@ -118,7 +117,6 @@ bool MSILWriter::doFinalization(Module &M) { - delete Mang; return false; } @@ -232,7 +230,7 @@ std::string MSILWriter::getValueName(const Value* V) { std::string Name; if (const GlobalValue *GV = dyn_cast(V)) - Name = Mang->getMangledName(GV); + Name = GV->getName(); else { unsigned &No = AnonValueNumbers[V]; if (No == 0) No = ++NextAnonValueNumber; @@ -259,7 +257,7 @@ std::string MSILWriter::getLabelName(const Value* V) { std::string Name; if (const GlobalValue *GV = dyn_cast(V)) - Name = Mang->getMangledName(GV); + Name = GV->getName(); else { unsigned &No = AnonValueNumbers[V]; if (No == 0) No = ++NextAnonValueNumber; @@ -1616,7 +1614,7 @@ const char* MSILWriter::getLibraryName(const GlobalVariable* GV) { - return getLibraryForSymbol(Mang->getMangledName(GV), false, CallingConv::C); + return getLibraryForSymbol(GV->getName(), false, CallingConv::C); } @@ -1674,7 +1672,7 @@ std::string Tmp = getTypeName(I->getType())+getValueName(&*I); printSimpleInstruction("ldsflda",Tmp.c_str()); Out << "\tldstr\t\"" << getLibraryName(&*I) << "\"\n"; - Out << "\tldstr\t\"" << Mang->getMangledName(&*I) << "\"\n"; + Out << "\tldstr\t\"" << I->getName() << "\"\n"; printSimpleInstruction("call","void* $MSIL_Import(string,string)"); printIndirectSave(I->getType()); } Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.h?rev=93626&r1=93625&r2=93626&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSIL/MSILWriter.h (original) +++ llvm/trunk/lib/Target/MSIL/MSILWriter.h Fri Jan 15 20:15:38 2010 @@ -27,7 +27,6 @@ #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Support/Mangler.h" namespace llvm { extern Target TheMSILTarget; @@ -78,7 +77,6 @@ formatted_raw_ostream &Out; Module* ModulePtr; const TargetData* TD; - Mangler* Mang; LoopInfo *LInfo; std::vector* InitListPtr; std::map > From sabre at nondot.org Fri Jan 15 20:16:09 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 02:16:09 -0000 Subject: [llvm-commits] [llvm] r93627 - in /llvm/trunk/lib: CodeGen/ELFWriter.cpp Target/TargetLoweringObjectFile.cpp Message-ID: <201001160216.o0G2G9tY011434@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 20:16:09 2010 New Revision: 93627 URL: http://llvm.org/viewvc/llvm-project?rev=93627&view=rev Log: remove a couple of actively incorrect uses of getMangledName. Modified: llvm/trunk/lib/CodeGen/ELFWriter.cpp llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Modified: llvm/trunk/lib/CodeGen/ELFWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ELFWriter.cpp?rev=93627&r1=93626&r2=93627&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ELFWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/ELFWriter.cpp Fri Jan 15 20:16:09 2010 @@ -54,7 +54,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/raw_ostream.h" - +#include "llvm/ADT/SmallString.h" using namespace llvm; char ELFWriter::ID = 0; @@ -906,9 +906,11 @@ ELFSym &Sym = *(*I); std::string Name; - if (Sym.isGlobalValue()) - Name.append(Mang->getMangledName(Sym.getGlobalValue())); - else if (Sym.isExternalSym()) + if (Sym.isGlobalValue()) { + SmallString<40> NameStr; + Mang->getNameWithPrefix(NameStr, Sym.getGlobalValue(), false); + Name.append(NameStr.begin(), NameStr.end()); + } else if (Sym.isExternalSym()) Name.append(Sym.getExternalSymbol()); else if (Sym.isFileType()) Name.append(ModuleName); Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=93627&r1=93626&r2=93627&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Fri Jan 15 20:16:09 2010 @@ -955,7 +955,8 @@ // FIXME: ObjC metadata is currently emitted as internal symbols that have // \1L and \0l prefixes on them. Fix them to be Private/LinkerPrivate and // this horrible hack can go away. - const std::string &Name = Mang->getMangledName(GV); + SmallString<64> Name; + Mang->getNameWithPrefix(NameTmp, GV, false); if (Name[0] == 'L' || Name[0] == 'l') return false; } From Edmund.Grimley-Evans at arm.com Fri Jan 15 11:09:34 2010 From: Edmund.Grimley-Evans at arm.com (Edmund Grimley Evans) Date: Fri, 15 Jan 2010 17:09:34 +0000 Subject: [llvm-commits] [PATCH] Bad escapes in a few tests Message-ID: <1263575374.23680.17.camel@pc31.cambridge.arm.com> There are some bad escapes in a few tests which mean that those tests have no effect. Fixing that seems to reveal a few bugs in the tests, which I have attempted to fix, and also a few regressions, which I haven't fixed in this patch. -- 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: test-grep.patch Type: text/x-patch Size: 2852 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100115/761645b4/attachment.bin From sabre at nondot.org Fri Jan 15 21:38:27 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 03:38:27 -0000 Subject: [llvm-commits] [llvm] r93628 - /llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Message-ID: <201001160338.o0G3cRBm014074@zion.cs.uiuc.edu> Author: lattner Date: Fri Jan 15 21:38:27 2010 New Revision: 93628 URL: http://llvm.org/viewvc/llvm-project?rev=93628&view=rev Log: fix build failure. Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=93628&r1=93627&r2=93628&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Fri Jan 15 21:38:27 2010 @@ -956,7 +956,7 @@ // \1L and \0l prefixes on them. Fix them to be Private/LinkerPrivate and // this horrible hack can go away. SmallString<64> Name; - Mang->getNameWithPrefix(NameTmp, GV, false); + Mang->getNameWithPrefix(Name, GV, false); if (Name[0] == 'L' || Name[0] == 'l') return false; } From dpatel at apple.com Sat Jan 16 00:09:36 2010 From: dpatel at apple.com (Devang Patel) Date: Sat, 16 Jan 2010 06:09:36 -0000 Subject: [llvm-commits] [llvm] r93630 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h include/llvm/CodeGen/MachineFunction.h include/llvm/Support/DebugLoc.h lib/Analysis/DebugInfo.cpp lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/MachineFunction.cpp lib/CodeGen/MachineInstr.cpp lib/ExecutionEngine/JIT/JITEmitter.cpp lib/Target/PIC16/PIC16DebugInfo.cpp Message-ID: <201001160609.o0G69brC019092@zion.cs.uiuc.edu> Author: dpatel Date: Sat Jan 16 00:09:35 2010 New Revision: 93630 URL: http://llvm.org/viewvc/llvm-project?rev=93630&view=rev Log: Replace DebugLocTuple with DILocation. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/include/llvm/CodeGen/MachineFunction.h llvm/trunk/include/llvm/Support/DebugLoc.h llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/MachineFunction.cpp llvm/trunk/lib/CodeGen/MachineInstr.cpp llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=93630&r1=93629&r2=93630&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Sat Jan 16 00:09:35 2010 @@ -17,6 +17,7 @@ #define LLVM_CODEGEN_ASMPRINTER_H #include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/Analysis/DebugInfo.h" #include "llvm/Support/DebugLoc.h" #include "llvm/Target/TargetMachine.h" #include "llvm/ADT/DenseMap.h" @@ -151,7 +152,7 @@ mutable unsigned Counter; // Private state for processDebugLoc() - mutable DebugLocTuple PrevDLT; + mutable DILocation PrevDLT; protected: explicit AsmPrinter(formatted_raw_ostream &o, TargetMachine &TM, Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?rev=93630&r1=93629&r2=93630&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFunction.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h Sat Jan 16 00:09:35 2010 @@ -368,8 +368,8 @@ // Debug location. // - /// getDebugLocTuple - Get the DebugLocTuple for a given DebugLoc object. - DebugLocTuple getDebugLocTuple(DebugLoc DL) const; + /// getDILocation - Get the DILocation for a given DebugLoc object. + DILocation getDILocation(DebugLoc DL) const; /// getDefaultDebugLoc - Get the default debug location for the machine /// function. Modified: llvm/trunk/include/llvm/Support/DebugLoc.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DebugLoc.h?rev=93630&r1=93629&r2=93630&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/DebugLoc.h (original) +++ llvm/trunk/include/llvm/Support/DebugLoc.h Sat Jan 16 00:09:35 2010 @@ -21,29 +21,6 @@ namespace llvm { class MDNode; - /// DebugLocTuple - Debug location tuple of filename id, line and column. - /// - struct DebugLocTuple { - MDNode *Scope; - MDNode *InlinedAtLoc; - unsigned Line, Col; - - DebugLocTuple() - : Scope(0), InlinedAtLoc(0), Line(~0U), Col(~0U) {} - - DebugLocTuple(MDNode *n, MDNode *i, unsigned l, unsigned c) - : Scope(n), InlinedAtLoc(i), Line(l), Col(c) {} - - bool operator==(const DebugLocTuple &DLT) const { - return Scope == DLT.Scope && - InlinedAtLoc == DLT.InlinedAtLoc && - Line == DLT.Line && Col == DLT.Col; - } - bool operator!=(const DebugLocTuple &DLT) const { - return !(*this == DLT); - } - }; - /// DebugLoc - Debug location id. This is carried by SDNode and MachineInstr /// to index into a vector of unique debug location tuples. class DebugLoc { @@ -65,40 +42,16 @@ bool operator!=(const DebugLoc &DL) const { return !(*this == DL); } }; - // Specialize DenseMapInfo for DebugLocTuple. - template<> struct DenseMapInfo { - static inline DebugLocTuple getEmptyKey() { - return DebugLocTuple(0, 0, ~0U, ~0U); - } - static inline DebugLocTuple getTombstoneKey() { - return DebugLocTuple((MDNode*)~1U, (MDNode*)~1U, ~1U, ~1U); - } - static unsigned getHashValue(const DebugLocTuple &Val) { - return DenseMapInfo::getHashValue(Val.Scope) ^ - DenseMapInfo::getHashValue(Val.InlinedAtLoc) ^ - DenseMapInfo::getHashValue(Val.Line) ^ - DenseMapInfo::getHashValue(Val.Col); - } - static bool isEqual(const DebugLocTuple &LHS, const DebugLocTuple &RHS) { - return LHS.Scope == RHS.Scope && - LHS.InlinedAtLoc == RHS.InlinedAtLoc && - LHS.Line == RHS.Line && - LHS.Col == RHS.Col; - } - }; - template <> struct isPodLike {static const bool value = true;}; - - - /// DebugLocTracker - This class tracks debug location information. + /// DebugLocTracker - This class tracks debug location information. /// struct DebugLocTracker { /// DebugLocations - A vector of unique DebugLocTuple's. /// - std::vector DebugLocations; + std::vector DebugLocations; /// DebugIdMap - This maps DebugLocTuple's to indices into the /// DebugLocations vector. - DenseMap DebugIdMap; + DenseMap DebugIdMap; DebugLocTracker() {} }; Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=93630&r1=93629&r2=93630&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Sat Jan 16 00:09:35 2010 @@ -1320,23 +1320,15 @@ /// from DILocation. DebugLoc llvm::ExtractDebugLocation(DILocation &Loc, DebugLocTracker &DebugLocInfo) { - DebugLoc DL; - MDNode *Context = Loc.getScope().getNode(); - MDNode *InlinedLoc = NULL; - if (!Loc.getOrigLocation().isNull()) - InlinedLoc = Loc.getOrigLocation().getNode(); - // If this location is already tracked then use it. - DebugLocTuple Tuple(Context, InlinedLoc, Loc.getLineNumber(), - Loc.getColumnNumber()); - DenseMap::iterator II - = DebugLocInfo.DebugIdMap.find(Tuple); + DenseMap::iterator II + = DebugLocInfo.DebugIdMap.find(Loc.getNode()); if (II != DebugLocInfo.DebugIdMap.end()) return DebugLoc::get(II->second); // Add a new location entry. unsigned Id = DebugLocInfo.DebugLocations.size(); - DebugLocInfo.DebugLocations.push_back(Tuple); - DebugLocInfo.DebugIdMap[Tuple] = Id; + DebugLocInfo.DebugLocations.push_back(Loc.getNode()); + DebugLocInfo.DebugIdMap[Loc.getNode()] = Id; return DebugLoc::get(Id); } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93630&r1=93629&r2=93630&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sat Jan 16 00:09:35 2010 @@ -61,8 +61,7 @@ // FIXME: Pass instprinter to streamer. OutStreamer(*createAsmStreamer(OutContext, O, *T, 0)), - LastMI(0), LastFn(0), Counter(~0U), - PrevDLT(0, 0, ~0U, ~0U) { + LastMI(0), LastFn(0), Counter(~0U), PrevDLT(NULL) { DW = 0; MMI = 0; switch (AsmVerbose) { case cl::BOU_UNSET: VerboseAsm = VDef; break; @@ -1406,14 +1405,15 @@ DebugLoc DL = MI->getDebugLoc(); if (DL.isUnknown()) return; - DebugLocTuple CurDLT = MF->getDebugLocTuple(DL); - if (CurDLT.Scope == 0) + DILocation CurDLT = MF->getDILocation(DL); + if (CurDLT.getScope().isNull()) return; if (BeforePrintingInsn) { - if (CurDLT != PrevDLT) { - unsigned L = DW->RecordSourceLine(CurDLT.Line, CurDLT.Col, - CurDLT.Scope); + if (CurDLT.getNode() != PrevDLT.getNode()) { + unsigned L = DW->RecordSourceLine(CurDLT.getLineNumber(), + CurDLT.getColumnNumber(), + CurDLT.getScope().getNode()); printLabel(L); O << '\n'; DW->BeginScope(MI, L); @@ -1910,20 +1910,20 @@ bool Newline = false; if (!MI.getDebugLoc().isUnknown()) { - DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc()); + DILocation DLT = MF->getDILocation(MI.getDebugLoc()); // Print source line info. O.PadToColumn(MAI->getCommentColumn()); O << MAI->getCommentString() << ' '; - DIScope Scope(DLT.Scope); + DIScope Scope = DLT.getScope(); // Omit the directory, because it's likely to be long and uninteresting. if (!Scope.isNull()) O << Scope.getFilename(); else O << ""; - O << ':' << DLT.Line; - if (DLT.Col != 0) - O << ':' << DLT.Col; + O << ':' << DLT.getLineNumber(); + if (DLT.getColumnNumber() != 0) + O << ':' << DLT.getColumnNumber(); Newline = true; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=93630&r1=93629&r2=93630&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Sat Jan 16 00:09:35 2010 @@ -2001,13 +2001,14 @@ MIIndexMap[MInsn] = MIIndex++; DebugLoc DL = MInsn->getDebugLoc(); if (DL.isUnknown()) continue; - DebugLocTuple DLT = MF->getDebugLocTuple(DL); - if (!DLT.Scope) continue; + DILocation DLT = MF->getDILocation(DL); + DIScope DLTScope = DLT.getScope(); + if (DLTScope.isNull()) continue; // There is no need to create another DIE for compile unit. For all // other scopes, create one DbgScope now. This will be translated // into a scope DIE at the end. - if (DIDescriptor(DLT.Scope).isCompileUnit()) continue; - createDbgScope(DLT.Scope, DLT.InlinedAtLoc); + if (DLTScope.isCompileUnit()) continue; + createDbgScope(DLTScope.getNode(), DLT.getOrigLocation().getNode()); } } @@ -2020,13 +2021,15 @@ const MachineInstr *MInsn = II; DebugLoc DL = MInsn->getDebugLoc(); if (DL.isUnknown()) continue; - DebugLocTuple DLT = MF->getDebugLocTuple(DL); - if (!DLT.Scope) continue; + DILocation DLT = MF->getDILocation(DL); + DIScope DLTScope = DLT.getScope(); + if (DLTScope.isNull()) continue; // There is no need to create another DIE for compile unit. For all // other scopes, create one DbgScope now. This will be translated // into a scope DIE at the end. - if (DIDescriptor(DLT.Scope).isCompileUnit()) continue; - DbgScope *Scope = getUpdatedDbgScope(DLT.Scope, MInsn, DLT.InlinedAtLoc); + if (DLTScope.isCompileUnit()) continue; + DbgScope *Scope = getUpdatedDbgScope(DLTScope.getNode(), MInsn, + DLT.getOrigLocation().getNode()); Scope->setLastInsn(MInsn); } } @@ -2091,13 +2094,16 @@ // function. DebugLoc FDL = MF->getDefaultDebugLoc(); if (!FDL.isUnknown()) { - DebugLocTuple DLT = MF->getDebugLocTuple(FDL); + DILocation DLT = MF->getDILocation(FDL); unsigned LabelID = 0; - DISubprogram SP = getDISubprogram(DLT.Scope); + DISubprogram SP = getDISubprogram(DLT.getScope().getNode()); if (!SP.isNull()) - LabelID = recordSourceLine(SP.getLineNumber(), 0, DLT.Scope); + LabelID = recordSourceLine(SP.getLineNumber(), 0, + DLT.getScope().getNode()); else - LabelID = recordSourceLine(DLT.Line, DLT.Col, DLT.Scope); + LabelID = recordSourceLine(DLT.getLineNumber(), + DLT.getColumnNumber(), + DLT.getScope().getNode()); Asm->printLabel(LabelID); O << '\n'; } Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=93630&r1=93629&r2=93630&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Sat Jan 16 00:09:35 2010 @@ -426,12 +426,12 @@ return VReg; } -/// getDebugLocTuple - Get the DebugLocTuple for a given DebugLoc object. -DebugLocTuple MachineFunction::getDebugLocTuple(DebugLoc DL) const { +/// getDILocation - Get the DILocation for a given DebugLoc object. +DILocation MachineFunction::getDILocation(DebugLoc DL) const { unsigned Idx = DL.getIndex(); assert(Idx < DebugLocInfo.DebugLocations.size() && "Invalid index into debug locations!"); - return DebugLocInfo.DebugLocations[Idx]; + return DILocation(DebugLocInfo.DebugLocations[Idx]); } //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=93630&r1=93629&r2=93630&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Sat Jan 16 00:09:35 2010 @@ -1189,17 +1189,17 @@ // TODO: print InlinedAtLoc information - DebugLocTuple DLT = MF->getDebugLocTuple(debugLoc); - DIScope Scope(DLT.Scope); + DILocation DLT = MF->getDILocation(debugLoc); + DIScope Scope = DLT.getScope(); OS << " dbg:"; // Omit the directory, since it's usually long and uninteresting. if (!Scope.isNull()) OS << Scope.getFilename(); else OS << ""; - OS << ':' << DLT.Line; - if (DLT.Col != 0) - OS << ':' << DLT.Col; + OS << ':' << DLT.getLineNumber(); + if (DLT.getColumnNumber() != 0) + OS << ':' << DLT.getColumnNumber(); } OS << "\n"; Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=93630&r1=93629&r2=93630&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Sat Jan 16 00:09:35 2010 @@ -368,12 +368,12 @@ // the stub is unused. DenseMap > StubFnRefs; - DebugLocTuple PrevDLT; + DILocation PrevDLT; public: JITEmitter(JIT &jit, JITMemoryManager *JMM, TargetMachine &TM) : SizeEstimate(0), Resolver(jit, *this), MMI(0), CurFn(0), - EmittedFunctions(this) { + EmittedFunctions(this), PrevDLT(NULL) { MemMgr = JMM ? JMM : JITMemoryManager::CreateDefaultMemManager(); if (jit.getJITInfo().needsGOT()) { MemMgr->AllocateGOT(); @@ -806,10 +806,11 @@ void JITEmitter::processDebugLoc(DebugLoc DL, bool BeforePrintingInsn) { if (!DL.isUnknown()) { - DebugLocTuple CurDLT = EmissionDetails.MF->getDebugLocTuple(DL); + DILocation CurDLT = EmissionDetails.MF->getDILocation(DL); if (BeforePrintingInsn) { - if (CurDLT.Scope != 0 && PrevDLT != CurDLT) { + if (CurDLT.getScope().getNode() != 0 + && PrevDLT.getNode() != CurDLT.getNode()) { JITEvent_EmittedFunctionDetails::LineStart NextLine; NextLine.Address = getCurrentPCValue(); NextLine.Loc = DL; Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=93630&r1=93629&r2=93630&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Sat Jan 16 00:09:35 2010 @@ -259,8 +259,9 @@ if (! EmitDebugDirectives) return; assert (! DL.isUnknown() && "can't change to invalid debug loc"); - MDNode *CU = MF.getDebugLocTuple(DL).Scope; - unsigned line = MF.getDebugLocTuple(DL).Line; + DILocation Loc = MF.getDILocation(DL); + MDNode *CU = Loc.getScope().getNode(); + unsigned line = Loc.getLineNumber(); SwitchToCU(CU); SwitchToLine(line, IsInBeginFunction); From dpatel at apple.com Sat Jan 16 00:11:08 2010 From: dpatel at apple.com (Devang Patel) Date: Fri, 15 Jan 2010 22:11:08 -0800 Subject: [llvm-commits] [llvm] r83207 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp In-Reply-To: References: <200910011825.n91IPNZF028439@zion.cs.uiuc.edu> <0C06FEC3-55F5-477E-A885-3D9EE47AD5AD@apple.com> <4764FB07-DE5E-457B-91C7-25E07D0297A9@apple.com> <3BE3E47E-F850-47A6-A28B-163A7C01A34E@apple.com> <97442F43-BD5F-4BF2-8BFE-B472838B1A34@apple.com> Message-ID: On Jan 15, 2010, at 2:51 PM, Chris Lattner wrote: >> On Jan 4, 2010, at 10:59 AM, Chris Lattner wrote: >> >>> >>> On Jan 4, 2010, at 8:55 AM, Devang Patel wrote: >>> >>>> >>>> On Jan 3, 2010, at 9:22 PM, Chris Lattner wrote: >>>> >>>>> On Oct 1, 2009, at 2:35 PM, Evan Cheng wrote: >>>>>> Can't we compute these on demand so codegen passes don't have to change these? >>>>> >>>>> Devang, I never saw an answer to this. >>>> >>>> Now, we compute this just before asmprint. >>> >>> DbgScope still maintains these as instance variables. I see that it is now an asmprinter local data structure, so we can't have pointer invalidation issues. However, we still have memory use to consider. >>> >>>>> I have serious concerns about DbgScope and the presence of two MachineInstr*'s that can dangle seems very dubious. >>>> >>>> DbgScope is representing lexical scopes for debug info. >>> >>> How many DbgScopes are created? One for each lexical scope identified by FE. - Devang -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100115/8e8e9c31/attachment.html From dpatel at apple.com Sat Jan 16 00:17:40 2010 From: dpatel at apple.com (Devang Patel) Date: Sat, 16 Jan 2010 06:17:40 -0000 Subject: [llvm-commits] [llvm] r93631 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <201001160617.o0G6Het2019338@zion.cs.uiuc.edu> Author: dpatel Date: Sat Jan 16 00:17:40 2010 New Revision: 93631 URL: http://llvm.org/viewvc/llvm-project?rev=93631&view=rev Log: No need to use WeakVH here. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=93631&r1=93630&r2=93631&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Sat Jan 16 00:17:40 2010 @@ -165,8 +165,7 @@ class DbgScope { DbgScope *Parent; // Parent to this scope. DIDescriptor Desc; // Debug info descriptor for scope. - // FIXME : Use of WeakVH may be expensive here. - WeakVH InlinedAtLocation; // Location at which scope is inlined. + MDNode * InlinedAtLocation; // Location at which scope is inlined. bool AbstractScope; // Abstract Scope unsigned StartLabelID; // Label ID of the beginning of scope. unsigned EndLabelID; // Label ID of the end of scope. From dpatel at apple.com Sat Jan 16 00:18:37 2010 From: dpatel at apple.com (Devang Patel) Date: Fri, 15 Jan 2010 22:18:37 -0800 Subject: [llvm-commits] [llvm] r84134 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h In-Reply-To: <4C66E3E1-3386-4656-98F7-1D66FBD077A2@apple.com> References: <200910142108.n9EL89PR023324@zion.cs.uiuc.edu> <1103E7BC-53DE-49F4-9DC1-A335327EA2A1@apple.com> <8265AAD1-9EDA-47AC-B3DA-A22F99378C4F@apple.com> <267B3E40-B81C-48D4-A180-E92F14BE90B6@apple.com> <4C66E3E1-3386-4656-98F7-1D66FBD077A2@apple.com> Message-ID: <8A21E0D2-B03B-4C77-9879-E8991EA75211@apple.com> done. There are other instances where we use WeakVH and ValueMap in DwarfDebug. I'll clean them up in a separate patch. - Devang On Jan 15, 2010, at 2:30 PM, Chris Lattner wrote: > > On Jan 15, 2010, at 2:06 PM, Devang Patel wrote: > >> >> On Jan 15, 2010, at 1:52 PM, Chris Lattner wrote: >> >>> ping? >> >> Right now, FE relies on MDNode::replaceAllUsesWith. We need to come up of another way to handle recursive constructs in FE. > > This code is in the code generator's asmwriter, not in the frontend. The frontend should be done by the time these are created. > >> Plus, >> MDNode's replaceOperand may also trigger MDNode::replaceAllUsesWith. So, Between beginFunction() and endFunction(), if metadata changes (Dale is introducing new machine instruction with a metadata operand, which may change during codegen pipeline) then we need WeakVH to track MDNode. >> >> I have not had a chance to measure DbgScope's impact on performance. I'll do the measurement then update it, if required, appropriately. Meanwhile, I am adding FIXME now. > > The code generator should only be run when the metadata is all done, I don't see how it can change here. > > -Chris From grosser at fim.uni-passau.de Sat Jan 16 04:56:42 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Sat, 16 Jan 2010 10:56:42 -0000 Subject: [llvm-commits] [llvm] r93632 - in /llvm/trunk: include/llvm/Analysis/DOTGraphTraitsPass.h lib/Analysis/DomPrinter.cpp Message-ID: <201001161056.o0GAugrw011041@zion.cs.uiuc.edu> Author: grosser Date: Sat Jan 16 04:56:41 2010 New Revision: 93632 URL: http://llvm.org/viewvc/llvm-project?rev=93632&view=rev Log: Create Generic DOTGraphTraits Printer/Viewer Move the DOTGraphTraits dotty printer/viewer templates, that were developed for the dominance tree into their own header file. This will allow reuse in future passes. Added: llvm/trunk/include/llvm/Analysis/DOTGraphTraitsPass.h Modified: llvm/trunk/lib/Analysis/DomPrinter.cpp Added: llvm/trunk/include/llvm/Analysis/DOTGraphTraitsPass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DOTGraphTraitsPass.h?rev=93632&view=auto ============================================================================== --- llvm/trunk/include/llvm/Analysis/DOTGraphTraitsPass.h (added) +++ llvm/trunk/include/llvm/Analysis/DOTGraphTraitsPass.h Sat Jan 16 04:56:41 2010 @@ -0,0 +1,83 @@ +//===-- DOTGraphTraitsPass.h - Print/View dotty graphs-----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Templates to create dotty viewer and printer passes for GraphTraits graphs. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ANALYSIS_DOT_GRAPHTRAITS_PASS_H +#define LLVM_ANALYSIS_DOT_GRAPHTRAITS_PASS_H + +#include "llvm/Pass.h" +#include "llvm/Analysis/CFGPrinter.h" + +namespace llvm { +template +struct DOTGraphTraitsViewer : public FunctionPass { + std::string Name; + + DOTGraphTraitsViewer(std::string GraphName, const void *ID) : FunctionPass(ID) { + Name = GraphName; + } + + virtual bool runOnFunction(Function &F) { + Analysis *Graph; + std::string Title, GraphName; + Graph = &getAnalysis(); + GraphName = DOTGraphTraits::getGraphName(Graph); + Title = GraphName + " for '" + F.getNameStr() + "' function"; + ViewGraph(Graph, Name, Simple, Title); + + return false; + } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + AU.addRequired(); + } +}; + +template +struct DOTGraphTraitsPrinter : public FunctionPass { + + std::string Name; + + DOTGraphTraitsPrinter(std::string GraphName, const void *ID) + : FunctionPass(ID) { + Name = GraphName; + } + + virtual bool runOnFunction(Function &F) { + Analysis *Graph; + std::string Filename = Name + "." + F.getNameStr() + ".dot"; + errs() << "Writing '" << Filename << "'..."; + + std::string ErrorInfo; + raw_fd_ostream File(Filename.c_str(), ErrorInfo); + Graph = &getAnalysis(); + + std::string Title, GraphName; + GraphName = DOTGraphTraits::getGraphName(Graph); + Title = GraphName + " for '" + F.getNameStr() + "' function"; + + if (ErrorInfo.empty()) + WriteGraph(File, Graph, Simple, Name, Title); + else + errs() << " error opening file for writing!"; + errs() << "\n"; + return false; + } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + AU.addRequired(); + } +}; +} +#endif Modified: llvm/trunk/lib/Analysis/DomPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DomPrinter.cpp?rev=93632&r1=93631&r2=93632&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DomPrinter.cpp (original) +++ llvm/trunk/lib/Analysis/DomPrinter.cpp Sat Jan 16 04:56:41 2010 @@ -19,10 +19,9 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/DomPrinter.h" -#include "llvm/Pass.h" -#include "llvm/Function.h" -#include "llvm/Analysis/CFGPrinter.h" + #include "llvm/Analysis/Dominators.h" +#include "llvm/Analysis/DOTGraphTraitsPass.h" #include "llvm/Analysis/PostDominators.h" using namespace llvm; @@ -110,29 +109,29 @@ }; struct DomViewer - : public GenericGraphViewer { + : public DOTGraphTraitsViewer { static char ID; - DomViewer() : GenericGraphViewer("dom", &ID){} + DomViewer() : DOTGraphTraitsViewer("dom", &ID){} }; struct DomOnlyViewer - : public GenericGraphViewer { + : public DOTGraphTraitsViewer { static char ID; - DomOnlyViewer() : GenericGraphViewer("domonly", &ID){} + DomOnlyViewer() : DOTGraphTraitsViewer("domonly", &ID){} }; struct PostDomViewer - : public GenericGraphViewer { + : public DOTGraphTraitsViewer { static char ID; PostDomViewer() : - GenericGraphViewer("postdom", &ID){} + DOTGraphTraitsViewer("postdom", &ID){} }; struct PostDomOnlyViewer - : public GenericGraphViewer { + : public DOTGraphTraitsViewer { static char ID; PostDomOnlyViewer() : - GenericGraphViewer("postdomonly", &ID){} + DOTGraphTraitsViewer("postdomonly", &ID){} }; } // end anonymous namespace @@ -155,67 +154,30 @@ "(with no function bodies)"); namespace { -template -struct GenericGraphPrinter : public FunctionPass { - - std::string Name; - - GenericGraphPrinter(std::string GraphName, const void *ID) - : FunctionPass(ID) { - Name = GraphName; - } - - virtual bool runOnFunction(Function &F) { - Analysis *Graph; - std::string Filename = Name + "." + F.getNameStr() + ".dot"; - errs() << "Writing '" << Filename << "'..."; - - std::string ErrorInfo; - raw_fd_ostream File(Filename.c_str(), ErrorInfo); - Graph = &getAnalysis(); - - std::string Title, GraphName; - GraphName = DOTGraphTraits::getGraphName(Graph); - Title = GraphName + " for '" + F.getNameStr() + "' function"; - - if (ErrorInfo.empty()) - WriteGraph(File, Graph, OnlyBBS, Name, Title); - else - errs() << " error opening file for writing!"; - errs() << "\n"; - return false; - } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - AU.addRequired(); - } -}; - struct DomPrinter - : public GenericGraphPrinter { + : public DOTGraphTraitsPrinter { static char ID; - DomPrinter() : GenericGraphPrinter("dom", &ID) {} + DomPrinter() : DOTGraphTraitsPrinter("dom", &ID) {} }; struct DomOnlyPrinter - : public GenericGraphPrinter { + : public DOTGraphTraitsPrinter { static char ID; - DomOnlyPrinter() : GenericGraphPrinter("domonly", &ID) {} + DomOnlyPrinter() : DOTGraphTraitsPrinter("domonly", &ID) {} }; struct PostDomPrinter - : public GenericGraphPrinter { + : public DOTGraphTraitsPrinter { static char ID; PostDomPrinter() : - GenericGraphPrinter("postdom", &ID) {} + DOTGraphTraitsPrinter("postdom", &ID) {} }; struct PostDomOnlyPrinter - : public GenericGraphPrinter { + : public DOTGraphTraitsPrinter { static char ID; PostDomOnlyPrinter() : - GenericGraphPrinter("postdomonly", &ID) {} + DOTGraphTraitsPrinter("postdomonly", &ID) {} }; } // end anonymous namespace From grosser at fim.uni-passau.de Sat Jan 16 07:38:07 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Sat, 16 Jan 2010 13:38:07 -0000 Subject: [llvm-commits] [llvm] r93633 - in /llvm/trunk: include/llvm/Analysis/DominatorInternals.h test/Analysis/PostDominators/pr6047_a.ll test/Analysis/PostDominators/pr6047_b.ll test/Analysis/PostDominators/pr6047_c.ll test/Analysis/PostDominators/pr6047_d.ll Message-ID: <201001161338.o0GDc8KQ016737@zion.cs.uiuc.edu> Author: grosser Date: Sat Jan 16 07:38:07 2010 New Revision: 93633 URL: http://llvm.org/viewvc/llvm-project?rev=93633&view=rev Log: Fix PR6047 Nodes that had children outside of the post dominator tree (infinite loops) where removed from the post dominator tree. This seems to be wrong. Leave them in the tree. Added: llvm/trunk/test/Analysis/PostDominators/pr6047_a.ll llvm/trunk/test/Analysis/PostDominators/pr6047_b.ll llvm/trunk/test/Analysis/PostDominators/pr6047_c.ll llvm/trunk/test/Analysis/PostDominators/pr6047_d.ll Modified: llvm/trunk/include/llvm/Analysis/DominatorInternals.h Modified: llvm/trunk/include/llvm/Analysis/DominatorInternals.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DominatorInternals.h?rev=93633&r1=93632&r2=93633&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DominatorInternals.h (original) +++ llvm/trunk/include/llvm/Analysis/DominatorInternals.h Sat Jan 16 07:38:07 2010 @@ -262,29 +262,17 @@ DT.Info[W]; // Step #2: Calculate the semidominators of all vertices - bool HasChildOutsideDFS = false; // initialize the semi dominator to point to the parent node WInfo.Semi = WInfo.Parent; for (typename GraphTraits >::ChildIteratorType CI = GraphTraits >::child_begin(W), - E = GraphTraits >::child_end(W); CI != E; ++CI) { + E = GraphTraits >::child_end(W); CI != E; ++CI) if (DT.Info.count(*CI)) { // Only if this predecessor is reachable! unsigned SemiU = DT.Info[Eval(DT, *CI)].Semi; if (SemiU < WInfo.Semi) WInfo.Semi = SemiU; } - else { - // if the child has no DFS number it is not post-dominated by any exit, - // and so is the current block. - HasChildOutsideDFS = true; - } - } - - // if some child has no DFS number it is not post-dominated by any exit, - // and so is the current block. - if (DT.isPostDominator() && HasChildOutsideDFS) - WInfo.Semi = 0; DT.Info[DT.Vertex[WInfo.Semi]].Bucket.push_back(W); Added: llvm/trunk/test/Analysis/PostDominators/pr6047_a.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/PostDominators/pr6047_a.ll?rev=93633&view=auto ============================================================================== --- llvm/trunk/test/Analysis/PostDominators/pr6047_a.ll (added) +++ llvm/trunk/test/Analysis/PostDominators/pr6047_a.ll Sat Jan 16 07:38:07 2010 @@ -0,0 +1,15 @@ +; RUN: opt < %s -postdomtree -analyze | FileCheck %s +define internal void @f() { +entry: + br i1 undef, label %bb35, label %bb3.i + +bb3.i: + br label %bb3.i + +bb35.loopexit3: + br label %bb35 + +bb35: + ret void +} +; CHECK: [3] %entry Added: llvm/trunk/test/Analysis/PostDominators/pr6047_b.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/PostDominators/pr6047_b.ll?rev=93633&view=auto ============================================================================== --- llvm/trunk/test/Analysis/PostDominators/pr6047_b.ll (added) +++ llvm/trunk/test/Analysis/PostDominators/pr6047_b.ll Sat Jan 16 07:38:07 2010 @@ -0,0 +1,19 @@ +; RUN: opt < %s -postdomtree -analyze | FileCheck %s +define internal void @f() { +entry: + br i1 undef, label %a, label %bb3.i + +a: + br i1 undef, label %bb35, label %bb3.i + +bb3.i: + br label %bb3.i + + +bb35.loopexit3: + br label %bb35 + +bb35: + ret void +} +; CHECK: [4] %entry Added: llvm/trunk/test/Analysis/PostDominators/pr6047_c.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/PostDominators/pr6047_c.ll?rev=93633&view=auto ============================================================================== --- llvm/trunk/test/Analysis/PostDominators/pr6047_c.ll (added) +++ llvm/trunk/test/Analysis/PostDominators/pr6047_c.ll Sat Jan 16 07:38:07 2010 @@ -0,0 +1,147 @@ +; RUN: opt < %s -postdomtree -analyze | FileCheck %s +define internal void @f() { +entry: + br i1 undef, label %bb35, label %bb3.i + +bb3.i: + br label %bb3.i + +bb: + br label %bb35 + +bb.i: + br label %bb35 + +_float32_unpack.exit: + br label %bb35 + +bb.i5: + br label %bb35 + +_float32_unpack.exit8: + br label %bb35 + +bb32.preheader: + br label %bb35 + +bb3: + br label %bb35 + +bb3.split.us: + br label %bb35 + +bb.i4.us: + br label %bb35 + +bb7.i.us: + br label %bb35 + +bb.i4.us.backedge: + br label %bb35 + +bb1.i.us: + br label %bb35 + +bb6.i.us: + br label %bb35 + +bb4.i.us: + br label %bb35 + +bb8.i.us: + br label %bb35 + +bb3.i.loopexit.us: + br label %bb35 + +bb.nph21: + br label %bb35 + +bb4: + br label %bb35 + +bb5: + br label %bb35 + +bb14.preheader: + br label %bb35 + +bb.nph18: + br label %bb35 + +bb8.us.preheader: + br label %bb35 + +bb8.preheader: + br label %bb35 + +bb8.us: + br label %bb35 + +bb8: + br label %bb35 + +bb15.loopexit: + br label %bb35 + +bb15.loopexit2: + br label %bb35 + +bb15: + br label %bb35 + +bb16: + br label %bb35 + +bb17.loopexit.split: + br label %bb35 + +bb.nph14: + br label %bb35 + +bb19: + br label %bb35 + +bb20: + br label %bb35 + +bb29.preheader: + br label %bb35 + +bb.nph: + br label %bb35 + +bb23.us.preheader: + br label %bb35 + +bb23.preheader: + br label %bb35 + +bb23.us: + br label %bb35 + +bb23: + br label %bb35 + +bb30.loopexit: + br label %bb35 + +bb30.loopexit1: + br label %bb35 + +bb30: + br label %bb35 + +bb31: + br label %bb35 + +bb35.loopexit: + br label %bb35 + +bb35.loopexit3: + br label %bb35 + +bb35: + ret void +} +; CHECK: [3] %entry Added: llvm/trunk/test/Analysis/PostDominators/pr6047_d.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/PostDominators/pr6047_d.ll?rev=93633&view=auto ============================================================================== --- llvm/trunk/test/Analysis/PostDominators/pr6047_d.ll (added) +++ llvm/trunk/test/Analysis/PostDominators/pr6047_d.ll Sat Jan 16 07:38:07 2010 @@ -0,0 +1,24 @@ +; RUN: opt < %s -postdomtree -analyze | FileCheck %s +define internal void @f() { +entry: + br i1 1, label %a, label %b + +a: +br label %c + +b: +br label %c + +c: + br i1 undef, label %bb35, label %bb3.i + +bb3.i: + br label %bb3.i + +bb35.loopexit3: + br label %bb35 + +bb35: + ret void +} +; CHECK: [4] %entry From asl at math.spbu.ru Sat Jan 16 08:06:58 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 16 Jan 2010 14:06:58 -0000 Subject: [llvm-commits] [llvm] r93635 - /llvm/trunk/Makefile.rules Message-ID: <201001161406.o0GE6wnO017841@zion.cs.uiuc.edu> Author: asl Date: Sat Jan 16 08:06:58 2010 New Revision: 93635 URL: http://llvm.org/viewvc/llvm-project?rev=93635&view=rev Log: Provide magic define on mingw to not generate inline variants of ctyper functions. Otherwise we'll end with random cyclic deps between libraries due to this. Proposed by Gianluigi Tiesi! Modified: llvm/trunk/Makefile.rules Modified: llvm/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=93635&r1=93634&r2=93635&view=diff ============================================================================== --- llvm/trunk/Makefile.rules (original) +++ llvm/trunk/Makefile.rules Sat Jan 16 08:06:58 2010 @@ -439,6 +439,17 @@ endif endif +ifeq ($(HOST_OS),MingW) + # Work around PR4957 + CPP.Defines += -D__NO_CTYPE_INLINE + ifeq ($(LLVM_CROSS_COMPILING),1) + # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016 + ifdef TOOLNAME + LD.Flags += -Wl,--allow-multiple-definition + endif + endif +endif + CXX.Flags += -Woverloaded-virtual CPP.BaseFlags += $(CPP.Defines) AR.Flags := cru @@ -457,15 +468,6 @@ LD.Flags += -Wl,--no-relax endif -ifeq ($(HOST_OS),MingW) - ifeq ($(LLVM_CROSS_COMPILING),1) - # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016 - ifdef TOOLNAME - LD.Flags += -Wl,--allow-multiple-definition - endif - endif -endif - ifdef ENABLE_EXPENSIVE_CHECKS # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above. # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160 From benny.kra at googlemail.com Sat Jan 16 10:14:55 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 16 Jan 2010 16:14:55 -0000 Subject: [llvm-commits] [llvm] r93638 - /llvm/trunk/include/llvm/Support/CFG.h Message-ID: <201001161614.o0GGEtNV022273@zion.cs.uiuc.edu> Author: d0k Date: Sat Jan 16 10:14:55 2010 New Revision: 93638 URL: http://llvm.org/viewvc/llvm-project?rev=93638&view=rev Log: Revive dead assert. 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=93638&r1=93637&r2=93638&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CFG.h (original) +++ llvm/trunk/include/llvm/Support/CFG.h Sat Jan 16 10:14:55 2010 @@ -149,8 +149,8 @@ } inline bool operator>(const _Self& x) const { - return idx > x.idx; assert(Term == x.Term && "Cannot compare iterators of different blocks!"); + return idx > x.idx; } inline _Self& operator+=(int Right) { From sabre at nondot.org Sat Jan 16 12:06:34 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 18:06:34 -0000 Subject: [llvm-commits] [llvm] r93641 - in /llvm/trunk: include/llvm/Support/Mangler.h lib/VMCore/Mangler.cpp Message-ID: <201001161806.o0GI6Zue026718@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 12:06:34 2010 New Revision: 93641 URL: http://llvm.org/viewvc/llvm-project?rev=93641&view=rev Log: add an inefficient version of getNameWithPrefix that returns an std::string. Modified: llvm/trunk/include/llvm/Support/Mangler.h llvm/trunk/lib/VMCore/Mangler.cpp Modified: llvm/trunk/include/llvm/Support/Mangler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=93641&r1=93640&r2=93641&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Mangler.h (original) +++ llvm/trunk/include/llvm/Support/Mangler.h Sat Jan 16 12:06:34 2010 @@ -120,6 +120,11 @@ void getNameWithPrefix(SmallVectorImpl &OutName, const Twine &GVName, ManglerPrefixTy PrefixTy = Mangler::Default); + /// getNameWithPrefix - Return the name of the appropriate prefix + /// and the specified global variable's name. If the global variable doesn't + /// have a name, this fills in a unique name for the global. + std::string getNameWithPrefix(const GlobalValue *GV,bool isImplicitlyPrivate); + private: /// makeNameProper - We don't want identifier names with ., space, or /// - in them, so we mangle these characters into the strings "d_", Modified: llvm/trunk/lib/VMCore/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=93641&r1=93640&r2=93641&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Mangler.cpp (original) +++ llvm/trunk/lib/VMCore/Mangler.cpp Sat Jan 16 12:06:34 2010 @@ -249,6 +249,16 @@ raw_svector_ostream(OutName) << "__unnamed_" << ID; } +/// getNameWithPrefix - Fill OutName with the name of the appropriate prefix +/// and the specified global variable's name. If the global variable doesn't +/// have a name, this fills in a unique name for the global. +std::string Mangler::getNameWithPrefix(const GlobalValue *GV, + bool isImplicitlyPrivate) { + SmallString<64> Buf; + getNameWithPrefix(Buf, GV, isImplicitlyPrivate); + return std::string(Buf.begin(), Buf.end()); +} + Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix, const char *linkerPrivatePrefix) From sabre at nondot.org Sat Jan 16 12:12:14 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 18:12:14 -0000 Subject: [llvm-commits] [llvm] r93643 - in /llvm/trunk: include/llvm/Support/Mangler.h tools/bugpoint/Miscompilation.cpp tools/lto/LTOCodeGenerator.cpp tools/lto/LTOModule.cpp Message-ID: <201001161812.o0GICEp9027029@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 12:12:14 2010 New Revision: 93643 URL: http://llvm.org/viewvc/llvm-project?rev=93643&view=rev Log: switch liblto to use the new getNameWithPrefix() method instead of getMangledName. Modified: llvm/trunk/include/llvm/Support/Mangler.h llvm/trunk/tools/bugpoint/Miscompilation.cpp llvm/trunk/tools/lto/LTOCodeGenerator.cpp llvm/trunk/tools/lto/LTOModule.cpp Modified: llvm/trunk/include/llvm/Support/Mangler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=93643&r1=93642&r2=93643&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Mangler.h (original) +++ llvm/trunk/include/llvm/Support/Mangler.h Sat Jan 16 12:12:14 2010 @@ -123,7 +123,8 @@ /// getNameWithPrefix - Return the name of the appropriate prefix /// and the specified global variable's name. If the global variable doesn't /// have a name, this fills in a unique name for the global. - std::string getNameWithPrefix(const GlobalValue *GV,bool isImplicitlyPrivate); + std::string getNameWithPrefix(const GlobalValue *GV, + bool isImplicitlyPrivate = false); private: /// makeNameProper - We don't want identifier names with ., space, or Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/Miscompilation.cpp?rev=93643&r1=93642&r2=93643&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original) +++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Sat Jan 16 12:12:14 2010 @@ -251,13 +251,13 @@ I != E; ++I) { // Don't mangle asm names. if (!I->hasName() || I->getName()[0] != 1) - I->setName(Mang.getMangledName(I)); + I->setName(Mang.getNameWithPrefix(I)); } for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) { // Don't mangle asm names or intrinsics. if ((!I->hasName() || I->getName()[0] != 1) && I->getIntrinsicID() == 0) - I->setName(Mang.getMangledName(I)); + I->setName(Mang.getNameWithPrefix(I)); } } Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=93643&r1=93642&r2=93643&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Sat Jan 16 12:12:14 2010 @@ -329,7 +329,7 @@ for (Module::iterator f = mergedModule->begin(), e = mergedModule->end(); f != e; ++f) { if ( !f->isDeclaration() - && _mustPreserveSymbols.count(mangler.getMangledName(f)) ) + && _mustPreserveSymbols.count(mangler.getNameWithPrefix(f)) ) mustPreserveList.push_back(::strdup(f->getNameStr().c_str())); } for (Module::global_iterator v = mergedModule->global_begin(), Modified: llvm/trunk/tools/lto/LTOModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=93643&r1=93642&r2=93643&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOModule.cpp (original) +++ llvm/trunk/tools/lto/LTOModule.cpp Sat Jan 16 12:12:14 2010 @@ -320,7 +320,7 @@ return; // string is owned by _defines - const char* symbolName = ::strdup(mangler.getMangledName(def).c_str()); + const char* symbolName = ::strdup(mangler.getNameWithPrefix(def).c_str()); // set alignment part log2() can have rounding errors uint32_t align = def->getAlignment(); @@ -393,7 +393,7 @@ if (isa(decl)) return; - std::string name = mangler.getMangledName(decl); + std::string name = mangler.getNameWithPrefix(decl); // we already have the symbol if (_undefines.find(name) != _undefines.end()) From sabre at nondot.org Sat Jan 16 12:17:26 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 18:17:26 -0000 Subject: [llvm-commits] [llvm] r93645 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <201001161817.o0GIHQYJ027304@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 12:17:26 2010 New Revision: 93645 URL: http://llvm.org/viewvc/llvm-project?rev=93645&view=rev Log: eliminate uses of getMangledName from AsmPrinter.cpp, last up is dwarf emission which is going to be more invasive. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93645&r1=93644&r2=93645&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sat Jan 16 12:17:26 2010 @@ -163,13 +163,17 @@ // Print out module-level global variables here. for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) { - if (I->hasExternalWeakLinkage()) - O << MAI->getWeakRefDirective() << Mang->getMangledName(I) << '\n'; + if (!I->hasExternalWeakLinkage()) continue; + O << MAI->getWeakRefDirective(); + GetGlobalValueSymbol(I)->print(O, MAI); + O << '\n'; } for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I) { - if (I->hasExternalWeakLinkage()) - O << MAI->getWeakRefDirective() << Mang->getMangledName(I) << '\n'; + if (!I->hasExternalWeakLinkage()) continue; + O << MAI->getWeakRefDirective(); + GetGlobalValueSymbol(I)->print(O, MAI); + O << '\n'; } } @@ -828,7 +832,7 @@ if (const GlobalValue *GV = dyn_cast(CV)) { // This is a constant address for a global variable or function. Use the // name of the variable or function as the address value. - O << Mang->getMangledName(GV); + GetGlobalValueSymbol(GV)->print(O, MAI); return; } From sabre at nondot.org Sat Jan 16 12:37:33 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 18:37:33 -0000 Subject: [llvm-commits] [llvm] r93646 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DwarfException.cpp lib/CodeGen/AsmPrinter/DwarfException.h lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Message-ID: <201001161837.o0GIbY9P028179@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 12:37:32 2010 New Revision: 93646 URL: http://llvm.org/viewvc/llvm-project?rev=93646&view=rev Log: rename GetPrivateGlobalValueSymbolStub -> GetSymbolWithGlobalValueBase, and add an explicit ForcePrivate argument. Switch FunctionEHFrameInfo to be MCSymbol based instead of string based. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=93646&r1=93645&r2=93646&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Sat Jan 16 12:37:32 2010 @@ -344,11 +344,12 @@ /// value. MCSymbol *GetGlobalValueSymbol(const GlobalValue *GV) const; - /// GetPrivateGlobalValueSymbolStub - Return the MCSymbol for a symbol with + /// GetSymbolWithGlobalValueBase - Return the MCSymbol for a symbol with /// global value name as its base, with the specified suffix, and where the - /// symbol is forced to have private linkage. - MCSymbol *GetPrivateGlobalValueSymbolStub(const GlobalValue *GV, - StringRef Suffix) const; + /// symbol is forced to have private linkage if ForcePrivate is true. + MCSymbol *GetSymbolWithGlobalValueBase(const GlobalValue *GV, + StringRef Suffix, + bool ForcePrivate = true) const; /// GetExternalSymbolSymbol - Return the MCSymbol for the specified /// ExternalSymbol. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93646&r1=93645&r2=93646&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sat Jan 16 12:37:32 2010 @@ -1719,13 +1719,14 @@ return OutContext.GetOrCreateSymbol(NameStr.str()); } -/// GetPrivateGlobalValueSymbolStub - Return the MCSymbol for a symbol with +/// GetSymbolWithGlobalValueBase - Return the MCSymbol for a symbol with /// global value name as its base, with the specified suffix, and where the -/// symbol is forced to have private linkage. -MCSymbol *AsmPrinter::GetPrivateGlobalValueSymbolStub(const GlobalValue *GV, - StringRef Suffix) const { +/// symbol is forced to have private linkage if ForcePrivate is true. +MCSymbol *AsmPrinter::GetSymbolWithGlobalValueBase(const GlobalValue *GV, + StringRef Suffix, + bool ForcePrivate) const { SmallString<60> NameStr; - Mang->getNameWithPrefix(NameStr, GV, true); + Mang->getNameWithPrefix(NameStr, GV, ForcePrivate); NameStr.append(Suffix.begin(), Suffix.end()); return OutContext.GetOrCreateSymbol(NameStr.str()); } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=93646&r1=93645&r2=93646&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Sat Jan 16 12:37:32 2010 @@ -22,6 +22,7 @@ #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCSection.h" #include "llvm/MC/MCStreamer.h" +#include "llvm/MC/MCSymbol.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetLoweringObjectFile.h" @@ -230,17 +231,26 @@ // Externally visible entry into the functions eh frame info. If the // corresponding function is static, this should not be externally visible. if (!TheFunc->hasLocalLinkage()) - if (const char *GlobalEHDirective = MAI->getGlobalEHDirective()) - O << GlobalEHDirective << EHFrameInfo.FnName << '\n'; + if (const char *GlobalEHDirective = MAI->getGlobalEHDirective()) { + O << GlobalEHDirective; + EHFrameInfo.FunctionEHSym->print(O, MAI); + O << '\n'; + } // If corresponding function is weak definition, this should be too. - if (TheFunc->isWeakForLinker() && MAI->getWeakDefDirective()) - O << MAI->getWeakDefDirective() << EHFrameInfo.FnName << '\n'; + if (TheFunc->isWeakForLinker() && MAI->getWeakDefDirective()) { + O << MAI->getWeakDefDirective(); + EHFrameInfo.FunctionEHSym->print(O, MAI); + O << '\n'; + } // If corresponding function is hidden, this should be too. if (TheFunc->hasHiddenVisibility()) - if (const char *HiddenDirective = MAI->getHiddenDirective()) - O << HiddenDirective << EHFrameInfo.FnName << '\n' ; + if (const char *HiddenDirective = MAI->getHiddenDirective()) { + O << HiddenDirective; + EHFrameInfo.FunctionEHSym->print(O, MAI); + O << '\n'; + } // If there are no calls then you can't unwind. This may mean we can omit the // EH Frame, but some environments do not handle weak absolute symbols. If @@ -250,14 +260,19 @@ (!TheFunc->isWeakForLinker() || !MAI->getWeakDefDirective() || MAI->getSupportsWeakOmittedEHFrame())) { - O << EHFrameInfo.FnName << " = 0\n"; + EHFrameInfo.FunctionEHSym->print(O, MAI); + O << " = 0\n"; // This name has no connection to the function, so it might get // dead-stripped when the function is not, erroneously. Prohibit // dead-stripping unconditionally. - if (const char *UsedDirective = MAI->getUsedDirective()) - O << UsedDirective << EHFrameInfo.FnName << "\n\n"; + if (const char *UsedDirective = MAI->getUsedDirective()) { + O << UsedDirective; + EHFrameInfo.FunctionEHSym->print(O, MAI); + O << "\n\n"; + } } else { - O << EHFrameInfo.FnName << ":\n"; + EHFrameInfo.FunctionEHSym->print(O, MAI); + O << ":\n"; // EH frame header. EmitDifference("eh_frame_end", EHFrameInfo.Number, @@ -328,8 +343,11 @@ // on unused functions (calling undefined externals) being dead-stripped to // link correctly. Yes, there really is. if (MMI->isUsedFunction(EHFrameInfo.function)) - if (const char *UsedDirective = MAI->getUsedDirective()) - O << UsedDirective << EHFrameInfo.FnName << "\n\n"; + if (const char *UsedDirective = MAI->getUsedDirective()) { + O << UsedDirective; + EHFrameInfo.FunctionEHSym->print(O, MAI); + O << "\n\n"; + } } Asm->EOL(); @@ -928,7 +946,7 @@ PrintRelDirective(); if (GV) { - O << Asm->Mang->getMangledName(GV); + Asm->GetGlobalValueSymbol(GV)->print(O, MAI); } else { O << "0x0"; } @@ -1019,12 +1037,12 @@ EmitLabel("eh_func_end", SubprogramCount); EmitExceptionTable(); - std::string FunctionEHName = - Asm->Mang->getMangledName(MF->getFunction(), ".eh", - Asm->MAI->is_EHSymbolPrivate()); + const MCSymbol *FunctionEHSym = + Asm->GetSymbolWithGlobalValueBase(MF->getFunction(), ".eh", + Asm->MAI->is_EHSymbolPrivate()); // Save EH frame information - EHFrames.push_back(FunctionEHFrameInfo(FunctionEHName, SubprogramCount, + EHFrames.push_back(FunctionEHFrameInfo(FunctionEHSym, SubprogramCount, MMI->getPersonalityIndex(), MF->getFrameInfo()->hasCalls(), !MMI->getLandingPads().empty(), Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h?rev=93646&r1=93645&r2=93646&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h Sat Jan 16 12:37:32 2010 @@ -34,19 +34,19 @@ /// class DwarfException : public Dwarf { struct FunctionEHFrameInfo { - std::string FnName; + const MCSymbol *FunctionEHSym; // L_foo.eh unsigned Number; unsigned PersonalityIndex; bool hasCalls; bool hasLandingPads; std::vector Moves; - const Function * function; + const Function *function; - FunctionEHFrameInfo(const std::string &FN, unsigned Num, unsigned P, + FunctionEHFrameInfo(const MCSymbol *EHSym, unsigned Num, unsigned P, bool hC, bool hL, const std::vector &M, const Function *f): - FnName(FN), Number(Num), PersonalityIndex(P), + FunctionEHSym(EHSym), Number(Num), PersonalityIndex(P), hasCalls(hC), hasLandingPads(hL), Moves(M), function (f) { } }; Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=93646&r1=93645&r2=93646&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Sat Jan 16 12:37:32 2010 @@ -190,7 +190,7 @@ GetGlobalValueSymbol(GV)->print(O, MAI); else { // FIXME: Remove this when Darwin transition to @GOT like syntax. - MCSymbol *Sym = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr"); + MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); Sym->print(O, MAI); MachineModuleInfoMachO &MMIMachO = Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp?rev=93646&r1=93645&r2=93646&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Sat Jan 16 12:37:32 2010 @@ -341,7 +341,7 @@ GlobalValue *GV = MO.getGlobal(); if (((GV->isDeclaration() || GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()))) { - GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr")->print(O, MAI); + GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr")->print(O, MAI); return; } } Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=93646&r1=93645&r2=93646&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Sat Jan 16 12:37:32 2010 @@ -70,9 +70,9 @@ if (Stub != 0) return; // Get the names. - Stub = Printer->GetPrivateGlobalValueSymbolStub(GV, "$stub"); - LazyPtr = Printer->GetPrivateGlobalValueSymbolStub(GV, "$lazy_ptr"); - AnonSymbol = Printer->GetPrivateGlobalValueSymbolStub(GV, "$stub$tmp"); + Stub = Printer->GetSymbolWithGlobalValueBase(GV, "$stub"); + LazyPtr = Printer->GetSymbolWithGlobalValueBase(GV, "$lazy_ptr"); + AnonSymbol = Printer->GetSymbolWithGlobalValueBase(GV, "$stub$tmp"); } void Init(StringRef GVName, Mangler *Mang, MCContext &Ctx) { @@ -450,11 +450,11 @@ if (TM.getRelocationModel() != Reloc::Static && (GV->isDeclaration() || GV->isWeakForLinker())) { if (!GV->hasHiddenVisibility()) { - SymToPrint = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr"); + SymToPrint = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); GVStubs[GetGlobalValueSymbol(GV)] = SymToPrint; } else if (GV->isDeclaration() || GV->hasCommonLinkage() || GV->hasAvailableExternallyLinkage()) { - SymToPrint = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr"); + SymToPrint = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); HiddenGVStubs[GetGlobalValueSymbol(GV)] = SymToPrint; } else { SymToPrint = GetGlobalValueSymbol(GV); @@ -1200,7 +1200,7 @@ E = Personalities.end(); I != E; ++I) { if (*I) GVStubs[GetGlobalValueSymbol(*I)] = - GetPrivateGlobalValueSymbolStub(*I, "$non_lazy_ptr"); + GetSymbolWithGlobalValueBase(*I, "$non_lazy_ptr"); } } Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=93646&r1=93645&r2=93646&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Sat Jan 16 12:37:32 2010 @@ -238,11 +238,11 @@ const MCSymbol *GVSym; if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) - GVSym = GetPrivateGlobalValueSymbolStub(GV, "$stub"); + GVSym = GetSymbolWithGlobalValueBase(GV, "$stub"); else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY || MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE || MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE) - GVSym = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr"); + GVSym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); else GVSym = GetGlobalValueSymbol(GV); @@ -258,7 +258,7 @@ if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY || MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) { - MCSymbol *Sym = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr"); + MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); const MCSymbol *&StubSym = MMI->getObjFileInfo().getGVStubEntry(Sym); @@ -266,13 +266,13 @@ StubSym = GetGlobalValueSymbol(GV); } else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){ - MCSymbol *Sym = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr"); + MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); const MCSymbol *&StubSym = MMI->getObjFileInfo().getHiddenGVStubEntry(Sym); if (StubSym == 0) StubSym = GetGlobalValueSymbol(GV); } else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) { - MCSymbol *Sym = GetPrivateGlobalValueSymbolStub(GV, "$stub"); + MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$stub"); const MCSymbol *&StubSym = MMI->getObjFileInfo().getFnStubEntry(Sym); if (StubSym == 0) From sabre at nondot.org Sat Jan 16 12:50:29 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 18:50:29 -0000 Subject: [llvm-commits] [llvm] r93647 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DIE.cpp DIE.h DwarfDebug.cpp DwarfDebug.h DwarfPrinter.cpp DwarfPrinter.h Message-ID: <201001161850.o0GIoTcV028695@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 12:50:28 2010 New Revision: 93647 URL: http://llvm.org/viewvc/llvm-project?rev=93647&view=rev Log: Change DIEObjectLabel to take an MCSymbol instead of std::string. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=93647&r1=93646&r2=93647&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Sat Jan 16 12:50:28 2010 @@ -15,6 +15,7 @@ #include "DwarfPrinter.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCSymbol.h" #include "llvm/Target/TargetData.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" @@ -276,7 +277,7 @@ /// void DIEObjectLabel::EmitValue(Dwarf *D, unsigned Form) const { bool IsSmall = Form == dwarf::DW_FORM_data4; - D->EmitReference(Label, false, IsSmall); + D->EmitReference(Sym, false, IsSmall); } /// SizeOf - Determine size of label value in bytes. @@ -288,7 +289,7 @@ #ifndef NDEBUG void DIEObjectLabel::print(raw_ostream &O) { - O << "Obj: " << Label; + O << "Obj: " << Sym->getName(); } #endif Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h?rev=93647&r1=93646&r2=93647&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h Sat Jan 16 12:50:28 2010 @@ -25,6 +25,7 @@ class AsmPrinter; class Dwarf; class TargetData; + class MCSymbol; //===--------------------------------------------------------------------===// /// DIEAbbrevData - Dwarf abbreviation data, describes the one attribute of a @@ -333,10 +334,10 @@ /// DIEObjectLabel - A label to an object in code or data. // class DIEObjectLabel : public DIEValue { - const std::string Label; + const MCSymbol *Sym; public: - explicit DIEObjectLabel(const std::string &L) - : DIEValue(isAsIsLabel), Label(L) {} + explicit DIEObjectLabel(const MCSymbol *S) + : DIEValue(isAsIsLabel), Sym(S) {} /// EmitValue - Emit label value. /// Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=93647&r1=93646&r2=93647&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Sat Jan 16 12:50:28 2010 @@ -361,8 +361,8 @@ /// addObjectLabel - Add an non-Dwarf label attribute data and value. /// void DwarfDebug::addObjectLabel(DIE *Die, unsigned Attribute, unsigned Form, - const std::string &Label) { - DIEValue *Value = new DIEObjectLabel(Label); + const MCSymbol *Sym) { + DIEValue *Value = new DIEObjectLabel(Sym); DIEValues.push_back(Value); Die->addValue(Attribute, Form, Value); } @@ -1665,14 +1665,14 @@ DIEBlock *Block = new DIEBlock(); addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr); addObjectLabel(Block, 0, dwarf::DW_FORM_udata, - Asm->Mang->getMangledName(DI_GV.getGlobal())); + Asm->GetGlobalValueSymbol(DI_GV.getGlobal())); addBlock(VariableSpecDIE, dwarf::DW_AT_location, 0, Block); ModuleCU->addDie(VariableSpecDIE); } else { DIEBlock *Block = new DIEBlock(); addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr); addObjectLabel(Block, 0, dwarf::DW_FORM_udata, - Asm->Mang->getMangledName(DI_GV.getGlobal())); + Asm->GetGlobalValueSymbol(DI_GV.getGlobal())); addBlock(VariableDie, dwarf::DW_AT_location, 0, Block); } addToContextOwner(VariableDie, GVContext); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=93647&r1=93646&r2=93647&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Sat Jan 16 12:50:28 2010 @@ -256,7 +256,7 @@ /// addObjectLabel - Add an non-Dwarf label attribute data and value. /// void addObjectLabel(DIE *Die, unsigned Attribute, unsigned Form, - const std::string &Label); + const MCSymbol *Sym); /// addSectionOffset - Add a section offset label attribute data and value. /// Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp?rev=93647&r1=93646&r2=93647&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp Sat Jan 16 12:50:28 2010 @@ -18,6 +18,7 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCSymbol.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetRegisterInfo.h" @@ -76,6 +77,13 @@ if (IsPCRelative) O << "-" << MAI->getPCSymbol(); } +void Dwarf::EmitReference(const MCSymbol *Sym, bool IsPCRelative, + bool Force32Bit) const { + PrintRelDirective(Force32Bit); + Sym->print(O, MAI); + if (IsPCRelative) O << "-" << MAI->getPCSymbol(); +} + /// EmitDifference - Emit the difference between two labels. Some assemblers do /// not behave with absolute expressions with data directives, so there is an /// option (needsSet) to use an intermediary set expression. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h?rev=93647&r1=93646&r2=93647&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h Sat Jan 16 12:50:28 2010 @@ -28,6 +28,7 @@ class MCAsmInfo; class TargetData; class TargetRegisterInfo; + class MCSymbol; class Dwarf { protected: @@ -123,6 +124,8 @@ bool Force32Bit = false) const; void EmitReference(const std::string &Name, bool IsPCRelative = false, bool Force32Bit = false) const; + void EmitReference(const MCSymbol *Sym, bool IsPCRelative = false, + bool Force32Bit = false) const; /// EmitDifference - Emit the difference between two labels. Some /// assemblers do not behave with absolute expressions with data directives, From sabre at nondot.org Sat Jan 16 13:08:51 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 19:08:51 -0000 Subject: [llvm-commits] [llvm] r93648 - in /llvm/trunk: include/llvm/Support/Mangler.h lib/CodeGen/MachOWriter.cpp lib/VMCore/Mangler.cpp Message-ID: <201001161908.o0GJ8qOO029273@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 13:08:51 2010 New Revision: 93648 URL: http://llvm.org/viewvc/llvm-project?rev=93648&view=rev Log: Mangler::getMangledName is now dead, remove it and all the other stuff in Mangler that is now transitively dead. woo. Modified: llvm/trunk/include/llvm/Support/Mangler.h llvm/trunk/lib/CodeGen/MachOWriter.cpp llvm/trunk/lib/VMCore/Mangler.cpp Modified: llvm/trunk/include/llvm/Support/Mangler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=93648&r1=93647&r2=93648&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Mangler.h (original) +++ llvm/trunk/include/llvm/Support/Mangler.h Sat Jan 16 13:08:51 2010 @@ -47,15 +47,6 @@ /// "linker_private" linkage. const char *LinkerPrivatePrefix; - /// UseQuotes - If this is set, the target accepts global names in quotes, - /// e.g. "foo bar" is a legal name. This syntax is used instead of escaping - /// the space character. By default, this is false. - bool UseQuotes; - - /// SymbolsCanStartWithDigit - If this is set, the target allows symbols to - /// start with digits (e.g., "0x0021"). By default, this is false. - bool SymbolsCanStartWithDigit; - /// AnonGlobalIDs - We need to give global values the same name every time /// they are mangled. This keeps track of the number we give to anonymous /// ones. @@ -66,48 +57,12 @@ /// unsigned NextAnonGlobalID; - /// AcceptableChars - This bitfield contains a one for each character that is - /// allowed to be part of an unmangled name. - unsigned AcceptableChars[256 / 32]; - public: // Mangler ctor - if a prefix is specified, it will be prepended onto all // symbols. Mangler(Module &M, const char *Prefix = "", const char *privatePrefix = "", const char *linkerPrivatePrefix = ""); - /// setUseQuotes - If UseQuotes is set to true, this target accepts quoted - /// strings for assembler labels. - void setUseQuotes(bool Val) { UseQuotes = Val; } - - /// setSymbolsCanStartWithDigit - If SymbolsCanStartWithDigit is set to true, - /// this target allows symbols to start with digits. - void setSymbolsCanStartWithDigit(bool Val) { SymbolsCanStartWithDigit = Val; } - - /// Acceptable Characters - This allows the target to specify which characters - /// are acceptable to the assembler without being mangled. By default we - /// allow letters, numbers, '_', '$', '.', which is what GAS accepts, and '@'. - void markCharAcceptable(unsigned char X) { - AcceptableChars[X/32] |= 1 << (X&31); - } - void markCharUnacceptable(unsigned char X) { - AcceptableChars[X/32] &= ~(1 << (X&31)); - } - bool isCharAcceptable(unsigned char X) const { - return (AcceptableChars[X/32] & (1 << (X&31))) != 0; - } - - /// getMangledName - Returns the mangled name of V, an LLVM Value, - /// in the current module. If 'Suffix' is specified, the name ends with the - /// specified suffix. If 'ForcePrivate' is specified, the label is specified - /// to have a private label prefix. - /// - /// FIXME: This is deprecated, new code should use getNameWithPrefix and use - /// MCSymbol printing to handle quotes or not etc. - /// - std::string getMangledName(const GlobalValue *V, const char *Suffix = "", - bool ForcePrivate = false); - /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix /// and the specified global variable's name. If the global variable doesn't /// have a name, this fills in a unique name for the global. @@ -125,22 +80,6 @@ /// have a name, this fills in a unique name for the global. std::string getNameWithPrefix(const GlobalValue *GV, bool isImplicitlyPrivate = false); - -private: - /// makeNameProper - We don't want identifier names with ., space, or - /// - in them, so we mangle these characters into the strings "d_", - /// "s_", and "D_", respectively. This is a very simple mangling that - /// doesn't guarantee unique names for values. getValueName already - /// does this for you, so there's no point calling it on the result - /// from getValueName. - /// - /// FIXME: This is deprecated, new code should use getNameWithPrefix and use - /// MCSymbol printing to handle quotes or not etc. - /// - void makeNameProper(SmallVectorImpl &OutName, - const Twine &Name, - ManglerPrefixTy PrefixTy = Mangler::Default); - }; } // End llvm namespace Modified: llvm/trunk/lib/CodeGen/MachOWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.cpp?rev=93648&r1=93647&r2=93648&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachOWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/MachOWriter.cpp Sat Jan 16 13:08:51 2010 @@ -72,12 +72,6 @@ Mang = new Mangler(M, MAI->getGlobalPrefix(), MAI->getPrivateGlobalPrefix(), MAI->getLinkerPrivateGlobalPrefix()); - if (MAI->doesAllowQuotesInName()) - Mang->setUseQuotes(true); - - if (MAI->doesAllowNameToStartWithDigit()) - Mang->setSymbolsCanStartWithDigit(true); - // Initialize TargetLoweringObjectFile. TM.getTargetLowering()->getObjFileLowering().Initialize(OutContext, TM); Modified: llvm/trunk/lib/VMCore/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=93648&r1=93647&r2=93648&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Mangler.cpp (original) +++ llvm/trunk/lib/VMCore/Mangler.cpp Sat Jan 16 13:08:51 2010 @@ -7,180 +7,17 @@ // //===----------------------------------------------------------------------===// // -// Unified name mangler for CWriter and assembly backends. +// Unified name mangler for assembly backends. // //===----------------------------------------------------------------------===// #include "llvm/Support/Mangler.h" -#include "llvm/Function.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/StringMap.h" +#include "llvm/GlobalValue.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/Twine.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; -static char HexDigit(int V) { - return V < 10 ? V+'0' : V+'A'-10; -} - -static void MangleLetter(SmallVectorImpl &OutName, unsigned char C) { - OutName.push_back('_'); - OutName.push_back(HexDigit(C >> 4)); - OutName.push_back(HexDigit(C & 15)); - OutName.push_back('_'); -} - -/// makeNameProper - We don't want identifier names non-C-identifier characters -/// in them, so mangle them as appropriate. -/// -/// FIXME: This is deprecated, new code should use getNameWithPrefix and use -/// MCSymbol printing to handle quotes or not etc. -/// -void Mangler::makeNameProper(SmallVectorImpl &OutName, - const Twine &TheName, - ManglerPrefixTy PrefixTy) { - SmallString<256> TmpData; - StringRef X = TheName.toStringRef(TmpData); - assert(!X.empty() && "Cannot mangle empty strings"); - - if (!UseQuotes) { - // If X does not start with (char)1, add the prefix. - StringRef::iterator I = X.begin(); - if (*I == 1) { - ++I; // Skip over the no-prefix marker. - } else { - if (PrefixTy == Mangler::Private) - OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); - else if (PrefixTy == Mangler::LinkerPrivate) - OutName.append(LinkerPrivatePrefix, - LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); - OutName.append(Prefix, Prefix+strlen(Prefix)); - } - - // Mangle the first letter specially, don't allow numbers unless the target - // explicitly allows them. - if (!SymbolsCanStartWithDigit && *I >= '0' && *I <= '9') - MangleLetter(OutName, *I++); - - for (StringRef::iterator E = X.end(); I != E; ++I) { - if (!isCharAcceptable(*I)) - MangleLetter(OutName, *I); - else - OutName.push_back(*I); - } - return; - } - - bool NeedPrefix = true; - bool NeedQuotes = false; - StringRef::iterator I = X.begin(); - if (*I == 1) { - NeedPrefix = false; - ++I; // Skip over the marker. - } - - // If the first character is a number, we need quotes. - if (*I >= '0' && *I <= '9') - NeedQuotes = true; - - // Do an initial scan of the string, checking to see if we need quotes or - // to escape a '"' or not. - if (!NeedQuotes) - for (StringRef::iterator E = X.end(); I != E; ++I) - if (!isCharAcceptable(*I)) { - NeedQuotes = true; - break; - } - - // In the common case, we don't need quotes. Handle this quickly. - if (!NeedQuotes) { - if (!NeedPrefix) { - OutName.append(X.begin()+1, X.end()); // Strip off the \001. - return; - } - - if (PrefixTy == Mangler::Private) - OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); - else if (PrefixTy == Mangler::LinkerPrivate) - OutName.append(LinkerPrivatePrefix, - LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); - - if (Prefix[0] == 0) - ; // Common noop, no prefix. - else if (Prefix[1] == 0) - OutName.push_back(Prefix[0]); // Common, one character prefix. - else - OutName.append(Prefix, Prefix+strlen(Prefix)); // Arbitrary prefix. - OutName.append(X.begin(), X.end()); - return; - } - - // Add leading quote. - OutName.push_back('"'); - - // Add prefixes unless disabled. - if (NeedPrefix) { - if (PrefixTy == Mangler::Private) - OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); - else if (PrefixTy == Mangler::LinkerPrivate) - OutName.append(LinkerPrivatePrefix, - LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); - OutName.append(Prefix, Prefix+strlen(Prefix)); - } - - // Add the piece that we already scanned through. - OutName.append(X.begin()+!NeedPrefix, I); - - // Otherwise, construct the string the expensive way. - for (StringRef::iterator E = X.end(); I != E; ++I) { - if (*I == '"') { - const char *Quote = "_QQ_"; - OutName.append(Quote, Quote+4); - } else if (*I == '\n') { - const char *Newline = "_NL_"; - OutName.append(Newline, Newline+4); - } else - OutName.push_back(*I); - } - - // Add trailing quote. - OutName.push_back('"'); -} - -/// getMangledName - Returns the mangled name of V, an LLVM Value, -/// in the current module. If 'Suffix' is specified, the name ends with the -/// specified suffix. If 'ForcePrivate' is specified, the label is specified -/// to have a private label prefix. -/// -/// FIXME: This is deprecated, new code should use getNameWithPrefix and use -/// MCSymbol printing to handle quotes or not etc. -/// -std::string Mangler::getMangledName(const GlobalValue *GV, const char *Suffix, - bool ForcePrivate) { - assert((!isa(GV) || !cast(GV)->isIntrinsic()) && - "Intrinsic functions cannot be mangled by Mangler"); - - ManglerPrefixTy PrefixTy = - (GV->hasPrivateLinkage() || ForcePrivate) ? Mangler::Private : - GV->hasLinkerPrivateLinkage() ? Mangler::LinkerPrivate : Mangler::Default; - - SmallString<128> Result; - if (GV->hasName()) { - makeNameProper(Result, GV->getNameStr() + Suffix, PrefixTy); - return Result.str().str(); - } - - // Get the ID for the global, assigning a new one if we haven't got one - // already. - unsigned &ID = AnonGlobalIDs[GV]; - if (ID == 0) ID = NextAnonGlobalID++; - - // Must mangle the global into a unique ID. - makeNameProper(Result, "__unnamed_" + utostr(ID) + Suffix, PrefixTy); - return Result.str().str(); -} - /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix /// and the specified name as the global variable name. GVName must not be /// empty. @@ -263,21 +100,5 @@ Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix, const char *linkerPrivatePrefix) : Prefix(prefix), PrivatePrefix(privatePrefix), - LinkerPrivatePrefix(linkerPrivatePrefix), UseQuotes(false), - SymbolsCanStartWithDigit(false), NextAnonGlobalID(1) { - std::fill(AcceptableChars, array_endof(AcceptableChars), 0); - - // Letters and numbers are acceptable. - for (unsigned char X = 'a'; X <= 'z'; ++X) - markCharAcceptable(X); - for (unsigned char X = 'A'; X <= 'Z'; ++X) - markCharAcceptable(X); - for (unsigned char X = '0'; X <= '9'; ++X) - markCharAcceptable(X); - - // These chars are acceptable. - markCharAcceptable('_'); - markCharAcceptable('$'); - markCharAcceptable('.'); - markCharAcceptable('@'); + LinkerPrivatePrefix(linkerPrivatePrefix), NextAnonGlobalID(1) { } From stuart at apple.com Sat Jan 16 13:30:19 2010 From: stuart at apple.com (Stuart Hastings) Date: Sat, 16 Jan 2010 19:30:19 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93649 - /llvm-gcc-4.2/trunk/gcc/config/i386/i386.c Message-ID: <201001161930.o0GJUJae029974@zion.cs.uiuc.edu> Author: stuart Date: Sat Jan 16 13:30:18 2010 New Revision: 93649 URL: http://llvm.org/viewvc/llvm-project?rev=93649&view=rev Log: More fine-tuning of the x86-64 ABI. The previous patch corrected the 128-bit store into a 96-bit struct, but it mistakenly passed a 128-bit aligned 32-bit struct as a 128-bit object. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.c Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/i386.c?rev=93649&r1=93648&r2=93649&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/i386.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/i386.c Sat Jan 16 13:30:18 2010 @@ -3474,16 +3474,24 @@ for (i = 0; i < words; i++) classes[i] = subclasses[i % num]; - /* If 32-bit class, consider upgrade to 64-bit. */ - if (bytes > 4 && - (subclasses[0] == X86_64_SSESF_CLASS || - subclasses[0] == X86_64_INTEGERSI_CLASS)) { - enum x86_64_reg_class upgrade64 = - (subclasses[0] == X86_64_SSESF_CLASS) ? + /* If the first register has a 32-bit class, but there are + more than 32-bits in the type, upgrade it to the + corresponding 64-bit class. */ + if ((bytes > 4) && + ((subclasses[0] == X86_64_SSESF_CLASS) || + (subclasses[0] == X86_64_INTEGERSI_CLASS))) { + classes[0] = (subclasses[0] == X86_64_SSESF_CLASS) ? X86_64_SSE_CLASS : X86_64_INTEGER_CLASS; - classes[0] = upgrade64; - if (bytes > 12) - classes[1] = upgrade64; + /* subclasses[1] is only valid if num == 2. If it's + invalid, or it's set to a 32-bit class, AND there + are more than twelve bytes in the type, upgrade the + second register to 64-bits. (If we got here, the + first register already has a 64-bit class.) */ + if (bytes > 12 && + (num == 1 || + subclasses[1] == X86_64_SSESF_CLASS || + subclasses[1] == X86_64_INTEGERSI_CLASS)) + classes[1] = classes[0]; } } break; From echristo at apple.com Sat Jan 16 13:59:56 2010 From: echristo at apple.com (Eric Christopher) Date: Sat, 16 Jan 2010 11:59:56 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r93649 - /llvm-gcc-4.2/trunk/gcc/config/i386/i386.c In-Reply-To: <201001161930.o0GJUJae029974@zion.cs.uiuc.edu> References: <201001161930.o0GJUJae029974@zion.cs.uiuc.edu> Message-ID: <99DBD1F9-FD01-4F1D-9531-CA05A7F1A95B@apple.com> On Jan 16, 2010, at 11:30 AM, Stuart Hastings wrote: > The previous patch corrected the 128-bit store into a 96-bit struct, > but it mistakenly passed a 128-bit aligned 32-bit struct as a 128-bit > object. Have you managed to run the structure compatibility tests yet? -eric From espindola at google.com Sat Jan 16 14:21:26 2010 From: espindola at google.com (Rafael Espindola) Date: Sat, 16 Jan 2010 15:21:26 -0500 Subject: [llvm-commits] [llvm] r93648 - in /llvm/trunk: include/llvm/Support/Mangler.h lib/CodeGen/MachOWriter.cpp lib/VMCore/Mangler.cpp In-Reply-To: <201001161908.o0GJ8qOO029273@zion.cs.uiuc.edu> References: <201001161908.o0GJ8qOO029273@zion.cs.uiuc.edu> Message-ID: <38a0d8451001161221u4af58c4fje726df68323f090a@mail.gmail.com> I think this broke the build: /home/espindola/llvm/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp: In member function ?virtual bool llvm::AsmPrinter::doInitialization(llvm::Module&)?: /home/espindola/llvm/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:109: error: ?class llvm::Mangler? has no member named ?setUseQuotes? /home/espindola/llvm/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:112: error: ?class llvm::Mangler? has no member named ?setSymbolsCanStartWithDigit? make[3]: *** [/home/espindola/llvm/llvm-build/lib/CodeGen/AsmPrinter/Debug/AsmPrinter.o] Error 1 2010/1/16 Chris Lattner : > Author: lattner > Date: Sat Jan 16 13:08:51 2010 > New Revision: 93648 > > URL: http://llvm.org/viewvc/llvm-project?rev=93648&view=rev > Log: > Mangler::getMangledName is now dead, remove it and all the other stuff in Mangler that is now transitively dead. ?woo. > > Modified: > ? ?llvm/trunk/include/llvm/Support/Mangler.h > ? ?llvm/trunk/lib/CodeGen/MachOWriter.cpp > ? ?llvm/trunk/lib/VMCore/Mangler.cpp > > Modified: llvm/trunk/include/llvm/Support/Mangler.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=93648&r1=93647&r2=93648&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/Support/Mangler.h (original) > +++ llvm/trunk/include/llvm/Support/Mangler.h Sat Jan 16 13:08:51 2010 > @@ -47,15 +47,6 @@ > ? /// "linker_private" linkage. > ? const char *LinkerPrivatePrefix; > > - ?/// UseQuotes - If this is set, the target accepts global names in quotes, > - ?/// e.g. "foo bar" is a legal name. ?This syntax is used instead of escaping > - ?/// the space character. ?By default, this is false. > - ?bool UseQuotes; > - > - ?/// SymbolsCanStartWithDigit - If this is set, the target allows symbols to > - ?/// start with digits (e.g., "0x0021"). ?By default, this is false. > - ?bool SymbolsCanStartWithDigit; > - > ? /// AnonGlobalIDs - We need to give global values the same name every time > ? /// they are mangled. ?This keeps track of the number we give to anonymous > ? /// ones. > @@ -66,48 +57,12 @@ > ? /// > ? unsigned NextAnonGlobalID; > > - ?/// AcceptableChars - This bitfield contains a one for each character that is > - ?/// allowed to be part of an unmangled name. > - ?unsigned AcceptableChars[256 / 32]; > - > ?public: > ? // Mangler ctor - if a prefix is specified, it will be prepended onto all > ? // symbols. > ? Mangler(Module &M, const char *Prefix = "", const char *privatePrefix = "", > ? ? ? ? ? const char *linkerPrivatePrefix = ""); > > - ?/// setUseQuotes - If UseQuotes is set to true, this target accepts quoted > - ?/// strings for assembler labels. > - ?void setUseQuotes(bool Val) { UseQuotes = Val; } > - > - ?/// setSymbolsCanStartWithDigit - If SymbolsCanStartWithDigit is set to true, > - ?/// this target allows symbols to start with digits. > - ?void setSymbolsCanStartWithDigit(bool Val) { SymbolsCanStartWithDigit = Val; } > - > - ?/// Acceptable Characters - This allows the target to specify which characters > - ?/// are acceptable to the assembler without being mangled. ?By default we > - ?/// allow letters, numbers, '_', '$', '.', which is what GAS accepts, and '@'. > - ?void markCharAcceptable(unsigned char X) { > - ? ?AcceptableChars[X/32] |= 1 << (X&31); > - ?} > - ?void markCharUnacceptable(unsigned char X) { > - ? ?AcceptableChars[X/32] &= ~(1 << (X&31)); > - ?} > - ?bool isCharAcceptable(unsigned char X) const { > - ? ?return (AcceptableChars[X/32] & (1 << (X&31))) != 0; > - ?} > - > - ?/// getMangledName - Returns the mangled name of V, an LLVM Value, > - ?/// in the current module. ?If 'Suffix' is specified, the name ends with the > - ?/// specified suffix. ?If 'ForcePrivate' is specified, the label is specified > - ?/// to have a private label prefix. > - ?/// > - ?/// FIXME: This is deprecated, new code should use getNameWithPrefix and use > - ?/// MCSymbol printing to handle quotes or not etc. > - ?/// > - ?std::string getMangledName(const GlobalValue *V, const char *Suffix = "", > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool ForcePrivate = false); > - > ? /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix > ? /// and the specified global variable's name. ?If the global variable doesn't > ? /// have a name, this fills in a unique name for the global. > @@ -125,22 +80,6 @@ > ? /// have a name, this fills in a unique name for the global. > ? std::string getNameWithPrefix(const GlobalValue *GV, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool isImplicitlyPrivate = false); > - > -private: > - ?/// makeNameProper - We don't want identifier names with ., space, or > - ?/// - in them, so we mangle these characters into the strings "d_", > - ?/// "s_", and "D_", respectively. This is a very simple mangling that > - ?/// doesn't guarantee unique names for values. getValueName already > - ?/// does this for you, so there's no point calling it on the result > - ?/// from getValueName. > - ?/// > - ?/// FIXME: This is deprecated, new code should use getNameWithPrefix and use > - ?/// MCSymbol printing to handle quotes or not etc. > - ?/// > - ?void makeNameProper(SmallVectorImpl &OutName, > - ? ? ? ? ? ? ? ? ? ? ?const Twine &Name, > - ? ? ? ? ? ? ? ? ? ? ?ManglerPrefixTy PrefixTy = Mangler::Default); > - > ?}; > > ?} // End llvm namespace > > Modified: llvm/trunk/lib/CodeGen/MachOWriter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.cpp?rev=93648&r1=93647&r2=93648&view=diff > > ============================================================================== > --- llvm/trunk/lib/CodeGen/MachOWriter.cpp (original) > +++ llvm/trunk/lib/CodeGen/MachOWriter.cpp Sat Jan 16 13:08:51 2010 > @@ -72,12 +72,6 @@ > ? Mang = new Mangler(M, MAI->getGlobalPrefix(), MAI->getPrivateGlobalPrefix(), > ? ? ? ? ? ? ? ? ? ? ?MAI->getLinkerPrivateGlobalPrefix()); > > - ?if (MAI->doesAllowQuotesInName()) > - ? ?Mang->setUseQuotes(true); > - > - ?if (MAI->doesAllowNameToStartWithDigit()) > - ? ?Mang->setSymbolsCanStartWithDigit(true); > - > ? // Initialize TargetLoweringObjectFile. > ? TM.getTargetLowering()->getObjFileLowering().Initialize(OutContext, TM); > > > Modified: llvm/trunk/lib/VMCore/Mangler.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=93648&r1=93647&r2=93648&view=diff > > ============================================================================== > --- llvm/trunk/lib/VMCore/Mangler.cpp (original) > +++ llvm/trunk/lib/VMCore/Mangler.cpp Sat Jan 16 13:08:51 2010 > @@ -7,180 +7,17 @@ > ?// > ?//===----------------------------------------------------------------------===// > ?// > -// Unified name mangler for CWriter and assembly backends. > +// Unified name mangler for assembly backends. > ?// > ?//===----------------------------------------------------------------------===// > > ?#include "llvm/Support/Mangler.h" > -#include "llvm/Function.h" > -#include "llvm/ADT/STLExtras.h" > -#include "llvm/ADT/StringExtras.h" > -#include "llvm/ADT/StringMap.h" > +#include "llvm/GlobalValue.h" > ?#include "llvm/ADT/SmallString.h" > +#include "llvm/ADT/Twine.h" > ?#include "llvm/Support/raw_ostream.h" > ?using namespace llvm; > > -static char HexDigit(int V) { > - ?return V < 10 ? V+'0' : V+'A'-10; > -} > - > -static void MangleLetter(SmallVectorImpl &OutName, unsigned char C) { > - ?OutName.push_back('_'); > - ?OutName.push_back(HexDigit(C >> 4)); > - ?OutName.push_back(HexDigit(C & 15)); > - ?OutName.push_back('_'); > -} > - > -/// makeNameProper - We don't want identifier names non-C-identifier characters > -/// in them, so mangle them as appropriate. > -/// > -/// FIXME: This is deprecated, new code should use getNameWithPrefix and use > -/// MCSymbol printing to handle quotes or not etc. > -/// > -void Mangler::makeNameProper(SmallVectorImpl &OutName, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? const Twine &TheName, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ManglerPrefixTy PrefixTy) { > - ?SmallString<256> TmpData; > - ?StringRef X = TheName.toStringRef(TmpData); > - ?assert(!X.empty() && "Cannot mangle empty strings"); > - > - ?if (!UseQuotes) { > - ? ?// If X does not start with (char)1, add the prefix. > - ? ?StringRef::iterator I = X.begin(); > - ? ?if (*I == 1) { > - ? ? ?++I; ?// Skip over the no-prefix marker. > - ? ?} else { > - ? ? ?if (PrefixTy == Mangler::Private) > - ? ? ? ?OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); > - ? ? ?else if (PrefixTy == Mangler::LinkerPrivate) > - ? ? ? ?OutName.append(LinkerPrivatePrefix, > - ? ? ? ? ? ? ? ? ? ? ? LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); > - ? ? ?OutName.append(Prefix, Prefix+strlen(Prefix)); > - ? ?} > - > - ? ?// Mangle the first letter specially, don't allow numbers unless the target > - ? ?// explicitly allows them. > - ? ?if (!SymbolsCanStartWithDigit && *I >= '0' && *I <= '9') > - ? ? ?MangleLetter(OutName, *I++); > - > - ? ?for (StringRef::iterator E = X.end(); I != E; ++I) { > - ? ? ?if (!isCharAcceptable(*I)) > - ? ? ? ?MangleLetter(OutName, *I); > - ? ? ?else > - ? ? ? ?OutName.push_back(*I); > - ? ?} > - ? ?return; > - ?} > - > - ?bool NeedPrefix = true; > - ?bool NeedQuotes = false; > - ?StringRef::iterator I = X.begin(); > - ?if (*I == 1) { > - ? ?NeedPrefix = false; > - ? ?++I; ?// Skip over the marker. > - ?} > - > - ?// If the first character is a number, we need quotes. > - ?if (*I >= '0' && *I <= '9') > - ? ?NeedQuotes = true; > - > - ?// Do an initial scan of the string, checking to see if we need quotes or > - ?// to escape a '"' or not. > - ?if (!NeedQuotes) > - ? ?for (StringRef::iterator E = X.end(); I != E; ++I) > - ? ? ?if (!isCharAcceptable(*I)) { > - ? ? ? ?NeedQuotes = true; > - ? ? ? ?break; > - ? ? ?} > - > - ?// In the common case, we don't need quotes. ?Handle this quickly. > - ?if (!NeedQuotes) { > - ? ?if (!NeedPrefix) { > - ? ? ?OutName.append(X.begin()+1, X.end()); ? // Strip off the \001. > - ? ? ?return; > - ? ?} > - > - ? ?if (PrefixTy == Mangler::Private) > - ? ? ?OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); > - ? ?else if (PrefixTy == Mangler::LinkerPrivate) > - ? ? ?OutName.append(LinkerPrivatePrefix, > - ? ? ? ? ? ? ? ? ? ? LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); > - > - ? ?if (Prefix[0] == 0) > - ? ? ?; // Common noop, no prefix. > - ? ?else if (Prefix[1] == 0) > - ? ? ?OutName.push_back(Prefix[0]); ?// Common, one character prefix. > - ? ?else > - ? ? ?OutName.append(Prefix, Prefix+strlen(Prefix)); // Arbitrary prefix. > - ? ?OutName.append(X.begin(), X.end()); > - ? ?return; > - ?} > - > - ?// Add leading quote. > - ?OutName.push_back('"'); > - > - ?// Add prefixes unless disabled. > - ?if (NeedPrefix) { > - ? ?if (PrefixTy == Mangler::Private) > - ? ? ?OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); > - ? ?else if (PrefixTy == Mangler::LinkerPrivate) > - ? ? ?OutName.append(LinkerPrivatePrefix, > - ? ? ? ? ? ? ? ? ? ? LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); > - ? ?OutName.append(Prefix, Prefix+strlen(Prefix)); > - ?} > - > - ?// Add the piece that we already scanned through. > - ?OutName.append(X.begin()+!NeedPrefix, I); > - > - ?// Otherwise, construct the string the expensive way. > - ?for (StringRef::iterator E = X.end(); I != E; ++I) { > - ? ?if (*I == '"') { > - ? ? ?const char *Quote = "_QQ_"; > - ? ? ?OutName.append(Quote, Quote+4); > - ? ?} else if (*I == '\n') { > - ? ? ?const char *Newline = "_NL_"; > - ? ? ?OutName.append(Newline, Newline+4); > - ? ?} else > - ? ? ?OutName.push_back(*I); > - ?} > - > - ?// Add trailing quote. > - ?OutName.push_back('"'); > -} > - > -/// getMangledName - Returns the mangled name of V, an LLVM Value, > -/// in the current module. ?If 'Suffix' is specified, the name ends with the > -/// specified suffix. ?If 'ForcePrivate' is specified, the label is specified > -/// to have a private label prefix. > -/// > -/// FIXME: This is deprecated, new code should use getNameWithPrefix and use > -/// MCSymbol printing to handle quotes or not etc. > -/// > -std::string Mangler::getMangledName(const GlobalValue *GV, const char *Suffix, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool ForcePrivate) { > - ?assert((!isa(GV) || !cast(GV)->isIntrinsic()) && > - ? ? ? ? "Intrinsic functions cannot be mangled by Mangler"); > - > - ?ManglerPrefixTy PrefixTy = > - ? ?(GV->hasPrivateLinkage() || ForcePrivate) ? Mangler::Private : > - ? ? ?GV->hasLinkerPrivateLinkage() ? Mangler::LinkerPrivate : Mangler::Default; > - > - ?SmallString<128> Result; > - ?if (GV->hasName()) { > - ? ?makeNameProper(Result, GV->getNameStr() + Suffix, PrefixTy); > - ? ?return Result.str().str(); > - ?} > - > - ?// Get the ID for the global, assigning a new one if we haven't got one > - ?// already. > - ?unsigned &ID = AnonGlobalIDs[GV]; > - ?if (ID == 0) ID = NextAnonGlobalID++; > - > - ?// Must mangle the global into a unique ID. > - ?makeNameProper(Result, "__unnamed_" + utostr(ID) + Suffix, PrefixTy); > - ?return Result.str().str(); > -} > - > ?/// getNameWithPrefix - Fill OutName with the name of the appropriate prefix > ?/// and the specified name as the global variable name. ?GVName must not be > ?/// empty. > @@ -263,21 +100,5 @@ > ?Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix, > ? ? ? ? ? ? ? ? ?const char *linkerPrivatePrefix) > ? : Prefix(prefix), PrivatePrefix(privatePrefix), > - ? ?LinkerPrivatePrefix(linkerPrivatePrefix), UseQuotes(false), > - ? ?SymbolsCanStartWithDigit(false), NextAnonGlobalID(1) { > - ?std::fill(AcceptableChars, array_endof(AcceptableChars), 0); > - > - ?// Letters and numbers are acceptable. > - ?for (unsigned char X = 'a'; X <= 'z'; ++X) > - ? ?markCharAcceptable(X); > - ?for (unsigned char X = 'A'; X <= 'Z'; ++X) > - ? ?markCharAcceptable(X); > - ?for (unsigned char X = '0'; X <= '9'; ++X) > - ? ?markCharAcceptable(X); > - > - ?// These chars are acceptable. > - ?markCharAcceptable('_'); > - ?markCharAcceptable('$'); > - ?markCharAcceptable('.'); > - ?markCharAcceptable('@'); > + ? ?LinkerPrivatePrefix(linkerPrivatePrefix), NextAnonGlobalID(1) { > ?} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- Rafael ?vila de Esp?ndola From rafael.espindola at gmail.com Sat Jan 16 14:27:59 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sat, 16 Jan 2010 20:27:59 -0000 Subject: [llvm-commits] [llvm] r93652 - in /llvm/trunk: include/llvm/Support/Mangler.h lib/CodeGen/MachOWriter.cpp lib/VMCore/Mangler.cpp Message-ID: <201001162027.o0GKRxOq032120@zion.cs.uiuc.edu> Author: rafael Date: Sat Jan 16 14:27:59 2010 New Revision: 93652 URL: http://llvm.org/viewvc/llvm-project?rev=93652&view=rev Log: Revert 93648. Mangler::getMangledName is used from lto Mangler::setUseQuotes is used in the AsmPrinter Mangler::setSymbolsCanStartWithDigit is used in the AsmPrinter Modified: llvm/trunk/include/llvm/Support/Mangler.h llvm/trunk/lib/CodeGen/MachOWriter.cpp llvm/trunk/lib/VMCore/Mangler.cpp Modified: llvm/trunk/include/llvm/Support/Mangler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=93652&r1=93651&r2=93652&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Mangler.h (original) +++ llvm/trunk/include/llvm/Support/Mangler.h Sat Jan 16 14:27:59 2010 @@ -47,6 +47,15 @@ /// "linker_private" linkage. const char *LinkerPrivatePrefix; + /// UseQuotes - If this is set, the target accepts global names in quotes, + /// e.g. "foo bar" is a legal name. This syntax is used instead of escaping + /// the space character. By default, this is false. + bool UseQuotes; + + /// SymbolsCanStartWithDigit - If this is set, the target allows symbols to + /// start with digits (e.g., "0x0021"). By default, this is false. + bool SymbolsCanStartWithDigit; + /// AnonGlobalIDs - We need to give global values the same name every time /// they are mangled. This keeps track of the number we give to anonymous /// ones. @@ -57,12 +66,48 @@ /// unsigned NextAnonGlobalID; + /// AcceptableChars - This bitfield contains a one for each character that is + /// allowed to be part of an unmangled name. + unsigned AcceptableChars[256 / 32]; + public: // Mangler ctor - if a prefix is specified, it will be prepended onto all // symbols. Mangler(Module &M, const char *Prefix = "", const char *privatePrefix = "", const char *linkerPrivatePrefix = ""); + /// setUseQuotes - If UseQuotes is set to true, this target accepts quoted + /// strings for assembler labels. + void setUseQuotes(bool Val) { UseQuotes = Val; } + + /// setSymbolsCanStartWithDigit - If SymbolsCanStartWithDigit is set to true, + /// this target allows symbols to start with digits. + void setSymbolsCanStartWithDigit(bool Val) { SymbolsCanStartWithDigit = Val; } + + /// Acceptable Characters - This allows the target to specify which characters + /// are acceptable to the assembler without being mangled. By default we + /// allow letters, numbers, '_', '$', '.', which is what GAS accepts, and '@'. + void markCharAcceptable(unsigned char X) { + AcceptableChars[X/32] |= 1 << (X&31); + } + void markCharUnacceptable(unsigned char X) { + AcceptableChars[X/32] &= ~(1 << (X&31)); + } + bool isCharAcceptable(unsigned char X) const { + return (AcceptableChars[X/32] & (1 << (X&31))) != 0; + } + + /// getMangledName - Returns the mangled name of V, an LLVM Value, + /// in the current module. If 'Suffix' is specified, the name ends with the + /// specified suffix. If 'ForcePrivate' is specified, the label is specified + /// to have a private label prefix. + /// + /// FIXME: This is deprecated, new code should use getNameWithPrefix and use + /// MCSymbol printing to handle quotes or not etc. + /// + std::string getMangledName(const GlobalValue *V, const char *Suffix = "", + bool ForcePrivate = false); + /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix /// and the specified global variable's name. If the global variable doesn't /// have a name, this fills in a unique name for the global. @@ -80,6 +125,22 @@ /// have a name, this fills in a unique name for the global. std::string getNameWithPrefix(const GlobalValue *GV, bool isImplicitlyPrivate = false); + +private: + /// makeNameProper - We don't want identifier names with ., space, or + /// - in them, so we mangle these characters into the strings "d_", + /// "s_", and "D_", respectively. This is a very simple mangling that + /// doesn't guarantee unique names for values. getValueName already + /// does this for you, so there's no point calling it on the result + /// from getValueName. + /// + /// FIXME: This is deprecated, new code should use getNameWithPrefix and use + /// MCSymbol printing to handle quotes or not etc. + /// + void makeNameProper(SmallVectorImpl &OutName, + const Twine &Name, + ManglerPrefixTy PrefixTy = Mangler::Default); + }; } // End llvm namespace Modified: llvm/trunk/lib/CodeGen/MachOWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.cpp?rev=93652&r1=93651&r2=93652&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachOWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/MachOWriter.cpp Sat Jan 16 14:27:59 2010 @@ -72,6 +72,12 @@ Mang = new Mangler(M, MAI->getGlobalPrefix(), MAI->getPrivateGlobalPrefix(), MAI->getLinkerPrivateGlobalPrefix()); + if (MAI->doesAllowQuotesInName()) + Mang->setUseQuotes(true); + + if (MAI->doesAllowNameToStartWithDigit()) + Mang->setSymbolsCanStartWithDigit(true); + // Initialize TargetLoweringObjectFile. TM.getTargetLowering()->getObjFileLowering().Initialize(OutContext, TM); Modified: llvm/trunk/lib/VMCore/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=93652&r1=93651&r2=93652&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Mangler.cpp (original) +++ llvm/trunk/lib/VMCore/Mangler.cpp Sat Jan 16 14:27:59 2010 @@ -7,17 +7,180 @@ // //===----------------------------------------------------------------------===// // -// Unified name mangler for assembly backends. +// Unified name mangler for CWriter and assembly backends. // //===----------------------------------------------------------------------===// #include "llvm/Support/Mangler.h" -#include "llvm/GlobalValue.h" +#include "llvm/Function.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringMap.h" #include "llvm/ADT/SmallString.h" -#include "llvm/ADT/Twine.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; +static char HexDigit(int V) { + return V < 10 ? V+'0' : V+'A'-10; +} + +static void MangleLetter(SmallVectorImpl &OutName, unsigned char C) { + OutName.push_back('_'); + OutName.push_back(HexDigit(C >> 4)); + OutName.push_back(HexDigit(C & 15)); + OutName.push_back('_'); +} + +/// makeNameProper - We don't want identifier names non-C-identifier characters +/// in them, so mangle them as appropriate. +/// +/// FIXME: This is deprecated, new code should use getNameWithPrefix and use +/// MCSymbol printing to handle quotes or not etc. +/// +void Mangler::makeNameProper(SmallVectorImpl &OutName, + const Twine &TheName, + ManglerPrefixTy PrefixTy) { + SmallString<256> TmpData; + StringRef X = TheName.toStringRef(TmpData); + assert(!X.empty() && "Cannot mangle empty strings"); + + if (!UseQuotes) { + // If X does not start with (char)1, add the prefix. + StringRef::iterator I = X.begin(); + if (*I == 1) { + ++I; // Skip over the no-prefix marker. + } else { + if (PrefixTy == Mangler::Private) + OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); + else if (PrefixTy == Mangler::LinkerPrivate) + OutName.append(LinkerPrivatePrefix, + LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); + OutName.append(Prefix, Prefix+strlen(Prefix)); + } + + // Mangle the first letter specially, don't allow numbers unless the target + // explicitly allows them. + if (!SymbolsCanStartWithDigit && *I >= '0' && *I <= '9') + MangleLetter(OutName, *I++); + + for (StringRef::iterator E = X.end(); I != E; ++I) { + if (!isCharAcceptable(*I)) + MangleLetter(OutName, *I); + else + OutName.push_back(*I); + } + return; + } + + bool NeedPrefix = true; + bool NeedQuotes = false; + StringRef::iterator I = X.begin(); + if (*I == 1) { + NeedPrefix = false; + ++I; // Skip over the marker. + } + + // If the first character is a number, we need quotes. + if (*I >= '0' && *I <= '9') + NeedQuotes = true; + + // Do an initial scan of the string, checking to see if we need quotes or + // to escape a '"' or not. + if (!NeedQuotes) + for (StringRef::iterator E = X.end(); I != E; ++I) + if (!isCharAcceptable(*I)) { + NeedQuotes = true; + break; + } + + // In the common case, we don't need quotes. Handle this quickly. + if (!NeedQuotes) { + if (!NeedPrefix) { + OutName.append(X.begin()+1, X.end()); // Strip off the \001. + return; + } + + if (PrefixTy == Mangler::Private) + OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); + else if (PrefixTy == Mangler::LinkerPrivate) + OutName.append(LinkerPrivatePrefix, + LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); + + if (Prefix[0] == 0) + ; // Common noop, no prefix. + else if (Prefix[1] == 0) + OutName.push_back(Prefix[0]); // Common, one character prefix. + else + OutName.append(Prefix, Prefix+strlen(Prefix)); // Arbitrary prefix. + OutName.append(X.begin(), X.end()); + return; + } + + // Add leading quote. + OutName.push_back('"'); + + // Add prefixes unless disabled. + if (NeedPrefix) { + if (PrefixTy == Mangler::Private) + OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); + else if (PrefixTy == Mangler::LinkerPrivate) + OutName.append(LinkerPrivatePrefix, + LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); + OutName.append(Prefix, Prefix+strlen(Prefix)); + } + + // Add the piece that we already scanned through. + OutName.append(X.begin()+!NeedPrefix, I); + + // Otherwise, construct the string the expensive way. + for (StringRef::iterator E = X.end(); I != E; ++I) { + if (*I == '"') { + const char *Quote = "_QQ_"; + OutName.append(Quote, Quote+4); + } else if (*I == '\n') { + const char *Newline = "_NL_"; + OutName.append(Newline, Newline+4); + } else + OutName.push_back(*I); + } + + // Add trailing quote. + OutName.push_back('"'); +} + +/// getMangledName - Returns the mangled name of V, an LLVM Value, +/// in the current module. If 'Suffix' is specified, the name ends with the +/// specified suffix. If 'ForcePrivate' is specified, the label is specified +/// to have a private label prefix. +/// +/// FIXME: This is deprecated, new code should use getNameWithPrefix and use +/// MCSymbol printing to handle quotes or not etc. +/// +std::string Mangler::getMangledName(const GlobalValue *GV, const char *Suffix, + bool ForcePrivate) { + assert((!isa(GV) || !cast(GV)->isIntrinsic()) && + "Intrinsic functions cannot be mangled by Mangler"); + + ManglerPrefixTy PrefixTy = + (GV->hasPrivateLinkage() || ForcePrivate) ? Mangler::Private : + GV->hasLinkerPrivateLinkage() ? Mangler::LinkerPrivate : Mangler::Default; + + SmallString<128> Result; + if (GV->hasName()) { + makeNameProper(Result, GV->getNameStr() + Suffix, PrefixTy); + return Result.str().str(); + } + + // Get the ID for the global, assigning a new one if we haven't got one + // already. + unsigned &ID = AnonGlobalIDs[GV]; + if (ID == 0) ID = NextAnonGlobalID++; + + // Must mangle the global into a unique ID. + makeNameProper(Result, "__unnamed_" + utostr(ID) + Suffix, PrefixTy); + return Result.str().str(); +} + /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix /// and the specified name as the global variable name. GVName must not be /// empty. @@ -100,5 +263,21 @@ Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix, const char *linkerPrivatePrefix) : Prefix(prefix), PrivatePrefix(privatePrefix), - LinkerPrivatePrefix(linkerPrivatePrefix), NextAnonGlobalID(1) { + LinkerPrivatePrefix(linkerPrivatePrefix), UseQuotes(false), + SymbolsCanStartWithDigit(false), NextAnonGlobalID(1) { + std::fill(AcceptableChars, array_endof(AcceptableChars), 0); + + // Letters and numbers are acceptable. + for (unsigned char X = 'a'; X <= 'z'; ++X) + markCharAcceptable(X); + for (unsigned char X = 'A'; X <= 'Z'; ++X) + markCharAcceptable(X); + for (unsigned char X = '0'; X <= '9'; ++X) + markCharAcceptable(X); + + // These chars are acceptable. + markCharAcceptable('_'); + markCharAcceptable('$'); + markCharAcceptable('.'); + markCharAcceptable('@'); } From sabre at nondot.org Sat Jan 16 14:53:11 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 20:53:11 -0000 Subject: [llvm-commits] [llvm] r93654 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <201001162053.o0GKrB2d000447@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 14:53:11 2010 New Revision: 93654 URL: http://llvm.org/viewvc/llvm-project?rev=93654&view=rev Log: unbreak the build. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93654&r1=93653&r2=93654&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sat Jan 16 14:53:11 2010 @@ -105,12 +105,6 @@ Mang = new Mangler(M, MAI->getGlobalPrefix(), MAI->getPrivateGlobalPrefix(), MAI->getLinkerPrivateGlobalPrefix()); - if (MAI->doesAllowQuotesInName()) - Mang->setUseQuotes(true); - - if (MAI->doesAllowNameToStartWithDigit()) - Mang->setSymbolsCanStartWithDigit(true); - // Allow the target to emit any magic that it wants at the start of the file. EmitStartOfAsmFile(M); From sabre at nondot.org Sat Jan 16 14:53:41 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 12:53:41 -0800 Subject: [llvm-commits] [llvm] r93648 - in /llvm/trunk: include/llvm/Support/Mangler.h lib/CodeGen/MachOWriter.cpp lib/VMCore/Mangler.cpp In-Reply-To: <38a0d8451001161221u4af58c4fje726df68323f090a@mail.gmail.com> References: <201001161908.o0GJ8qOO029273@zion.cs.uiuc.edu> <38a0d8451001161221u4af58c4fje726df68323f090a@mail.gmail.com> Message-ID: Doh, sorry about that. The makefiles sometimes forget to recurse into a directory when the llvm checkout is under a symlink or something. :( :( Fixed in r93654 -Chris On Jan 16, 2010, at 12:21 PM, Rafael Espindola wrote: > I think this broke the build: > > /home/espindola/llvm/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp: In > member function ?virtual bool > llvm::AsmPrinter::doInitialization(llvm::Module&)?: > /home/espindola/llvm/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:109: > error: ?class llvm::Mangler? has no member named ?setUseQuotes? > /home/espindola/llvm/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:112: > error: ?class llvm::Mangler? has no member named > ?setSymbolsCanStartWithDigit? > make[3]: *** [/home/espindola/llvm/llvm-build/lib/CodeGen/AsmPrinter/Debug/AsmPrinter.o] > Error 1 > > 2010/1/16 Chris Lattner : >> Author: lattner >> Date: Sat Jan 16 13:08:51 2010 >> New Revision: 93648 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=93648&view=rev >> Log: >> Mangler::getMangledName is now dead, remove it and all the other stuff in Mangler that is now transitively dead. woo. >> >> Modified: >> llvm/trunk/include/llvm/Support/Mangler.h >> llvm/trunk/lib/CodeGen/MachOWriter.cpp >> llvm/trunk/lib/VMCore/Mangler.cpp >> >> Modified: llvm/trunk/include/llvm/Support/Mangler.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=93648&r1=93647&r2=93648&view=diff >> >> ============================================================================== >> --- llvm/trunk/include/llvm/Support/Mangler.h (original) >> +++ llvm/trunk/include/llvm/Support/Mangler.h Sat Jan 16 13:08:51 2010 >> @@ -47,15 +47,6 @@ >> /// "linker_private" linkage. >> const char *LinkerPrivatePrefix; >> >> - /// UseQuotes - If this is set, the target accepts global names in quotes, >> - /// e.g. "foo bar" is a legal name. This syntax is used instead of escaping >> - /// the space character. By default, this is false. >> - bool UseQuotes; >> - >> - /// SymbolsCanStartWithDigit - If this is set, the target allows symbols to >> - /// start with digits (e.g., "0x0021"). By default, this is false. >> - bool SymbolsCanStartWithDigit; >> - >> /// AnonGlobalIDs - We need to give global values the same name every time >> /// they are mangled. This keeps track of the number we give to anonymous >> /// ones. >> @@ -66,48 +57,12 @@ >> /// >> unsigned NextAnonGlobalID; >> >> - /// AcceptableChars - This bitfield contains a one for each character that is >> - /// allowed to be part of an unmangled name. >> - unsigned AcceptableChars[256 / 32]; >> - >> public: >> // Mangler ctor - if a prefix is specified, it will be prepended onto all >> // symbols. >> Mangler(Module &M, const char *Prefix = "", const char *privatePrefix = "", >> const char *linkerPrivatePrefix = ""); >> >> - /// setUseQuotes - If UseQuotes is set to true, this target accepts quoted >> - /// strings for assembler labels. >> - void setUseQuotes(bool Val) { UseQuotes = Val; } >> - >> - /// setSymbolsCanStartWithDigit - If SymbolsCanStartWithDigit is set to true, >> - /// this target allows symbols to start with digits. >> - void setSymbolsCanStartWithDigit(bool Val) { SymbolsCanStartWithDigit = Val; } >> - >> - /// Acceptable Characters - This allows the target to specify which characters >> - /// are acceptable to the assembler without being mangled. By default we >> - /// allow letters, numbers, '_', '$', '.', which is what GAS accepts, and '@'. >> - void markCharAcceptable(unsigned char X) { >> - AcceptableChars[X/32] |= 1 << (X&31); >> - } >> - void markCharUnacceptable(unsigned char X) { >> - AcceptableChars[X/32] &= ~(1 << (X&31)); >> - } >> - bool isCharAcceptable(unsigned char X) const { >> - return (AcceptableChars[X/32] & (1 << (X&31))) != 0; >> - } >> - >> - /// getMangledName - Returns the mangled name of V, an LLVM Value, >> - /// in the current module. If 'Suffix' is specified, the name ends with the >> - /// specified suffix. If 'ForcePrivate' is specified, the label is specified >> - /// to have a private label prefix. >> - /// >> - /// FIXME: This is deprecated, new code should use getNameWithPrefix and use >> - /// MCSymbol printing to handle quotes or not etc. >> - /// >> - std::string getMangledName(const GlobalValue *V, const char *Suffix = "", >> - bool ForcePrivate = false); >> - >> /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix >> /// and the specified global variable's name. If the global variable doesn't >> /// have a name, this fills in a unique name for the global. >> @@ -125,22 +80,6 @@ >> /// have a name, this fills in a unique name for the global. >> std::string getNameWithPrefix(const GlobalValue *GV, >> bool isImplicitlyPrivate = false); >> - >> -private: >> - /// makeNameProper - We don't want identifier names with ., space, or >> - /// - in them, so we mangle these characters into the strings "d_", >> - /// "s_", and "D_", respectively. This is a very simple mangling that >> - /// doesn't guarantee unique names for values. getValueName already >> - /// does this for you, so there's no point calling it on the result >> - /// from getValueName. >> - /// >> - /// FIXME: This is deprecated, new code should use getNameWithPrefix and use >> - /// MCSymbol printing to handle quotes or not etc. >> - /// >> - void makeNameProper(SmallVectorImpl &OutName, >> - const Twine &Name, >> - ManglerPrefixTy PrefixTy = Mangler::Default); >> - >> }; >> >> } // End llvm namespace >> >> Modified: llvm/trunk/lib/CodeGen/MachOWriter.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.cpp?rev=93648&r1=93647&r2=93648&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/MachOWriter.cpp (original) >> +++ llvm/trunk/lib/CodeGen/MachOWriter.cpp Sat Jan 16 13:08:51 2010 >> @@ -72,12 +72,6 @@ >> Mang = new Mangler(M, MAI->getGlobalPrefix(), MAI->getPrivateGlobalPrefix(), >> MAI->getLinkerPrivateGlobalPrefix()); >> >> - if (MAI->doesAllowQuotesInName()) >> - Mang->setUseQuotes(true); >> - >> - if (MAI->doesAllowNameToStartWithDigit()) >> - Mang->setSymbolsCanStartWithDigit(true); >> - >> // Initialize TargetLoweringObjectFile. >> TM.getTargetLowering()->getObjFileLowering().Initialize(OutContext, TM); >> >> >> Modified: llvm/trunk/lib/VMCore/Mangler.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=93648&r1=93647&r2=93648&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/VMCore/Mangler.cpp (original) >> +++ llvm/trunk/lib/VMCore/Mangler.cpp Sat Jan 16 13:08:51 2010 >> @@ -7,180 +7,17 @@ >> // >> //===----------------------------------------------------------------------===// >> // >> -// Unified name mangler for CWriter and assembly backends. >> +// Unified name mangler for assembly backends. >> // >> //===----------------------------------------------------------------------===// >> >> #include "llvm/Support/Mangler.h" >> -#include "llvm/Function.h" >> -#include "llvm/ADT/STLExtras.h" >> -#include "llvm/ADT/StringExtras.h" >> -#include "llvm/ADT/StringMap.h" >> +#include "llvm/GlobalValue.h" >> #include "llvm/ADT/SmallString.h" >> +#include "llvm/ADT/Twine.h" >> #include "llvm/Support/raw_ostream.h" >> using namespace llvm; >> >> -static char HexDigit(int V) { >> - return V < 10 ? V+'0' : V+'A'-10; >> -} >> - >> -static void MangleLetter(SmallVectorImpl &OutName, unsigned char C) { >> - OutName.push_back('_'); >> - OutName.push_back(HexDigit(C >> 4)); >> - OutName.push_back(HexDigit(C & 15)); >> - OutName.push_back('_'); >> -} >> - >> -/// makeNameProper - We don't want identifier names non-C-identifier characters >> -/// in them, so mangle them as appropriate. >> -/// >> -/// FIXME: This is deprecated, new code should use getNameWithPrefix and use >> -/// MCSymbol printing to handle quotes or not etc. >> -/// >> -void Mangler::makeNameProper(SmallVectorImpl &OutName, >> - const Twine &TheName, >> - ManglerPrefixTy PrefixTy) { >> - SmallString<256> TmpData; >> - StringRef X = TheName.toStringRef(TmpData); >> - assert(!X.empty() && "Cannot mangle empty strings"); >> - >> - if (!UseQuotes) { >> - // If X does not start with (char)1, add the prefix. >> - StringRef::iterator I = X.begin(); >> - if (*I == 1) { >> - ++I; // Skip over the no-prefix marker. >> - } else { >> - if (PrefixTy == Mangler::Private) >> - OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); >> - else if (PrefixTy == Mangler::LinkerPrivate) >> - OutName.append(LinkerPrivatePrefix, >> - LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); >> - OutName.append(Prefix, Prefix+strlen(Prefix)); >> - } >> - >> - // Mangle the first letter specially, don't allow numbers unless the target >> - // explicitly allows them. >> - if (!SymbolsCanStartWithDigit && *I >= '0' && *I <= '9') >> - MangleLetter(OutName, *I++); >> - >> - for (StringRef::iterator E = X.end(); I != E; ++I) { >> - if (!isCharAcceptable(*I)) >> - MangleLetter(OutName, *I); >> - else >> - OutName.push_back(*I); >> - } >> - return; >> - } >> - >> - bool NeedPrefix = true; >> - bool NeedQuotes = false; >> - StringRef::iterator I = X.begin(); >> - if (*I == 1) { >> - NeedPrefix = false; >> - ++I; // Skip over the marker. >> - } >> - >> - // If the first character is a number, we need quotes. >> - if (*I >= '0' && *I <= '9') >> - NeedQuotes = true; >> - >> - // Do an initial scan of the string, checking to see if we need quotes or >> - // to escape a '"' or not. >> - if (!NeedQuotes) >> - for (StringRef::iterator E = X.end(); I != E; ++I) >> - if (!isCharAcceptable(*I)) { >> - NeedQuotes = true; >> - break; >> - } >> - >> - // In the common case, we don't need quotes. Handle this quickly. >> - if (!NeedQuotes) { >> - if (!NeedPrefix) { >> - OutName.append(X.begin()+1, X.end()); // Strip off the \001. >> - return; >> - } >> - >> - if (PrefixTy == Mangler::Private) >> - OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); >> - else if (PrefixTy == Mangler::LinkerPrivate) >> - OutName.append(LinkerPrivatePrefix, >> - LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); >> - >> - if (Prefix[0] == 0) >> - ; // Common noop, no prefix. >> - else if (Prefix[1] == 0) >> - OutName.push_back(Prefix[0]); // Common, one character prefix. >> - else >> - OutName.append(Prefix, Prefix+strlen(Prefix)); // Arbitrary prefix. >> - OutName.append(X.begin(), X.end()); >> - return; >> - } >> - >> - // Add leading quote. >> - OutName.push_back('"'); >> - >> - // Add prefixes unless disabled. >> - if (NeedPrefix) { >> - if (PrefixTy == Mangler::Private) >> - OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); >> - else if (PrefixTy == Mangler::LinkerPrivate) >> - OutName.append(LinkerPrivatePrefix, >> - LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); >> - OutName.append(Prefix, Prefix+strlen(Prefix)); >> - } >> - >> - // Add the piece that we already scanned through. >> - OutName.append(X.begin()+!NeedPrefix, I); >> - >> - // Otherwise, construct the string the expensive way. >> - for (StringRef::iterator E = X.end(); I != E; ++I) { >> - if (*I == '"') { >> - const char *Quote = "_QQ_"; >> - OutName.append(Quote, Quote+4); >> - } else if (*I == '\n') { >> - const char *Newline = "_NL_"; >> - OutName.append(Newline, Newline+4); >> - } else >> - OutName.push_back(*I); >> - } >> - >> - // Add trailing quote. >> - OutName.push_back('"'); >> -} >> - >> -/// getMangledName - Returns the mangled name of V, an LLVM Value, >> -/// in the current module. If 'Suffix' is specified, the name ends with the >> -/// specified suffix. If 'ForcePrivate' is specified, the label is specified >> -/// to have a private label prefix. >> -/// >> -/// FIXME: This is deprecated, new code should use getNameWithPrefix and use >> -/// MCSymbol printing to handle quotes or not etc. >> -/// >> -std::string Mangler::getMangledName(const GlobalValue *GV, const char *Suffix, >> - bool ForcePrivate) { >> - assert((!isa(GV) || !cast(GV)->isIntrinsic()) && >> - "Intrinsic functions cannot be mangled by Mangler"); >> - >> - ManglerPrefixTy PrefixTy = >> - (GV->hasPrivateLinkage() || ForcePrivate) ? Mangler::Private : >> - GV->hasLinkerPrivateLinkage() ? Mangler::LinkerPrivate : Mangler::Default; >> - >> - SmallString<128> Result; >> - if (GV->hasName()) { >> - makeNameProper(Result, GV->getNameStr() + Suffix, PrefixTy); >> - return Result.str().str(); >> - } >> - >> - // Get the ID for the global, assigning a new one if we haven't got one >> - // already. >> - unsigned &ID = AnonGlobalIDs[GV]; >> - if (ID == 0) ID = NextAnonGlobalID++; >> - >> - // Must mangle the global into a unique ID. >> - makeNameProper(Result, "__unnamed_" + utostr(ID) + Suffix, PrefixTy); >> - return Result.str().str(); >> -} >> - >> /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix >> /// and the specified name as the global variable name. GVName must not be >> /// empty. >> @@ -263,21 +100,5 @@ >> Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix, >> const char *linkerPrivatePrefix) >> : Prefix(prefix), PrivatePrefix(privatePrefix), >> - LinkerPrivatePrefix(linkerPrivatePrefix), UseQuotes(false), >> - SymbolsCanStartWithDigit(false), NextAnonGlobalID(1) { >> - std::fill(AcceptableChars, array_endof(AcceptableChars), 0); >> - >> - // Letters and numbers are acceptable. >> - for (unsigned char X = 'a'; X <= 'z'; ++X) >> - markCharAcceptable(X); >> - for (unsigned char X = 'A'; X <= 'Z'; ++X) >> - markCharAcceptable(X); >> - for (unsigned char X = '0'; X <= '9'; ++X) >> - markCharAcceptable(X); >> - >> - // These chars are acceptable. >> - markCharAcceptable('_'); >> - markCharAcceptable('$'); >> - markCharAcceptable('.'); >> - markCharAcceptable('@'); >> + LinkerPrivatePrefix(linkerPrivatePrefix), NextAnonGlobalID(1) { >> } >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > > > -- > Rafael ?vila de Esp?ndola From sabre at nondot.org Sat Jan 16 14:56:06 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 20:56:06 -0000 Subject: [llvm-commits] [llvm] r93655 - /llvm/trunk/tools/lto/LTOCodeGenerator.cpp Message-ID: <201001162056.o0GKu6xk000560@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 14:56:05 2010 New Revision: 93655 URL: http://llvm.org/viewvc/llvm-project?rev=93655&view=rev Log: remove use of getMangledName. Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=93655&r1=93654&r2=93655&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Sat Jan 16 14:56:05 2010 @@ -335,7 +335,7 @@ for (Module::global_iterator v = mergedModule->global_begin(), e = mergedModule->global_end(); v != e; ++v) { if ( !v->isDeclaration() - && _mustPreserveSymbols.count(mangler.getMangledName(v)) ) + && _mustPreserveSymbols.count(mangler.getNameWithPrefix(v)) ) mustPreserveList.push_back(::strdup(v->getNameStr().c_str())); } passes.add(createInternalizePass(mustPreserveList)); From clattner at apple.com Sat Jan 16 14:56:48 2010 From: clattner at apple.com (Chris Lattner) Date: Sat, 16 Jan 2010 12:56:48 -0800 Subject: [llvm-commits] [llvm] r93631 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp In-Reply-To: <201001160617.o0G6Het2019338@zion.cs.uiuc.edu> References: <201001160617.o0G6Het2019338@zion.cs.uiuc.edu> Message-ID: On Jan 15, 2010, at 10:17 PM, Devang Patel wrote: > Author: dpatel > Date: Sat Jan 16 00:17:40 2010 > New Revision: 93631 > > URL: http://llvm.org/viewvc/llvm-project?rev=93631&view=rev > Log: > > No need to use WeakVH here. BTW, if you're worried about the pointer moving, it would be very reasonable to use AssertingVH. -Chris > > Modified: > llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp > > Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=93631&r1=93630&r2=93631&view=diff > > ============================================================================== > --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) > +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Sat Jan 16 00:17:40 2010 > @@ -165,8 +165,7 @@ > class DbgScope { > DbgScope *Parent; // Parent to this scope. > DIDescriptor Desc; // Debug info descriptor for scope. > - // FIXME : Use of WeakVH may be expensive here. > - WeakVH InlinedAtLocation; // Location at which scope is inlined. > + MDNode * InlinedAtLocation; // Location at which scope is inlined. > bool AbstractScope; // Abstract Scope > unsigned StartLabelID; // Label ID of the beginning of scope. > unsigned EndLabelID; // Label ID of the end of scope. > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Sat Jan 16 15:08:46 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 21:08:46 -0000 Subject: [llvm-commits] [llvm] r93656 - in /llvm/trunk: include/llvm/Support/Mangler.h lib/CodeGen/MachOWriter.cpp lib/VMCore/Mangler.cpp Message-ID: <201001162108.o0GL8kXq001064@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 15:08:46 2010 New Revision: 93656 URL: http://llvm.org/viewvc/llvm-project?rev=93656&view=rev Log: reapply the mangler gutting patch. Modified: llvm/trunk/include/llvm/Support/Mangler.h llvm/trunk/lib/CodeGen/MachOWriter.cpp llvm/trunk/lib/VMCore/Mangler.cpp Modified: llvm/trunk/include/llvm/Support/Mangler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=93656&r1=93655&r2=93656&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Mangler.h (original) +++ llvm/trunk/include/llvm/Support/Mangler.h Sat Jan 16 15:08:46 2010 @@ -47,15 +47,6 @@ /// "linker_private" linkage. const char *LinkerPrivatePrefix; - /// UseQuotes - If this is set, the target accepts global names in quotes, - /// e.g. "foo bar" is a legal name. This syntax is used instead of escaping - /// the space character. By default, this is false. - bool UseQuotes; - - /// SymbolsCanStartWithDigit - If this is set, the target allows symbols to - /// start with digits (e.g., "0x0021"). By default, this is false. - bool SymbolsCanStartWithDigit; - /// AnonGlobalIDs - We need to give global values the same name every time /// they are mangled. This keeps track of the number we give to anonymous /// ones. @@ -66,48 +57,12 @@ /// unsigned NextAnonGlobalID; - /// AcceptableChars - This bitfield contains a one for each character that is - /// allowed to be part of an unmangled name. - unsigned AcceptableChars[256 / 32]; - public: // Mangler ctor - if a prefix is specified, it will be prepended onto all // symbols. Mangler(Module &M, const char *Prefix = "", const char *privatePrefix = "", const char *linkerPrivatePrefix = ""); - /// setUseQuotes - If UseQuotes is set to true, this target accepts quoted - /// strings for assembler labels. - void setUseQuotes(bool Val) { UseQuotes = Val; } - - /// setSymbolsCanStartWithDigit - If SymbolsCanStartWithDigit is set to true, - /// this target allows symbols to start with digits. - void setSymbolsCanStartWithDigit(bool Val) { SymbolsCanStartWithDigit = Val; } - - /// Acceptable Characters - This allows the target to specify which characters - /// are acceptable to the assembler without being mangled. By default we - /// allow letters, numbers, '_', '$', '.', which is what GAS accepts, and '@'. - void markCharAcceptable(unsigned char X) { - AcceptableChars[X/32] |= 1 << (X&31); - } - void markCharUnacceptable(unsigned char X) { - AcceptableChars[X/32] &= ~(1 << (X&31)); - } - bool isCharAcceptable(unsigned char X) const { - return (AcceptableChars[X/32] & (1 << (X&31))) != 0; - } - - /// getMangledName - Returns the mangled name of V, an LLVM Value, - /// in the current module. If 'Suffix' is specified, the name ends with the - /// specified suffix. If 'ForcePrivate' is specified, the label is specified - /// to have a private label prefix. - /// - /// FIXME: This is deprecated, new code should use getNameWithPrefix and use - /// MCSymbol printing to handle quotes or not etc. - /// - std::string getMangledName(const GlobalValue *V, const char *Suffix = "", - bool ForcePrivate = false); - /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix /// and the specified global variable's name. If the global variable doesn't /// have a name, this fills in a unique name for the global. @@ -125,22 +80,6 @@ /// have a name, this fills in a unique name for the global. std::string getNameWithPrefix(const GlobalValue *GV, bool isImplicitlyPrivate = false); - -private: - /// makeNameProper - We don't want identifier names with ., space, or - /// - in them, so we mangle these characters into the strings "d_", - /// "s_", and "D_", respectively. This is a very simple mangling that - /// doesn't guarantee unique names for values. getValueName already - /// does this for you, so there's no point calling it on the result - /// from getValueName. - /// - /// FIXME: This is deprecated, new code should use getNameWithPrefix and use - /// MCSymbol printing to handle quotes or not etc. - /// - void makeNameProper(SmallVectorImpl &OutName, - const Twine &Name, - ManglerPrefixTy PrefixTy = Mangler::Default); - }; } // End llvm namespace Modified: llvm/trunk/lib/CodeGen/MachOWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.cpp?rev=93656&r1=93655&r2=93656&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachOWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/MachOWriter.cpp Sat Jan 16 15:08:46 2010 @@ -72,12 +72,6 @@ Mang = new Mangler(M, MAI->getGlobalPrefix(), MAI->getPrivateGlobalPrefix(), MAI->getLinkerPrivateGlobalPrefix()); - if (MAI->doesAllowQuotesInName()) - Mang->setUseQuotes(true); - - if (MAI->doesAllowNameToStartWithDigit()) - Mang->setSymbolsCanStartWithDigit(true); - // Initialize TargetLoweringObjectFile. TM.getTargetLowering()->getObjFileLowering().Initialize(OutContext, TM); Modified: llvm/trunk/lib/VMCore/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=93656&r1=93655&r2=93656&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Mangler.cpp (original) +++ llvm/trunk/lib/VMCore/Mangler.cpp Sat Jan 16 15:08:46 2010 @@ -7,180 +7,17 @@ // //===----------------------------------------------------------------------===// // -// Unified name mangler for CWriter and assembly backends. +// Unified name mangler for assembly backends. // //===----------------------------------------------------------------------===// #include "llvm/Support/Mangler.h" -#include "llvm/Function.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/StringMap.h" +#include "llvm/GlobalValue.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/Twine.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; -static char HexDigit(int V) { - return V < 10 ? V+'0' : V+'A'-10; -} - -static void MangleLetter(SmallVectorImpl &OutName, unsigned char C) { - OutName.push_back('_'); - OutName.push_back(HexDigit(C >> 4)); - OutName.push_back(HexDigit(C & 15)); - OutName.push_back('_'); -} - -/// makeNameProper - We don't want identifier names non-C-identifier characters -/// in them, so mangle them as appropriate. -/// -/// FIXME: This is deprecated, new code should use getNameWithPrefix and use -/// MCSymbol printing to handle quotes or not etc. -/// -void Mangler::makeNameProper(SmallVectorImpl &OutName, - const Twine &TheName, - ManglerPrefixTy PrefixTy) { - SmallString<256> TmpData; - StringRef X = TheName.toStringRef(TmpData); - assert(!X.empty() && "Cannot mangle empty strings"); - - if (!UseQuotes) { - // If X does not start with (char)1, add the prefix. - StringRef::iterator I = X.begin(); - if (*I == 1) { - ++I; // Skip over the no-prefix marker. - } else { - if (PrefixTy == Mangler::Private) - OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); - else if (PrefixTy == Mangler::LinkerPrivate) - OutName.append(LinkerPrivatePrefix, - LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); - OutName.append(Prefix, Prefix+strlen(Prefix)); - } - - // Mangle the first letter specially, don't allow numbers unless the target - // explicitly allows them. - if (!SymbolsCanStartWithDigit && *I >= '0' && *I <= '9') - MangleLetter(OutName, *I++); - - for (StringRef::iterator E = X.end(); I != E; ++I) { - if (!isCharAcceptable(*I)) - MangleLetter(OutName, *I); - else - OutName.push_back(*I); - } - return; - } - - bool NeedPrefix = true; - bool NeedQuotes = false; - StringRef::iterator I = X.begin(); - if (*I == 1) { - NeedPrefix = false; - ++I; // Skip over the marker. - } - - // If the first character is a number, we need quotes. - if (*I >= '0' && *I <= '9') - NeedQuotes = true; - - // Do an initial scan of the string, checking to see if we need quotes or - // to escape a '"' or not. - if (!NeedQuotes) - for (StringRef::iterator E = X.end(); I != E; ++I) - if (!isCharAcceptable(*I)) { - NeedQuotes = true; - break; - } - - // In the common case, we don't need quotes. Handle this quickly. - if (!NeedQuotes) { - if (!NeedPrefix) { - OutName.append(X.begin()+1, X.end()); // Strip off the \001. - return; - } - - if (PrefixTy == Mangler::Private) - OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); - else if (PrefixTy == Mangler::LinkerPrivate) - OutName.append(LinkerPrivatePrefix, - LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); - - if (Prefix[0] == 0) - ; // Common noop, no prefix. - else if (Prefix[1] == 0) - OutName.push_back(Prefix[0]); // Common, one character prefix. - else - OutName.append(Prefix, Prefix+strlen(Prefix)); // Arbitrary prefix. - OutName.append(X.begin(), X.end()); - return; - } - - // Add leading quote. - OutName.push_back('"'); - - // Add prefixes unless disabled. - if (NeedPrefix) { - if (PrefixTy == Mangler::Private) - OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); - else if (PrefixTy == Mangler::LinkerPrivate) - OutName.append(LinkerPrivatePrefix, - LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); - OutName.append(Prefix, Prefix+strlen(Prefix)); - } - - // Add the piece that we already scanned through. - OutName.append(X.begin()+!NeedPrefix, I); - - // Otherwise, construct the string the expensive way. - for (StringRef::iterator E = X.end(); I != E; ++I) { - if (*I == '"') { - const char *Quote = "_QQ_"; - OutName.append(Quote, Quote+4); - } else if (*I == '\n') { - const char *Newline = "_NL_"; - OutName.append(Newline, Newline+4); - } else - OutName.push_back(*I); - } - - // Add trailing quote. - OutName.push_back('"'); -} - -/// getMangledName - Returns the mangled name of V, an LLVM Value, -/// in the current module. If 'Suffix' is specified, the name ends with the -/// specified suffix. If 'ForcePrivate' is specified, the label is specified -/// to have a private label prefix. -/// -/// FIXME: This is deprecated, new code should use getNameWithPrefix and use -/// MCSymbol printing to handle quotes or not etc. -/// -std::string Mangler::getMangledName(const GlobalValue *GV, const char *Suffix, - bool ForcePrivate) { - assert((!isa(GV) || !cast(GV)->isIntrinsic()) && - "Intrinsic functions cannot be mangled by Mangler"); - - ManglerPrefixTy PrefixTy = - (GV->hasPrivateLinkage() || ForcePrivate) ? Mangler::Private : - GV->hasLinkerPrivateLinkage() ? Mangler::LinkerPrivate : Mangler::Default; - - SmallString<128> Result; - if (GV->hasName()) { - makeNameProper(Result, GV->getNameStr() + Suffix, PrefixTy); - return Result.str().str(); - } - - // Get the ID for the global, assigning a new one if we haven't got one - // already. - unsigned &ID = AnonGlobalIDs[GV]; - if (ID == 0) ID = NextAnonGlobalID++; - - // Must mangle the global into a unique ID. - makeNameProper(Result, "__unnamed_" + utostr(ID) + Suffix, PrefixTy); - return Result.str().str(); -} - /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix /// and the specified name as the global variable name. GVName must not be /// empty. @@ -263,21 +100,5 @@ Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix, const char *linkerPrivatePrefix) : Prefix(prefix), PrivatePrefix(privatePrefix), - LinkerPrivatePrefix(linkerPrivatePrefix), UseQuotes(false), - SymbolsCanStartWithDigit(false), NextAnonGlobalID(1) { - std::fill(AcceptableChars, array_endof(AcceptableChars), 0); - - // Letters and numbers are acceptable. - for (unsigned char X = 'a'; X <= 'z'; ++X) - markCharAcceptable(X); - for (unsigned char X = 'A'; X <= 'Z'; ++X) - markCharAcceptable(X); - for (unsigned char X = '0'; X <= '9'; ++X) - markCharAcceptable(X); - - // These chars are acceptable. - markCharAcceptable('_'); - markCharAcceptable('$'); - markCharAcceptable('.'); - markCharAcceptable('@'); + LinkerPrivatePrefix(linkerPrivatePrefix), NextAnonGlobalID(1) { } From sabre at nondot.org Sat Jan 16 15:20:35 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 21:20:35 -0000 Subject: [llvm-commits] [llvm] r93657 - /llvm/trunk/tools/lto/LTOModule.cpp Message-ID: <201001162120.o0GLKZrr001455@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 15:20:34 2010 New Revision: 93657 URL: http://llvm.org/viewvc/llvm-project?rev=93657&view=rev Log: remove calls to dead methods. Modified: llvm/trunk/tools/lto/LTOModule.cpp Modified: llvm/trunk/tools/lto/LTOModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=93657&r1=93656&r2=93657&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOModule.cpp (original) +++ llvm/trunk/tools/lto/LTOModule.cpp Sat Jan 16 15:20:34 2010 @@ -440,14 +440,6 @@ // Use mangler to add GlobalPrefix to names to match linker names. Mangler mangler(*_module, _target->getMCAsmInfo()->getGlobalPrefix()); - // add chars used in ObjC method names so method names aren't mangled - mangler.markCharAcceptable('['); - mangler.markCharAcceptable(']'); - mangler.markCharAcceptable('('); - mangler.markCharAcceptable(')'); - mangler.markCharAcceptable('-'); - mangler.markCharAcceptable('+'); - mangler.markCharAcceptable(' '); // add functions for (Module::iterator f = _module->begin(); f != _module->end(); ++f) { From sabre at nondot.org Sat Jan 16 15:25:13 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 21:25:13 -0000 Subject: [llvm-commits] [llvm] r93659 - /llvm/trunk/docs/ReleaseNotes.html Message-ID: <201001162125.o0GLPDki001610@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 15:25:13 2010 New Revision: 93659 URL: http://llvm.org/viewvc/llvm-project?rev=93659&view=rev Log: add a thing to investigate. Modified: llvm/trunk/docs/ReleaseNotes.html Modified: llvm/trunk/docs/ReleaseNotes.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes.html?rev=93659&r1=93658&r2=93659&view=diff ============================================================================== --- llvm/trunk/docs/ReleaseNotes.html (original) +++ llvm/trunk/docs/ReleaseNotes.html Sat Jan 16 15:25:13 2010 @@ -59,6 +59,7 @@ lib/Transforms/IPO/MergeFunctions.cpp => consider for 2.8. llvm/Analysis/PointerTracking.h => Edwin wants this, consider for 2.8. ABCD, SCCVN, GEPSplitterPass + MSIL backend? --> From sabre at nondot.org Sat Jan 16 15:34:01 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 21:34:01 -0000 Subject: [llvm-commits] [llvm] r93660 - /llvm/trunk/tools/bugpoint/Miscompilation.cpp Message-ID: <201001162134.o0GLY1oP001873@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 15:34:01 2010 New Revision: 93660 URL: http://llvm.org/viewvc/llvm-project?rev=93660&view=rev Log: bugpoint doesn't need the mangler at all. DisambiguateGlobalSymbols dates to a time when two different LLVM values could have the same name but different types. Simplify it to just assign names to unnamed things and let the core symtab resolve duplicates. Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/Miscompilation.cpp?rev=93660&r1=93659&r2=93660&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original) +++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Sat Jan 16 15:34:01 2010 @@ -22,7 +22,6 @@ #include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/Analysis/Verifier.h" -#include "llvm/Support/Mangler.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileUtilities.h" @@ -235,29 +234,18 @@ return TestFn(BD, ToOptimize, ToNotOptimize); } -/// DisambiguateGlobalSymbols - Mangle symbols to guarantee uniqueness by -/// modifying predominantly internal symbols rather than external ones. +/// DisambiguateGlobalSymbols - Give anonymous global values names. /// static void DisambiguateGlobalSymbols(Module *M) { - // Try not to cause collisions by minimizing chances of renaming an - // already-external symbol, so take in external globals and functions as-is. - // The code should work correctly without disambiguation (assuming the same - // mangler is used by the two code generators), but having symbols with the - // same name causes warnings to be emitted by the code generator. - Mangler Mang(*M); - // Agree with the CBE on symbol naming - Mang.markCharUnacceptable('.'); for (Module::global_iterator I = M->global_begin(), E = M->global_end(); I != E; ++I) { // Don't mangle asm names. - if (!I->hasName() || I->getName()[0] != 1) - I->setName(Mang.getNameWithPrefix(I)); + if (!I->hasName()) + I->setName("anon_global"); } for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) { - // Don't mangle asm names or intrinsics. - if ((!I->hasName() || I->getName()[0] != 1) && - I->getIntrinsicID() == 0) - I->setName(Mang.getNameWithPrefix(I)); + if (!I->hasName()) + I->setName("anon_fn"); } } @@ -548,10 +536,6 @@ ExtractLoops(BD, TestFn, MiscompiledFunctions)) { // Okay, we extracted some loops and the problem still appears. See if we // can eliminate some of the created functions from being candidates. - - // Loop extraction can introduce functions with the same name (foo_code). - // Make sure to disambiguate the symbols so that when the program is split - // apart that we can link it back together again. DisambiguateGlobalSymbols(BD.getProgram()); // Do the reduction... @@ -569,10 +553,6 @@ ExtractBlocks(BD, TestFn, MiscompiledFunctions)) { // Okay, we extracted some blocks and the problem still appears. See if we // can eliminate some of the created functions from being candidates. - - // Block extraction can introduce functions with the same name (foo_code). - // Make sure to disambiguate the symbols so that when the program is split - // apart that we can link it back together again. DisambiguateGlobalSymbols(BD.getProgram()); // Do the reduction... From sabre at nondot.org Sat Jan 16 15:34:51 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 21:34:51 -0000 Subject: [llvm-commits] [llvm] r93661 - /llvm/trunk/tools/bugpoint/Miscompilation.cpp Message-ID: <201001162134.o0GLYpWB001907@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 15:34:51 2010 New Revision: 93661 URL: http://llvm.org/viewvc/llvm-project?rev=93661&view=rev Log: remove obsolete comment. Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/Miscompilation.cpp?rev=93661&r1=93660&r2=93661&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original) +++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Sat Jan 16 15:34:51 2010 @@ -238,15 +238,12 @@ /// static void DisambiguateGlobalSymbols(Module *M) { for (Module::global_iterator I = M->global_begin(), E = M->global_end(); - I != E; ++I) { - // Don't mangle asm names. + I != E; ++I) if (!I->hasName()) I->setName("anon_global"); - } - for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) { + for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) if (!I->hasName()) I->setName("anon_fn"); - } } /// ExtractLoops - Given a reduced list of functions that still exposed the bug, From sabre at nondot.org Sat Jan 16 15:35:10 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 21:35:10 -0000 Subject: [llvm-commits] [llvm] r93662 - /llvm/trunk/include/llvm/LinkAllVMCore.h Message-ID: <201001162135.o0GLZA9m001926@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 15:35:09 2010 New Revision: 93662 URL: http://llvm.org/viewvc/llvm-project?rev=93662&view=rev Log: this doesn't need to suck in Mangler. Modified: llvm/trunk/include/llvm/LinkAllVMCore.h Modified: llvm/trunk/include/llvm/LinkAllVMCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllVMCore.h?rev=93662&r1=93661&r2=93662&view=diff ============================================================================== --- llvm/trunk/include/llvm/LinkAllVMCore.h (original) +++ llvm/trunk/include/llvm/LinkAllVMCore.h Sat Jan 16 15:35:09 2010 @@ -32,7 +32,6 @@ #include "llvm/System/Signals.h" #include "llvm/System/TimeValue.h" #include "llvm/Support/Dwarf.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/SlowOperationInformer.h" #include @@ -49,7 +48,6 @@ llvm::Module* M = new llvm::Module("", llvm::getGlobalContext()); (void)new llvm::UnreachableInst(llvm::getGlobalContext()); (void) llvm::createVerifierPass(); - (void) new llvm::Mangler(*M,""); } } ForceVMCoreLinking; } From sabre at nondot.org Sat Jan 16 15:55:24 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 21:55:24 -0000 Subject: [llvm-commits] [llvm] r93663 - /llvm/trunk/include/llvm/LinkAllVMCore.h Message-ID: <201001162155.o0GLtOji002563@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 15:55:24 2010 New Revision: 93663 URL: http://llvm.org/viewvc/llvm-project?rev=93663&view=rev Log: fix a warning. Modified: llvm/trunk/include/llvm/LinkAllVMCore.h Modified: llvm/trunk/include/llvm/LinkAllVMCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllVMCore.h?rev=93663&r1=93662&r2=93663&view=diff ============================================================================== --- llvm/trunk/include/llvm/LinkAllVMCore.h (original) +++ llvm/trunk/include/llvm/LinkAllVMCore.h Sat Jan 16 15:55:24 2010 @@ -45,7 +45,7 @@ // to know that getenv() never returns -1, this will do the job. if (std::getenv("bar") != (char*) -1) return; - llvm::Module* M = new llvm::Module("", llvm::getGlobalContext()); + (void)new llvm::Module("", llvm::getGlobalContext()); (void)new llvm::UnreachableInst(llvm::getGlobalContext()); (void) llvm::createVerifierPass(); } From sabre at nondot.org Sat Jan 16 15:57:07 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 16 Jan 2010 21:57:07 -0000 Subject: [llvm-commits] [llvm] r93664 - in /llvm/trunk: include/llvm/Support/ include/llvm/Target/ lib/CodeGen/ lib/CodeGen/AsmPrinter/ lib/Target/ lib/Target/CBackend/ lib/Target/PowerPC/AsmPrinter/ lib/Target/X86/ lib/Target/X86/AsmPrinter/ lib/VMCore/ tools/lto/ Message-ID: <201001162157.o0GLv7T6002649@zion.cs.uiuc.edu> Author: lattner Date: Sat Jan 16 15:57:06 2010 New Revision: 93664 URL: http://llvm.org/viewvc/llvm-project?rev=93664&view=rev Log: move the mangler into libtarget from vmcore. Added: llvm/trunk/include/llvm/Target/Mangler.h - copied, changed from r93656, llvm/trunk/include/llvm/Support/Mangler.h llvm/trunk/lib/Target/Mangler.cpp - copied, changed from r93656, llvm/trunk/lib/VMCore/Mangler.cpp Removed: llvm/trunk/include/llvm/Support/Mangler.h llvm/trunk/lib/VMCore/Mangler.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp llvm/trunk/lib/CodeGen/ELFWriter.cpp llvm/trunk/lib/CodeGen/MachOWriter.cpp llvm/trunk/lib/Target/CBackend/CBackend.cpp llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp llvm/trunk/tools/lto/LTOCodeGenerator.cpp llvm/trunk/tools/lto/LTOModule.cpp Removed: llvm/trunk/include/llvm/Support/Mangler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=93663&view=auto ============================================================================== --- llvm/trunk/include/llvm/Support/Mangler.h (original) +++ llvm/trunk/include/llvm/Support/Mangler.h (removed) @@ -1,87 +0,0 @@ -//===-- llvm/Support/Mangler.h - Self-contained name mangler ----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Unified name mangler for various backends. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_MANGLER_H -#define LLVM_SUPPORT_MANGLER_H - -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/SmallPtrSet.h" -#include - -namespace llvm { -class Twine; -class Type; -class Module; -class Value; -class GlobalValue; -template class SmallVectorImpl; - -class Mangler { -public: - enum ManglerPrefixTy { - Default, ///< Emit default string before each symbol. - Private, ///< Emit "private" prefix before each symbol. - LinkerPrivate ///< Emit "linker private" prefix before each symbol. - }; - -private: - /// Prefix - This string is added to each symbol that is emitted, unless the - /// symbol is marked as not needing this prefix. - const char *Prefix; - - /// PrivatePrefix - This string is emitted before each symbol with private - /// linkage. - const char *PrivatePrefix; - - /// LinkerPrivatePrefix - This string is emitted before each symbol with - /// "linker_private" linkage. - const char *LinkerPrivatePrefix; - - /// AnonGlobalIDs - We need to give global values the same name every time - /// they are mangled. This keeps track of the number we give to anonymous - /// ones. - /// - DenseMap AnonGlobalIDs; - - /// NextAnonGlobalID - This simple counter is used to unique value names. - /// - unsigned NextAnonGlobalID; - -public: - // Mangler ctor - if a prefix is specified, it will be prepended onto all - // symbols. - Mangler(Module &M, const char *Prefix = "", const char *privatePrefix = "", - const char *linkerPrivatePrefix = ""); - - /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix - /// and the specified global variable's name. If the global variable doesn't - /// have a name, this fills in a unique name for the global. - void getNameWithPrefix(SmallVectorImpl &OutName, const GlobalValue *GV, - bool isImplicitlyPrivate); - - /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix - /// and the specified name as the global variable name. GVName must not be - /// empty. - void getNameWithPrefix(SmallVectorImpl &OutName, const Twine &GVName, - ManglerPrefixTy PrefixTy = Mangler::Default); - - /// getNameWithPrefix - Return the name of the appropriate prefix - /// and the specified global variable's name. If the global variable doesn't - /// have a name, this fills in a unique name for the global. - std::string getNameWithPrefix(const GlobalValue *GV, - bool isImplicitlyPrivate = false); -}; - -} // End llvm namespace - -#endif // LLVM_SUPPORT_MANGLER_H Copied: llvm/trunk/include/llvm/Target/Mangler.h (from r93656, llvm/trunk/include/llvm/Support/Mangler.h) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/Mangler.h?p2=llvm/trunk/include/llvm/Target/Mangler.h&p1=llvm/trunk/include/llvm/Support/Mangler.h&r1=93656&r2=93664&rev=93664&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Mangler.h (original) +++ llvm/trunk/include/llvm/Target/Mangler.h Sat Jan 16 15:57:06 2010 @@ -15,7 +15,6 @@ #define LLVM_SUPPORT_MANGLER_H #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/SmallPtrSet.h" #include namespace llvm { Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93664&r1=93663&r2=93664&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sat Jan 16 15:57:06 2010 @@ -16,6 +16,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/Constants.h" #include "llvm/Module.h" +#include "llvm/CodeGen/DwarfWriter.h" #include "llvm/CodeGen/GCMetadataPrinter.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineFrameInfo.h" @@ -23,7 +24,6 @@ #include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/CodeGen/MachineLoopInfo.h" #include "llvm/CodeGen/MachineModuleInfo.h" -#include "llvm/CodeGen/DwarfWriter.h" #include "llvm/Analysis/DebugInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCInst.h" @@ -33,8 +33,8 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Mangler.h" #include "llvm/MC/MCAsmInfo.h" +#include "llvm/Target/Mangler.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetLowering.h" Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=93664&r1=93663&r2=93664&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Sat Jan 16 15:57:06 2010 @@ -18,6 +18,7 @@ #include "llvm/MC/MCSection.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCAsmInfo.h" +#include "llvm/Target/Mangler.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetLoweringObjectFile.h" @@ -25,7 +26,6 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/Timer.h" #include "llvm/System/Path.h" using namespace llvm; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=93664&r1=93663&r2=93664&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Sat Jan 16 15:57:06 2010 @@ -23,13 +23,13 @@ #include "llvm/MC/MCSection.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" +#include "llvm/Target/Mangler.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Support/Dwarf.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/SmallString.h" Modified: llvm/trunk/lib/CodeGen/ELFWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ELFWriter.cpp?rev=93664&r1=93663&r2=93664&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ELFWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/ELFWriter.cpp Sat Jan 16 15:57:06 2010 @@ -45,6 +45,7 @@ #include "llvm/MC/MCContext.h" #include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCAsmInfo.h" +#include "llvm/Target/Mangler.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetELFWriterInfo.h" #include "llvm/Target/TargetLowering.h" @@ -52,7 +53,6 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/SmallString.h" using namespace llvm; Modified: llvm/trunk/lib/CodeGen/MachOWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.cpp?rev=93664&r1=93663&r2=93664&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachOWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/MachOWriter.cpp Sat Jan 16 15:57:06 2010 @@ -33,8 +33,8 @@ #include "llvm/MC/MCStreamer.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Target/Mangler.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetLoweringObjectFile.h" Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=93664&r1=93663&r2=93664&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Sat Jan 16 15:57:06 2010 @@ -33,6 +33,7 @@ #include "llvm/Analysis/ValueTracking.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/IntrinsicLowering.h" +#include "llvm/Target/Mangler.h" #include "llvm/Transforms/Scalar.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCSymbol.h" @@ -44,7 +45,6 @@ #include "llvm/Support/FormattedStream.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/InstVisitor.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/MathExtras.h" #include "llvm/System/Host.h" #include "llvm/Config/config.h" Copied: llvm/trunk/lib/Target/Mangler.cpp (from r93656, llvm/trunk/lib/VMCore/Mangler.cpp) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mangler.cpp?p2=llvm/trunk/lib/Target/Mangler.cpp&p1=llvm/trunk/lib/VMCore/Mangler.cpp&r1=93656&r2=93664&rev=93664&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Mangler.cpp (original) +++ llvm/trunk/lib/Target/Mangler.cpp Sat Jan 16 15:57:06 2010 @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Support/Mangler.h" +#include "llvm/Target/Mangler.h" #include "llvm/GlobalValue.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=93664&r1=93663&r2=93664&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Sat Jan 16 15:57:06 2010 @@ -36,12 +36,12 @@ #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" +#include "llvm/Target/Mangler.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegistry.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=93664&r1=93663&r2=93664&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Sat Jan 16 15:57:06 2010 @@ -22,11 +22,11 @@ #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSymbol.h" +#include "llvm/Target/Mangler.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" @@ -300,6 +300,7 @@ IsIndirect = false; IsPCRel = false; + // FIXME: Use GetGlobalValueSymbol. SmallString<128> Name; Mang->getNameWithPrefix(Name, GV, false); return MCSymbolRefExpr::Create(Name.str(), getContext()); Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=93664&r1=93663&r2=93664&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Sat Jan 16 15:57:06 2010 @@ -21,11 +21,9 @@ #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" #include "llvm/MC/MCStreamer.h" -#include "llvm/Support/ErrorHandling.h" +#include "llvm/Target/Mangler.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Mangler.h" #include "llvm/ADT/SmallString.h" -#include "llvm/Analysis/DebugInfo.h" using namespace llvm; Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=93664&r1=93663&r2=93664&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Sat Jan 16 15:57:06 2010 @@ -8,11 +8,11 @@ //===----------------------------------------------------------------------===// #include "X86TargetObjectFile.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/Support/Mangler.h" +#include "llvm/CodeGen/MachineModuleInfoImpls.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCExpr.h" -#include "llvm/CodeGen/MachineModuleInfoImpls.h" +#include "llvm/Target/Mangler.h" +#include "llvm/ADT/SmallString.h" using namespace llvm; const MCExpr *X8632_MachoTargetObjectFile:: @@ -27,6 +27,7 @@ MachineModuleInfoMachO &MachOMMI = MMI->getObjFileInfo(); + // FIXME: Use GetSymbolWithGlobalValueBase. SmallString<128> Name; Mang->getNameWithPrefix(Name, GV, true); Name += "$non_lazy_ptr"; Removed: llvm/trunk/lib/VMCore/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=93663&view=auto ============================================================================== --- llvm/trunk/lib/VMCore/Mangler.cpp (original) +++ llvm/trunk/lib/VMCore/Mangler.cpp (removed) @@ -1,104 +0,0 @@ -//===-- Mangler.cpp - Self-contained c/asm llvm name mangler --------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Unified name mangler for assembly backends. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/Mangler.h" -#include "llvm/GlobalValue.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/ADT/Twine.h" -#include "llvm/Support/raw_ostream.h" -using namespace llvm; - -/// getNameWithPrefix - Fill OutName with the name of the appropriate prefix -/// and the specified name as the global variable name. GVName must not be -/// empty. -void Mangler::getNameWithPrefix(SmallVectorImpl &OutName, - const Twine &GVName, ManglerPrefixTy PrefixTy) { - SmallString<256> TmpData; - StringRef Name = GVName.toStringRef(TmpData); - assert(!Name.empty() && "getNameWithPrefix requires non-empty name"); - - // If the global name is not led with \1, add the appropriate prefixes. - if (Name[0] != '\1') { - if (PrefixTy == Mangler::Private) - OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); - else if (PrefixTy == Mangler::LinkerPrivate) - OutName.append(LinkerPrivatePrefix, - LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); - - if (Prefix[0] == 0) - ; // Common noop, no prefix. - else if (Prefix[1] == 0) - OutName.push_back(Prefix[0]); // Common, one character prefix. - else - OutName.append(Prefix, Prefix+strlen(Prefix)); // Arbitrary prefix. - } else { - Name = Name.substr(1); - } - - OutName.append(Name.begin(), Name.end()); -} - - -/// getNameWithPrefix - Fill OutName with the name of the appropriate prefix -/// and the specified global variable's name. If the global variable doesn't -/// have a name, this fills in a unique name for the global. -void Mangler::getNameWithPrefix(SmallVectorImpl &OutName, - const GlobalValue *GV, - bool isImplicitlyPrivate) { - // If this global has a name, handle it simply. - if (GV->hasName()) { - ManglerPrefixTy PrefixTy = Mangler::Default; - if (GV->hasPrivateLinkage() || isImplicitlyPrivate) - PrefixTy = Mangler::Private; - else if (GV->hasLinkerPrivateLinkage()) - PrefixTy = Mangler::LinkerPrivate; - - return getNameWithPrefix(OutName, GV->getName(), PrefixTy); - } - - // If the global variable doesn't have a name, return a unique name for the - // global based on a numbering. - - // Anonymous names always get prefixes. - if (GV->hasPrivateLinkage() || isImplicitlyPrivate) - OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); - else if (GV->hasLinkerPrivateLinkage()) - OutName.append(LinkerPrivatePrefix, - LinkerPrivatePrefix+strlen(LinkerPrivatePrefix));; - OutName.append(Prefix, Prefix+strlen(Prefix)); - - // Get the ID for the global, assigning a new one if we haven't got one - // already. - unsigned &ID = AnonGlobalIDs[GV]; - if (ID == 0) ID = NextAnonGlobalID++; - - // Must mangle the global into a unique ID. - raw_svector_ostream(OutName) << "__unnamed_" << ID; -} - -/// getNameWithPrefix - Fill OutName with the name of the appropriate prefix -/// and the specified global variable's name. If the global variable doesn't -/// have a name, this fills in a unique name for the global. -std::string Mangler::getNameWithPrefix(const GlobalValue *GV, - bool isImplicitlyPrivate) { - SmallString<64> Buf; - getNameWithPrefix(Buf, GV, isImplicitlyPrivate); - return std::string(Buf.begin(), Buf.end()); -} - - -Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix, - const char *linkerPrivatePrefix) - : Prefix(prefix), PrivatePrefix(privatePrefix), - LinkerPrivatePrefix(linkerPrivatePrefix), NextAnonGlobalID(1) { -} Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=93664&r1=93663&r2=93664&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Sat Jan 16 15:57:06 2010 @@ -32,13 +32,13 @@ #include "llvm/CodeGen/FileWriters.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/StandardPasses.h" #include "llvm/Support/SystemUtils.h" #include "llvm/System/Host.h" #include "llvm/System/Program.h" #include "llvm/System/Signals.h" +#include "llvm/Target/Mangler.h" #include "llvm/Target/SubtargetFeature.h" #include "llvm/Target/TargetOptions.h" #include "llvm/MC/MCAsmInfo.h" Modified: llvm/trunk/tools/lto/LTOModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=93664&r1=93663&r2=93664&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOModule.cpp (original) +++ llvm/trunk/tools/lto/LTOModule.cpp Sat Jan 16 15:57:06 2010 @@ -22,12 +22,12 @@ #include "llvm/ADT/Triple.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Support/SystemUtils.h" -#include "llvm/Support/Mangler.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MathExtras.h" #include "llvm/System/Host.h" #include "llvm/System/Path.h" #include "llvm/System/Process.h" +#include "llvm/Target/Mangler.h" #include "llvm/Target/SubtargetFeature.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/Target/TargetMachine.h" From benny.kra at googlemail.com Sat Jan 16 16:23:09 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 16 Jan 2010 22:23:09 -0000 Subject: [llvm-commits] [llvm] r93665 - in /llvm/trunk/lib: Target/CMakeLists.txt VMCore/CMakeLists.txt Message-ID: <201001162223.o0GMNAUY003726@zion.cs.uiuc.edu> Author: d0k Date: Sat Jan 16 16:23:09 2010 New Revision: 93665 URL: http://llvm.org/viewvc/llvm-project?rev=93665&view=rev Log: Update CMake files for Mangler move. Modified: llvm/trunk/lib/Target/CMakeLists.txt llvm/trunk/lib/VMCore/CMakeLists.txt Modified: llvm/trunk/lib/Target/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CMakeLists.txt?rev=93665&r1=93664&r2=93665&view=diff ============================================================================== --- llvm/trunk/lib/Target/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/CMakeLists.txt Sat Jan 16 16:23:09 2010 @@ -1,4 +1,5 @@ add_llvm_library(LLVMTarget + Mangler.cpp SubtargetFeature.cpp Target.cpp TargetData.cpp Modified: llvm/trunk/lib/VMCore/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/CMakeLists.txt?rev=93665&r1=93664&r2=93665&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/CMakeLists.txt (original) +++ llvm/trunk/lib/VMCore/CMakeLists.txt Sat Jan 16 16:23:09 2010 @@ -16,7 +16,6 @@ IRBuilder.cpp LLVMContext.cpp LeakDetector.cpp - Mangler.cpp Metadata.cpp Module.cpp ModuleProvider.cpp From stuart at apple.com Sat Jan 16 16:51:43 2010 From: stuart at apple.com (Stuart Hastings) Date: Sat, 16 Jan 2010 14:51:43 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r93649 - /llvm-gcc-4.2/trunk/gcc/config/i386/i386.c In-Reply-To: <99DBD1F9-FD01-4F1D-9531-CA05A7F1A95B@apple.com> References: <201001161930.o0GJUJae029974@zion.cs.uiuc.edu> <99DBD1F9-FD01-4F1D-9531-CA05A7F1A95B@apple.com> Message-ID: <64ADABB3-BDA9-46F3-A58D-6999A58BB582@apple.com> On Jan 16, 2010, at 11:59 AM, Eric Christopher wrote: > > On Jan 16, 2010, at 11:30 AM, Stuart Hastings wrote: > >> The previous patch corrected the 128-bit store into a 96-bit struct, >> but it mistakenly passed a 128-bit aligned 32-bit struct as a 128-bit >> object. > > Have you managed to run the structure compatibility tests yet? Yes. Also at 32-bit, not that I expected a problem there. stuart From kennethuil at gmail.com Sat Jan 16 17:37:33 2010 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Sat, 16 Jan 2010 23:37:33 -0000 Subject: [llvm-commits] [llvm] r93667 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp test/CodeGen/X86/bigstructret2.ll Message-ID: <201001162337.o0GNbYwJ006321@zion.cs.uiuc.edu> Author: kennethuil Date: Sat Jan 16 17:37:33 2010 New Revision: 93667 URL: http://llvm.org/viewvc/llvm-project?rev=93667&view=rev Log: When checking for sret-demotion, it needs to use legal types. When using the return value of an sret-demoted call, it needs to use possibly illegal types that match the declared Type of the callee. Added: llvm/trunk/test/CodeGen/X86/bigstructret2.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=93667&r1=93666&r2=93667&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Sat Jan 16 17:37:33 2010 @@ -800,18 +800,19 @@ SDNodeOrder, Chain, NULL); } -/// Get the EVTs and ArgFlags collections that represent the return type -/// of the given function. This does not require a DAG or a return value, and -/// is suitable for use before any DAGs for the function are constructed. +/// Get the EVTs and ArgFlags collections that represent the legalized return +/// type of the given function. This does not require a DAG or a return value, +/// and is suitable for use before any DAGs for the function are constructed. static void getReturnInfo(const Type* ReturnType, Attributes attr, SmallVectorImpl &OutVTs, SmallVectorImpl &OutFlags, TargetLowering &TLI, SmallVectorImpl *Offsets = 0) { SmallVector ValueVTs; - ComputeValueVTs(TLI, ReturnType, ValueVTs, Offsets); + ComputeValueVTs(TLI, ReturnType, ValueVTs); unsigned NumValues = ValueVTs.size(); - if ( NumValues == 0 ) return; + if (NumValues == 0) return; + unsigned Offset = 0; for (unsigned j = 0, f = NumValues; j != f; ++j) { EVT VT = ValueVTs[j]; @@ -834,6 +835,9 @@ unsigned NumParts = TLI.getNumRegisters(ReturnType->getContext(), VT); EVT PartVT = TLI.getRegisterType(ReturnType->getContext(), VT); + unsigned PartSize = TLI.getTargetData()->getTypeAllocSize( + PartVT.getTypeForEVT(ReturnType->getContext())); + // 'inreg' on function refers to return value ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy(); if (attr & Attribute::InReg) @@ -848,6 +852,11 @@ for (unsigned i = 0; i < NumParts; ++i) { OutVTs.push_back(PartVT); OutFlags.push_back(Flags); + if (Offsets) + { + Offsets->push_back(Offset); + Offset += PartSize; + } } } } @@ -5098,16 +5107,37 @@ SDValue Chain = DAG.getNode(ISD::TokenFactor, getCurDebugLoc(), MVT::Other, &Chains[0], NumValues); PendingLoads.push_back(Chain); + + // Collect the legal value parts into potentially illegal values + // that correspond to the original function's return values. + SmallVector RetTys; + RetTy = FTy->getReturnType(); + ComputeValueVTs(TLI, RetTy, RetTys); + ISD::NodeType AssertOp = ISD::DELETED_NODE; + SmallVector ReturnValues; + unsigned CurReg = 0; + for (unsigned I = 0, E = RetTys.size(); I != E; ++I) { + EVT VT = RetTys[I]; + EVT RegisterVT = TLI.getRegisterType(RetTy->getContext(), VT); + unsigned NumRegs = TLI.getNumRegisters(RetTy->getContext(), VT); + + SDValue ReturnValue = + getCopyFromParts(DAG, getCurDebugLoc(), SDNodeOrder, &Values[CurReg], NumRegs, + RegisterVT, VT, AssertOp); + ReturnValues.push_back(ReturnValue); + if (DisableScheduling) + DAG.AssignOrdering(ReturnValue.getNode(), SDNodeOrder); + CurReg += NumRegs; + } + SDValue Res = DAG.getNode(ISD::MERGE_VALUES, getCurDebugLoc(), + DAG.getVTList(&RetTys[0], RetTys.size()), + &ReturnValues[0], ReturnValues.size()); - SDValue MV = DAG.getNode(ISD::MERGE_VALUES, - getCurDebugLoc(), - DAG.getVTList(&OutVTs[0], NumValues), - &Values[0], NumValues); - setValue(CS.getInstruction(), MV); + setValue(CS.getInstruction(), Res); if (DisableScheduling) { DAG.AssignOrdering(Chain.getNode(), SDNodeOrder); - DAG.AssignOrdering(MV.getNode(), SDNodeOrder); + DAG.AssignOrdering(Res.getNode(), SDNodeOrder); } } Added: llvm/trunk/test/CodeGen/X86/bigstructret2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/bigstructret2.ll?rev=93667&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/bigstructret2.ll (added) +++ llvm/trunk/test/CodeGen/X86/bigstructret2.ll Sat Jan 16 17:37:33 2010 @@ -0,0 +1,12 @@ +; RUN: llc < %s -march=x86 -o %t + +%0 = type { i64, i64 } + +declare fastcc %0 @ReturnBigStruct() nounwind readnone + +define void @test(%0* %p) { + %1 = call fastcc %0 @ReturnBigStruct() + store %0 %1, %0* %p + ret void +} + From isanbard at gmail.com Sat Jan 16 18:21:21 2010 From: isanbard at gmail.com (Bill Wendling) Date: Sun, 17 Jan 2010 00:21:21 -0000 Subject: [llvm-commits] [llvm] r93669 - in /llvm/trunk/test/Transforms/InstCombine: fsub-fadd.ll fsub-fsub.ll fsub.ll Message-ID: <201001170021.o0H0LL9p007804@zion.cs.uiuc.edu> Author: void Date: Sat Jan 16 18:21:21 2010 New Revision: 93669 URL: http://llvm.org/viewvc/llvm-project?rev=93669&view=rev Log: Reduce fsub-fadd.ll and merge it into fsub-fsub.ll. Rename fsub-fsub.ll to fsub.ll and FileCheckify it. Added: llvm/trunk/test/Transforms/InstCombine/fsub.ll - copied, changed from r93635, llvm/trunk/test/Transforms/InstCombine/fsub-fsub.ll Removed: llvm/trunk/test/Transforms/InstCombine/fsub-fadd.ll llvm/trunk/test/Transforms/InstCombine/fsub-fsub.ll Removed: llvm/trunk/test/Transforms/InstCombine/fsub-fadd.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fsub-fadd.ll?rev=93668&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/fsub-fadd.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/fsub-fadd.ll (removed) @@ -1,39 +0,0 @@ -; RUN: opt < %s -instcombine -S | FileCheck %s -; - -define void @func(double* %rhi, double* %rlo, double %xh, double %xl, double %yh, double %yl) nounwind ssp { -entry: - %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] - %tmp = fmul double %xh, 0x41A0000002000000 ; [#uses=2] - %tmp1 = fsub double %xh, %tmp ; [#uses=1] - %tmp2 = fadd double %tmp1, %tmp ; [#uses=3] - %tmp3 = fsub double %xh, %tmp2 ; [#uses=2] - %tmp4 = fmul double %yh, 0x41A0000002000000 ; [#uses=2] - %tmp5 = fsub double %yh, %tmp4 ; [#uses=1] - %tmp6 = fadd double %tmp5, %tmp4 ; [#uses=3] - %tmp7 = fsub double %yh, %tmp6 ; [#uses=2] - %tmp8 = fmul double %xh, %yh ; [#uses=3] - %tmp9 = fmul double %tmp2, %tmp6 ; [#uses=1] - %tmp10 = fsub double %tmp9, %tmp8 ; [#uses=1] - %tmp11 = fmul double %tmp2, %tmp7 ; [#uses=1] - %tmp12 = fadd double %tmp10, %tmp11 ; [#uses=1] - %tmp13 = fmul double %tmp3, %tmp6 ; [#uses=1] - %tmp14 = fadd double %tmp12, %tmp13 ; [#uses=1] - %tmp15 = fmul double %tmp3, %tmp7 ; [#uses=1] - %tmp16 = fadd double %tmp14, %tmp15 ; [#uses=1] - %tmp17 = fmul double %xh, %yl ; [#uses=1] - %tmp18 = fmul double %xl, %yh ; [#uses=1] - %tmp19 = fadd double %tmp17, %tmp18 ; [#uses=1] - %tmp20 = fadd double %tmp19, %tmp16 ; [#uses=2] - %tmp21 = fadd double %tmp8, %tmp20 ; [#uses=1] - store double %tmp21, double* %rhi, align 8 - %tmp22 = load double* %rhi, align 8 ; [#uses=1] - %tmp23 = fsub double %tmp8, %tmp22 ; [#uses=1] - %tmp24 = fadd double %tmp23, %tmp20 ; [#uses=1] - -; CHECK: %tmp23 = fsub double %tmp8, %tmp21 -; CHECK: %tmp24 = fadd double %tmp23, %tmp20 - - store double %tmp24, double* %rlo, align 8 - ret void -} Removed: llvm/trunk/test/Transforms/InstCombine/fsub-fsub.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fsub-fsub.ll?rev=93668&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/fsub-fsub.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/fsub-fsub.ll (removed) @@ -1,8 +0,0 @@ -; RUN: opt < %s -instcombine -S | grep fsub | count 2 -; PR4374 - -define float @func(float %a, float %b) nounwind { - %tmp3 = fsub float %a, %b - %tmp4 = fsub float -0.000000e+00, %tmp3 - ret float %tmp4 -} Copied: llvm/trunk/test/Transforms/InstCombine/fsub.ll (from r93635, llvm/trunk/test/Transforms/InstCombine/fsub-fsub.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fsub.ll?p2=llvm/trunk/test/Transforms/InstCombine/fsub.ll&p1=llvm/trunk/test/Transforms/InstCombine/fsub-fsub.ll&r1=93635&r2=93669&rev=93669&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/fsub-fsub.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/fsub.ll Sat Jan 16 18:21:21 2010 @@ -1,8 +1,23 @@ -; RUN: opt < %s -instcombine -S | grep fsub | count 2 +; RUN: opt < %s -instcombine -S | FileCheck %s + ; PR4374 +define float @test1(float %a, float %b) nounwind { + %t1 = fsub float %a, %b + %t2 = fsub float -0.000000e+00, %t1 + +; CHECK: %t1 = fsub float %a, %b +; CHECK-NEXT: %t2 = fsub float -0.000000e+00, %t1 + + ret float %t2 +} + +; +define double @test2(double %x, double %y) nounwind { + %t1 = fadd double %x, %y + %t2 = fsub double %x, %t1 + +; CHECK: %t1 = fadd double %x, %y +; CHECK-NEXT: %t2 = fsub double %x, %t1 -define float @func(float %a, float %b) nounwind { - %tmp3 = fsub float %a, %b - %tmp4 = fsub float -0.000000e+00, %tmp3 - ret float %tmp4 + ret double %t2 } From isanbard at gmail.com Sat Jan 16 18:22:10 2010 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 16 Jan 2010 16:22:10 -0800 Subject: [llvm-commits] [llvm] r93369 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineAddSub.cpp test/Transforms/InstCombine/fsub-fadd.ll In-Reply-To: <6DE216F9-6246-4C21-A4D0-03E5FFB8D652@apple.com> References: <201001132323.o0DNNIpO026876@zion.cs.uiuc.edu> <6DE216F9-6246-4C21-A4D0-03E5FFB8D652@apple.com> Message-ID: <6209AEB5-31B6-440B-978D-C35E16086303@gmail.com> On Jan 15, 2010, at 11:55 AM, Chris Lattner wrote: > Hi Bill, > > The patch is fine, but please reduce the testcase to the minimum needed to repro the issue ("X-(X+Y) == -Y") and add it to an existing .ll file. > Done. :) -bw From natebegeman at mac.com Sat Jan 16 21:49:02 2010 From: natebegeman at mac.com (Nate Begeman) Date: Sun, 17 Jan 2010 03:49:02 -0000 Subject: [llvm-commits] [llvm] r93670 - in /llvm/trunk/lib: CodeGen/MachOWriter.cpp MC/MCMachOStreamer.cpp Message-ID: <201001170349.o0H3n2lV014089@zion.cs.uiuc.edu> Author: sampo Date: Sat Jan 16 21:49:01 2010 New Revision: 93670 URL: http://llvm.org/viewvc/llvm-project?rev=93670&view=rev Log: Add a note for the macho streamer and remove a used of the mangler from the soon to be defunct machowriter pass. Modified: llvm/trunk/lib/CodeGen/MachOWriter.cpp llvm/trunk/lib/MC/MCMachOStreamer.cpp Modified: llvm/trunk/lib/CodeGen/MachOWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.cpp?rev=93670&r1=93669&r2=93670&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachOWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/MachOWriter.cpp Sat Jan 16 21:49:01 2010 @@ -69,9 +69,6 @@ } bool MachOWriter::doInitialization(Module &M) { - Mang = new Mangler(M, MAI->getGlobalPrefix(), MAI->getPrivateGlobalPrefix(), - MAI->getLinkerPrivateGlobalPrefix()); - // Initialize TargetLoweringObjectFile. TM.getTargetLowering()->getObjFileLowering().Initialize(OutContext, TM); @@ -81,9 +78,6 @@ /// doFinalization - Now that the module has been completely processed, emit /// the Mach-O file to 'O'. bool MachOWriter::doFinalization(Module &M) { - // Release the name mangler object. - delete Mang; Mang = 0; - OutStreamer.Finish(); return false; } Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=93670&r1=93669&r2=93670&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Sat Jan 16 21:49:01 2010 @@ -353,6 +353,8 @@ if (!Emitter) llvm_unreachable("no code emitter available!"); + // FIXME: Emitting an instruction should cause S_ATTR_SOME_INSTRUCTIONS to + // be set for the current section. // FIXME: Relocations! SmallString<256> Code; raw_svector_ostream VecOS(Code); From rafael.espindola at gmail.com Sat Jan 16 22:44:57 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sun, 17 Jan 2010 04:44:57 -0000 Subject: [llvm-commits] [llvm] r93671 - /llvm/trunk/test/FrontendC/pr5406.c Message-ID: <201001170444.o0H4iwPk015644@zion.cs.uiuc.edu> Author: rafael Date: Sat Jan 16 22:44:55 2010 New Revision: 93671 URL: http://llvm.org/viewvc/llvm-project?rev=93671&view=rev Log: Add test for pr5406 Added: llvm/trunk/test/FrontendC/pr5406.c Added: llvm/trunk/test/FrontendC/pr5406.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/pr5406.c?rev=93671&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/pr5406.c (added) +++ llvm/trunk/test/FrontendC/pr5406.c Sat Jan 16 22:44:55 2010 @@ -0,0 +1,20 @@ +// RUN: %llvmgcc %s -S -emit-llvm -O0 -o - | FileCheck %s +// PR 5406 + +// ARM test. +// XFAIL: !arm + +typedef struct { char x[3]; } A0; +void foo (int i, ...); + + +// CHECK: call arm_aapcscc void (i32, ...)* @foo(i32 1, i32 {{.*}}) nounwind +int main (void) +{ + A0 a3; + a3.x[0] = 0; + a3.x[0] = 0; + a3.x[2] = 26; + foo (1, a3 ); + return 0; +} From rafael.espindola at gmail.com Sat Jan 16 23:40:43 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sun, 17 Jan 2010 05:40:43 -0000 Subject: [llvm-commits] [llvm] r93672 - /llvm/trunk/test/FrontendC/pr5406.c Message-ID: <201001170540.o0H5ehB0017231@zion.cs.uiuc.edu> Author: rafael Date: Sat Jan 16 23:40:41 2010 New Revision: 93672 URL: http://llvm.org/viewvc/llvm-project?rev=93672&view=rev Log: Looks like XFAIL has to list every unsupported arch Modified: llvm/trunk/test/FrontendC/pr5406.c Modified: llvm/trunk/test/FrontendC/pr5406.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/pr5406.c?rev=93672&r1=93671&r2=93672&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/pr5406.c (original) +++ llvm/trunk/test/FrontendC/pr5406.c Sat Jan 16 23:40:41 2010 @@ -2,7 +2,7 @@ // PR 5406 // ARM test. -// XFAIL: !arm +// XFAIL: sparc,powerpc,alpha,x86,mips,xcore,cellspu,blackfin,pic16,systemz typedef struct { char x[3]; } A0; void foo (int i, ...); From bob.wilson at apple.com Sat Jan 16 23:58:24 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Sun, 17 Jan 2010 05:58:24 -0000 Subject: [llvm-commits] [llvm] r93673 - /llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Message-ID: <201001170558.o0H5wOmY017690@zion.cs.uiuc.edu> Author: bwilson Date: Sat Jan 16 23:58:23 2010 New Revision: 93673 URL: http://llvm.org/viewvc/llvm-project?rev=93673&view=rev Log: Fix an off-by-one error that caused the chain operand to be dropped from Neon vector load-lane and store-lane instructions. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=93673&r1=93672&r2=93673&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Sat Jan 16 23:58:23 2010 @@ -1296,12 +1296,12 @@ Ops.push_back(Chain); if (!IsLoad) - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), NumVecs+7); + return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), NumVecs+8); std::vector ResTys(NumVecs, RegVT); ResTys.push_back(MVT::Other); SDNode *VLdLn = - CurDAG->getMachineNode(Opc, dl, ResTys, Ops.data(), NumVecs+7); + CurDAG->getMachineNode(Opc, dl, ResTys, Ops.data(), NumVecs+8); // For a 64-bit vector load to D registers, nothing more needs to be done. if (is64BitVector) return VLdLn; From rafael.espindola at gmail.com Sat Jan 16 23:58:33 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sun, 17 Jan 2010 05:58:33 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93674 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h Message-ID: <201001170558.o0H5wX2R017703@zion.cs.uiuc.edu> Author: rafael Date: Sat Jan 16 23:58:33 2010 New Revision: 93674 URL: http://llvm.org/viewvc/llvm-project?rev=93674&view=rev Log: I wanted to removed the Elts std::vector, but we don't have an API to do that. Just move it closer to its only use and make it clear that its maximum size is 2! Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=93674&r1=93673&r2=93674&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Sat Jan 16 23:58:33 2010 @@ -614,11 +614,6 @@ bool UseInt64 = (getTargetData().isLegalInteger(64) && (DontCheckAlignment || Align >= Int64Align)); - // FIXME: In cases where we can, we should use the original struct. - // Consider cases like { int, int } and {int, short} for example! This will - // produce far better LLVM code! - std::vector Elts; - unsigned ElementSize = UseInt64 ? 8:4; unsigned ArraySize = Size / ElementSize; @@ -631,7 +626,6 @@ Type::getInt64Ty(getGlobalContext()) : Type::getInt32Ty(getGlobalContext())); ATy = ArrayType::get(ArrayElementType, ArraySize); - Elts.push_back(ATy); } // Pass any leftover bytes as a separate element following the array. @@ -647,11 +641,15 @@ LastEltTy = Type::getInt8Ty(getGlobalContext()); } if (LastEltTy) { - Elts.push_back(LastEltTy); if (Size != getTargetData().getTypeAllocSize(LastEltTy)) LastEltRealSize = Size; } + std::vector Elts; + if (ATy) + Elts.push_back(ATy); + if (LastEltTy) + Elts.push_back(LastEltTy); const StructType *STy = StructType::get(getGlobalContext(), Elts, false); unsigned i = 0; From bob.wilson at apple.com Sun Jan 17 00:20:55 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Sun, 17 Jan 2010 06:20:55 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93676 - /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/polytypes.c Message-ID: <201001170620.o0H6KtP6018355@zion.cs.uiuc.edu> Author: bwilson Date: Sun Jan 17 00:20:54 2010 New Revision: 93676 URL: http://llvm.org/viewvc/llvm-project?rev=93676&view=rev Log: Adjust the expected error message to match what llvm-gcc reports. With llvm-gcc, the type in question is not a raw vector but a vector wrapped in a struct, so the error message is different. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/polytypes.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/polytypes.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/polytypes.c?rev=93676&r1=93675&r2=93676&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/polytypes.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/polytypes.c Sun Jan 17 00:20:54 2010 @@ -29,7 +29,8 @@ poly8x16_t v128_8; poly16x8_t v128_16; - s64_8 (v64_8); /* { dg-error "use -flax-vector-conversions.*incompatible type for argument 1 of 's64_8'" } */ + /* LLVM LOCAL remove "use -flax-vector-conversions" from expected error */ + s64_8 (v64_8); /* { dg-error "incompatible type for argument 1 of 's64_8'" } */ u64_8 (v64_8); /* { dg-error "incompatible type for argument 1 of 'u64_8'" } */ p64_8 (v64_8); From bob.wilson at apple.com Sun Jan 17 00:35:17 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Sun, 17 Jan 2010 06:35:17 -0000 Subject: [llvm-commits] [llvm] r93677 - in /llvm/trunk: lib/Target/ARM/ARMInstrNEON.td test/CodeGen/ARM/vbits.ll Message-ID: <201001170635.o0H6ZIgV018717@zion.cs.uiuc.edu> Author: bwilson Date: Sun Jan 17 00:35:17 2010 New Revision: 93677 URL: http://llvm.org/viewvc/llvm-project?rev=93677&view=rev Log: The Neon "vtst" instruction takes a suffix that is the element size alone -- adding an "i" to the suffix, indicating that the elements are integers, is accepted but not part of the standard syntax. This helps us pass a few more of the Neon tests from gcc. Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td llvm/trunk/test/CodeGen/ARM/vbits.ll Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=93677&r1=93676&r2=93677&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Sun Jan 17 00:35:17 2010 @@ -2116,7 +2116,7 @@ v4i32, v4f32, int_arm_neon_vacgtq, 0>; // VTST : Vector Test Bits defm VTST : N3V_QHS<0, 0, 0b1000, 1, IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q, - IIC_VBINi4Q, "vtst", "i", NEONvtst, 1>; + IIC_VBINi4Q, "vtst", "", NEONvtst, 1>; // Vector Bitwise Operations. Modified: llvm/trunk/test/CodeGen/ARM/vbits.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vbits.ll?rev=93677&r1=93676&r2=93677&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vbits.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vbits.ll Sun Jan 17 00:35:17 2010 @@ -442,7 +442,7 @@ define <8 x i8> @vtsti8(<8 x i8>* %A, <8 x i8>* %B) nounwind { ;CHECK: vtsti8: -;CHECK: vtst.i8 +;CHECK: vtst.8 %tmp1 = load <8 x i8>* %A %tmp2 = load <8 x i8>* %B %tmp3 = and <8 x i8> %tmp1, %tmp2 @@ -453,7 +453,7 @@ define <4 x i16> @vtsti16(<4 x i16>* %A, <4 x i16>* %B) nounwind { ;CHECK: vtsti16: -;CHECK: vtst.i16 +;CHECK: vtst.16 %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B %tmp3 = and <4 x i16> %tmp1, %tmp2 @@ -464,7 +464,7 @@ define <2 x i32> @vtsti32(<2 x i32>* %A, <2 x i32>* %B) nounwind { ;CHECK: vtsti32: -;CHECK: vtst.i32 +;CHECK: vtst.32 %tmp1 = load <2 x i32>* %A %tmp2 = load <2 x i32>* %B %tmp3 = and <2 x i32> %tmp1, %tmp2 @@ -475,7 +475,7 @@ define <16 x i8> @vtstQi8(<16 x i8>* %A, <16 x i8>* %B) nounwind { ;CHECK: vtstQi8: -;CHECK: vtst.i8 +;CHECK: vtst.8 %tmp1 = load <16 x i8>* %A %tmp2 = load <16 x i8>* %B %tmp3 = and <16 x i8> %tmp1, %tmp2 @@ -486,7 +486,7 @@ define <8 x i16> @vtstQi16(<8 x i16>* %A, <8 x i16>* %B) nounwind { ;CHECK: vtstQi16: -;CHECK: vtst.i16 +;CHECK: vtst.16 %tmp1 = load <8 x i16>* %A %tmp2 = load <8 x i16>* %B %tmp3 = and <8 x i16> %tmp1, %tmp2 @@ -497,7 +497,7 @@ define <4 x i32> @vtstQi32(<4 x i32>* %A, <4 x i32>* %B) nounwind { ;CHECK: vtstQi32: -;CHECK: vtst.i32 +;CHECK: vtst.32 %tmp1 = load <4 x i32>* %A %tmp2 = load <4 x i32>* %B %tmp3 = and <4 x i32> %tmp1, %tmp2 From bob.wilson at apple.com Sun Jan 17 00:43:47 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Sun, 17 Jan 2010 06:43:47 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r93678 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon: vuzpf32.c vuzps32.c vuzpu32.c vzipf32.c vzips32.c vzipu32.c Message-ID: <201001170643.o0H6hliS018989@zion.cs.uiuc.edu> Author: bwilson Date: Sun Jan 17 00:43:46 2010 New Revision: 93678 URL: http://llvm.org/viewvc/llvm-project?rev=93678&view=rev Log: The Neon vzip.32 and vuzp.32 instructions are equivalent to vtrn.32, so adjust the expected output of these tests to use vtrn.32. GCC handles these as intrinsics so it can keep them separate, but llvm treats them as shuffles so there is no distinction between them and we generate vtrn.32 for all of them. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vuzpf32.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vuzps32.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vuzpu32.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vzipf32.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vzips32.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vzipu32.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vuzpf32.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vuzpf32.c?rev=93678&r1=93677&r2=93678&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vuzpf32.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vuzpf32.c Sun Jan 17 00:43:46 2010 @@ -17,5 +17,6 @@ out_float32x2x2_t = vuzp_f32 (arg0_float32x2_t, arg1_float32x2_t); } -/* { dg-final { scan-assembler "vuzp\.32\[ \]+\[dD\]\[0-9\]+, \[dD\]\[0-9\]+!?\(\[ \]+@\[a-zA-Z0-9 \]+\)?\n" } } */ +/* LLVM LOCAL vuzp.32 is a synonym for vtrn.32 */ +/* { dg-final { scan-assembler "vtrn\.32\[ \]+\[dD\]\[0-9\]+, \[dD\]\[0-9\]+!?\(\[ \]+@\[a-zA-Z0-9 \]+\)?\n" } } */ /* { dg-final { cleanup-saved-temps } } */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vuzps32.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vuzps32.c?rev=93678&r1=93677&r2=93678&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vuzps32.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vuzps32.c Sun Jan 17 00:43:46 2010 @@ -17,5 +17,6 @@ out_int32x2x2_t = vuzp_s32 (arg0_int32x2_t, arg1_int32x2_t); } -/* { dg-final { scan-assembler "vuzp\.32\[ \]+\[dD\]\[0-9\]+, \[dD\]\[0-9\]+!?\(\[ \]+@\[a-zA-Z0-9 \]+\)?\n" } } */ +/* LLVM LOCAL vuzp.32 is a synonym for vtrn.32 */ +/* { dg-final { scan-assembler "vtrn\.32\[ \]+\[dD\]\[0-9\]+, \[dD\]\[0-9\]+!?\(\[ \]+@\[a-zA-Z0-9 \]+\)?\n" } } */ /* { dg-final { cleanup-saved-temps } } */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vuzpu32.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vuzpu32.c?rev=93678&r1=93677&r2=93678&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vuzpu32.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vuzpu32.c Sun Jan 17 00:43:46 2010 @@ -17,5 +17,6 @@ out_uint32x2x2_t = vuzp_u32 (arg0_uint32x2_t, arg1_uint32x2_t); } -/* { dg-final { scan-assembler "vuzp\.32\[ \]+\[dD\]\[0-9\]+, \[dD\]\[0-9\]+!?\(\[ \]+@\[a-zA-Z0-9 \]+\)?\n" } } */ +/* LLVM LOCAL vuzp.32 is a synonym for vtrn.32 */ +/* { dg-final { scan-assembler "vtrn\.32\[ \]+\[dD\]\[0-9\]+, \[dD\]\[0-9\]+!?\(\[ \]+@\[a-zA-Z0-9 \]+\)?\n" } } */ /* { dg-final { cleanup-saved-temps } } */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vzipf32.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vzipf32.c?rev=93678&r1=93677&r2=93678&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vzipf32.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vzipf32.c Sun Jan 17 00:43:46 2010 @@ -17,5 +17,6 @@ out_float32x2x2_t = vzip_f32 (arg0_float32x2_t, arg1_float32x2_t); } -/* { dg-final { scan-assembler "vzip\.32\[ \]+\[dD\]\[0-9\]+, \[dD\]\[0-9\]+!?\(\[ \]+@\[a-zA-Z0-9 \]+\)?\n" } } */ +/* LLVM LOCAL vzip.32 is a synonym for vtrn.32 */ +/* { dg-final { scan-assembler "vtrn\.32\[ \]+\[dD\]\[0-9\]+, \[dD\]\[0-9\]+!?\(\[ \]+@\[a-zA-Z0-9 \]+\)?\n" } } */ /* { dg-final { cleanup-saved-temps } } */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vzips32.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vzips32.c?rev=93678&r1=93677&r2=93678&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vzips32.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vzips32.c Sun Jan 17 00:43:46 2010 @@ -17,5 +17,6 @@ out_int32x2x2_t = vzip_s32 (arg0_int32x2_t, arg1_int32x2_t); } -/* { dg-final { scan-assembler "vzip\.32\[ \]+\[dD\]\[0-9\]+, \[dD\]\[0-9\]+!?\(\[ \]+@\[a-zA-Z0-9 \]+\)?\n" } } */ +/* LLVM LOCAL vzip.32 is a synonym for vtrn.32 */ +/* { dg-final { scan-assembler "vtrn\.32\[ \]+\[dD\]\[0-9\]+, \[dD\]\[0-9\]+!?\(\[ \]+@\[a-zA-Z0-9 \]+\)?\n" } } */ /* { dg-final { cleanup-saved-temps } } */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vzipu32.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vzipu32.c?rev=93678&r1=93677&r2=93678&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vzipu32.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/arm/neon/vzipu32.c Sun Jan 17 00:43:46 2010 @@ -17,5 +17,6 @@ out_uint32x2x2_t = vzip_u32 (arg0_uint32x2_t, arg1_uint32x2_t); } -/* { dg-final { scan-assembler "vzip\.32\[ \]+\[dD\]\[0-9\]+, \[dD\]\[0-9\]+!?\(\[ \]+@\[a-zA-Z0-9 \]+\)?\n" } } */ +/* LLVM LOCAL vzip.32 is a synonym for vtrn.32 */ +/* { dg-final { scan-assembler "vtrn\.32\[ \]+\[dD\]\[0-9\]+, \[dD\]\[0-9\]+!?\(\[ \]+@\[a-zA-Z0-9 \]+\)?\n" } } */ /* { dg-final { cleanup-saved-temps } } */ From resistor at mac.com Sun Jan 17 00:49:03 2010 From: resistor at mac.com (Owen Anderson) Date: Sun, 17 Jan 2010 06:49:03 -0000 Subject: [llvm-commits] [llvm] r93679 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Message-ID: <201001170649.o0H6n42X019135@zion.cs.uiuc.edu> Author: resistor Date: Sun Jan 17 00:49:03 2010 New Revision: 93679 URL: http://llvm.org/viewvc/llvm-project?rev=93679&view=rev Log: Fix comment. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=93679&r1=93678&r2=93679&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Sun Jan 17 00:49:03 2010 @@ -407,7 +407,7 @@ return Common; if (ConstantInt *C = dyn_cast(Op1)) { - // X udiv C^2 -> X >> C + // X udiv 2^C -> X >> C // Check to see if this is an unsigned division with an exact power of 2, // if so, convert to a right shift. if (C->getValue().isPowerOf2()) // 0 not included in isPowerOf2 From benny.kra at googlemail.com Sun Jan 17 01:46:39 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sun, 17 Jan 2010 07:46:39 -0000 Subject: [llvm-commits] [llvm] r93680 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DIE.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfPrinter.cpp Message-ID: <201001170746.o0H7kdCp020877@zion.cs.uiuc.edu> Author: d0k Date: Sun Jan 17 01:46:39 2010 New Revision: 93680 URL: http://llvm.org/viewvc/llvm-project?rev=93680&view=rev Log: Switch some functions to take Twines, eliminate uses of StringExtras.h. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=93680&r1=93679&r2=93680&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Sun Jan 17 01:46:39 2010 @@ -53,6 +53,7 @@ class Mangler; class MCAsmInfo; class TargetLoweringObjectFile; + class Twine; class Type; class formatted_raw_ostream; @@ -262,14 +263,13 @@ /// PrintHex - Print a value as a hexidecimal value. /// - void PrintHex(int Value) const; + void PrintHex(uint64_t Value) const; /// EOL - Print a newline character to asm stream. If a comment is present /// then it will be printed first. Comments should not contain '\n'. void EOL() const; - void EOL(const std::string &Comment) const; - void EOL(const char* Comment) const; - void EOL(const char *Comment, unsigned Encoding) const; + void EOL(const Twine &Comment) const; + void EOL(const Twine &Comment, unsigned Encoding) const; /// EmitULEB128Bytes - Emit an assembler byte data directive to compose an /// unsigned leb128 value. @@ -302,7 +302,7 @@ void EmitString(const char *String, unsigned Size) const; /// EmitFile - Emit a .file directive. - void EmitFile(unsigned Number, const std::string &Name) const; + void EmitFile(unsigned Number, StringRef Name) const; //===------------------------------------------------------------------===// Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93680&r1=93679&r2=93680&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sun Jan 17 01:46:39 2010 @@ -43,7 +43,6 @@ #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallString.h" -#include "llvm/ADT/StringExtras.h" #include using namespace llvm; @@ -523,12 +522,11 @@ /// PrintULEB128 - Print a series of hexadecimal values (separated by commas) /// representing an unsigned leb128 value. void AsmPrinter::PrintULEB128(unsigned Value) const { - char Buffer[20]; do { unsigned char Byte = static_cast(Value & 0x7f); Value >>= 7; if (Value) Byte |= 0x80; - O << "0x" << utohex_buffer(Byte, Buffer+20); + PrintHex(Byte); if (Value) O << ", "; } while (Value); } @@ -538,14 +536,13 @@ void AsmPrinter::PrintSLEB128(int Value) const { int Sign = Value >> (8 * sizeof(Value) - 1); bool IsMore; - char Buffer[20]; do { unsigned char Byte = static_cast(Value & 0x7f); Value >>= 7; IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0; if (IsMore) Byte |= 0x80; - O << "0x" << utohex_buffer(Byte, Buffer+20); + PrintHex(Byte); if (IsMore) O << ", "; } while (IsMore); } @@ -556,9 +553,9 @@ /// PrintHex - Print a value as a hexadecimal value. /// -void AsmPrinter::PrintHex(int Value) const { - char Buffer[20]; - O << "0x" << utohex_buffer(static_cast(Value), Buffer+20); +void AsmPrinter::PrintHex(uint64_t Value) const { + O << "0x"; + O.write_hex(Value); } /// EOL - Print a newline character to asm stream. If a comment is present @@ -567,18 +564,8 @@ O << '\n'; } -void AsmPrinter::EOL(const std::string &Comment) const { - if (VerboseAsm && !Comment.empty()) { - O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() - << ' ' - << Comment; - } - O << '\n'; -} - -void AsmPrinter::EOL(const char* Comment) const { - if (VerboseAsm && *Comment) { +void AsmPrinter::EOL(const Twine &Comment) const { + if (VerboseAsm && !Comment.isTriviallyEmpty()) { O.PadToColumn(MAI->getCommentColumn()); O << MAI->getCommentString() << ' ' @@ -624,8 +611,8 @@ return 0; } -void AsmPrinter::EOL(const char *Comment, unsigned Encoding) const { - if (VerboseAsm && *Comment) { +void AsmPrinter::EOL(const Twine &Comment, unsigned Encoding) const { + if (VerboseAsm && !Comment.isTriviallyEmpty()) { O.PadToColumn(MAI->getCommentColumn()); O << MAI->getCommentString() << ' ' @@ -755,7 +742,7 @@ /// EmitFile - Emit a .file directive. -void AsmPrinter::EmitFile(unsigned Number, const std::string &Name) const { +void AsmPrinter::EmitFile(unsigned Number, StringRef Name) const { O << "\t.file\t" << Number << " \""; for (unsigned i = 0, N = Name.size(); i < N; ++i) printStringChar(O, Name[i]); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=93680&r1=93679&r2=93680&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Sun Jan 17 01:46:39 2010 @@ -13,6 +13,7 @@ #include "DIE.h" #include "DwarfPrinter.h" +#include "llvm/ADT/Twine.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCSymbol.h" Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=93680&r1=93679&r2=93680&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Sun Jan 17 01:46:39 2010 @@ -2343,14 +2343,10 @@ // Emit the code (index) for the abbreviation. Asm->EmitULEB128Bytes(AbbrevNumber); - if (Asm->isVerbose()) - Asm->EOL(std::string("Abbrev [" + - utostr(AbbrevNumber) + - "] 0x" + utohexstr(Die->getOffset()) + - ":0x" + utohexstr(Die->getSize()) + " " + - dwarf::TagString(Abbrev->getTag()))); - else - Asm->EOL(); + Asm->EOL("Abbrev [" + Twine(AbbrevNumber) + "] 0x" + + Twine::utohexstr(Die->getOffset()) + ":0x" + + Twine::utohexstr(Die->getSize()) + " " + + dwarf::TagString(Abbrev->getTag())); SmallVector &Values = Die->getValues(); const SmallVector &AbbrevData = Abbrev->getData(); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp?rev=93680&r1=93679&r2=93680&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp Sun Jan 17 01:46:39 2010 @@ -24,7 +24,6 @@ #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/ADT/StringExtras.h" using namespace llvm; Dwarf::Dwarf(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T, @@ -225,10 +224,7 @@ Asm->EOL("Offset"); } else if (Reg < 64) { Asm->EmitInt8(dwarf::DW_CFA_offset + Reg); - if (Asm->isVerbose()) - Asm->EOL("DW_CFA_offset + Reg (" + utostr(Reg) + ")"); - else - Asm->EOL(); + Asm->EOL("DW_CFA_offset + Reg (" + Twine(Reg) + ")"); Asm->EmitULEB128Bytes(Offset); Asm->EOL("Offset"); } else { From mm.beck at gmx.net Sun Jan 17 09:39:38 2010 From: mm.beck at gmx.net (Michael Beck) Date: Sun, 17 Jan 2010 16:39:38 +0100 Subject: [llvm-commits] [Patch] Patch for llvm-config References: <13E01678D13D43229821E721E2F1C4A8@nvidia.com> <2E24F4CA-7094-4F4F-9059-4FBD807B94B1@apple.com> Message-ID: <59BDF01DEDFD4FAE803F0CE870514BBB@sigma> >> Hi all, >> >>> Applying this patch breaks llvm-config for me. I don't know anything >>> about it, but maybe this will help: >>> Bareword found where operator expected at /Users/sabre/llvm/Debug/ bin/ >>> llvm-config line 133, near "--src >> >> Yep, this patch was broken. Attached is the correct one. > > Remind me what this patch does? Replaces system("cd bla; pwd") by perl OS dependent function to determine absolute path. The first one did not work on win32 and native perl for instance. best regards, -- Michael Beck From gohman at apple.com Sun Jan 17 11:47:24 2010 From: gohman at apple.com (Dan Gohman) Date: Sun, 17 Jan 2010 17:47:24 -0000 Subject: [llvm-commits] [llvm] r93685 - /llvm/trunk/tools/opt/opt.cpp Message-ID: <201001171747.o0HHlOFv015424@zion.cs.uiuc.edu> Author: djg Date: Sun Jan 17 11:47:24 2010 New Revision: 93685 URL: http://llvm.org/viewvc/llvm-project?rev=93685&view=rev Log: Don't create a (empty) output file, and don't warn about bitcode output to a console, when --analyze is used. Similarly, avoid creating an empty output file when --disable-output is used. Print a warning when the -o option appears with either --analyze or --disable-output, to indicate that the option is being ignored. Modified: llvm/trunk/tools/opt/opt.cpp Modified: llvm/trunk/tools/opt/opt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=93685&r1=93684&r2=93685&view=diff ============================================================================== --- llvm/trunk/tools/opt/opt.cpp (original) +++ llvm/trunk/tools/opt/opt.cpp Sun Jan 17 11:47:24 2010 @@ -373,24 +373,29 @@ // FIXME: outs() is not binary! raw_ostream *Out = &outs(); // Default to printing to stdout... if (OutputFilename != "-") { - // Make sure that the Output file gets unlinked from the disk if we get a - // SIGINT - sys::RemoveFileOnSignal(sys::Path(OutputFilename)); - - std::string ErrorInfo; - Out = new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo, - raw_fd_ostream::F_Binary); - if (!ErrorInfo.empty()) { - errs() << ErrorInfo << '\n'; - delete Out; - return 1; + if (NoOutput || AnalyzeOnly) { + errs() << "WARNING: The -o (output filename) option is ignored when\n" + "the --disable-output or --analyze options are used.\n"; + } else { + // Make sure that the Output file gets unlinked from the disk if we get a + // SIGINT + sys::RemoveFileOnSignal(sys::Path(OutputFilename)); + + std::string ErrorInfo; + Out = new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo, + raw_fd_ostream::F_Binary); + if (!ErrorInfo.empty()) { + errs() << ErrorInfo << '\n'; + delete Out; + return 1; + } } } // If the output is set to be emitted to standard out, and standard out is a // console, print out a warning message and refuse to do it. We don't // impress anyone by spewing tons of binary goo to a terminal. - if (!Force && !NoOutput && !OutputAssembly) + if (!Force && !NoOutput && !AnalyzeOnly && !OutputAssembly) if (CheckBitcodeOutputToConsole(*Out, !Quiet)) NoOutput = true; @@ -517,7 +522,7 @@ if (!NoVerify && !VerifyEach) Passes.add(createVerifierPass()); - // Write bitcode or assembly out to disk or outs() as the last step... + // Write bitcode or assembly out to disk or outs() as the last step... if (!NoOutput && !AnalyzeOnly) { if (OutputAssembly) Passes.add(createPrintModulePass(Out)); From clattner at apple.com Sun Jan 17 11:55:49 2010 From: clattner at apple.com (Chris Lattner) Date: Sun, 17 Jan 2010 09:55:49 -0800 Subject: [llvm-commits] [llvm] r93672 - /llvm/trunk/test/FrontendC/pr5406.c In-Reply-To: <201001170540.o0H5ehB0017231@zion.cs.uiuc.edu> References: <201001170540.o0H5ehB0017231@zion.cs.uiuc.edu> Message-ID: <8794AA69-8E0C-4B13-AE4B-99E573040A60@apple.com> On Jan 16, 2010, at 9:40 PM, Rafael Espindola wrote: > Author: rafael > Date: Sat Jan 16 23:40:41 2010 > New Revision: 93672 > > URL: http://llvm.org/viewvc/llvm-project?rev=93672&view=rev > Log: > Looks like XFAIL has to list every unsupported arch Is it possible to turn this into an execution test in llvm-test/singlesource/unittests? -Chris > > Modified: > llvm/trunk/test/FrontendC/pr5406.c > > Modified: llvm/trunk/test/FrontendC/pr5406.c > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/pr5406.c?rev=93672&r1=93671&r2=93672&view=diff > > ============================================================================== > --- llvm/trunk/test/FrontendC/pr5406.c (original) > +++ llvm/trunk/test/FrontendC/pr5406.c Sat Jan 16 23:40:41 2010 > @@ -2,7 +2,7 @@ > // PR 5406 > > // ARM test. > -// XFAIL: !arm > +// XFAIL: sparc,powerpc,alpha,x86,mips,xcore,cellspu,blackfin,pic16,systemz > > typedef struct { char x[3]; } A0; > void foo (int i, ...); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Sun Jan 17 12:22:35 2010 From: sabre at nondot.org (Chris Lattner) Date: Sun, 17 Jan 2010 18:22:35 -0000 Subject: [llvm-commits] [llvm] r93686 - in /llvm/trunk: include/llvm/Target/Mangler.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/ELFWriter.cpp lib/Target/CBackend/CBackend.cpp lib/Target/Mangler.cpp tools/lto/LTOCodeGenerator.cpp tools/lto/LTOModule.cpp Message-ID: <201001171822.o0HIMa6o016870@zion.cs.uiuc.edu> Author: lattner Date: Sun Jan 17 12:22:35 2010 New Revision: 93686 URL: http://llvm.org/viewvc/llvm-project?rev=93686&view=rev Log: now that mangler is in libtarget, it can use MCAsmInfo instead of clients having to pass various fields from it in. Simplify. Modified: llvm/trunk/include/llvm/Target/Mangler.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/ELFWriter.cpp llvm/trunk/lib/Target/CBackend/CBackend.cpp llvm/trunk/lib/Target/Mangler.cpp llvm/trunk/tools/lto/LTOCodeGenerator.cpp llvm/trunk/tools/lto/LTOModule.cpp Modified: llvm/trunk/include/llvm/Target/Mangler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/Mangler.h?rev=93686&r1=93685&r2=93686&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/Mangler.h (original) +++ llvm/trunk/include/llvm/Target/Mangler.h Sun Jan 17 12:22:35 2010 @@ -19,11 +19,10 @@ namespace llvm { class Twine; -class Type; -class Module; class Value; class GlobalValue; template class SmallVectorImpl; +class MCAsmInfo; class Mangler { public: @@ -34,17 +33,7 @@ }; private: - /// Prefix - This string is added to each symbol that is emitted, unless the - /// symbol is marked as not needing this prefix. - const char *Prefix; - - /// PrivatePrefix - This string is emitted before each symbol with private - /// linkage. - const char *PrivatePrefix; - - /// LinkerPrivatePrefix - This string is emitted before each symbol with - /// "linker_private" linkage. - const char *LinkerPrivatePrefix; + const MCAsmInfo &MAI; /// AnonGlobalIDs - We need to give global values the same name every time /// they are mangled. This keeps track of the number we give to anonymous @@ -59,8 +48,7 @@ public: // Mangler ctor - if a prefix is specified, it will be prepended onto all // symbols. - Mangler(Module &M, const char *Prefix = "", const char *privatePrefix = "", - const char *linkerPrivatePrefix = ""); + Mangler(const MCAsmInfo &mai) : MAI(mai) {} /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix /// and the specified global variable's name. If the global variable doesn't Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=93686&r1=93685&r2=93686&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sun Jan 17 12:22:35 2010 @@ -101,8 +101,7 @@ const_cast(getObjFileLowering()) .Initialize(OutContext, TM); - Mang = new Mangler(M, MAI->getGlobalPrefix(), MAI->getPrivateGlobalPrefix(), - MAI->getLinkerPrivateGlobalPrefix()); + Mang = new Mangler(*MAI); // Allow the target to emit any magic that it wants at the start of the file. EmitStartOfAsmFile(M); Modified: llvm/trunk/lib/CodeGen/ELFWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ELFWriter.cpp?rev=93686&r1=93685&r2=93686&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ELFWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/ELFWriter.cpp Sun Jan 17 12:22:35 2010 @@ -119,7 +119,7 @@ // Initialize TargetLoweringObjectFile. const_cast(TLOF).Initialize(OutContext, TM); - Mang = new Mangler(M); + Mang = new Mangler(*MAI); // ELF Header // ---------- Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=93686&r1=93685&r2=93686&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Sun Jan 17 12:22:35 2010 @@ -58,6 +58,13 @@ } namespace { + class CBEMCAsmInfo : public MCAsmInfo { + public: + CBEMCAsmInfo() { + GlobalPrefix = ""; + PrivateGlobalPrefix = ""; + } + }; /// CBackendNameAllUsedStructsAndMergeFunctions - This pass inserts names for /// any unnamed structure types that are used by the program, and merges /// external functions with the same name. @@ -1869,8 +1876,17 @@ IL = new IntrinsicLowering(*TD); IL->AddPrototypes(M); - // Ensure that all structure types have names... - Mang = new Mangler(M); +#if 0 + std::string Triple = TheModule->getTargetTriple(); + if (Triple.empty()) + Triple = llvm::sys::getHostTriple(); + + std::string E; + if (const Target *Match = TargetRegistry::lookupTarget(Triple, E)) + TAsm = Match->createAsmInfo(Triple); +#endif + TAsm = new CBEMCAsmInfo(); + Mang = new Mangler(*TAsm); // Keep track of which functions are static ctors/dtors so they can have // an attribute added to their prototypes. @@ -3240,30 +3256,31 @@ // of the per target tables // handle multiple constraint codes std::string CWriter::InterpretASMConstraint(InlineAsm::ConstraintInfo& c) { - assert(c.Codes.size() == 1 && "Too many asm constraint codes to handle"); - const char *const *table = 0; - // Grab the translation table from MCAsmInfo if it exists. - if (!TAsm) { - std::string Triple = TheModule->getTargetTriple(); - if (Triple.empty()) - Triple = llvm::sys::getHostTriple(); - - std::string E; - if (const Target *Match = TargetRegistry::lookupTarget(Triple, E)) - TAsm = Match->createAsmInfo(Triple); - } - if (TAsm) - table = TAsm->getAsmCBE(); + const MCAsmInfo *TargetAsm; + std::string Triple = TheModule->getTargetTriple(); + if (Triple.empty()) + Triple = llvm::sys::getHostTriple(); + + std::string E; + if (const Target *Match = TargetRegistry::lookupTarget(Triple, E)) + TargetAsm = Match->createAsmInfo(Triple); + else + return c.Codes[0]; + + const char *const *table = TargetAsm->getAsmCBE(); // Search the translation table if it exists. for (int i = 0; table && table[i]; i += 2) - if (c.Codes[0] == table[i]) + if (c.Codes[0] == table[i]) { + delete TargetAsm; return table[i+1]; + } // Default is identity. + delete TargetAsm; return c.Codes[0]; } Modified: llvm/trunk/lib/Target/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mangler.cpp?rev=93686&r1=93685&r2=93686&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mangler.cpp (original) +++ llvm/trunk/lib/Target/Mangler.cpp Sun Jan 17 12:22:35 2010 @@ -13,6 +13,7 @@ #include "llvm/Target/Mangler.h" #include "llvm/GlobalValue.h" +#include "llvm/MC/MCAsmInfo.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/raw_ostream.h" @@ -29,18 +30,21 @@ // If the global name is not led with \1, add the appropriate prefixes. if (Name[0] != '\1') { - if (PrefixTy == Mangler::Private) - OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); - else if (PrefixTy == Mangler::LinkerPrivate) - OutName.append(LinkerPrivatePrefix, - LinkerPrivatePrefix+strlen(LinkerPrivatePrefix)); - + if (PrefixTy == Mangler::Private) { + const char *Prefix = MAI.getPrivateGlobalPrefix(); + OutName.append(Prefix, Prefix+strlen(Prefix)); + } else if (PrefixTy == Mangler::LinkerPrivate) { + const char *Prefix = MAI.getLinkerPrivateGlobalPrefix(); + OutName.append(Prefix, Prefix+strlen(Prefix)); + } + + const char *Prefix = MAI.getGlobalPrefix(); if (Prefix[0] == 0) ; // Common noop, no prefix. else if (Prefix[1] == 0) OutName.push_back(Prefix[0]); // Common, one character prefix. else - OutName.append(Prefix, Prefix+strlen(Prefix)); // Arbitrary prefix. + OutName.append(Prefix, Prefix+strlen(Prefix)); // Arbitrary length prefix. } else { Name = Name.substr(1); } @@ -68,14 +72,21 @@ // If the global variable doesn't have a name, return a unique name for the // global based on a numbering. + if (GV->hasPrivateLinkage() || isImplicitlyPrivate) { + const char *Prefix = MAI.getPrivateGlobalPrefix(); + OutName.append(Prefix, Prefix+strlen(Prefix)); + } else if (GV->hasLinkerPrivateLinkage()) { + const char *Prefix = MAI.getLinkerPrivateGlobalPrefix(); + OutName.append(Prefix, Prefix+strlen(Prefix)); + } - // Anonymous names always get prefixes. - if (GV->hasPrivateLinkage() || isImplicitlyPrivate) - OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix)); - else if (GV->hasLinkerPrivateLinkage()) - OutName.append(LinkerPrivatePrefix, - LinkerPrivatePrefix+strlen(LinkerPrivatePrefix));; - OutName.append(Prefix, Prefix+strlen(Prefix)); + const char *Prefix = MAI.getGlobalPrefix(); + if (Prefix[0] == 0) + ; // Common noop, no prefix. + else if (Prefix[1] == 0) + OutName.push_back(Prefix[0]); // Common, one character prefix. + else + OutName.append(Prefix, Prefix+strlen(Prefix)); // Arbitrary length prefix. // Get the ID for the global, assigning a new one if we haven't got one // already. @@ -95,10 +106,3 @@ getNameWithPrefix(Buf, GV, isImplicitlyPrivate); return std::string(Buf.begin(), Buf.end()); } - - -Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix, - const char *linkerPrivatePrefix) - : Prefix(prefix), PrivatePrefix(privatePrefix), - LinkerPrivatePrefix(linkerPrivatePrefix), NextAnonGlobalID(1) { -} Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=93686&r1=93685&r2=93686&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Sun Jan 17 12:22:35 2010 @@ -323,8 +323,7 @@ // mark which symbols can not be internalized if ( !_mustPreserveSymbols.empty() ) { - Mangler mangler(*mergedModule, - _target->getMCAsmInfo()->getGlobalPrefix()); + Mangler mangler(*_target->getMCAsmInfo()); std::vector mustPreserveList; for (Module::iterator f = mergedModule->begin(), e = mergedModule->end(); f != e; ++f) { Modified: llvm/trunk/tools/lto/LTOModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=93686&r1=93685&r2=93686&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOModule.cpp (original) +++ llvm/trunk/tools/lto/LTOModule.cpp Sun Jan 17 12:22:35 2010 @@ -439,7 +439,7 @@ _symbolsParsed = true; // Use mangler to add GlobalPrefix to names to match linker names. - Mangler mangler(*_module, _target->getMCAsmInfo()->getGlobalPrefix()); + Mangler mangler(*_target->getMCAsmInfo()); // add functions for (Module::iterator f = _module->begin(); f != _module->end(); ++f) { From sabre at nondot.org Sun Jan 17 12:52:17 2010 From: sabre at nondot.org (Chris Lattner) Date: Sun, 17 Jan 2010 18:52:17 -0000 Subject: [llvm-commits] [llvm] r93687 - /llvm/trunk/lib/Target/Mangler.cpp Message-ID: <201001171852.o0HIqHiR018141@zion.cs.uiuc.edu> Author: lattner Date: Sun Jan 17 12:52:16 2010 New Revision: 93687 URL: http://llvm.org/viewvc/llvm-project?rev=93687&view=rev Log: factor this code better how that the string version of getNameWithPrefix takes a twine. Modified: llvm/trunk/lib/Target/Mangler.cpp Modified: llvm/trunk/lib/Target/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mangler.cpp?rev=93687&r1=93686&r2=93687&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mangler.cpp (original) +++ llvm/trunk/lib/Target/Mangler.cpp Sun Jan 17 12:52:16 2010 @@ -16,7 +16,6 @@ #include "llvm/MC/MCAsmInfo.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" -#include "llvm/Support/raw_ostream.h" using namespace llvm; /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix @@ -59,34 +58,15 @@ void Mangler::getNameWithPrefix(SmallVectorImpl &OutName, const GlobalValue *GV, bool isImplicitlyPrivate) { + ManglerPrefixTy PrefixTy = Mangler::Default; + if (GV->hasPrivateLinkage() || isImplicitlyPrivate) + PrefixTy = Mangler::Private; + else if (GV->hasLinkerPrivateLinkage()) + PrefixTy = Mangler::LinkerPrivate; + // If this global has a name, handle it simply. - if (GV->hasName()) { - ManglerPrefixTy PrefixTy = Mangler::Default; - if (GV->hasPrivateLinkage() || isImplicitlyPrivate) - PrefixTy = Mangler::Private; - else if (GV->hasLinkerPrivateLinkage()) - PrefixTy = Mangler::LinkerPrivate; - + if (GV->hasName()) return getNameWithPrefix(OutName, GV->getName(), PrefixTy); - } - - // If the global variable doesn't have a name, return a unique name for the - // global based on a numbering. - if (GV->hasPrivateLinkage() || isImplicitlyPrivate) { - const char *Prefix = MAI.getPrivateGlobalPrefix(); - OutName.append(Prefix, Prefix+strlen(Prefix)); - } else if (GV->hasLinkerPrivateLinkage()) { - const char *Prefix = MAI.getLinkerPrivateGlobalPrefix(); - OutName.append(Prefix, Prefix+strlen(Prefix)); - } - - const char *Prefix = MAI.getGlobalPrefix(); - if (Prefix[0] == 0) - ; // Common noop, no prefix. - else if (Prefix[1] == 0) - OutName.push_back(Prefix[0]); // Common, one character prefix. - else - OutName.append(Prefix, Prefix+strlen(Prefix)); // Arbitrary length prefix. // Get the ID for the global, assigning a new one if we haven't got one // already. @@ -94,7 +74,7 @@ if (ID == 0) ID = NextAnonGlobalID++; // Must mangle the global into a unique ID. - raw_svector_ostream(OutName) << "__unnamed_" << ID; + getNameWithPrefix(OutName, "__unnamed_" + Twine(ID), PrefixTy); } /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix From sabre at nondot.org Sun Jan 17 13:09:13 2010 From: sabre at nondot.org (Chris Lattner) Date: Sun, 17 Jan 2010 19:09:13 -0000 Subject: [llvm-commits] [llvm] r93688 - /llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll Message-ID: <201001171909.o0HJ9DMj019076@zion.cs.uiuc.edu> Author: lattner Date: Sun Jan 17 13:09:12 2010 New Revision: 93688 URL: http://llvm.org/viewvc/llvm-project?rev=93688&view=rev Log: reduce this test and convert to filecheck, hopefully the linux buildbot will tell me something more useful. Modified: llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll Modified: llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll?rev=93688&r1=93687&r2=93688&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll Sun Jan 17 13:09:12 2010 @@ -1,26 +1,16 @@ -; RUN: llc < %s | grep unnamed_1.eh +; RUN: llc < %s | FileCheck %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:128:128" target triple = "i386-apple-darwin8" define void @_Z3bazv() { - call i32 @0( ) ; :1 [#uses=0] - br label %2 -;