From echristo at apple.com Mon May 18 00:33:05 2009 From: echristo at apple.com (Eric Christopher) Date: Sun, 17 May 2009 22:33:05 -0700 Subject: [llvm-commits] [PATCH] Detect GCC atomic builtins in configure In-Reply-To: <39E5492E-0BA1-465F-8A42-BAA459433D4B@mac.com> References: <7FDB65CF-9461-4DA6-B206-FD2F5EEFA615@mac.com> <39E5492E-0BA1-465F-8A42-BAA459433D4B@mac.com> Message-ID: On May 17, 2009, at 7:47 PM, Owen Anderson wrote: > Couple of comments: a) the idea of testing host configuration (which may not work) for something target specific seems a bit problematic. b) the indenting is a bit weird too, ok, now real stuff c) AC_RUN_IFELSE(AC_LANG_SOURCE([[int main() { + volatile unsigned long val = 1; + __sync_synchronize(); + if (__sync_val_compare_and_swap(&val, 1, 0) != 1 || + val != 0) + return 1; + return 0; }]]), Do you care if it runs or if it links? I'd have thought the latter, but it's up to you. d) + AC_DEFINE(ENABLE_THREADS, [0]) You can do this using something like: AC_DEFINE(ENABLE_THREADS, 0, Define if gcc atomic builtins work on your system.) e) ENABLE_THREADS seems like a really bad name :) f) It seems like you want to do a configure time flag? I'm not positive though. If you did then something like this may work better: AC_ARG_ENABLE(enable-gcc-atomics, [ --enable-gcc-atomics gcc atomic functions],, enable_gcc_atomics=no) (or yes, depending on what you want it to default to) and then something like: if test x$enable_gcc_atomics = xyes ; then AC_DEFINE(ENABLE_THREADS, 1, Define if gcc atomic builtins work on your system.) fi g) + AC_SUBST(ENABLE_THREADS, [0]) You probably don't mean to SUBST and DEFINE this. Is it for the environment or the compiled C/C++ files? Sorry to seemingly pick it apart so much, but you did ask :) -eric From eli.friedman at gmail.com Mon May 18 03:44:07 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Mon, 18 May 2009 08:44:07 -0000 Subject: [llvm-commits] [llvm] r71998 - /llvm/trunk/lib/Support/MemoryBuffer.cpp Message-ID: <200905180844.n4I8i7sn030779@zion.cs.uiuc.edu> Author: efriedma Date: Mon May 18 03:44:04 2009 New Revision: 71998 URL: http://llvm.org/viewvc/llvm-project?rev=71998&view=rev Log: Tweak MemoryBuffer::getSTDIN so that it returns after the first EOF. It doesn't matter for piped input, but it's annoying when typing at the console. Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=71998&r1=71997&r2=71998&view=diff ============================================================================== --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original) +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Mon May 18 03:44:04 2009 @@ -258,13 +258,16 @@ MemoryBuffer *MemoryBuffer::getSTDIN() { char Buffer[4096*4]; - + std::vector FileData; - + // Read in all of the data from stdin, we cannot mmap stdin. sys::Program::ChangeStdinToBinary(); - while (size_t ReadBytes = fread(Buffer, sizeof(char), 4096*4, stdin)) + size_t ReadBytes; + do { + ReadBytes = fread(Buffer, sizeof(char), sizeof(Buffer), stdin); FileData.insert(FileData.end(), Buffer, Buffer+ReadBytes); + } while (ReadBytes == sizeof(Buffer)); FileData.push_back(0); // &FileData[Size] is invalid. So is &*FileData.end(). size_t Size = FileData.size(); From resistor at mac.com Mon May 18 03:50:48 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 18 May 2009 01:50:48 -0700 Subject: [llvm-commits] [PATCH] Detect GCC atomic builtins in configure In-Reply-To: References: <7FDB65CF-9461-4DA6-B206-FD2F5EEFA615@mac.com> <39E5492E-0BA1-465F-8A42-BAA459433D4B@mac.com> Message-ID: <73637BEF-61A8-4BA9-88FB-985D955108FF@mac.com> On May 17, 2009, at 10:33 PM, Eric Christopher wrote: > a) the idea of testing host configuration (which may not work) for > something target specific seems a bit problematic. I don't really have a better idea. > c) > > AC_RUN_IFELSE(AC_LANG_SOURCE([[int main() { > + volatile unsigned long val = 1; > + __sync_synchronize(); > + if (__sync_val_compare_and_swap(&val, 1, 0) != 1 || > + val != 0) > + return 1; > + return 0; }]]), > > Do you care if it runs or if it links? I'd have thought the latter, > but it's up to you. Probably just links, I guess. > d) > > + AC_DEFINE(ENABLE_THREADS, [0]) > > You can do this using something like: > > AC_DEFINE(ENABLE_THREADS, 0, > Define if gcc atomic builtins work on your system.) What does this achieve? > e) ENABLE_THREADS seems like a really bad name :) I didn't choose it. It's already part of LLVM's configure.ac. > f) It seems like you want to do a configure time flag? I'm not > positive though. If you did then something like this may work better: > > AC_ARG_ENABLE(enable-gcc-atomics, > [ --enable-gcc-atomics gcc atomic functions],, > enable_gcc_atomics=no) > > (or yes, depending on what you want it to default to) and then > something like: > > if test x$enable_gcc_atomics = xyes ; then > AC_DEFINE(ENABLE_THREADS, 1, > Define if gcc atomic builtins work on your system.) > fi There's already a --enable-threads configure thread, that defaults to true. > g) > > + AC_SUBST(ENABLE_THREADS, [0]) > > You probably don't mean to SUBST and DEFINE this. Is it for the > environment or the compiled C/C++ files? I'm somewhat confused on this one myself. Early parts of the configure.ac use AC_SUBST, but there is a #define for it in config.h, which doesn't get changed if I just use AC_SUBST, hence whey I added the AC_DEFINE. Perhaps it's a bug in the rest of configure.ac? > Sorry to seemingly pick it apart so much, but you did ask :) Much appreciated! --Owen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090518/447527d4/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2620 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090518/447527d4/attachment.bin From baldrick at free.fr Mon May 18 09:05:11 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 18 May 2009 16:05:11 +0200 Subject: [llvm-commits] [llvm] r71986 - /llvm/trunk/test/FrontendC/2009-05-17-AlwaysInline.c In-Reply-To: <533C8EB1-0A3D-4C41-AFEA-95C91DBF7C8F@gmail.com> References: <200905171937.n4HJb3NQ025904@zion.cs.uiuc.edu> <533C8EB1-0A3D-4C41-AFEA-95C91DBF7C8F@gmail.com> Message-ID: <4A116B17.2030806@free.fr> Hi Bill, > It's very strange, but on a self-hosted release build, I'm getting > this error: > > Running /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/ > FrontendC/dg.exp ... FAIL: > /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/FrontendC/ > 2009-05-17-AlwaysInline.c Failed with exit(1) at line 1 while running: > /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmgcc42.roots/ > llvmgcc42~dst/Developer/usr/bin/llvm-gcc-4.2 -m32 -fstrict-aliasing - > Wstrict-aliasing -I/usr/include/c++/4.0.0/i686-apple-darwin9 -I/usr/ > include/c++/4.0.0 -emit-llvm -w -S > /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/FrontendC/ > 2009-05-17-AlwaysInline.c -O0 -o - -mllvm --disable-llvm-optzns | /usr/ > bin/grep bar cc1: Unknown command line argument '-fdisable-llvm- > optzns'. Try: 'cc1 --help' > I'm not sure where the '-fdisable-llvm-optzns' command is coming from... this is similar to what you get when you are compiling with the system gcc and not llvm-gcc, and you pass it -mllvm --disable-llvm-optzns. So is it possible that it's not llvm-gcc being used here, but standard gcc? Ciao, Duncan. > > -bw > > On May 17, 2009, at 12:37 PM, Duncan Sands wrote: > >> Author: baldrick >> Date: Sun May 17 14:37:02 2009 >> New Revision: 71986 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=71986&view=rev >> Log: >> Check that the gcc front-end is not doing inlining >> when not doing unit-at-a-time. >> >> Added: >> llvm/trunk/test/FrontendC/2009-05-17-AlwaysInline.c >> >> Added: llvm/trunk/test/FrontendC/2009-05-17-AlwaysInline.c >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2009-05-17-AlwaysInline.c?rev=71986&view=auto >> >> = >> = >> = >> = >> = >> = >> = >> = >> ====================================================================== >> --- llvm/trunk/test/FrontendC/2009-05-17-AlwaysInline.c (added) >> +++ llvm/trunk/test/FrontendC/2009-05-17-AlwaysInline.c Sun May 17 >> 14:37:02 2009 >> @@ -0,0 +1,17 @@ >> +// RUN: %llvmgcc -S %s -O0 -o - -mllvm --disable-llvm-optzns | grep >> bar >> +// Check that the gcc inliner is turned off. >> + >> +#include >> +static __inline__ __attribute__ ((always_inline)) >> + int bar (int x) >> +{ >> + return 4; >> +} >> + >> +void >> +foo () >> +{ >> + long long b = 1; >> + int Y = bar (4); >> + printf ("%d\n", Y); >> +} >> >> >> _______________________________________________ >> 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 criswell at uiuc.edu Mon May 18 10:08:29 2009 From: criswell at uiuc.edu (John Criswell) Date: Mon, 18 May 2009 15:08:29 -0000 Subject: [llvm-commits] [poolalloc] r72001 - in /poolalloc/trunk/lib: DSA/DataStructure.cpp DSA/Local.cpp PoolAllocate/Heuristic.cpp PoolAllocate/PASimple.cpp PoolAllocate/PointerCompress.cpp PoolAllocate/TransformFunctionBody.cpp Message-ID: <200905181508.n4IF8TPb017038@zion.cs.uiuc.edu> Author: criswell Date: Mon May 18 10:08:28 2009 New Revision: 72001 URL: http://llvm.org/viewvc/llvm-project?rev=72001&view=rev Log: Updated to new LLVM API for TargetData. Patch contributed by Haohui Mai. Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp poolalloc/trunk/lib/DSA/Local.cpp poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp poolalloc/trunk/lib/PoolAllocate/PASimple.cpp poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=72001&r1=72000&r2=72001&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DataStructure.cpp (original) +++ poolalloc/trunk/lib/DSA/DataStructure.cpp Mon May 18 10:08:28 2009 @@ -400,7 +400,7 @@ const ArrayType *AT = cast(SS.Ty); ++SS.Idx; if (SS.Idx != AT->getNumElements()) { - SS.Offset += unsigned(TD.getTypePaddedSize(AT->getElementType())); + SS.Offset += unsigned(TD.getTypeAllocSize(AT->getElementType())); return; } Stack.pop_back(); // At the end of the array @@ -435,7 +435,7 @@ assert(SS.Idx < AT->getNumElements()); Stack.push_back(StackState(AT->getElementType(), SS.Offset+SS.Idx* - unsigned(TD.getTypePaddedSize(AT->getElementType())))); + unsigned(TD.getTypeAllocSize(AT->getElementType())))); } } } @@ -492,7 +492,7 @@ (Size == 0 && !Ty->isSized() && !isArray()) || (Size == 1 && Ty == Type::VoidTy && isArray()) || (Size == 0 && !Ty->isSized() && !isArray()) || - (TD.getTypePaddedSize(Ty) == Size)) && + (TD.getTypeAllocSize(Ty) == Size)) && "Size member of DSNode doesn't match the type structure!"); assert(NewTy != Type::VoidTy && "Cannot merge void type into DSNode!"); @@ -515,7 +515,7 @@ } // Figure out how big the new type we're merging in is... - unsigned NewTySize = NewTy->isSized() ? (unsigned)TD.getTypePaddedSize(NewTy) : 0; + unsigned NewTySize = NewTy->isSized() ? (unsigned)TD.getTypeAllocSize(NewTy) : 0; // Otherwise check to see if we can fold this type into the current node. If // we can't, we fold the node completely, if we can, we potentially update our @@ -655,7 +655,7 @@ unsigned O = 0; const Type *SubType = Ty; while (O < Offset) { - assert(Offset-O < TD.getTypePaddedSize(SubType) && "Offset out of range!"); + assert(Offset-O < TD.getTypeAllocSize(SubType) && "Offset out of range!"); switch (SubType->getTypeID()) { case Type::StructTyID: { @@ -670,7 +670,7 @@ } case Type::ArrayTyID: { SubType = cast(SubType)->getElementType(); - unsigned ElSize = (unsigned)TD.getTypePaddedSize(SubType); + unsigned ElSize = (unsigned)TD.getTypeAllocSize(SubType); unsigned Remainder = (Offset-O) % ElSize; O = Offset-Remainder; break; @@ -692,7 +692,7 @@ isa(NewTy)) return false; unsigned SubTypeSize = SubType->isSized() ? - (unsigned)TD.getTypePaddedSize(SubType) : 0; + (unsigned)TD.getTypeAllocSize(SubType) : 0; // Ok, we are getting desperate now. Check for physical subtyping, where we // just require each element in the node to be compatible. @@ -720,12 +720,12 @@ else NextPadSize = SubTypeSize; NextSubType = STy->getElementType(0); - NextSubTypeSize = (unsigned)TD.getTypePaddedSize(NextSubType); + NextSubTypeSize = (unsigned)TD.getTypeAllocSize(NextSubType); break; } case Type::ArrayTyID: NextSubType = cast(SubType)->getElementType(); - NextSubTypeSize = (unsigned)TD.getTypePaddedSize(NextSubType); + NextSubTypeSize = (unsigned)TD.getTypeAllocSize(NextSubType); NextPadSize = NextSubTypeSize; break; default: ; Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=72001&r1=72000&r2=72001&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Mon May 18 10:08:28 2009 @@ -447,7 +447,7 @@ if (ConstantInt *CS = dyn_cast(GEP.getOperand(i))) { Offset += (CS->getType()->isSigned() ? CS->getSExtValue() : CS->getZExtValue()) - * TD.getTypePaddedSize(CurTy); + * TD.getTypeAllocSize(CurTy); } else { // Variable index into a node. We must merge all of the elements of the // sequential type here. @@ -455,7 +455,7 @@ cerr << "Pointer indexing not handled yet!\n"; else { const ArrayType *ATy = cast(STy); - unsigned ElSize = TD.getTypePaddedSize(CurTy); + unsigned ElSize = TD.getTypeAllocSize(CurTy); DSNode *N = Value.getNode(); assert(N && "Value must have a node!"); unsigned RawOffset = Offset+Value.getOffset(); Modified: poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp?rev=72001&r1=72000&r2=72001&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp Mon May 18 10:08:28 2009 @@ -57,7 +57,7 @@ unsigned Heuristic::getRecommendedSize(const DSNode *N) { unsigned PoolSize = 0; if (!N->isArray() && N->getType()->isSized()) { - PoolSize = N->getParentGraph()->getTargetData().getTypePaddedSize(N->getType()); + PoolSize = N->getParentGraph()->getTargetData().getTypeAllocSize(N->getType()); } if (PoolSize == 1) PoolSize = 0; return PoolSize; Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=72001&r1=72000&r2=72001&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Mon May 18 10:08:28 2009 @@ -178,7 +178,7 @@ if (MI->isArrayAllocation()) { Value * NumElements = MI->getArraySize(); Value * ElementSize = ConstantInt::get (Type::Int32Ty, - TD.getTypePaddedSize(MI->getAllocatedType())); + TD.getTypeAllocSize(MI->getAllocatedType())); AllocSize = BinaryOperator::Create (Instruction::Mul, ElementSize, NumElements, @@ -186,7 +186,7 @@ MI); } else { AllocSize = ConstantInt::get (Type::Int32Ty, - TD.getTypePaddedSize(MI->getAllocatedType())); + TD.getTypeAllocSize(MI->getAllocatedType())); } Value* args[] = {TheGlobalPool, AllocSize}; Modified: poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp?rev=72001&r1=72000&r2=72001&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp Mon May 18 10:08:28 2009 @@ -226,7 +226,7 @@ NewTy = ComputeCompressedType(Pool->getType(), 0, Nodes); // Get the compressed type size. - NewSize = NewTy->isSized() ? TD.getTypePaddedSize(NewTy) : 0; + NewSize = NewTy->isSized() ? TD.getTypeAllocSize(NewTy) : 0; } @@ -318,9 +318,9 @@ const TargetData &TD = getNode()->getParentGraph()->getTargetData(); std::cerr << " From size: " << (getNode()->getType()->isSized() ? - TD.getTypePaddedSize(getNode()->getType()) : 0) + TD.getTypeAllocSize(getNode()->getType()) : 0) << " To size: " - << (NewTy->isSized() ? TD.getTypePaddedSize(NewTy) : 0) << "\n"; + << (NewTy->isSized() ? TD.getTypeAllocSize(NewTy) : 0) << "\n"; std::cerr << "Node: "; getNode()->dump(); std::cerr << "New Type: " << *NewTy << "\n"; } @@ -733,7 +733,7 @@ Idx = CastInst::CreateSExtOrBitCast(Idx, SCALARUINTTYPE, Idx->getName(), &GEPI); Constant *Scale = ConstantInt::get(SCALARUINTTYPE, - TD.getTypePaddedSize(ElTy)); + TD.getTypeAllocSize(ElTy)); Idx = BinaryOperator::CreateMul(Idx, Scale, "fieldidx", &GEPI); Val = BinaryOperator::CreateAdd(Val, Idx, GEPI.getName(), &GEPI); } Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=72001&r1=72000&r2=72001&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Mon May 18 10:08:28 2009 @@ -216,7 +216,7 @@ TargetData &TD = PAInfo.getAnalysis(); Value *AllocSize = - ConstantInt::get(Type::Int32Ty, TD.getTypePaddedSize(MI.getAllocatedType())); + ConstantInt::get(Type::Int32Ty, TD.getTypeAllocSize(MI.getAllocatedType())); if (MI.isArrayAllocation()) AllocSize = BinaryOperator::Create(Instruction::Mul, AllocSize, @@ -274,7 +274,7 @@ if (PH == 0 || isa(PH)) return; TargetData &TD = PAInfo.getAnalysis(); Value *AllocSize = - ConstantInt::get(Type::Int32Ty, TD.getTypePaddedSize(MI.getAllocatedType())); + ConstantInt::get(Type::Int32Ty, TD.getTypeAllocSize(MI.getAllocatedType())); if (MI.isArrayAllocation()) AllocSize = BinaryOperator::Create(Instruction::Mul, AllocSize, @@ -335,7 +335,7 @@ void FuncTransform::visitCallocCall(CallSite CS) { TargetData& TD = PAInfo.getAnalysis(); - bool useLong = TD.getTypePaddedSize(PointerType::getUnqual(Type::Int8Ty)) != 4; + bool useLong = TD.getTypeAllocSize(PointerType::getUnqual(Type::Int8Ty)) != 4; Module *M = CS.getInstruction()->getParent()->getParent()->getParent(); assert(CS.arg_end()-CS.arg_begin() == 2 && "calloc takes two arguments!"); From gohman at apple.com Mon May 18 10:16:49 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 18 May 2009 15:16:49 -0000 Subject: [llvm-commits] [llvm] r72002 - in /llvm/trunk/test: Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll CodeGen/ARM/arm-negative-stride.ll CodeGen/ARM/lsr-scale-addr-mode.ll CodeGen/X86/2007-11-06-InstrSched.ll CodeGen/X86/loop-hoist.ll Transforms/IndVarSimplify/2007-01-08-X86-64-Pointer.ll Message-ID: <200905181516.n4IFGo8U017308@zion.cs.uiuc.edu> Author: djg Date: Mon May 18 10:16:49 2009 New Revision: 72002 URL: http://llvm.org/viewvc/llvm-project?rev=72002&view=rev Log: Add nounwind to a few tests. Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll llvm/trunk/test/CodeGen/ARM/arm-negative-stride.ll llvm/trunk/test/CodeGen/ARM/lsr-scale-addr-mode.ll llvm/trunk/test/CodeGen/X86/2007-11-06-InstrSched.ll llvm/trunk/test/CodeGen/X86/loop-hoist.ll llvm/trunk/test/Transforms/IndVarSimplify/2007-01-08-X86-64-Pointer.ll Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll?rev=72002&r1=72001&r2=72002&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll Mon May 18 10:16:49 2009 @@ -3,7 +3,7 @@ ; RUN: grep -F "backedge-taken count is (-2147483632 + (2147483632 smax (-1 + (-1 * %x)) smax (-1 + (-1 * %y))))" ; PR2607 -define i32 @b(i32 %x, i32 %y) { +define i32 @b(i32 %x, i32 %y) nounwind { entry: %cmp2 = icmp slt i32 %y, %x %cond3 = select i1 %cmp2, i32 %y, i32 %x Modified: llvm/trunk/test/CodeGen/ARM/arm-negative-stride.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/arm-negative-stride.ll?rev=72002&r1=72001&r2=72002&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/arm-negative-stride.ll (original) +++ llvm/trunk/test/CodeGen/ARM/arm-negative-stride.ll Mon May 18 10:16:49 2009 @@ -1,6 +1,6 @@ ; RUN: llvm-as < %s | llc -march=arm | grep {str r1, \\\[r.*, -r.*, lsl #2\} -define void @test(i32* %P, i32 %A, i32 %i) { +define void @test(i32* %P, i32 %A, i32 %i) nounwind { entry: icmp eq i32 %i, 0 ; :0 [#uses=1] br i1 %0, label %return, label %bb Modified: llvm/trunk/test/CodeGen/ARM/lsr-scale-addr-mode.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/lsr-scale-addr-mode.ll?rev=72002&r1=72001&r2=72002&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/lsr-scale-addr-mode.ll (original) +++ llvm/trunk/test/CodeGen/ARM/lsr-scale-addr-mode.ll Mon May 18 10:16:49 2009 @@ -1,7 +1,7 @@ ; RUN: llvm-as < %s | llc -march=arm | grep -F {str r2, \[r0, +r3, lsl #2\]} ; Should use scaled addressing mode. -define void @sintzero(i32* %a) { +define void @sintzero(i32* %a) nounwind { entry: store i32 0, i32* %a br label %cond_next Modified: llvm/trunk/test/CodeGen/X86/2007-11-06-InstrSched.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-11-06-InstrSched.ll?rev=72002&r1=72001&r2=72002&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2007-11-06-InstrSched.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-11-06-InstrSched.ll Mon May 18 10:16:49 2009 @@ -1,6 +1,6 @@ ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | not grep lea -define float @foo(i32* %x, float* %y, i32 %c) { +define float @foo(i32* %x, float* %y, i32 %c) nounwind { entry: %tmp2132 = icmp eq i32 %c, 0 ; [#uses=1] br i1 %tmp2132, label %bb23, label %bb18 Modified: llvm/trunk/test/CodeGen/X86/loop-hoist.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/loop-hoist.ll?rev=72002&r1=72001&r2=72002&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/loop-hoist.ll (original) +++ llvm/trunk/test/CodeGen/X86/loop-hoist.ll Mon May 18 10:16:49 2009 @@ -8,7 +8,7 @@ @Arr = external global [0 x i32] ; <[0 x i32]*> [#uses=1] -define void @foo(i32 %N.in, i32 %x) { +define void @foo(i32 %N.in, i32 %x) nounwind { entry: %N = bitcast i32 %N.in to i32 ; [#uses=1] br label %cond_true Modified: llvm/trunk/test/Transforms/IndVarSimplify/2007-01-08-X86-64-Pointer.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/2007-01-08-X86-64-Pointer.ll?rev=72002&r1=72001&r2=72002&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/2007-01-08-X86-64-Pointer.ll (original) +++ llvm/trunk/test/Transforms/IndVarSimplify/2007-01-08-X86-64-Pointer.ll Mon May 18 10:16:49 2009 @@ -1,7 +1,7 @@ ; RUN: llvm-as < %s | llc -march=x86-64 | grep {(%rdi,%rax,8)} ; RUN: llvm-as < %s | llc -march=x86-64 | not grep {addq.*8} -define void @foo(double* %y) { +define void @foo(double* %y) nounwind { entry: br label %bb From gohman at apple.com Mon May 18 10:22:40 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 18 May 2009 15:22:40 -0000 Subject: [llvm-commits] [llvm] r72003 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h lib/Analysis/ScalarEvolution.cpp Message-ID: <200905181522.n4IFMeAq017531@zion.cs.uiuc.edu> Author: djg Date: Mon May 18 10:22:39 2009 New Revision: 72003 URL: http://llvm.org/viewvc/llvm-project?rev=72003&view=rev Log: Add an isOne() utility function to ScalarEvolution, similar to isZero() and similar to ConstantInt's isOne(). Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=72003&r1=72002&r2=72003&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Mon May 18 10:22:39 2009 @@ -77,6 +77,10 @@ /// bool isZero() const; + /// isOne - Return true if the expression is a constant one. + /// + bool isOne() const; + /// replaceSymbolicValuesWithConcrete - If this SCEV internally references /// the symbolic value "Sym", construct and return a new SCEV that produces /// the same value, but which uses the concrete value Conc instead of the Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=72003&r1=72002&r2=72003&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon May 18 10:22:39 2009 @@ -127,6 +127,11 @@ return false; } +bool SCEV::isOne() const { + if (const SCEVConstant *SC = dyn_cast(this)) + return SC->getValue()->isOne(); + return false; +} SCEVCouldNotCompute::SCEVCouldNotCompute() : SCEV(scCouldNotCompute) {} SCEVCouldNotCompute::~SCEVCouldNotCompute() {} @@ -3392,7 +3397,7 @@ const SCEVConstant *CStep = dyn_cast(Step); if (!CStep || CStep->isZero()) return UnknownValue; - if (CStep->getValue()->getValue() == 1) { + if (CStep->isOne()) { // With unit stride, the iteration never steps past the limit value. } else if (CStep->getValue()->getValue().isStrictlyPositive()) { if (const SCEVConstant *CLimit = dyn_cast(RHS)) { From gohman at apple.com Mon May 18 10:36:10 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 18 May 2009 15:36:10 -0000 Subject: [llvm-commits] [llvm] r72004 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h lib/Analysis/ScalarEvolution.cpp test/Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll Message-ID: <200905181536.n4IFaARp018136@zion.cs.uiuc.edu> Author: djg Date: Mon May 18 10:36:09 2009 New Revision: 72004 URL: http://llvm.org/viewvc/llvm-project?rev=72004&view=rev Log: Make ScalarEvolution::isLoopGuardedByCond work even when the edge entering a loop is a non-split critical edge. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/test/Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=72004&r1=72003&r2=72004&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Mon May 18 10:36:09 2009 @@ -341,6 +341,10 @@ BackedgeTakenInfo HowManyLessThans(const SCEV *LHS, const SCEV *RHS, const Loop *L, bool isSigned); + /// getLoopPredecessor - If the given loop's header has exactly one unique + /// predecessor outside the loop, return it. Otherwise return null. + BasicBlock *getLoopPredecessor(const Loop *L); + /// getPredecessorWithUniqueSuccessorForBB - Return a predecessor of BB /// (which may not be an immediate predecessor) which has exactly one /// successor from which BB is reachable, or null if no such block is Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=72004&r1=72003&r2=72004&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon May 18 10:36:09 2009 @@ -3246,6 +3246,21 @@ return UnknownValue; } +/// getLoopPredecessor - If the given loop's header has exactly one unique +/// predecessor outside the loop, return it. Otherwise return null. +/// +BasicBlock *ScalarEvolution::getLoopPredecessor(const Loop *L) { + BasicBlock *Header = L->getHeader(); + BasicBlock *Pred = 0; + for (pred_iterator PI = pred_begin(Header), E = pred_end(Header); + PI != E; ++PI) + if (!L->contains(*PI)) { + if (Pred && Pred != *PI) return 0; // Multiple predecessors. + Pred = *PI; + } + return Pred; +} + /// getPredecessorWithUniqueSuccessorForBB - Return a predecessor of BB /// (which may not be an immediate predecessor) which has exactly one /// successor from which BB is reachable, or null if no such block is @@ -3260,11 +3275,10 @@ return Pred; // A loop's header is defined to be a block that dominates the loop. - // If the loop has a preheader, it must be a block that has exactly - // one successor that can reach BB. This is slightly more strict - // than necessary, but works if critical edges are split. + // If the header has a unique predecessor outside the loop, it must be + // a block that has exactly one successor that can reach the loop. if (Loop *L = LI->getLoopFor(BB)) - return L->getLoopPreheader(); + return getLoopPredecessor(L); return 0; } @@ -3275,18 +3289,18 @@ bool ScalarEvolution::isLoopGuardedByCond(const Loop *L, ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS) { - BasicBlock *Preheader = L->getLoopPreheader(); - BasicBlock *PreheaderDest = L->getHeader(); + BasicBlock *Predecessor = getLoopPredecessor(L); + BasicBlock *PredecessorDest = L->getHeader(); - // Starting at the preheader, climb up the predecessor chain, as long as - // there are predecessors that can be found that have unique successors + // Starting at the loop predecessor, climb up the predecessor chain, as long + // as there are predecessors that can be found that have unique successors // leading to the original header. - for (; Preheader; - PreheaderDest = Preheader, - Preheader = getPredecessorWithUniqueSuccessorForBB(Preheader)) { + for (; Predecessor; + PredecessorDest = Predecessor, + Predecessor = getPredecessorWithUniqueSuccessorForBB(Predecessor)) { BranchInst *LoopEntryPredicate = - dyn_cast(Preheader->getTerminator()); + dyn_cast(Predecessor->getTerminator()); if (!LoopEntryPredicate || LoopEntryPredicate->isUnconditional()) continue; @@ -3299,7 +3313,7 @@ Value *PreCondLHS = ICI->getOperand(0); Value *PreCondRHS = ICI->getOperand(1); ICmpInst::Predicate Cond; - if (LoopEntryPredicate->getSuccessor(0) == PreheaderDest) + if (LoopEntryPredicate->getSuccessor(0) == PredecessorDest) Cond = ICI->getPredicate(); else Cond = ICI->getInversePredicate(); Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll?rev=72004&r1=72003&r2=72004&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-07-29-SMinExpr.ll Mon May 18 10:36:09 2009 @@ -1,6 +1,6 @@ ; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \ ; RUN: -scalar-evolution-max-iterations=0 | \ -; RUN: grep -F "backedge-taken count is (-2147483632 + (2147483632 smax (-1 + (-1 * %x)) smax (-1 + (-1 * %y))))" +; RUN: grep -F "backedge-taken count is (-2147483632 + ((-1 + (-1 * %x)) smax (-1 + (-1 * %y))))" ; PR2607 define i32 @b(i32 %x, i32 %y) nounwind { From baldrick at free.fr Mon May 18 10:39:14 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 18 May 2009 17:39:14 +0200 Subject: [llvm-commits] [llvm] r71410 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp In-Reply-To: <48386810-85B9-46D5-8CE6-13FC50D21FFE@apple.com> References: <200905102314.n4ANEdP9010260@zion.cs.uiuc.edu> <99CEAE6F-A380-404D-9081-1BA1D8CB74F3@apple.com> <48386810-85B9-46D5-8CE6-13FC50D21FFE@apple.com> Message-ID: <4A118122.9040303@free.fr> Hi Dale, >>> This doesn't take care of all of the problems with debug info for >>> inlined >>> functions, but it's a step in the right direction. For one thing, >>> llvm-gcc >>> generates wrong IR (it's missing some llvm.dbg intrinsics at the >>> point where the >>> function's inlined) for this example: >>> >>> #include >>> static __inline__ __attribute__((always_inline)) int bar(int x) >>> { return 4; } >>> void foo() { >>> long long b = 1; >>> int Y = bar(4); >>> printf("%d\n", Y); >>> } >> The body for "bar" is gone by the time llvm_asm_file_end is called: I >> think the tree inliner is still being used??? > > Yeah, looks like it's not disabled fully at -O0 (no-unit-at-a-time > seems to be the relevant setting). A significantly different high- > level code path, implemented by having if(flag_unit_at_a_time) all > over the place in common code.... yes, the cgraph stuff is icky. I've fixed the problem by having all functions be classified as uninlineable. Ciao, Duncan. From gohman at apple.com Mon May 18 10:44:59 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 18 May 2009 15:44:59 -0000 Subject: [llvm-commits] [llvm] r72006 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <200905181544.n4IFixNb018461@zion.cs.uiuc.edu> Author: djg Date: Mon May 18 10:44:58 2009 New Revision: 72006 URL: http://llvm.org/viewvc/llvm-project?rev=72006&view=rev Log: Add assertion checks to the SCEV operator creation methods to catch type mismatches. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=72006&r1=72005&r2=72006&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon May 18 10:44:58 2009 @@ -921,6 +921,12 @@ SCEVHandle ScalarEvolution::getAddExpr(std::vector &Ops) { assert(!Ops.empty() && "Cannot get empty add!"); if (Ops.size() == 1) return Ops[0]; +#ifndef NDEBUG + for (unsigned i = 1, e = Ops.size(); i != e; ++i) + assert(getEffectiveSCEVType(Ops[i]->getType()) == + getEffectiveSCEVType(Ops[0]->getType()) && + "SCEVAddExpr operand types don't match!"); +#endif // Sort by complexity, this groups all similar expression types together. GroupByComplexity(Ops, LI); @@ -1205,6 +1211,12 @@ SCEVHandle ScalarEvolution::getMulExpr(std::vector &Ops) { assert(!Ops.empty() && "Cannot get empty mul!"); +#ifndef NDEBUG + for (unsigned i = 1, e = Ops.size(); i != e; ++i) + assert(getEffectiveSCEVType(Ops[i]->getType()) == + getEffectiveSCEVType(Ops[0]->getType()) && + "SCEVMulExpr operand types don't match!"); +#endif // Sort by complexity, this groups all similar expression types together. GroupByComplexity(Ops, LI); @@ -1362,6 +1374,10 @@ SCEVHandle ScalarEvolution::getUDivExpr(const SCEVHandle &LHS, const SCEVHandle &RHS) { + assert(getEffectiveSCEVType(LHS->getType()) == + getEffectiveSCEVType(RHS->getType()) && + "SCEVUDivExpr operand types don't match!"); + if (const SCEVConstant *RHSC = dyn_cast(RHS)) { if (RHSC->getValue()->equalsInt(1)) return LHS; // X udiv 1 --> x @@ -1466,6 +1482,12 @@ SCEVHandle ScalarEvolution::getAddRecExpr(std::vector &Operands, const Loop *L) { if (Operands.size() == 1) return Operands[0]; +#ifndef NDEBUG + for (unsigned i = 1, e = Operands.size(); i != e; ++i) + assert(getEffectiveSCEVType(Operands[i]->getType()) == + getEffectiveSCEVType(Operands[0]->getType()) && + "SCEVAddRecExpr operand types don't match!"); +#endif if (Operands.back()->isZero()) { Operands.pop_back(); @@ -1502,6 +1524,12 @@ SCEVHandle ScalarEvolution::getSMaxExpr(std::vector Ops) { assert(!Ops.empty() && "Cannot get empty smax!"); if (Ops.size() == 1) return Ops[0]; +#ifndef NDEBUG + for (unsigned i = 1, e = Ops.size(); i != e; ++i) + assert(getEffectiveSCEVType(Ops[i]->getType()) == + getEffectiveSCEVType(Ops[0]->getType()) && + "SCEVSMaxExpr operand types don't match!"); +#endif // Sort by complexity, this groups all similar expression types together. GroupByComplexity(Ops, LI); @@ -1582,6 +1610,12 @@ SCEVHandle ScalarEvolution::getUMaxExpr(std::vector Ops) { assert(!Ops.empty() && "Cannot get empty umax!"); if (Ops.size() == 1) return Ops[0]; +#ifndef NDEBUG + for (unsigned i = 1, e = Ops.size(); i != e; ++i) + assert(getEffectiveSCEVType(Ops[i]->getType()) == + getEffectiveSCEVType(Ops[0]->getType()) && + "SCEVUMaxExpr operand types don't match!"); +#endif // Sort by complexity, this groups all similar expression types together. GroupByComplexity(Ops, LI); From gohman at apple.com Mon May 18 10:58:40 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 18 May 2009 15:58:40 -0000 Subject: [llvm-commits] [llvm] r72007 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <200905181558.n4IFwelE018892@zion.cs.uiuc.edu> Author: djg Date: Mon May 18 10:58:39 2009 New Revision: 72007 URL: http://llvm.org/viewvc/llvm-project?rev=72007&view=rev Log: Minor code cleanups. Do more of the work before the if statements instead of within their controlling expressions. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=72007&r1=72006&r2=72007&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon May 18 10:58:39 2009 @@ -806,8 +806,9 @@ // the addrec's type. The count is always unsigned. SCEVHandle CastedMaxBECount = getTruncateOrZeroExtend(MaxBECount, Start->getType()); - if (MaxBECount == - getTruncateOrZeroExtend(CastedMaxBECount, MaxBECount->getType())) { + SCEVHandle RecastedMaxBECount = + getTruncateOrZeroExtend(CastedMaxBECount, MaxBECount->getType()); + if (MaxBECount == RecastedMaxBECount) { const Type *WideTy = IntegerType::get(getTypeSizeInBits(Start->getType()) * 2); // Check whether Start+Step*MaxBECount has no unsigned overflow. @@ -815,10 +816,11 @@ getMulExpr(CastedMaxBECount, getTruncateOrZeroExtend(Step, Start->getType())); SCEVHandle Add = getAddExpr(Start, ZMul); - if (getZeroExtendExpr(Add, WideTy) == - getAddExpr(getZeroExtendExpr(Start, WideTy), - getMulExpr(getZeroExtendExpr(CastedMaxBECount, WideTy), - getZeroExtendExpr(Step, WideTy)))) + SCEVHandle OperandExtendedAdd = + getAddExpr(getZeroExtendExpr(Start, WideTy), + getMulExpr(getZeroExtendExpr(CastedMaxBECount, WideTy), + getZeroExtendExpr(Step, WideTy))); + if (getZeroExtendExpr(Add, WideTy) == OperandExtendedAdd) // Return the expression with the addrec on the outside. return getAddRecExpr(getZeroExtendExpr(Start, Ty), getZeroExtendExpr(Step, Ty), @@ -830,10 +832,11 @@ getMulExpr(CastedMaxBECount, getTruncateOrSignExtend(Step, Start->getType())); Add = getAddExpr(Start, SMul); - if (getZeroExtendExpr(Add, WideTy) == - getAddExpr(getZeroExtendExpr(Start, WideTy), - getMulExpr(getZeroExtendExpr(CastedMaxBECount, WideTy), - getSignExtendExpr(Step, WideTy)))) + OperandExtendedAdd = + getAddExpr(getZeroExtendExpr(Start, WideTy), + getMulExpr(getZeroExtendExpr(CastedMaxBECount, WideTy), + getSignExtendExpr(Step, WideTy))); + if (getZeroExtendExpr(Add, WideTy) == OperandExtendedAdd) // Return the expression with the addrec on the outside. return getAddRecExpr(getZeroExtendExpr(Start, Ty), getSignExtendExpr(Step, Ty), @@ -891,8 +894,9 @@ // the addrec's type. The count is always unsigned. SCEVHandle CastedMaxBECount = getTruncateOrZeroExtend(MaxBECount, Start->getType()); - if (MaxBECount == - getTruncateOrZeroExtend(CastedMaxBECount, MaxBECount->getType())) { + SCEVHandle RecastedMaxBECount = + getTruncateOrZeroExtend(CastedMaxBECount, MaxBECount->getType()); + if (MaxBECount == RecastedMaxBECount) { const Type *WideTy = IntegerType::get(getTypeSizeInBits(Start->getType()) * 2); // Check whether Start+Step*MaxBECount has no signed overflow. @@ -900,10 +904,11 @@ getMulExpr(CastedMaxBECount, getTruncateOrSignExtend(Step, Start->getType())); SCEVHandle Add = getAddExpr(Start, SMul); - if (getSignExtendExpr(Add, WideTy) == - getAddExpr(getSignExtendExpr(Start, WideTy), - getMulExpr(getZeroExtendExpr(CastedMaxBECount, WideTy), - getSignExtendExpr(Step, WideTy)))) + SCEVHandle OperandExtendedAdd = + getAddExpr(getSignExtendExpr(Start, WideTy), + getMulExpr(getZeroExtendExpr(CastedMaxBECount, WideTy), + getSignExtendExpr(Step, WideTy))); + if (getSignExtendExpr(Add, WideTy) == OperandExtendedAdd) // Return the expression with the addrec on the outside. return getAddRecExpr(getSignExtendExpr(Start, Ty), getSignExtendExpr(Step, Ty), From gohman at apple.com Mon May 18 11:03:58 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 18 May 2009 16:03:58 -0000 Subject: [llvm-commits] [llvm] r72008 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <200905181603.n4IG3wVh019068@zion.cs.uiuc.edu> Author: djg Date: Mon May 18 11:03:58 2009 New Revision: 72008 URL: http://llvm.org/viewvc/llvm-project?rev=72008&view=rev Log: Fix ScalarEvolution::isLoopGuardedByCond to accept a null Loop*, for consistency with other routines that use a null Loop* to mean code not contained by any loop. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=72008&r1=72007&r2=72008&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon May 18 11:03:58 2009 @@ -3328,6 +3328,10 @@ bool ScalarEvolution::isLoopGuardedByCond(const Loop *L, ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS) { + // Interpret a null as meaning no loop, where there is obviously no guard + // (interprocedural conditions notwithstanding). + if (!L) return false; + BasicBlock *Predecessor = getLoopPredecessor(L); BasicBlock *PredecessorDest = L->getHeader(); From gohman at apple.com Mon May 18 11:17:45 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 18 May 2009 16:17:45 -0000 Subject: [llvm-commits] [llvm] r72009 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <200905181617.n4IGHjHP019521@zion.cs.uiuc.edu> Author: djg Date: Mon May 18 11:17:44 2009 New Revision: 72009 URL: http://llvm.org/viewvc/llvm-project?rev=72009&view=rev Log: Delete a redundant 'else'. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=72009&r1=72008&r2=72009&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon May 18 11:17:44 2009 @@ -2201,7 +2201,7 @@ getSCEV(U->getOperand(1))); // If the RHS of xor is -1, then this is a not operation. - else if (CI->isAllOnesValue()) + if (CI->isAllOnesValue()) return getNotSCEV(getSCEV(U->getOperand(0))); } break; From gohman at apple.com Mon May 18 11:29:05 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 18 May 2009 16:29:05 -0000 Subject: [llvm-commits] [llvm] r72010 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Analysis/ScalarEvolution/and-xor.ll Message-ID: <200905181629.n4IGT5dh019885@zion.cs.uiuc.edu> Author: djg Date: Mon May 18 11:29:04 2009 New Revision: 72010 URL: http://llvm.org/viewvc/llvm-project?rev=72010&view=rev Log: Teach ScalarEvolution to recognize x^-1 in the case where non-demanded bits have been stripped out by instcombine. Added: llvm/trunk/test/Analysis/ScalarEvolution/and-xor.ll Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=72010&r1=72009&r2=72010&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon May 18 11:29:04 2009 @@ -2203,6 +2203,19 @@ // If the RHS of xor is -1, then this is a not operation. if (CI->isAllOnesValue()) return getNotSCEV(getSCEV(U->getOperand(0))); + + // Model xor(and(x, C), C) as and(~x, C), if C is a low-bits mask. + // This is a variant of the check for xor with -1, and it handles + // the case where instcombine has trimmed non-demanded bits out + // of an xor with -1. + if (BinaryOperator *BO = dyn_cast(U->getOperand(0))) + if (ConstantInt *LCI = dyn_cast(BO->getOperand(1))) + if (BO->getOpcode() == Instruction::And && + LCI->getValue() == CI->getValue()) + if (const SCEVZeroExtendExpr *Z = + dyn_cast(getSCEV(U->getOperand(0)))) + return getZeroExtendExpr(getNotSCEV(Z->getOperand()), + U->getType()); } break; Added: llvm/trunk/test/Analysis/ScalarEvolution/and-xor.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/and-xor.ll?rev=72010&view=auto ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/and-xor.ll (added) +++ llvm/trunk/test/Analysis/ScalarEvolution/and-xor.ll Mon May 18 11:29:04 2009 @@ -0,0 +1,8 @@ +; RUN: llvm-as < %s | opt -scalar-evolution -analyze -disable-output \ +; RUN: | grep {\\--> (zext} | count 2 + +define i32 @foo(i32 %x) { + %n = and i32 %x, 255 + %y = xor i32 %n, 255 + ret i32 %y +} From daniel at zuster.org Mon May 18 11:43:04 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 18 May 2009 16:43:04 -0000 Subject: [llvm-commits] [llvm] r72011 - in /llvm/trunk/lib: Analysis/ScalarEvolution.cpp CodeGen/SelectionDAG/DAGCombiner.cpp CodeGen/SelectionDAG/ScheduleDAGSDNodesEmit.cpp Message-ID: <200905181643.n4IGh4ii020305@zion.cs.uiuc.edu> Author: ddunbar Date: Mon May 18 11:43:04 2009 New Revision: 72011 URL: http://llvm.org/viewvc/llvm-project?rev=72011&view=rev Log: Silence Release-Asserts warnings. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodesEmit.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=72011&r1=72010&r2=72011&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon May 18 11:43:04 2009 @@ -3081,6 +3081,7 @@ } assert(0 && "Unknown SCEV type!"); + return 0; } /// getSCEVAtScope - This is a convenience function which does Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=72011&r1=72010&r2=72011&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon May 18 11:43:04 2009 @@ -6000,9 +6000,9 @@ // Get alias information for node. SDValue Ptr; - int64_t Size; - const Value *SrcValue; - int SrcValueOffset; + int64_t Size = 0; + const Value *SrcValue = 0; + int SrcValueOffset = 0; bool IsLoad = FindAliasInfo(N, Ptr, Size, SrcValue, SrcValueOffset); // Starting off. @@ -6028,9 +6028,9 @@ case ISD::STORE: { // Get alias information for Chain. SDValue OpPtr; - int64_t OpSize; - const Value *OpSrcValue; - int OpSrcValueOffset; + int64_t OpSize = 0; + const Value *OpSrcValue = 0; + int OpSrcValueOffset = 0; bool IsOpLoad = FindAliasInfo(Chain.getNode(), OpPtr, OpSize, OpSrcValue, OpSrcValueOffset); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodesEmit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodesEmit.cpp?rev=72011&r1=72010&r2=72011&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodesEmit.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodesEmit.cpp Mon May 18 11:43:04 2009 @@ -119,6 +119,7 @@ DstRC, SrcRC); assert(Emitted && "Unable to issue a copy instruction!\n"); + (void) Emitted; } SDValue Op(Node, ResNo); @@ -254,6 +255,7 @@ bool Emitted = TII->copyRegToReg(*BB, InsertPos, NewVReg, VReg, DstRC, SrcRC); assert(Emitted && "Unable to issue a copy instruction!\n"); + (void) Emitted; VReg = NewVReg; } } @@ -445,6 +447,7 @@ DstRC, SrcRC); assert(Emitted && "Unable to issue a copy instruction for a COPY_TO_REGCLASS node!\n"); + (void) Emitted; SDValue Op(Node, 0); bool isNew = VRBaseMap.insert(std::make_pair(Op, NewVReg)).second; @@ -568,6 +571,7 @@ bool Emitted = TII->copyRegToReg(*BB, InsertPos, DestReg, SrcReg, DstTRC, SrcTRC); assert(Emitted && "Unable to issue a copy instruction!\n"); + (void) Emitted; break; } case ISD::CopyFromReg: { From gohman at apple.com Mon May 18 11:45:29 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 18 May 2009 16:45:29 -0000 Subject: [llvm-commits] [llvm] r72012 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200905181645.n4IGjT2o020397@zion.cs.uiuc.edu> Author: djg Date: Mon May 18 11:45:28 2009 New Revision: 72012 URL: http://llvm.org/viewvc/llvm-project?rev=72012&view=rev Log: Rename UseTy to AccessTy, for consistency with getAccessType, and to avoid ambiguity with the word "use" in IVStrideUse. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=72012&r1=72011&r2=72012&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Mon May 18 11:45:28 2009 @@ -291,9 +291,9 @@ /// getAccessType - Return the type of the memory being accessed. static const Type *getAccessType(const Instruction *Inst) { - const Type *UseTy = Inst->getType(); + const Type *AccessTy = Inst->getType(); if (const StoreInst *SI = dyn_cast(Inst)) - UseTy = SI->getOperand(0)->getType(); + AccessTy = SI->getOperand(0)->getType(); else if (const IntrinsicInst *II = dyn_cast(Inst)) { // Addressing modes can also be folded into prefetches and a variety // of intrinsics. @@ -303,11 +303,11 @@ case Intrinsic::x86_sse2_storeu_pd: case Intrinsic::x86_sse2_storeu_dq: case Intrinsic::x86_sse2_storel_dq: - UseTy = II->getOperand(1)->getType(); + AccessTy = II->getOperand(1)->getType(); break; } } - return UseTy; + return AccessTy; } namespace { @@ -547,7 +547,7 @@ /// fitsInAddressMode - Return true if V can be subsumed within an addressing /// mode, and does not need to be put in a register first. -static bool fitsInAddressMode(const SCEVHandle &V, const Type *UseTy, +static bool fitsInAddressMode(const SCEVHandle &V, const Type *AccessTy, const TargetLowering *TLI, bool HasBaseReg) { if (const SCEVConstant *SC = dyn_cast(V)) { int64_t VC = SC->getValue()->getSExtValue(); @@ -555,7 +555,7 @@ TargetLowering::AddrMode AM; AM.BaseOffs = VC; AM.HasBaseReg = HasBaseReg; - return TLI->isLegalAddressingMode(AM, UseTy); + return TLI->isLegalAddressingMode(AM, AccessTy); } else { // Defaults to PPC. PPC allows a sign-extended 16-bit immediate field. return (VC > -(1 << 16) && VC < (1 << 16)-1); @@ -568,7 +568,7 @@ TargetLowering::AddrMode AM; AM.BaseGV = GV; AM.HasBaseReg = HasBaseReg; - return TLI->isLegalAddressingMode(AM, UseTy); + return TLI->isLegalAddressingMode(AM, AccessTy); } else { // Default: assume global addresses are not legal. } @@ -620,7 +620,7 @@ /// that can fit into the immediate field of instructions in the target. /// Accumulate these immediate values into the Imm value. static void MoveImmediateValues(const TargetLowering *TLI, - const Type *UseTy, + const Type *AccessTy, SCEVHandle &Val, SCEVHandle &Imm, bool isAddress, Loop *L, ScalarEvolution *SE) { @@ -630,7 +630,7 @@ for (unsigned i = 0; i != SAE->getNumOperands(); ++i) { SCEVHandle NewOp = SAE->getOperand(i); - MoveImmediateValues(TLI, UseTy, NewOp, Imm, isAddress, L, SE); + MoveImmediateValues(TLI, AccessTy, NewOp, Imm, isAddress, L, SE); if (!NewOp->isLoopInvariant(L)) { // If this is a loop-variant expression, it must stay in the immediate @@ -649,7 +649,7 @@ } else if (const SCEVAddRecExpr *SARE = dyn_cast(Val)) { // Try to pull immediates out of the start value of nested addrec's. SCEVHandle Start = SARE->getStart(); - MoveImmediateValues(TLI, UseTy, Start, Imm, isAddress, L, SE); + MoveImmediateValues(TLI, AccessTy, Start, Imm, isAddress, L, SE); if (Start != SARE->getStart()) { std::vector Ops(SARE->op_begin(), SARE->op_end()); @@ -659,12 +659,13 @@ return; } else if (const SCEVMulExpr *SME = dyn_cast(Val)) { // Transform "8 * (4 + v)" -> "32 + 8*V" if "32" fits in the immed field. - if (isAddress && fitsInAddressMode(SME->getOperand(0), UseTy, TLI, false) && + if (isAddress && + fitsInAddressMode(SME->getOperand(0), AccessTy, TLI, false) && SME->getNumOperands() == 2 && SME->isLoopInvariant(L)) { SCEVHandle SubImm = SE->getIntegerSCEV(0, Val->getType()); SCEVHandle NewOp = SME->getOperand(1); - MoveImmediateValues(TLI, UseTy, NewOp, SubImm, isAddress, L, SE); + MoveImmediateValues(TLI, AccessTy, NewOp, SubImm, isAddress, L, SE); // If we extracted something out of the subexpressions, see if we can // simplify this! @@ -672,7 +673,7 @@ // Scale SubImm up by "8". If the result is a target constant, we are // good. SubImm = SE->getMulExpr(SubImm, SME->getOperand(0)); - if (fitsInAddressMode(SubImm, UseTy, TLI, false)) { + if (fitsInAddressMode(SubImm, AccessTy, TLI, false)) { // Accumulate the immediate. Imm = SE->getAddExpr(Imm, SubImm); @@ -686,7 +687,7 @@ // Loop-variant expressions must stay in the immediate field of the // expression. - if ((isAddress && fitsInAddressMode(Val, UseTy, TLI, false)) || + if ((isAddress && fitsInAddressMode(Val, AccessTy, TLI, false)) || !Val->isLoopInvariant(L)) { Imm = SE->getAddExpr(Imm, Val); Val = SE->getIntegerSCEV(0, Val->getType()); @@ -701,8 +702,8 @@ SCEVHandle &Val, SCEVHandle &Imm, bool isAddress, Loop *L, ScalarEvolution *SE) { - const Type *UseTy = getAccessType(User); - MoveImmediateValues(TLI, UseTy, Val, Imm, isAddress, L, SE); + const Type *AccessTy = getAccessType(User); + MoveImmediateValues(TLI, AccessTy, Val, Imm, isAddress, L, SE); } /// SeparateSubExprs - Decompose Expr into all of the subexpressions that are @@ -796,11 +797,11 @@ // If this use is as an address we may be able to put CSEs in the addressing // mode rather than hoisting them. bool isAddrUse = isAddressUse(Uses[i].Inst, Uses[i].OperandValToReplace); - // We may need the UseTy below, but only when isAddrUse, so compute it + // We may need the AccessTy below, but only when isAddrUse, so compute it // only in that case. - const Type *UseTy = 0; + const Type *AccessTy = 0; if (isAddrUse) - UseTy = getAccessType(Uses[i].Inst); + AccessTy = getAccessType(Uses[i].Inst); // Split the expression into subexprs. SeparateSubExprs(SubExprs, Uses[i].Base, SE); @@ -811,7 +812,7 @@ for (unsigned j = 0, e = SubExprs.size(); j != e; ++j) { if (++SubExpressionUseData[SubExprs[j]].Count == 1) UniqueSubExprs.push_back(SubExprs[j]); - if (!isAddrUse || !fitsInAddressMode(SubExprs[j], UseTy, TLI, false)) + if (!isAddrUse || !fitsInAddressMode(SubExprs[j], AccessTy, TLI, false)) SubExpressionUseData[SubExprs[j]].notAllUsesAreFree = true; } SubExprs.clear(); @@ -845,8 +846,8 @@ continue; // We know this is an addressing mode use; if there are any uses that // are not, FreeResult would be Zero. - const Type *UseTy = getAccessType(Uses[i].Inst); - if (!fitsInAddressMode(FreeResult, UseTy, TLI, Result!=Zero)) { + const Type *AccessTy = getAccessType(Uses[i].Inst); + if (!fitsInAddressMode(FreeResult, AccessTy, TLI, Result!=Zero)) { // FIXME: could split up FreeResult into pieces here, some hoisted // and some not. There is no obvious advantage to this. Result = SE->getAddExpr(Result, FreeResult); @@ -1258,11 +1259,11 @@ if (!CurImm) CurImm = SE->getIntegerSCEV(0, Stride->getType()); if (!Imm) Imm = SE->getIntegerSCEV(0, Stride->getType()); const Instruction *Inst = UsersToProcess[i].Inst; - const Type *UseTy = getAccessType(Inst); + const Type *AccessTy = getAccessType(Inst); SCEVHandle Diff = SE->getMinusSCEV(UsersToProcess[i].Imm, Imm); if (!Diff->isZero() && (!AllUsesAreAddresses || - !fitsInAddressMode(Diff, UseTy, TLI, /*HasBaseReg=*/true))) + !fitsInAddressMode(Diff, AccessTy, TLI, /*HasBaseReg=*/true))) return false; } } while (++i != e && Base == UsersToProcess[i].Base); From dgregor at apple.com Mon May 18 12:21:34 2009 From: dgregor at apple.com (Douglas Gregor) Date: Mon, 18 May 2009 17:21:34 -0000 Subject: [llvm-commits] [llvm] r72018 - in /llvm/trunk: autoconf/configure.ac cmake/config-ix.cmake configure include/llvm/Config/config.h.cmake include/llvm/Config/config.h.in lib/System/Unix/Process.inc Message-ID: <200905181721.n4IHLZbj021853@zion.cs.uiuc.edu> Author: dgregor Date: Mon May 18 12:21:34 2009 New Revision: 72018 URL: http://llvm.org/viewvc/llvm-project?rev=72018&view=rev Log: termios.h contains the winsize structure we need to determine the width of a terminal. Don't try to get the width of a terminal if we don't have this header. Modified: llvm/trunk/autoconf/configure.ac llvm/trunk/cmake/config-ix.cmake llvm/trunk/configure llvm/trunk/include/llvm/Config/config.h.cmake llvm/trunk/include/llvm/Config/config.h.in llvm/trunk/lib/System/Unix/Process.inc Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=72018&r1=72017&r2=72018&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Mon May 18 12:21:34 2009 @@ -823,8 +823,8 @@ AC_HEADER_TIME AC_CHECK_HEADERS([dlfcn.h execinfo.h fcntl.h inttypes.h limits.h link.h]) -AC_CHECK_HEADERS([malloc.h setjmp.h signal.h stdint.h unistd.h utime.h]) -AC_CHECK_HEADERS([windows.h]) +AC_CHECK_HEADERS([malloc.h setjmp.h signal.h stdint.h termios.h unistd.h]) +AC_CHECK_HEADERS([utime.h windows.h]) AC_CHECK_HEADERS([sys/mman.h sys/param.h sys/resource.h sys/time.h]) AC_CHECK_HEADERS([sys/types.h sys/ioctl.h malloc/malloc.h mach/mach.h]) if test "$ENABLE_THREADS" -eq 1 ; then Modified: llvm/trunk/cmake/config-ix.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=72018&r1=72017&r2=72018&view=diff ============================================================================== --- llvm/trunk/cmake/config-ix.cmake (original) +++ llvm/trunk/cmake/config-ix.cmake Mon May 18 12:21:34 2009 @@ -34,6 +34,7 @@ check_include_file(sys/stat.h HAVE_SYS_STAT_H) check_include_file(sys/time.h HAVE_SYS_TIME_H) check_include_file(sys/types.h HAVE_SYS_TYPES_H) +check_include_file(termios.h HAVE_TERMIOS_H) check_include_file(unistd.h HAVE_UNISTD_H) check_include_file(utime.h HAVE_UTIME_H) check_include_file(windows.h HAVE_WINDOWS_H) Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=72018&r1=72017&r2=72018&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Mon May 18 12:21:34 2009 @@ -28963,7 +28963,7 @@ -for ac_header in malloc.h setjmp.h signal.h stdint.h unistd.h utime.h +for ac_header in malloc.h setjmp.h signal.h stdint.h termios.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then @@ -29132,7 +29132,8 @@ done -for ac_header in windows.h + +for ac_header in utime.h windows.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then Modified: llvm/trunk/include/llvm/Config/config.h.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.cmake?rev=72018&r1=72017&r2=72018&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.cmake (original) +++ llvm/trunk/include/llvm/Config/config.h.cmake Mon May 18 12:21:34 2009 @@ -419,6 +419,9 @@ /* Define to 1 if the system has the type `uint64_t'. */ #undef HAVE_UINT64_T +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_TERMIOS_H ${HAVE_TERMIOS_H} + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H} Modified: llvm/trunk/include/llvm/Config/config.h.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.in?rev=72018&r1=72017&r2=72018&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.in (original) +++ llvm/trunk/include/llvm/Config/config.h.in Mon May 18 12:21:34 2009 @@ -419,6 +419,9 @@ /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_TERMIOS_H + /* Define to 1 if the system has the type `uint64_t'. */ #undef HAVE_UINT64_T Modified: llvm/trunk/lib/System/Unix/Process.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Process.inc?rev=72018&r1=72017&r2=72018&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Process.inc (original) +++ llvm/trunk/lib/System/Unix/Process.inc Mon May 18 12:21:34 2009 @@ -27,6 +27,9 @@ #ifdef HAVE_SYS_IOCTL_H # include #endif +#ifdef HAVE_TERMIOS_H +# include +#endif //===----------------------------------------------------------------------===// //=== WARNING: Implementation here must contain only generic UNIX code that @@ -204,7 +207,7 @@ unsigned Columns = 0; -#ifdef HAVE_SYS_IOCTL_H +#if defined(HAVE_SYS_IOCTL_H) && defined(HAVE_TERMIOS_H) // Try to determine the width of the terminal. struct winsize ws; if (ioctl(FileID, TIOCGWINSZ, &ws) == 0) From evan at fallingsnow.net Mon May 18 12:31:25 2009 From: evan at fallingsnow.net (Evan Phoenix) Date: Mon, 18 May 2009 10:31:25 -0700 Subject: [llvm-commits] [PATCH] Generate info about the JIT process In-Reply-To: <0A9506FE-111E-4D3C-BC04-D962645AA1DE@apple.com> References: <978B1AEF-4B6B-4BA1-A73F-6FEF5C95A12D@fallingsnow.net> <4A0A6C85.1030909@gmail.com> <4A0A90FB.3000907@gmail.com> <0A9506FE-111E-4D3C-BC04-D962645AA1DE@apple.com> Message-ID: <0F735E86-C6C7-4352-8262-B394C70A5D26@fallingsnow.net> I haven't heard anything from Argiris, or any other thoughts on what the JITListener would look like. I hesitate to write such a thing without an idea of what people want, so I'm hoping we can commit my patch as is. When there is more discussion about the JITListener, it will be easy to make MachineCodeInfo sit on top of it without any external API changes. I've attached an updated version of the patch against SVN HEAD. - Evan -------------- next part -------------- A non-text attachment was scrubbed... Name: jit-info.diff Type: application/octet-stream Size: 6510 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090518/36f9b50d/attachment.obj -------------- next part -------------- On May 13, 2009, at 10:21 AM, Chris Lattner wrote: > On May 13, 2009, at 2:20 AM, Argiris Kirtzidis wrote: >>> Thats basically what MachineCodeInfo enables. ATM, there are only 2 >>> things it publishes directly to the MCI, but future APIs can >>> easily be >>> added using virtual methods to allow for subclasses of >>> MachineCodeInfo >>> to do new things. >>> >>> This is far from a final set of things MCI will do, it's primarily a >>> way of introduce an API that we can add future things to. >> >> Ok, that sounds great. It's just that MachineCodeInfo is restricted >> to >> the "function level", how about "module level" info, specifically >> getting notifications during code execution like: >> -"I lazy JITed this function" >> -"I allocated this memory chunk for this global variable" >> >> Of course, MachineCodeInfo could be the one for the "function >> level" and >> something like "JITListener" at the module level. The JITListener >> could >> have a method that passes a MachineCodeInfo before function JITing. >> IMO >> this is flexible and clean. > > I agree with Argiris: there should be a simple abstract interface > with methods like the above. The JIT should have an optional > pointer to it. If non-null, it would invoke the methods on the > JITListener. This would allow lots of detailed instrumentation, but > would introduce no overhead if it's not being used. > > -Chris From dalej at apple.com Mon May 18 12:44:15 2009 From: dalej at apple.com (Dale Johannesen) Date: Mon, 18 May 2009 17:44:15 -0000 Subject: [llvm-commits] [llvm] r72022 - /llvm/trunk/lib/Target/X86/X86InstrInfo.td Message-ID: <200905181744.n4IHiFPc022776@zion.cs.uiuc.edu> Author: johannes Date: Mon May 18 12:44:15 2009 New Revision: 72022 URL: http://llvm.org/viewvc/llvm-project?rev=72022&view=rev Log: Fill in the missing patterns for ADC and SBB. Some comment cleanup. 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=72022&r1=72021&r2=72022&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon May 18 12:44:15 2009 @@ -34,7 +34,6 @@ [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>]>; - def SDTX86BrCond : SDTypeProfile<0, 3, [SDTCisVT<0, OtherVT>, SDTCisVT<1, i8>, SDTCisVT<2, i32>]>; @@ -2275,24 +2274,69 @@ let Uses = [EFLAGS] in { let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y -def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2), +def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2), + "adc{b}\t{$src2, $dst|$dst, $src2}", + [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>; +def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst), + (ins GR16:$src1, GR16:$src2), + "adc{w}\t{$src2, $dst|$dst, $src2}", + [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>; +def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), + (ins GR32:$src1, GR32:$src2), "adc{l}\t{$src2, $dst|$dst, $src2}", [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>; } -def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2), +def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst), + (ins GR8:$src1, i8mem:$src2), + "adc{b}\t{$src2, $dst|$dst, $src2}", + [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>; +def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst), + (ins GR16:$src1, i16mem:$src2), + "adc{w}\t{$src2, $dst|$dst, $src2}", + [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>; +def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), + (ins GR32:$src1, i32mem:$src2), "adc{l}\t{$src2, $dst|$dst, $src2}", [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>; -def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2), +def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), + "adc{b}\t{$src2, $dst|$dst, $src2}", + [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>; +def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst), + (ins GR16:$src1, i16imm:$src2), + "adc{w}\t{$src2, $dst|$dst, $src2}", + [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>; +def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst), + (ins GR16:$src1, i16i8imm:$src2), + "adc{w}\t{$src2, $dst|$dst, $src2}", + [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>; +def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), + (ins GR32:$src1, i32imm:$src2), "adc{l}\t{$src2, $dst|$dst, $src2}", [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>; -def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2), +def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), + (ins GR32:$src1, i32i8imm:$src2), "adc{l}\t{$src2, $dst|$dst, $src2}", [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>; let isTwoAddress = 0 in { + def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2), + "adc{b}\t{$src2, $dst|$dst, $src2}", + [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>; + def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), + "adc{w}\t{$src2, $dst|$dst, $src2}", + [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>; def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), "adc{l}\t{$src2, $dst|$dst, $src2}", [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>; + def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2), + "adc{b}\t{$src2, $dst|$dst, $src2}", + [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>; + def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2), + "adc{w}\t{$src2, $dst|$dst, $src2}", + [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>; + def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2), + "adc{w}\t{$src2, $dst|$dst, $src2}", + [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>; def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2), "adc{l}\t{$src2, $dst|$dst, $src2}", [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>; @@ -2401,17 +2445,38 @@ } let Uses = [EFLAGS] in { -def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2), +def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst), + (ins GR8:$src1, GR8:$src2), + "sbb{b}\t{$src2, $dst|$dst, $src2}", + [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>; +def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst), + (ins GR16:$src1, GR16:$src2), + "sbb{w}\t{$src2, $dst|$dst, $src2}", + [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>; +def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), + (ins GR32:$src1, GR32:$src2), "sbb{l}\t{$src2, $dst|$dst, $src2}", [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>; let isTwoAddress = 0 in { + def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2), + "sbb{b}\t{$src2, $dst|$dst, $src2}", + [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>; + def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), + "sbb{w}\t{$src2, $dst|$dst, $src2}", + [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>; def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), "sbb{l}\t{$src2, $dst|$dst, $src2}", [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>; def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2), "sbb{b}\t{$src2, $dst|$dst, $src2}", [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>; + def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2), + "sbb{w}\t{$src2, $dst|$dst, $src2}", + [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>; + def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2), + "sbb{w}\t{$src2, $dst|$dst, $src2}", + [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>; def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2), "sbb{l}\t{$src2, $dst|$dst, $src2}", [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>; @@ -2419,13 +2484,34 @@ "sbb{l}\t{$src2, $dst|$dst, $src2}", [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>; } -def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2), +def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2), + "sbb{b}\t{$src2, $dst|$dst, $src2}", + [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>; +def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst), + (ins GR16:$src1, i16mem:$src2), + "sbb{w}\t{$src2, $dst|$dst, $src2}", + [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>; +def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), + (ins GR32:$src1, i32mem:$src2), "sbb{l}\t{$src2, $dst|$dst, $src2}", [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>; -def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2), +def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), + "sbb{b}\t{$src2, $dst|$dst, $src2}", + [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>; +def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst), + (ins GR16:$src1, i16imm:$src2), + "sbb{w}\t{$src2, $dst|$dst, $src2}", + [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>; +def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst), + (ins GR16:$src1, i16i8imm:$src2), + "sbb{w}\t{$src2, $dst|$dst, $src2}", + [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>; +def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), + (ins GR32:$src1, i32imm:$src2), "sbb{l}\t{$src2, $dst|$dst, $src2}", [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>; -def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2), +def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), + (ins GR32:$src1, i32i8imm:$src2), "sbb{l}\t{$src2, $dst|$dst, $src2}", [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>; } // Uses = [EFLAGS] @@ -3598,8 +3684,6 @@ def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2), (implicit EFLAGS)), (ADD8rr GR8:$src1, GR8:$src2)>; - -// Register-Register Addition with EFLAGS result def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2), (implicit EFLAGS)), (ADD16rr GR16:$src1, GR16:$src2)>; @@ -3622,8 +3706,6 @@ def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2), (implicit EFLAGS)), (ADD8ri GR8:$src1, imm:$src2)>; - -// Register-Integer Addition with EFLAGS result def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2), (implicit EFLAGS)), (ADD16ri GR16:$src1, imm:$src2)>; @@ -3650,6 +3732,8 @@ addr:$dst), (implicit EFLAGS)), (ADD32mr addr:$dst, GR32:$src2)>; + +// Memory-Integer Addition with EFLAGS result def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2), addr:$dst), (implicit EFLAGS)), @@ -3836,7 +3920,6 @@ (implicit EFLAGS)), (DEC32m addr:$dst)>, Requires<[In32BitMode]>; - //===----------------------------------------------------------------------===// // Floating Point Stack Support //===----------------------------------------------------------------------===// From isanbard at gmail.com Mon May 18 13:04:58 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 18 May 2009 11:04:58 -0700 Subject: [llvm-commits] [llvm] r71986 - /llvm/trunk/test/FrontendC/2009-05-17-AlwaysInline.c In-Reply-To: <4A116B17.2030806@free.fr> References: <200905171937.n4HJb3NQ025904@zion.cs.uiuc.edu> <533C8EB1-0A3D-4C41-AFEA-95C91DBF7C8F@gmail.com> <4A116B17.2030806@free.fr> Message-ID: <16e5fdf90905181104q1cbfcd4cyae2bab1e902e1fbd@mail.gmail.com> On Mon, May 18, 2009 at 7:05 AM, Duncan Sands wrote: > Hi Bill, > >> It's very strange, but on a self-hosted release build, I'm getting >> this error: >> >> Running /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/ >> FrontendC/dg.exp ... FAIL: >> /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/FrontendC/ >> 2009-05-17-AlwaysInline.c Failed with exit(1) at line 1 while running: >> /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmgcc42.roots/ >> llvmgcc42~dst/Developer/usr/bin/llvm-gcc-4.2 -m32 -fstrict-aliasing - >> Wstrict-aliasing -I/usr/include/c++/4.0.0/i686-apple-darwin9 -I/usr/ >> include/c++/4.0.0 -emit-llvm -w -S >> /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/FrontendC/ >> 2009-05-17-AlwaysInline.c -O0 -o - -mllvm --disable-llvm-optzns | /usr/ >> bin/grep bar cc1: Unknown command line argument '-fdisable-llvm- >> optzns'. Try: 'cc1 --help' >> I'm not sure where the '-fdisable-llvm-optzns' command is coming from... > > this is similar to what you get when you are compiling with the system > gcc and not llvm-gcc, and you pass it -mllvm --disable-llvm-optzns. ?So > is it possible that it's not llvm-gcc being used here, but standard gcc? > I doubt it. The log file shows that it's using "llvm-gcc". This must be a release-mode deal, as it's failing in release mode for me (and not just self-hosting). Here's an option. Use "-disable-llvm-optzns" instead of "--disable-llvm-optzns". It seems that '--' is converted to '-f' in gcc. I have no clue why: $ /Developer/usr/bin/llvm-gcc -c t.c -o /dev/null -mllvm --relocation-model=pic cc1: for the -relocation-model=pic option: : may only occur zero or one times! $ /Developer/usr/bin/llvm-gcc -c t.c -o /dev/null -mllvm --relocation-model=pic cc1: Unknown command line argument '-frelocation-model=pic'. Try: 'cc1 --help' -bw From isanbard at gmail.com Mon May 18 13:09:37 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 18 May 2009 18:09:37 -0000 Subject: [llvm-commits] [llvm] r72023 - /llvm/trunk/test/FrontendC/2009-05-17-AlwaysInline.c Message-ID: <200905181809.n4II9bTv023638@zion.cs.uiuc.edu> Author: void Date: Mon May 18 13:09:36 2009 New Revision: 72023 URL: http://llvm.org/viewvc/llvm-project?rev=72023&view=rev Log: Commands beginning with '--' are converted to '-f' by gcc. Blech! Modified: llvm/trunk/test/FrontendC/2009-05-17-AlwaysInline.c Modified: llvm/trunk/test/FrontendC/2009-05-17-AlwaysInline.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2009-05-17-AlwaysInline.c?rev=72023&r1=72022&r2=72023&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2009-05-17-AlwaysInline.c (original) +++ llvm/trunk/test/FrontendC/2009-05-17-AlwaysInline.c Mon May 18 13:09:36 2009 @@ -1,4 +1,4 @@ -// RUN: %llvmgcc -S %s -O0 -o - -mllvm --disable-llvm-optzns | grep bar +// RUN: %llvmgcc -S %s -O0 -o - -mllvm -disable-llvm-optzns | grep bar // Check that the gcc inliner is turned off. #include From isanbard at gmail.com Mon May 18 13:17:23 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 18 May 2009 18:17:23 -0000 Subject: [llvm-commits] [llvm] r72024 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Message-ID: <200905181817.n4IIHNvL023916@zion.cs.uiuc.edu> Author: void Date: Mon May 18 13:17:22 2009 New Revision: 72024 URL: http://llvm.org/viewvc/llvm-project?rev=72024&view=rev Log: Don't call RegionInlinedFnEnd if our optimization level isn't -O0. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=72024&r1=72023&r2=72024&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Mon May 18 13:17:22 2009 @@ -3929,7 +3929,8 @@ MachineFunction &MF = DAG.getMachineFunction(); DISubprogram Subprogram(cast(REI.getContext())); - if (Subprogram.isNull() || Subprogram.describes(MF.getFunction())) { + if (OptLevel == CodeGenOpt::None || + Subprogram.isNull() || Subprogram.describes(MF.getFunction())) { unsigned LabelID = DW->RecordRegionEnd(cast(REI.getContext())); DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(), From gohman at apple.com Mon May 18 13:18:57 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 18 May 2009 18:18:57 -0000 Subject: [llvm-commits] [llvm] r72025 - /llvm/trunk/lib/VMCore/Instructions.cpp Message-ID: <200905181818.n4IIIwkf023971@zion.cs.uiuc.edu> Author: djg Date: Mon May 18 13:18:57 2009 New Revision: 72025 URL: http://llvm.org/viewvc/llvm-project?rev=72025&view=rev Log: Add assertions to CastInst::getCastOpcode to catch attempted conversions between integers and pointers when the source type is marked signed, since inttoptr and ptrtoint always use zero-extension when the destination is larger than the source. Modified: llvm/trunk/lib/VMCore/Instructions.cpp Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=72025&r1=72024&r2=72025&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Mon May 18 13:18:57 2009 @@ -2220,6 +2220,8 @@ } else { assert(isa(SrcTy) && "Casting from a value that is not first-class type"); + assert(!SrcIsSigned && + "Pointer types cannot be considered signed for conversions!"); return PtrToInt; // ptr -> int } } else if (DestTy->isFloatingPoint()) { // Casting to floating pt @@ -2259,6 +2261,7 @@ if (isa(SrcTy)) { return BitCast; // ptr -> ptr } else if (SrcTy->isInteger()) { + assert(!SrcIsSigned && "Cannot cast signed integer to pointer!"); return IntToPtr; // int -> ptr } else { assert(!"Casting pointer to other than pointer or int"); From isanbard at gmail.com Mon May 18 13:21:03 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 18 May 2009 18:21:03 -0000 Subject: [llvm-commits] [llvm] r72026 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Message-ID: <200905181821.n4IIL3sW024083@zion.cs.uiuc.edu> Author: void Date: Mon May 18 13:21:03 2009 New Revision: 72026 URL: http://llvm.org/viewvc/llvm-project?rev=72026&view=rev Log: Revert last commit. It was wrong. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=72026&r1=72025&r2=72026&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Mon May 18 13:21:03 2009 @@ -3929,8 +3929,7 @@ MachineFunction &MF = DAG.getMachineFunction(); DISubprogram Subprogram(cast(REI.getContext())); - if (OptLevel == CodeGenOpt::None || - Subprogram.isNull() || Subprogram.describes(MF.getFunction())) { + if (Subprogram.isNull() || Subprogram.describes(MF.getFunction())) { unsigned LabelID = DW->RecordRegionEnd(cast(REI.getContext())); DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(), From echristo at apple.com Mon May 18 13:46:57 2009 From: echristo at apple.com (Eric Christopher) Date: Mon, 18 May 2009 18:46:57 -0000 Subject: [llvm-commits] [llvm] r72028 - /llvm/trunk/include/llvm/Instructions.h Message-ID: <200905181846.n4IIkvhx025117@zion.cs.uiuc.edu> Author: echristo Date: Mon May 18 13:46:57 2009 New Revision: 72028 URL: http://llvm.org/viewvc/llvm-project?rev=72028&view=rev Log: Remove getType() overrides for ExtractValueInst and InsertValueInst. Patch by John McCall. Modified: llvm/trunk/include/llvm/Instructions.h Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=72028&r1=72027&r2=72028&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Mon May 18 13:46:57 2009 @@ -1616,11 +1616,6 @@ virtual ExtractValueInst *clone() const; - // getType - Overload to return most specific pointer type... - const PointerType *getType() const { - return reinterpret_cast(Instruction::getType()); - } - /// getIndexedType - Returns the type of the element that would be extracted /// with an extractvalue instruction with the specified parameters. /// @@ -1794,11 +1789,6 @@ /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); - // getType - Overload to return most specific pointer type... - const PointerType *getType() const { - return reinterpret_cast(Instruction::getType()); - } - typedef const unsigned* idx_iterator; inline idx_iterator idx_begin() const { return Indices.begin(); } inline idx_iterator idx_end() const { return Indices.end(); } From gohman at apple.com Mon May 18 13:55:40 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 18 May 2009 18:55:40 -0000 Subject: [llvm-commits] [llvm] r72029 - /llvm/trunk/lib/VMCore/Instructions.cpp Message-ID: <200905181855.n4IIte3R025392@zion.cs.uiuc.edu> Author: djg Date: Mon May 18 13:55:39 2009 New Revision: 72029 URL: http://llvm.org/viewvc/llvm-project?rev=72029&view=rev Log: Revert r72025. It is possible for clients to convert between signed types and pointer types safely if they only do so when the sizes are the same. llvm-gcc is such a client. Modified: llvm/trunk/lib/VMCore/Instructions.cpp Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=72029&r1=72028&r2=72029&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Mon May 18 13:55:39 2009 @@ -2220,8 +2220,6 @@ } else { assert(isa(SrcTy) && "Casting from a value that is not first-class type"); - assert(!SrcIsSigned && - "Pointer types cannot be considered signed for conversions!"); return PtrToInt; // ptr -> int } } else if (DestTy->isFloatingPoint()) { // Casting to floating pt @@ -2261,7 +2259,6 @@ if (isa(SrcTy)) { return BitCast; // ptr -> ptr } else if (SrcTy->isInteger()) { - assert(!SrcIsSigned && "Cannot cast signed integer to pointer!"); return IntToPtr; // int -> ptr } else { assert(!"Casting pointer to other than pointer or int"); From gohman at apple.com Mon May 18 14:02:08 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 18 May 2009 12:02:08 -0700 Subject: [llvm-commits] [llvm] r71757 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp In-Reply-To: <95C426D7-58A9-4A1A-B276-40C8FEB9C03D@apple.com> References: <200905140030.n4E0UJ3H020876@zion.cs.uiuc.edu> <95C426D7-58A9-4A1A-B276-40C8FEB9C03D@apple.com> Message-ID: On May 13, 2009, at 6:38 PM, Chris Lattner wrote: > > On May 13, 2009, at 5:30 PM, Dan Gohman wrote: > >> Author: djg >> Date: Wed May 13 19:30:16 2009 >> New Revision: 71757 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=71757&view=rev >> Log: >> Add an assert to turn a segfault on an unsupported inline >> asm construct into an assertion failure. > > Should this use printf+exit(1)? I don't know. I was just following similar code elsewhere in the same file. Is there a conscious decision to use printf+exit for certain cases now? Dan From lhames at gmail.com Mon May 18 14:03:16 2009 From: lhames at gmail.com (Lang Hames) Date: Mon, 18 May 2009 19:03:16 -0000 Subject: [llvm-commits] [llvm] r72030 - in /llvm/trunk/lib/CodeGen: RegAllocLinearScan.cpp Spiller.cpp Spiller.h Message-ID: <200905181903.n4IJ3G6o025658@zion.cs.uiuc.edu> Author: lhames Date: Mon May 18 14:03:16 2009 New Revision: 72030 URL: http://llvm.org/viewvc/llvm-project?rev=72030&view=rev Log: New Spiller interface and trivial implementation. Added: llvm/trunk/lib/CodeGen/Spiller.cpp llvm/trunk/lib/CodeGen/Spiller.h Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=72030&r1=72029&r2=72030&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Mon May 18 14:03:16 2009 @@ -14,6 +14,7 @@ #define DEBUG_TYPE "regalloc" #include "VirtRegMap.h" #include "VirtRegRewriter.h" +#include "Spiller.h" #include "llvm/Function.h" #include "llvm/CodeGen/LiveIntervalAnalysis.h" #include "llvm/CodeGen/LiveStackAnalysis.h" @@ -56,6 +57,11 @@ cl::desc("Pre-register allocation live interval splitting"), cl::init(false), cl::Hidden); +static cl::opt +NewSpillFramework("new-spill-framework", + cl::desc("New spilling framework"), + cl::init(false), cl::Hidden); + static RegisterRegAlloc linearscanRegAlloc("linearscan", "linear scan register allocator", createLinearScanRegisterAllocator); @@ -127,6 +133,8 @@ std::auto_ptr rewriter_; + std::auto_ptr spiller_; + public: virtual const char* getPassName() const { return "Linear Scan Register Allocator"; @@ -420,6 +428,13 @@ vrm_ = &getAnalysis(); if (!rewriter_.get()) rewriter_.reset(createVirtRegRewriter()); + + if (NewSpillFramework) { + spiller_.reset(createSpiller(mf_, li_, vrm_)); + } + else { + spiller_.reset(0); + } initIntervalSets(); @@ -1108,8 +1123,15 @@ if (cur->weight != HUGE_VALF && cur->weight <= minWeight) { DOUT << "\t\t\tspilling(c): " << *cur << '\n'; SmallVector spillIs; - std::vector added = - li_->addIntervalsForSpills(*cur, spillIs, loopInfo, *vrm_); + std::vector added; + + if (!NewSpillFramework) { + added = li_->addIntervalsForSpills(*cur, spillIs, loopInfo, *vrm_); + } + else { + added = spiller_->spill(cur); + } + std::sort(added.begin(), added.end(), LISorter()); addStackInterval(cur, ls_, li_, mri_, *vrm_); if (added.empty()) Added: llvm/trunk/lib/CodeGen/Spiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.cpp?rev=72030&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/Spiller.cpp (added) +++ llvm/trunk/lib/CodeGen/Spiller.cpp Mon May 18 14:03:16 2009 @@ -0,0 +1,206 @@ +//===-- llvm/CodeGen/Spiller.cpp - Spiller -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "spiller" + +#include "Spiller.h" +#include "VirtRegMap.h" +#include "llvm/CodeGen/LiveIntervalAnalysis.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/MachineFrameInfo.h" +#include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetInstrInfo.h" +#include "llvm/Support/Debug.h" + +#include +#include + +using namespace llvm; + +Spiller::~Spiller() {} + +namespace { + +class TrivialSpiller : public Spiller { +public: + TrivialSpiller(MachineFunction *mf, LiveIntervals *lis, VirtRegMap *vrm) : + mf(mf), lis(lis), vrm(vrm) + { + mfi = mf->getFrameInfo(); + mri = &mf->getRegInfo(); + tii = mf->getTarget().getInstrInfo(); + } + + std::vector spill(LiveInterval *li) { + + DOUT << "Trivial spiller spilling " << *li << "\n"; + + assert(li->weight != HUGE_VALF && + "Attempting to spill already spilled value."); + + assert(!li->isStackSlot() && + "Trying to spill a stack slot."); + + std::vector added; + + const TargetRegisterClass *trc = mri->getRegClass(li->reg); + /*unsigned ss = mfi->CreateStackObject(trc->getSize(), + trc->getAlignment());*/ + unsigned ss = vrm->assignVirt2StackSlot(li->reg); + + MachineRegisterInfo::reg_iterator regItr = mri->reg_begin(li->reg); + + while (regItr != mri->reg_end()) { + + MachineInstr *mi = &*regItr; + + SmallVector indices; + bool hasUse = false; + bool hasDef = false; + + for (unsigned i = 0; i != mi->getNumOperands(); ++i) { + MachineOperand &op = mi->getOperand(i); + + if (!op.isReg() || op.getReg() != li->reg) + continue; + + hasUse |= mi->getOperand(i).isUse(); + hasDef |= mi->getOperand(i).isDef(); + + indices.push_back(i); + } + + unsigned newVReg = mri->createVirtualRegister(trc); + LiveInterval *newLI = &lis->getOrCreateInterval(newVReg); + newLI->weight = HUGE_VALF; + + vrm->grow(); + vrm->assignVirt2StackSlot(newVReg, ss); + + for (unsigned i = 0; i < indices.size(); ++i) { + mi->getOperand(indices[i]).setReg(newVReg); + + if (mi->getOperand(indices[i]).isUse()) { + mi->getOperand(indices[i]).setIsKill(true); + } + } + + if (hasUse) { + unsigned loadInstIdx = insertLoadFor(mi, ss, newVReg, trc); + unsigned start = lis->getDefIndex(loadInstIdx), + end = lis->getUseIndex(lis->getInstructionIndex(mi)); + + VNInfo *vni = + newLI->getNextValue(loadInstIdx, 0, lis->getVNInfoAllocator()); + vni->kills.push_back(lis->getInstructionIndex(mi)); + LiveRange lr(start, end, vni); + + newLI->addRange(lr); + added.push_back(newLI); + } + + if (hasDef) { + unsigned storeInstIdx = insertStoreFor(mi, ss, newVReg, trc); + unsigned start = lis->getDefIndex(lis->getInstructionIndex(mi)), + end = lis->getUseIndex(storeInstIdx); + + VNInfo *vni = + newLI->getNextValue(storeInstIdx, 0, lis->getVNInfoAllocator()); + vni->kills.push_back(storeInstIdx); + LiveRange lr(start, end, vni); + + newLI->addRange(lr); + added.push_back(newLI); + } + + regItr = mri->reg_begin(li->reg); + } + + + return added; + } + + +private: + + MachineFunction *mf; + LiveIntervals *lis; + MachineFrameInfo *mfi; + MachineRegisterInfo *mri; + const TargetInstrInfo *tii; + VirtRegMap *vrm; + + + + void makeRoomForInsertBefore(MachineInstr *mi) { + if (!lis->hasGapBeforeInstr(lis->getInstructionIndex(mi))) { + lis->computeNumbering(); + } + + assert(lis->hasGapBeforeInstr(lis->getInstructionIndex(mi))); + } + + unsigned insertStoreFor(MachineInstr *mi, unsigned ss, + unsigned newVReg, + const TargetRegisterClass *trc) { + MachineBasicBlock::iterator nextInstItr(mi); + ++nextInstItr; + + makeRoomForInsertBefore(&*nextInstItr); + + unsigned miIdx = lis->getInstructionIndex(mi); + + tii->storeRegToStackSlot(*mi->getParent(), nextInstItr, newVReg, + true, ss, trc); + MachineBasicBlock::iterator storeInstItr(mi); + ++storeInstItr; + MachineInstr *storeInst = &*storeInstItr; + unsigned storeInstIdx = miIdx + LiveIntervals::InstrSlots::NUM; + + assert(lis->getInstructionFromIndex(storeInstIdx) == 0 && + "Store inst index already in use."); + + lis->InsertMachineInstrInMaps(storeInst, storeInstIdx); + + return storeInstIdx; + } + + unsigned insertLoadFor(MachineInstr *mi, unsigned ss, + unsigned newVReg, + const TargetRegisterClass *trc) { + MachineBasicBlock::iterator useInstItr(mi); + + makeRoomForInsertBefore(mi); + + unsigned miIdx = lis->getInstructionIndex(mi); + + tii->loadRegFromStackSlot(*mi->getParent(), useInstItr, newVReg, ss, trc); + MachineBasicBlock::iterator loadInstItr(mi); + --loadInstItr; + MachineInstr *loadInst = &*loadInstItr; + unsigned loadInstIdx = miIdx - LiveIntervals::InstrSlots::NUM; + + assert(lis->getInstructionFromIndex(loadInstIdx) == 0 && + "Load inst index already in use."); + + lis->InsertMachineInstrInMaps(loadInst, loadInstIdx); + + return loadInstIdx; + } + +}; + +} + + +llvm::Spiller* llvm::createSpiller(MachineFunction *mf, LiveIntervals *lis, + VirtRegMap *vrm) { + return new TrivialSpiller(mf, lis, vrm); +} Added: llvm/trunk/lib/CodeGen/Spiller.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.h?rev=72030&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/Spiller.h (added) +++ llvm/trunk/lib/CodeGen/Spiller.h Mon May 18 14:03:16 2009 @@ -0,0 +1,32 @@ +//===-- llvm/CodeGen/Spiller.h - Spiller -*- C++ -*------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CODEGEN_SPILLER_H +#define LLVM_CODEGEN_SPILLER_H + +#include + +namespace llvm { + + /// Spiller interface. + /// + /// Implementations are utility classes which insert spill or remat code on + /// demand. + class Spiller { + public: + virtual ~Spiller() = 0; + virtual std::vector spill(class LiveInterval *li) = 0; + }; + + /// Create and return a spiller object, as specified on the command line. + Spiller* createSpiller(class MachineFunction *mf, class LiveIntervals *li, + class VirtRegMap *vrm); +} + +#endif From akyrtzi at gmail.com Mon May 18 15:17:23 2009 From: akyrtzi at gmail.com (Argiris Kirtzidis) Date: Mon, 18 May 2009 23:17:23 +0300 Subject: [llvm-commits] Add scope info in DebugLoc In-Reply-To: <16e5fdf90905121328r50ee3767n290bc2ff7000c6a6@mail.gmail.com> References: <4A037F8D.90001@gmail.com> <16e5fdf90905121328r50ee3767n290bc2ff7000c6a6@mail.gmail.com> Message-ID: <4A11C253.8050401@gmail.com> Hi Bill, Bill Wendling wrote: > - /// DebugLocTuple - Debug location tuple of filename id, line and column. > + /// DebugScope - Debug scope id. > > Please flesh out this comment. Add more about what a debug scope is > and how it will be used. > > + class DebugScope { > + unsigned Idx; > + > + public: > + DebugScope() : Idx(~0U) {} // Defaults to null. > > Well...it's not really Null. :-) Maybe it would be better to name it > "invalid" (with appropriate changes to the other methods' names)? > > + /// DebugScopeInfo - Contains info about the scope global variable and the > + /// parent debug scope. > > Could you explain why this is different from DebugScope. > Ok to all. > + /// DebugLocTuple - Debug location tuple of compile unit, scope, > + /// line and column. > > The term "compile unit" is overloaded. There's the idea of a CU in the > debug info, then the actual CompileUnit class, then a DICompileUnit > class. Could you name it something else? Just for my sanity? :-) That > is, unless CompileUnit is really absolutely correct here... > I modified it to "DICompileUnit global variable", is this more clear ? > + void EnterDebugScope(GlobalVariable *ScopeGV, MachineFunction &MF); > + void ExitDebugScope(GlobalVariable *ScopeGV, MachineFunction &MF); > > FastISel has MF available as an ivar. Do you need to pass this in as a > parameter? Also, please comment these methods. > Moved them into a new DebugScopeTracker class. > +DebugScope MachineFunction::CreateDebugScope(GlobalVariable *ScopeGV, > + DebugScope Parent) { > + DbgScopeInfos.push_back(DebugScopeInfo(ScopeGV, Parent)); > + return DebugScope::get(DbgScopeInfos.size() - 1); > > Should you verify that DbgScopeInfos.size() > 0 here? Is it really needed ? A new item is pushed into the DbgScopeInfos in the immediate line above it. > Actually, why > subtract one here at all? In the assert, you can verify that Idx <= > DbgScopeInfos.size(). > Well, there's not much difference but I'd prefer to have DebugScope::getIndex return the "actual index" into the vector. This is similar to the way DebugLoc's index is created. > + // FIXME: Proper debug scope. > + DebugScope DbgScope; > > What's stopping you from using a proper debug scope here? > I added comments about this. Let me know what you think about this part. > @@ -3817,6 +3821,25 @@ > setValue(&I, result); > } > > +void SelectionDAGLowering::EnterDebugScope(GlobalVariable *ScopeGV, > + MachineFunction &MF) { > + assert(ScopeGV && "GlobalVariable for scope is null!"); > + setCurDebugScope(MF.CreateDebugScope(ScopeGV, getCurDebugScope())); > +} > + > +void SelectionDAGLowering::ExitDebugScope(GlobalVariable *ScopeGV, > + MachineFunction &MF) { > + assert(ScopeGV && "GlobalVariable for scope is null!"); > + assert(!getCurDebugScope().isNull() && "Mismatched region.end ?"); > + // We may have skipped a region.end because it was in an unreachable block. > + // Go up the scope chain until we reach the scope that ScopeGV points to. > + DebugScopeInfo DSI; > + do { > + DSI = MF.getDebugScopeInfo(getCurDebugScope()); > + setCurDebugScope(DSI.Parent); > + } while (!DSI.Parent.isNull() && DSI.GV != ScopeGV); > +} > > Because these methods are used in both SelectionDAGBuild.cpp and > FastISel.cpp, is there a way to factor them out into another module? > Maybe a CodeGen/DebugLoc.cpp module? > Done. I attached a new patch, thanks for reviewing! -Argiris -------------- next part -------------- A non-text attachment was scrubbed... Name: debugscope.patch Type: text/x-diff Size: 21354 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090518/8f5c062a/attachment.bin From evan.cheng at apple.com Mon May 18 15:29:32 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 18 May 2009 13:29:32 -0700 Subject: [llvm-commits] [llvm] r72030 - in /llvm/trunk/lib/CodeGen: RegAllocLinearScan.cpp Spiller.cpp Spiller.h In-Reply-To: <200905181903.n4IJ3G6o025658@zion.cs.uiuc.edu> References: <200905181903.n4IJ3G6o025658@zion.cs.uiuc.edu> Message-ID: Hi Lang, Thanks. Some comments: + if (NewSpillFramework) { + spiller_.reset(createSpiller(mf_, li_, vrm_)); + } + else { + spiller_.reset(0); + } + std::vector spill(LiveInterval *li) { + + DOUT << "Trivial spiller spilling " << *li << "\n"; spill() is the top level interface used by the register allocators, right? I am assuming you are going to grow this spiller to do splitting etc. If so, please move the part that does the trivial spilling into a second route. Is the else part necessary? Also, the coding convention used throughout llvm is if () { } else { } + /*unsigned ss = mfi->CreateStackObject(trc->getSize(), + trc->getAlignment());*/ Please delete the commented lines. + MachineRegisterInfo::reg_iterator regItr = mri->reg_begin(li->reg); + + while (regItr != mri->reg_end()) { + + MachineInstr *mi = &*regItr; ... + regItr = mri->reg_begin(li->reg); + } Why not just use a for loop iterating from begin() to end()? for (MachineRegisterInfo::reg_iterator regItr = mri_->reg_begin(li- >reg), E = mri_->reg_end(); regItr != E; ) { MachineInstr *mi = &*regItr; ++regItr; Please add some comments. :-) Thanks, Evan On May 18, 2009, at 12:03 PM, Lang Hames wrote: > Author: lhames > Date: Mon May 18 14:03:16 2009 > New Revision: 72030 > > URL: http://llvm.org/viewvc/llvm-project?rev=72030&view=rev > Log: > New Spiller interface and trivial implementation. > > Added: > llvm/trunk/lib/CodeGen/Spiller.cpp > llvm/trunk/lib/CodeGen/Spiller.h > Modified: > llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp > > Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=72030&r1=72029&r2=72030&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp (original) > +++ llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Mon May 18 > 14:03:16 2009 > @@ -14,6 +14,7 @@ > #define DEBUG_TYPE "regalloc" > #include "VirtRegMap.h" > #include "VirtRegRewriter.h" > +#include "Spiller.h" > #include "llvm/Function.h" > #include "llvm/CodeGen/LiveIntervalAnalysis.h" > #include "llvm/CodeGen/LiveStackAnalysis.h" > @@ -56,6 +57,11 @@ > cl::desc("Pre-register allocation live interval > splitting"), > cl::init(false), cl::Hidden); > > +static cl::opt > +NewSpillFramework("new-spill-framework", > + cl::desc("New spilling framework"), > + cl::init(false), cl::Hidden); > + > static RegisterRegAlloc > linearscanRegAlloc("linearscan", "linear scan register allocator", > createLinearScanRegisterAllocator); > @@ -127,6 +133,8 @@ > > std::auto_ptr rewriter_; > > + std::auto_ptr spiller_; > + > public: > virtual const char* getPassName() const { > return "Linear Scan Register Allocator"; > @@ -420,6 +428,13 @@ > > vrm_ = &getAnalysis(); > if (!rewriter_.get()) rewriter_.reset(createVirtRegRewriter()); > + > + if (NewSpillFramework) { > + spiller_.reset(createSpiller(mf_, li_, vrm_)); > + } > + else { > + spiller_.reset(0); > + } > > initIntervalSets(); > > @@ -1108,8 +1123,15 @@ > if (cur->weight != HUGE_VALF && cur->weight <= minWeight) { > DOUT << "\t\t\tspilling(c): " << *cur << '\n'; > SmallVector spillIs; > - std::vector added = > - li_->addIntervalsForSpills(*cur, spillIs, loopInfo, *vrm_); > + std::vector added; > + > + if (!NewSpillFramework) { > + added = li_->addIntervalsForSpills(*cur, spillIs, loopInfo, > *vrm_); > + } > + else { > + added = spiller_->spill(cur); > + } > + > std::sort(added.begin(), added.end(), LISorter()); > addStackInterval(cur, ls_, li_, mri_, *vrm_); > if (added.empty()) > > Added: llvm/trunk/lib/CodeGen/Spiller.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.cpp?rev=72030&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/Spiller.cpp (added) > +++ llvm/trunk/lib/CodeGen/Spiller.cpp Mon May 18 14:03:16 2009 > @@ -0,0 +1,206 @@ > +//===-- llvm/CodeGen/Spiller.cpp - Spiller > -------------------------------===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open > Source > +// License. See LICENSE.TXT for details. > +// > +// > = > = > = > ----------------------------------------------------------------------= > ==// > + > +#define DEBUG_TYPE "spiller" > + > +#include "Spiller.h" > +#include "VirtRegMap.h" > +#include "llvm/CodeGen/LiveIntervalAnalysis.h" > +#include "llvm/CodeGen/MachineFunction.h" > +#include "llvm/CodeGen/MachineRegisterInfo.h" > +#include "llvm/CodeGen/MachineFrameInfo.h" > +#include "llvm/Target/TargetMachine.h" > +#include "llvm/Target/TargetInstrInfo.h" > +#include "llvm/Support/Debug.h" > + > +#include > +#include > + > +using namespace llvm; > + > +Spiller::~Spiller() {} > + > +namespace { > + > +class TrivialSpiller : public Spiller { > +public: > + TrivialSpiller(MachineFunction *mf, LiveIntervals *lis, > VirtRegMap *vrm) : > + mf(mf), lis(lis), vrm(vrm) > + { > + mfi = mf->getFrameInfo(); > + mri = &mf->getRegInfo(); > + tii = mf->getTarget().getInstrInfo(); > + } > + > + std::vector spill(LiveInterval *li) { > + > + DOUT << "Trivial spiller spilling " << *li << "\n"; > + > + assert(li->weight != HUGE_VALF && > + "Attempting to spill already spilled value."); > + > + assert(!li->isStackSlot() && > + "Trying to spill a stack slot."); > + > + std::vector added; > + > + const TargetRegisterClass *trc = mri->getRegClass(li->reg); > + /*unsigned ss = mfi->CreateStackObject(trc->getSize(), > + trc->getAlignment());*/ > + unsigned ss = vrm->assignVirt2StackSlot(li->reg); > + > + MachineRegisterInfo::reg_iterator regItr = mri->reg_begin(li- > >reg); > + > + while (regItr != mri->reg_end()) { > + > + MachineInstr *mi = &*regItr; > + > + SmallVector indices; > + bool hasUse = false; > + bool hasDef = false; > + > + for (unsigned i = 0; i != mi->getNumOperands(); ++i) { > + MachineOperand &op = mi->getOperand(i); > + > + if (!op.isReg() || op.getReg() != li->reg) > + continue; > + > + hasUse |= mi->getOperand(i).isUse(); > + hasDef |= mi->getOperand(i).isDef(); > + > + indices.push_back(i); > + } > + > + unsigned newVReg = mri->createVirtualRegister(trc); > + LiveInterval *newLI = &lis->getOrCreateInterval(newVReg); > + newLI->weight = HUGE_VALF; > + > + vrm->grow(); > + vrm->assignVirt2StackSlot(newVReg, ss); > + > + for (unsigned i = 0; i < indices.size(); ++i) { > + mi->getOperand(indices[i]).setReg(newVReg); > + > + if (mi->getOperand(indices[i]).isUse()) { > + mi->getOperand(indices[i]).setIsKill(true); > + } > + } > + > + if (hasUse) { > + unsigned loadInstIdx = insertLoadFor(mi, ss, newVReg, trc); > + unsigned start = lis->getDefIndex(loadInstIdx), > + end = lis->getUseIndex(lis->getInstructionIndex > (mi)); > + > + VNInfo *vni = > + newLI->getNextValue(loadInstIdx, 0, lis- > >getVNInfoAllocator()); > + vni->kills.push_back(lis->getInstructionIndex(mi)); > + LiveRange lr(start, end, vni); > + > + newLI->addRange(lr); > + added.push_back(newLI); > + } > + > + if (hasDef) { > + unsigned storeInstIdx = insertStoreFor(mi, ss, newVReg, trc); > + unsigned start = lis->getDefIndex(lis->getInstructionIndex > (mi)), > + end = lis->getUseIndex(storeInstIdx); > + > + VNInfo *vni = > + newLI->getNextValue(storeInstIdx, 0, lis- > >getVNInfoAllocator()); > + vni->kills.push_back(storeInstIdx); > + LiveRange lr(start, end, vni); > + > + newLI->addRange(lr); > + added.push_back(newLI); > + } > + > + regItr = mri->reg_begin(li->reg); > + } > + > + > + return added; > + } > + > + > +private: > + > + MachineFunction *mf; > + LiveIntervals *lis; > + MachineFrameInfo *mfi; > + MachineRegisterInfo *mri; > + const TargetInstrInfo *tii; > + VirtRegMap *vrm; > + > + > + > + void makeRoomForInsertBefore(MachineInstr *mi) { > + if (!lis->hasGapBeforeInstr(lis->getInstructionIndex(mi))) { > + lis->computeNumbering(); > + } > + > + assert(lis->hasGapBeforeInstr(lis->getInstructionIndex(mi))); > + } > + > + unsigned insertStoreFor(MachineInstr *mi, unsigned ss, > + unsigned newVReg, > + const TargetRegisterClass *trc) { > + MachineBasicBlock::iterator nextInstItr(mi); > + ++nextInstItr; > + > + makeRoomForInsertBefore(&*nextInstItr); > + > + unsigned miIdx = lis->getInstructionIndex(mi); > + > + tii->storeRegToStackSlot(*mi->getParent(), nextInstItr, newVReg, > + true, ss, trc); > + MachineBasicBlock::iterator storeInstItr(mi); > + ++storeInstItr; > + MachineInstr *storeInst = &*storeInstItr; > + unsigned storeInstIdx = miIdx + LiveIntervals::InstrSlots::NUM; > + > + assert(lis->getInstructionFromIndex(storeInstIdx) == 0 && > + "Store inst index already in use."); > + > + lis->InsertMachineInstrInMaps(storeInst, storeInstIdx); > + > + return storeInstIdx; > + } > + > + unsigned insertLoadFor(MachineInstr *mi, unsigned ss, > + unsigned newVReg, > + const TargetRegisterClass *trc) { > + MachineBasicBlock::iterator useInstItr(mi); > + > + makeRoomForInsertBefore(mi); > + > + unsigned miIdx = lis->getInstructionIndex(mi); > + > + tii->loadRegFromStackSlot(*mi->getParent(), useInstItr, > newVReg, ss, trc); > + MachineBasicBlock::iterator loadInstItr(mi); > + --loadInstItr; > + MachineInstr *loadInst = &*loadInstItr; > + unsigned loadInstIdx = miIdx - LiveIntervals::InstrSlots::NUM; > + > + assert(lis->getInstructionFromIndex(loadInstIdx) == 0 && > + "Load inst index already in use."); > + > + lis->InsertMachineInstrInMaps(loadInst, loadInstIdx); > + > + return loadInstIdx; > + } > + > +}; > + > +} > + > + > +llvm::Spiller* llvm::createSpiller(MachineFunction *mf, > LiveIntervals *lis, > + VirtRegMap *vrm) { > + return new TrivialSpiller(mf, lis, vrm); > +} > > Added: llvm/trunk/lib/CodeGen/Spiller.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.h?rev=72030&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/Spiller.h (added) > +++ llvm/trunk/lib/CodeGen/Spiller.h Mon May 18 14:03:16 2009 > @@ -0,0 +1,32 @@ > +//===-- llvm/CodeGen/Spiller.h - Spiller -*- C++ - > *------------------------===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open > Source > +// License. See LICENSE.TXT for details. > +// > +// > = > = > = > ----------------------------------------------------------------------= > ==// > + > +#ifndef LLVM_CODEGEN_SPILLER_H > +#define LLVM_CODEGEN_SPILLER_H > + > +#include > + > +namespace llvm { > + > + /// Spiller interface. > + /// > + /// Implementations are utility classes which insert spill or > remat code on > + /// demand. > + class Spiller { > + public: > + virtual ~Spiller() = 0; > + virtual std::vector spill(class > LiveInterval *li) = 0; > + }; > + > + /// Create and return a spiller object, as specified on the > command line. > + Spiller* createSpiller(class MachineFunction *mf, class > LiveIntervals *li, > + class VirtRegMap *vrm); > +} > + > +#endif > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From baldrick at free.fr Mon May 18 15:30:30 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 18 May 2009 22:30:30 +0200 Subject: [llvm-commits] [llvm] r71986 - /llvm/trunk/test/FrontendC/2009-05-17-AlwaysInline.c In-Reply-To: <16e5fdf90905181104q1cbfcd4cyae2bab1e902e1fbd@mail.gmail.com> References: <200905171937.n4HJb3NQ025904@zion.cs.uiuc.edu> <533C8EB1-0A3D-4C41-AFEA-95C91DBF7C8F@gmail.com> <4A116B17.2030806@free.fr> <16e5fdf90905181104q1cbfcd4cyae2bab1e902e1fbd@mail.gmail.com> Message-ID: <4A11C566.5080808@free.fr> Hi Bill, > I doubt it. The log file shows that it's using "llvm-gcc". This must > be a release-mode deal, as it's failing in release mode for me (and > not just self-hosting). Here's an option. Use "-disable-llvm-optzns" > instead of "--disable-llvm-optzns". It seems that '--' is converted to > '-f' in gcc. I have no clue why: > > $ /Developer/usr/bin/llvm-gcc -c t.c -o /dev/null -mllvm --relocation-model=pic > cc1: for the -relocation-model=pic option: : may only occur zero or one times! > > $ /Developer/usr/bin/llvm-gcc -c t.c -o /dev/null -mllvm --relocation-model=pic > cc1: Unknown command line argument '-frelocation-model=pic'. Try: 'cc1 --help' that's... very strange! I'm not planning to look into it though. Ciao, Duncan. From isanbard at gmail.com Mon May 18 15:39:18 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 18 May 2009 13:39:18 -0700 Subject: [llvm-commits] [llvm] r71986 - /llvm/trunk/test/FrontendC/2009-05-17-AlwaysInline.c In-Reply-To: <4A11C566.5080808@free.fr> References: <200905171937.n4HJb3NQ025904@zion.cs.uiuc.edu> <533C8EB1-0A3D-4C41-AFEA-95C91DBF7C8F@gmail.com> <4A116B17.2030806@free.fr> <16e5fdf90905181104q1cbfcd4cyae2bab1e902e1fbd@mail.gmail.com> <4A11C566.5080808@free.fr> Message-ID: <16e5fdf90905181339y8710f86h3c2e16c244ea11a8@mail.gmail.com> On Mon, May 18, 2009 at 1:30 PM, Duncan Sands wrote: > Hi Bill, > >> I doubt it. The log file shows that it's using "llvm-gcc". This must >> be a release-mode deal, as it's failing in release mode for me (and >> not just self-hosting). Here's an option. Use "-disable-llvm-optzns" >> instead of "--disable-llvm-optzns". It seems that '--' is converted to >> '-f' in gcc. I have no clue why: >> >> $ /Developer/usr/bin/llvm-gcc -c t.c -o /dev/null -mllvm --relocation-model=pic >> cc1: for the -relocation-model=pic option: : may only occur zero or one times! >> >> $ /Developer/usr/bin/llvm-gcc -c t.c -o /dev/null -mllvm --relocation-model=pic >> cc1: Unknown command line argument '-frelocation-model=pic'. ?Try: 'cc1 --help' > > that's... very strange! I agree! >?I'm not planning to look into it though. > I wouldn't suggest it either. :-) This way lies madness. -bw From bob.wilson at apple.com Mon May 18 15:55:41 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 18 May 2009 20:55:41 -0000 Subject: [llvm-commits] [llvm] r72037 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <200905182055.n4IKtmPi029794@zion.cs.uiuc.edu> Author: bwilson Date: Mon May 18 15:55:32 2009 New Revision: 72037 URL: http://llvm.org/viewvc/llvm-project?rev=72037&view=rev Log: Fix pr4202: Disable CodePlacementOpt for ARM. The ARMConstantIslandPass has to run last because it needs to know the exact size and position of every basic block. Currently CodePlacementOpt is set up to run last. It might be worthwhile to investigate reordering these passes, but for now, let's just make it work. 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=72037&r1=72036&r2=72037&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Mon May 18 15:55:32 2009 @@ -288,7 +288,10 @@ setIfCvtDupBlockSizeLimit(Subtarget->isThumb() ? 0 : 2); maxStoresPerMemcpy = 1; //// temporary - rewrite interface to use type - benefitFromCodePlacementOpt = true; + // Do not enable CodePlacementOpt for now: it currently runs after the + // ARMConstantIslandPass and messes up branch relaxation and placement + // of constant islands. + // benefitFromCodePlacementOpt = true; } const char *ARMTargetLowering::getTargetNodeName(unsigned Opcode) const { From bob.wilson at apple.com Mon May 18 16:03:03 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 18 May 2009 21:03:03 -0000 Subject: [llvm-commits] [llvm] r72038 - /llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Message-ID: <200905182103.n4IL37c5030058@zion.cs.uiuc.edu> Author: bwilson Date: Mon May 18 16:02:18 2009 New Revision: 72038 URL: http://llvm.org/viewvc/llvm-project?rev=72038&view=rev Log: Fix CodePlacementOpt::OptimizeIntraLoopEdges so that its return value correctly indicates whether it changed the code. Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp?rev=72038&r1=72037&r2=72038&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp (original) +++ llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Mon May 18 16:02:18 2009 @@ -134,6 +134,7 @@ TII->RemoveBranch(*MBB); ChangedMBBs.insert(MBB); ++NumIntraElim; + Changed = true; continue; } @@ -231,6 +232,7 @@ TII->InsertBranch(*FtMBB, FtTBB, FtFBB, FtCond); ChangedMBBs.insert(FtMBB); } + Changed = true; // If BB is the loop latch, we may have a new loop headr. if (MBB == L->getLoopLatch()) { From akyrtzi at gmail.com Mon May 18 16:06:48 2009 From: akyrtzi at gmail.com (Argiris Kirtzidis) Date: Mon, 18 May 2009 21:06:48 -0000 Subject: [llvm-commits] [llvm] r72040 - in /llvm/trunk: include/llvm/ExecutionEngine/ExecutionEngine.h lib/ExecutionEngine/JIT/JIT.cpp lib/ExecutionEngine/JIT/JIT.h lib/ExecutionEngine/JIT/JITEmitter.cpp Message-ID: <200905182106.n4IL6xl1030221@zion.cs.uiuc.edu> Author: akirtzidis Date: Mon May 18 16:06:40 2009 New Revision: 72040 URL: http://llvm.org/viewvc/llvm-project?rev=72040&view=rev Log: Allow the JIT ExecutionEngine to report details about the generated machine code. Introduce a new class (MachineCodeInfo) that the JIT can fill in with details. Right now, just the address and the size of the machine code are reported. Patch by Evan Phoenix! Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp llvm/trunk/lib/ExecutionEngine/JIT/JIT.h llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h?rev=72040&r1=72039&r2=72040&view=diff ============================================================================== --- llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h (original) +++ llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h Mon May 18 16:06:40 2009 @@ -35,6 +35,7 @@ class Type; class MutexGuard; class JITMemoryManager; +class MachineCodeInfo; class ExecutionEngineState { private: @@ -241,6 +242,9 @@ return getPointerToFunction(F); } + // The JIT overrides a version that actually does this. + virtual void runJITOnFunction(Function *F, MachineCodeInfo *MCI = 0) { } + /// getGlobalValueAtAddress - Return the LLVM global value object that starts /// at the specified address. /// Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=72040&r1=72039&r2=72040&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Mon May 18 16:06:40 2009 @@ -21,6 +21,7 @@ #include "llvm/ModuleProvider.h" #include "llvm/CodeGen/MachineCodeEmitter.h" #include "llvm/ExecutionEngine/GenericValue.h" +#include "llvm/CodeGen/MachineCodeInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetJITInfo.h" @@ -512,9 +513,14 @@ /// just-in-time compilation passes on F, hopefully filling in /// GlobalAddress[F] with the address of F's machine code. /// -void JIT::runJITOnFunction(Function *F) { +void JIT::runJITOnFunction(Function *F, MachineCodeInfo *MCI) { MutexGuard locked(lock); + + registerMachineCodeInfo(MCI); + runJITOnFunctionUnlocked(F, locked); + + registerMachineCodeInfo(0); } void JIT::runJITOnFunctionUnlocked(Function *F, const MutexGuard &locked) { Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.h?rev=72040&r1=72039&r2=72040&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.h (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.h Mon May 18 16:06:40 2009 @@ -23,6 +23,7 @@ class TargetMachine; class TargetJITInfo; class MachineCodeEmitter; +class MachineCodeInfo; class JITState { private: @@ -151,14 +152,18 @@ static ExecutionEngine *createJIT(ModuleProvider *MP, std::string *Err, JITMemoryManager *JMM, CodeGenOpt::Level OptLevel); - + + + // Run the JIT on F and return information about the generated code + void runJITOnFunction(Function *F, MachineCodeInfo *MCI = 0); + private: static MachineCodeEmitter *createEmitter(JIT &J, JITMemoryManager *JMM); - void runJITOnFunction(Function *F); + void registerMachineCodeInfo(MachineCodeInfo *MCI); void runJITOnFunctionUnlocked(Function *F, const MutexGuard &locked); void updateFunctionStub(Function *F); void updateDlsymStubTable(); - + protected: /// getMemoryforGV - Allocate memory for a global variable. Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=72040&r1=72039&r2=72040&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Mon May 18 16:06:40 2009 @@ -26,6 +26,7 @@ #include "llvm/CodeGen/MachineRelocation.h" #include "llvm/ExecutionEngine/JITMemoryManager.h" #include "llvm/ExecutionEngine/GenericValue.h" +#include "llvm/CodeGen/MachineCodeInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetJITInfo.h" #include "llvm/Target/TargetMachine.h" @@ -614,9 +615,12 @@ // ExtFnStubs - A map of external function names to stubs which have entries // in the JITResolver's ExternalFnToStubMap. StringMap ExtFnStubs; - + + // MCI - A pointer to a MachineCodeInfo object to update with information. + MachineCodeInfo *MCI; + public: - JITEmitter(JIT &jit, JITMemoryManager *JMM) : Resolver(jit), CurFn(0) { + JITEmitter(JIT &jit, JITMemoryManager *JMM) : Resolver(jit), CurFn(0), MCI(0) { MemMgr = JMM ? JMM : JITMemoryManager::CreateDefaultMemManager(); if (jit.getJITInfo().needsGOT()) { MemMgr->AllocateGOT(); @@ -712,6 +716,10 @@ JITMemoryManager *getMemMgr(void) const { return MemMgr; } + void setMachineCodeInfo(MachineCodeInfo *mci) { + MCI = mci; + } + private: void *getPointerToGlobal(GlobalValue *GV, void *Reference, bool NoNeedStub); void *getPointerToGVIndirectSym(GlobalValue *V, void *Reference, @@ -1155,6 +1163,12 @@ << "] Function: " << F.getFunction()->getName() << ": " << (FnEnd-FnStart) << " bytes of text, " << Relocations.size() << " relocations\n"; + + if (MCI) { + MCI->setAddress(FnStart); + MCI->setSize(FnEnd-FnStart); + } + Relocations.clear(); ConstPoolAddresses.clear(); @@ -1478,6 +1492,13 @@ return JE->getJITResolver().getFunctionStub(F); } +void JIT::registerMachineCodeInfo(MachineCodeInfo *mc) { + assert(isa(MCE) && "Unexpected MCE?"); + JITEmitter *JE = cast(getCodeEmitter()); + + JE->setMachineCodeInfo(mc); +} + void JIT::updateFunctionStub(Function *F) { // Get the empty stub we generated earlier. assert(isa(MCE) && "Unexpected MCE?"); From akyrtzi at gmail.com Mon May 18 16:08:46 2009 From: akyrtzi at gmail.com (Argiris Kirtzidis) Date: Mon, 18 May 2009 21:08:46 -0000 Subject: [llvm-commits] [llvm] r72042 - /llvm/trunk/include/llvm/CodeGen/MachineCodeInfo.h Message-ID: <200905182108.n4IL8lOs030292@zion.cs.uiuc.edu> Author: akirtzidis Date: Mon May 18 16:08:45 2009 New Revision: 72042 URL: http://llvm.org/viewvc/llvm-project?rev=72042&view=rev Log: Add missing file. Added: llvm/trunk/include/llvm/CodeGen/MachineCodeInfo.h Added: llvm/trunk/include/llvm/CodeGen/MachineCodeInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineCodeInfo.h?rev=72042&view=auto ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineCodeInfo.h (added) +++ llvm/trunk/include/llvm/CodeGen/MachineCodeInfo.h Mon May 18 16:08:45 2009 @@ -0,0 +1,51 @@ +//===-- MachineCodeInfo.h - Class used to report JIT info -------*- 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 MachineCodeInfo, a class used by the JIT ExecutionEngine +// to report information about the generated machine code. +// +// See JIT::runJITOnFunction for usage. +// +//===----------------------------------------------------------------------===// + +#ifndef EE_MACHINE_CODE_INFO_H +#define EE_MACHINE_CODE_INFO_H + +namespace llvm { + +class MachineCodeInfo { +private: + size_t Size; // Number of bytes in memory used + void *Address; // The address of the function in memory + +public: + MachineCodeInfo() : Size(0), Address(0) {} + + void setSize(size_t s) { + Size = s; + } + + void setAddress(void *a) { + Address = a; + } + + size_t size() const { + return Size; + } + + void *address() const { + return Address; + } + +}; + +} + +#endif + From akyrtzi at gmail.com Mon May 18 16:13:28 2009 From: akyrtzi at gmail.com (Argiris Kirtzidis) Date: Tue, 19 May 2009 00:13:28 +0300 Subject: [llvm-commits] [PATCH] Generate info about the JIT process In-Reply-To: <0F735E86-C6C7-4352-8262-B394C70A5D26@fallingsnow.net> References: <978B1AEF-4B6B-4BA1-A73F-6FEF5C95A12D@fallingsnow.net> <4A0A6C85.1030909@gmail.com> <4A0A90FB.3000907@gmail.com> <0A9506FE-111E-4D3C-BC04-D962645AA1DE@apple.com> <0F735E86-C6C7-4352-8262-B394C70A5D26@fallingsnow.net> Message-ID: <4A11CF78.8020301@gmail.com> Hi Evan, I commited the patch, thanks! -Argiris Evan Phoenix wrote: > I haven't heard anything from Argiris, or any other thoughts on what > the JITListener would look like. I hesitate to write such a thing > without an idea of what people want, so I'm hoping we can commit my > patch as is. > > When there is more discussion about the JITListener, it will be easy > to make MachineCodeInfo sit on top of it without any external API > changes. > > I've attached an updated version of the patch against SVN HEAD. > > - Evan > > > > On May 13, 2009, at 10:21 AM, Chris Lattner wrote: > >> On May 13, 2009, at 2:20 AM, Argiris Kirtzidis wrote: >>>> Thats basically what MachineCodeInfo enables. ATM, there are only 2 >>>> things it publishes directly to the MCI, but future APIs can easily be >>>> added using virtual methods to allow for subclasses of MachineCodeInfo >>>> to do new things. >>>> >>>> This is far from a final set of things MCI will do, it's primarily a >>>> way of introduce an API that we can add future things to. >>> >>> Ok, that sounds great. It's just that MachineCodeInfo is restricted to >>> the "function level", how about "module level" info, specifically >>> getting notifications during code execution like: >>> -"I lazy JITed this function" >>> -"I allocated this memory chunk for this global variable" >>> >>> Of course, MachineCodeInfo could be the one for the "function level" >>> and >>> something like "JITListener" at the module level. The JITListener could >>> have a method that passes a MachineCodeInfo before function JITing. IMO >>> this is flexible and clean. >> >> I agree with Argiris: there should be a simple abstract interface >> with methods like the above. The JIT should have an optional pointer >> to it. If non-null, it would invoke the methods on the JITListener. >> This would allow lots of detailed instrumentation, but would >> introduce no overhead if it's not being used. >> >> -Chris > > ------------------------------------------------------------------------ > > _______________________________________________ > 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 Mon May 18 16:17:21 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 18 May 2009 21:17:21 -0000 Subject: [llvm-commits] [nightly-test-server] r72043 - /nightly-test-server/trunk/NightlyTestAccept.php Message-ID: <200905182117.n4ILHS2b030542@zion.cs.uiuc.edu> Author: bwilson Date: Mon May 18 16:17:03 2009 New Revision: 72043 URL: http://llvm.org/viewvc/llvm-project?rev=72043&view=rev Log: Fix pr4030: Include the $machine_id in the URL for the buildlog. Modified: nightly-test-server/trunk/NightlyTestAccept.php Modified: nightly-test-server/trunk/NightlyTestAccept.php URL: http://llvm.org/viewvc/llvm-project/nightly-test-server/trunk/NightlyTestAccept.php?rev=72043&r1=72042&r2=72043&view=diff ============================================================================== --- nightly-test-server/trunk/NightlyTestAccept.php (original) +++ nightly-test-server/trunk/NightlyTestAccept.php Mon May 18 16:17:03 2009 @@ -939,7 +939,7 @@ } else{ $email .= "\nBuildlog available at http://llvm.org/nightlytest/". - "machines/$db_date-Build-Log.txt\n"; + "machines/$machine_id/$db_date-Build-Log.txt\n"; } $email_addr = "llvm-testresults\@cs.uiuc.edu"; From evan at fallingsnow.net Mon May 18 16:38:59 2009 From: evan at fallingsnow.net (Evan Phoenix) Date: Mon, 18 May 2009 14:38:59 -0700 Subject: [llvm-commits] [PATCH] Generate info about the JIT process In-Reply-To: <4A11CF78.8020301@gmail.com> References: <978B1AEF-4B6B-4BA1-A73F-6FEF5C95A12D@fallingsnow.net> <4A0A6C85.1030909@gmail.com> <4A0A90FB.3000907@gmail.com> <0A9506FE-111E-4D3C-BC04-D962645AA1DE@apple.com> <0F735E86-C6C7-4352-8262-B394C70A5D26@fallingsnow.net> <4A11CF78.8020301@gmail.com> Message-ID: On May 18, 2009, at 2:13 PM, Argiris Kirtzidis wrote: > Hi Evan, > > I commited the patch, thanks! Wonderful! Thanks so much! - Evan > > > -Argiris > > > Evan Phoenix wrote: >> I haven't heard anything from Argiris, or any other thoughts on >> what the JITListener would look like. I hesitate to write such a >> thing without an idea of what people want, so I'm hoping we can >> commit my patch as is. >> >> When there is more discussion about the JITListener, it will be >> easy to make MachineCodeInfo sit on top of it without any external >> API changes. >> >> I've attached an updated version of the patch against SVN HEAD. >> >> - Evan >> >> >> >> On May 13, 2009, at 10:21 AM, Chris Lattner wrote: >> >>> On May 13, 2009, at 2:20 AM, Argiris Kirtzidis wrote: >>>>> Thats basically what MachineCodeInfo enables. ATM, there are >>>>> only 2 >>>>> things it publishes directly to the MCI, but future APIs can >>>>> easily be >>>>> added using virtual methods to allow for subclasses of >>>>> MachineCodeInfo >>>>> to do new things. >>>>> >>>>> This is far from a final set of things MCI will do, it's >>>>> primarily a >>>>> way of introduce an API that we can add future things to. >>>> >>>> Ok, that sounds great. It's just that MachineCodeInfo is >>>> restricted to >>>> the "function level", how about "module level" info, specifically >>>> getting notifications during code execution like: >>>> -"I lazy JITed this function" >>>> -"I allocated this memory chunk for this global variable" >>>> >>>> Of course, MachineCodeInfo could be the one for the "function >>>> level" and >>>> something like "JITListener" at the module level. The JITListener >>>> could >>>> have a method that passes a MachineCodeInfo before function >>>> JITing. IMO >>>> this is flexible and clean. >>> >>> I agree with Argiris: there should be a simple abstract interface >>> with methods like the above. The JIT should have an optional >>> pointer to it. If non-null, it would invoke the methods on the >>> JITListener. This would allow lots of detailed instrumentation, >>> but would introduce no overhead if it's not being used. >>> >>> -Chris >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> From dalej at apple.com Mon May 18 16:42:26 2009 From: dalej at apple.com (Dale Johannesen) Date: Mon, 18 May 2009 21:42:26 -0000 Subject: [llvm-commits] [llvm] r72045 - /llvm/trunk/lib/Target/X86/X86InstrInfo.td Message-ID: <200905182142.n4ILgWgP031346@zion.cs.uiuc.edu> Author: johannes Date: Mon May 18 16:41:59 2009 New Revision: 72045 URL: http://llvm.org/viewvc/llvm-project?rev=72045&view=rev Log: Add OpSize to 16-bit ADC and SBB. 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=72045&r1=72044&r2=72045&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon May 18 16:41:59 2009 @@ -2280,7 +2280,7 @@ def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), "adc{w}\t{$src2, $dst|$dst, $src2}", - [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>; + [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize; def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2), "adc{l}\t{$src2, $dst|$dst, $src2}", @@ -2293,7 +2293,8 @@ def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2), "adc{w}\t{$src2, $dst|$dst, $src2}", - [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>; + [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>, + OpSize; def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2), "adc{l}\t{$src2, $dst|$dst, $src2}", @@ -2304,11 +2305,12 @@ def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), "adc{w}\t{$src2, $dst|$dst, $src2}", - [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>; + [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize; def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2), "adc{w}\t{$src2, $dst|$dst, $src2}", - [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>; + [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>, + OpSize; def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2), "adc{l}\t{$src2, $dst|$dst, $src2}", @@ -2324,7 +2326,8 @@ [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>; def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), "adc{w}\t{$src2, $dst|$dst, $src2}", - [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>; + [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>, + OpSize; def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), "adc{l}\t{$src2, $dst|$dst, $src2}", [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>; @@ -2333,10 +2336,12 @@ [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>; def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2), "adc{w}\t{$src2, $dst|$dst, $src2}", - [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>; + [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>, + OpSize; def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2), "adc{w}\t{$src2, $dst|$dst, $src2}", - [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>; + [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>, + OpSize; def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2), "adc{l}\t{$src2, $dst|$dst, $src2}", [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>; @@ -2452,7 +2457,7 @@ def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), "sbb{w}\t{$src2, $dst|$dst, $src2}", - [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>; + [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize; def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2), "sbb{l}\t{$src2, $dst|$dst, $src2}", @@ -2464,7 +2469,8 @@ [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>; def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), "sbb{w}\t{$src2, $dst|$dst, $src2}", - [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>; + [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>, + OpSize; def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), "sbb{l}\t{$src2, $dst|$dst, $src2}", [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>; @@ -2473,10 +2479,12 @@ [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>; def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2), "sbb{w}\t{$src2, $dst|$dst, $src2}", - [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>; + [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>, + OpSize; def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2), "sbb{w}\t{$src2, $dst|$dst, $src2}", - [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>; + [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>, + OpSize; def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2), "sbb{l}\t{$src2, $dst|$dst, $src2}", [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>; @@ -2490,7 +2498,8 @@ def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2), "sbb{w}\t{$src2, $dst|$dst, $src2}", - [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>; + [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>, + OpSize; def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2), "sbb{l}\t{$src2, $dst|$dst, $src2}", @@ -2501,11 +2510,12 @@ def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), "sbb{w}\t{$src2, $dst|$dst, $src2}", - [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>; + [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize; def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2), "sbb{w}\t{$src2, $dst|$dst, $src2}", - [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>; + [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>, + OpSize; def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2), "sbb{l}\t{$src2, $dst|$dst, $src2}", From isanbard at gmail.com Mon May 18 17:02:44 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 18 May 2009 22:02:44 -0000 Subject: [llvm-commits] [llvm] r72047 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h Message-ID: <200905182202.n4IM2jVA032127@zion.cs.uiuc.edu> Author: void Date: Mon May 18 17:02:36 2009 New Revision: 72047 URL: http://llvm.org/viewvc/llvm-project?rev=72047&view=rev Log: RecordVariable is called each time a DECLARE node is encountered. For an inlined function, this could be many, many times. We don't want to re-add variables to that DIE for each time. We just want to add them once. Check to make sure that we haven't added them already. 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=72047&r1=72046&r2=72047&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon May 18 17:02:36 2009 @@ -855,7 +855,8 @@ /// CreateSubprogramDIE - Create new DIE using SP. DIE *DwarfDebug::CreateSubprogramDIE(CompileUnit *DW_Unit, const DISubprogram &SP, - bool IsConstructor) { + bool IsConstructor, + bool IsInlined) { DIE *SPDie = new DIE(dwarf::DW_TAG_subprogram); std::string Name; @@ -903,7 +904,7 @@ } } - if (!SP.isLocalToUnit()) + if (!SP.isLocalToUnit() && !IsInlined) AddUInt(SPDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1); // DW_TAG_inlined_subroutine may refer to this DIE. @@ -2425,7 +2426,7 @@ return ID; } -/// RecordVariable - Indicate the declaration of a local variable. +/// RecordVariable - Indicate the declaration of a local variable. void DwarfDebug::RecordVariable(GlobalVariable *GV, unsigned FrameIndex, const MachineInstr *MI) { if (TimePassesIsEnabled) @@ -2453,12 +2454,33 @@ DenseMap::iterator AI = AbstractInstanceRootMap.find(V); - if (AI != AbstractInstanceRootMap.end()) + if (AI != AbstractInstanceRootMap.end()) { + // This method is called each time a DECLARE node is encountered. For an + // inlined function, this could be many, many times. We don't want to + // re-add variables to that DIE for each time. We just want to add them + // once. Check to make sure that we haven't added them already. + DenseMap >::iterator + IP = InlinedParamMap.find(V); + + if (IP != InlinedParamMap.end()) { + SmallSet &S = IP->second; + + if (S.count(GV) > 0) { + if (TimePassesIsEnabled) + DebugTimer->stopTimer(); + return; + } + + } + // or GV is an inlined local variable. Scope = AI->second; - else + InlinedParamMap[V].insert(GV); + } else { // or GV is a local variable. Scope = getOrCreateScope(V); + } } } @@ -2494,13 +2516,13 @@ CompileUnit *Unit = &FindCompileUnit(SP.getCompileUnit()); DIE *SPDie = Unit->getDieMapSlotFor(GV); if (!SPDie) - SPDie = CreateSubprogramDIE(Unit, SP); + SPDie = CreateSubprogramDIE(Unit, SP, false, true); // Mark as being inlined. This makes this subprogram entry an abstract // instance root. // FIXME: Our debugger doesn't care about the value of DW_AT_inline, only - // that it's defined. It probably won't change in the future, but this - // could be more elegant. + // that it's defined. That probably won't change in the future. However, + // this could be more elegant. AddUInt(SPDie, dwarf::DW_AT_inline, 0, dwarf::DW_INL_declared_not_inlined); // Keep track of the abstract scope for this function. @@ -2566,6 +2588,7 @@ I = DbgConcreteScopeMap.find(GV); if (I == DbgConcreteScopeMap.end()) { + // FIXME: Can this situation actually happen? And if so, should it? if (TimePassesIsEnabled) DebugTimer->stopTimer(); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=72047&r1=72046&r2=72047&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon May 18 17:02:36 2009 @@ -22,6 +22,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/UniqueVector.h" #include @@ -163,6 +164,11 @@ /// attribute. DenseMap AbstractInstanceRootMap; + /// InlinedParamMap - A map keeping track of which parameters are assigned to + /// which abstract instance. + DenseMap > InlinedParamMap; + /// AbstractInstanceRootList - List of abstract instance roots of inlined /// functions. These are subroutine entries that contain a DW_AT_inline /// attribute. @@ -333,7 +339,8 @@ /// CreateSubprogramDIE - Create new DIE using SP. DIE *CreateSubprogramDIE(CompileUnit *DW_Unit, const DISubprogram &SP, - bool IsConstructor = false); + bool IsConstructor = false, + bool IsInlined = false); /// FindCompileUnit - Get the compile unit for the given descriptor. /// From evan.cheng at apple.com Mon May 18 17:14:46 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 18 May 2009 22:14:46 -0000 Subject: [llvm-commits] [llvm] r72050 - /llvm/trunk/docs/TableGenFundamentals.html Message-ID: <200905182214.n4IMEkcm032623@zion.cs.uiuc.edu> Author: evancheng Date: Mon May 18 17:14:45 2009 New Revision: 72050 URL: http://llvm.org/viewvc/llvm-project?rev=72050&view=rev Log: Add short descriptions of 'implicit' and 'parallel'. Modified: llvm/trunk/docs/TableGenFundamentals.html Modified: llvm/trunk/docs/TableGenFundamentals.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/TableGenFundamentals.html?rev=72050&r1=72049&r2=72050&view=diff ============================================================================== --- llvm/trunk/docs/TableGenFundamentals.html (original) +++ llvm/trunk/docs/TableGenFundamentals.html Mon May 18 17:14:45 2009 @@ -395,6 +395,13 @@
a dag value. The first element is required to be a record definition, the remaining elements in the list may be arbitrary other values, including nested `dag' values.
+
(implicit a)
+
an implicitly defined physical register. This tells the dag instruction + selection emitter the input pattern's extra definitions matches implicit + physical register definitions.
+
(parallel (a), (b))
+
a list of dags specifying parallel operations which map to the same + instruction.
!strconcat(a, b)
A string value that is the result of concatenating the 'a' and 'b' strings.
From gohman at apple.com Mon May 18 17:15:25 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 18 May 2009 22:15:25 -0000 Subject: [llvm-commits] [llvm] r72051 - /llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h Message-ID: <200905182215.n4IMFQJA032653@zion.cs.uiuc.edu> Author: djg Date: Mon May 18 17:15:25 2009 New Revision: 72051 URL: http://llvm.org/viewvc/llvm-project?rev=72051&view=rev Log: Update a comment to reflect changes in the surrounding code. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h?rev=72051&r1=72050&r2=72051&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h Mon May 18 17:15:25 2009 @@ -220,7 +220,7 @@ return true; } - // hasComputableLoopEvolution - Commutative expressions have computable loop + // hasComputableLoopEvolution - N-ary expressions have computable loop // evolutions iff they have at least one operand that varies with the loop, // but that all varying operands are computable. virtual bool hasComputableLoopEvolution(const Loop *L) const { From isanbard at gmail.com Mon May 18 17:33:01 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 18 May 2009 22:33:01 -0000 Subject: [llvm-commits] [llvm] r72057 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200905182233.n4IMX1fi000848@zion.cs.uiuc.edu> Author: void Date: Mon May 18 17:33:01 2009 New Revision: 72057 URL: http://llvm.org/viewvc/llvm-project?rev=72057&view=rev Log: Small code cleanup. 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=72057&r1=72056&r2=72057&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon May 18 17:33:01 2009 @@ -2463,15 +2463,10 @@ SmallSet >::iterator IP = InlinedParamMap.find(V); - if (IP != InlinedParamMap.end()) { - SmallSet &S = IP->second; - - if (S.count(GV) > 0) { - if (TimePassesIsEnabled) - DebugTimer->stopTimer(); - return; - } - + if (IP != InlinedParamMap.end() && IP->second.count(GV) > 0) { + if (TimePassesIsEnabled) + DebugTimer->stopTimer(); + return; } // or GV is an inlined local variable. From resistor at mac.com Mon May 18 16:44:42 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 18 May 2009 16:44:42 -0500 Subject: [llvm-commits] [PATCH] Detect GCC atomic builtins in configure In-Reply-To: <73637BEF-61A8-4BA9-88FB-985D955108FF@mac.com> References: <7FDB65CF-9461-4DA6-B206-FD2F5EEFA615@mac.com> <39E5492E-0BA1-465F-8A42-BAA459433D4B@mac.com> <73637BEF-61A8-4BA9-88FB-985D955108FF@mac.com> Message-ID: <7296517323013093458502609274541346967-Webmail@me.com> And here's Take 3, in which I incorporate feedback from Eric, and figure out the difference between AC_SUBST and AC_DEFINE! --Owen -------------- next part -------------- A non-text attachment was scrubbed... Name: config.patch Type: application/octet-stream Size: 1314 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090518/b190eb81/attachment.obj From echristo at apple.com Mon May 18 18:06:14 2009 From: echristo at apple.com (Eric Christopher) Date: Mon, 18 May 2009 16:06:14 -0700 Subject: [llvm-commits] [PATCH] Detect GCC atomic builtins in configure In-Reply-To: <7296517323013093458502609274541346967-Webmail@me.com> References: <7FDB65CF-9461-4DA6-B206-FD2F5EEFA615@mac.com> <39E5492E-0BA1-465F-8A42-BAA459433D4B@mac.com> <73637BEF-61A8-4BA9-88FB-985D955108FF@mac.com> <7296517323013093458502609274541346967-Webmail@me.com> Message-ID: <26BF1D56-5396-4B37-9D07-C51DE955D79A@apple.com> On May 18, 2009, at 2:44 PM, Owen Anderson wrote: > And here's Take 3, in which I incorporate feedback from Eric, and > figure out the difference between AC_SUBST and AC_DEFINE! Quite a better, couple of questions/comments: a) If you're doing this then why the configure flag? Shouldn't something just fail to link ultimately if this is wrong? b) I'm pretty sure that you don't need the [] around the values - at least not for AC_SUBST and AC_DEFINE. c) The bits above for enable_thread should probably look like what I sent last night. d) This should also probably be right under that in the configure.ac file. Confusing otherwise :) -eric From isanbard at gmail.com Mon May 18 18:08:55 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 18 May 2009 23:08:55 -0000 Subject: [llvm-commits] [llvm] r72064 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200905182308.n4IN8tEn002301@zion.cs.uiuc.edu> Author: void Date: Mon May 18 18:08:55 2009 New Revision: 72064 URL: http://llvm.org/viewvc/llvm-project?rev=72064&view=rev Log: Don't set the "location" information for inlined functions' variables. 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=72064&r1=72063&r2=72064&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon May 18 18:08:55 2009 @@ -129,12 +129,15 @@ class VISIBILITY_HIDDEN DbgVariable { DIVariable Var; // Variable Descriptor. unsigned FrameIndex; // Variable frame index. + bool InlinedFnVar; // Variable for an inlined function. public: - DbgVariable(DIVariable V, unsigned I) : Var(V), FrameIndex(I) {} + DbgVariable(DIVariable V, unsigned I, bool IFV) + : Var(V), FrameIndex(I), InlinedFnVar(IFV) {} // Accessors. - DIVariable getVariable() const { return Var; } + DIVariable getVariable() const { return Var; } unsigned getFrameIndex() const { return FrameIndex; } + bool isInlinedFnVar() const { return InlinedFnVar; } }; //===----------------------------------------------------------------------===// @@ -956,10 +959,14 @@ AddType(Unit, VariableDie, VD.getType()); // Add variable address. - MachineLocation Location; - Location.set(RI->getFrameRegister(*MF), - RI->getFrameIndexOffset(*MF, DV->getFrameIndex())); - AddAddress(VariableDie, dwarf::DW_AT_location, Location); + if (!DV->isInlinedFnVar()) { + // Variables for abstract instances of inlined functions don't get a + // location. + MachineLocation Location; + Location.set(RI->getFrameRegister(*MF), + RI->getFrameIndexOffset(*MF, DV->getFrameIndex())); + AddAddress(VariableDie, dwarf::DW_AT_location, Location); + } return VariableDie; } @@ -2434,6 +2441,7 @@ DIDescriptor Desc(GV); DbgScope *Scope = NULL; + bool InlinedFnVar = false; if (Desc.getTag() == dwarf::DW_TAG_variable) { // GV is a global variable. @@ -2472,6 +2480,7 @@ // or GV is an inlined local variable. Scope = AI->second; InlinedParamMap[V].insert(GV); + InlinedFnVar = true; } else { // or GV is a local variable. Scope = getOrCreateScope(V); @@ -2480,7 +2489,7 @@ } assert(Scope && "Unable to find the variable's scope"); - DbgVariable *DV = new DbgVariable(DIVariable(GV), FrameIndex); + DbgVariable *DV = new DbgVariable(DIVariable(GV), FrameIndex, InlinedFnVar); Scope->AddVariable(DV); if (TimePassesIsEnabled) From kremenek at apple.com Mon May 18 18:20:16 2009 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 18 May 2009 23:20:16 -0000 Subject: [llvm-commits] [llvm] r72068 - /llvm/tags/checker/checker-0.209/ Message-ID: <200905182320.n4INKGUX002728@zion.cs.uiuc.edu> Author: kremenek Date: Mon May 18 18:20:15 2009 New Revision: 72068 URL: http://llvm.org/viewvc/llvm-project?rev=72068&view=rev Log: Tagging checker-0.209. Added: llvm/tags/checker/checker-0.209/ - copied from r72067, llvm/trunk/ From daniel at zuster.org Mon May 18 18:24:27 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 18 May 2009 23:24:27 -0000 Subject: [llvm-commits] [llvm] r72070 - /llvm/trunk/utils/NewNightlyTest.pl Message-ID: <200905182324.n4INORhv002912@zion.cs.uiuc.edu> Author: ddunbar Date: Mon May 18 18:24:26 2009 New Revision: 72070 URL: http://llvm.org/viewvc/llvm-project?rev=72070&view=rev Log: Add -submit-aux option to NewNightlyTest.pl - If given, the argument will be run using system with the path to the sent data. Useful for testing nightlytest server replacements. Modified: llvm/trunk/utils/NewNightlyTest.pl Modified: llvm/trunk/utils/NewNightlyTest.pl URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/NewNightlyTest.pl?rev=72070&r1=72069&r2=72070&view=diff ============================================================================== --- llvm/trunk/utils/NewNightlyTest.pl (original) +++ llvm/trunk/utils/NewNightlyTest.pl Mon May 18 18:24:26 2009 @@ -75,6 +75,9 @@ # this option is not specified it defaults to # /nightlytest/NightlyTestAccept.php. This is basically # everything after the www.yourserver.org. +# -submit-aux If specified, an auxiliary script to run in addition to the +# normal submit script. The script will be passed the path to +# the "sentdata.txt" file as its sole argument. # -nosubmit Do not report the test results back to a submit server. # # CVSROOT is the CVS repository from which the tree will be checked out, @@ -128,6 +131,7 @@ $MAKECMD="make"; $SUBMITSERVER = "llvm.org"; $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php"; +$SUBMITAUX=""; $SUBMIT = 1; while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) { @@ -168,6 +172,7 @@ shift; next; } if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; } if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; } + if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; } if (/^-nosubmit$/) { $SUBMIT = 0; next; } if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; } if (/^-gccpath/) { $CONFIGUREARGS .= @@ -477,6 +482,9 @@ } WriteFile "$Prefix-sentdata.txt", $sentdata; + if (!($SUBMITAUX eq "")) { + system "$SUBMITAUX \"$Prefix-sentdata.txt\""; + } return $result; } From resistor at mac.com Mon May 18 18:29:07 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 18 May 2009 18:29:07 -0500 Subject: [llvm-commits] [PATCH] Detect GCC atomic builtins in configure In-Reply-To: <26BF1D56-5396-4B37-9D07-C51DE955D79A@apple.com> References: <7FDB65CF-9461-4DA6-B206-FD2F5EEFA615@mac.com> <39E5492E-0BA1-465F-8A42-BAA459433D4B@mac.com> <73637BEF-61A8-4BA9-88FB-985D955108FF@mac.com> <7296517323013093458502609274541346967-Webmail@me.com> <26BF1D56-5396-4B37-9D07-C51DE955D79A@apple.com> Message-ID: <148449344759468636145448259517377278506-Webmail@me.com> On Monday, May 18, 2009, at 06:06PM, "Eric Christopher" wrote: >Quite a better, couple of questions/comments: > >a) If you're doing this then why the configure flag? Shouldn't >something just fail to link ultimately if this is wrong? LLVM can be built in threads-disabled mode, which turns mutexes into no-ops, etc. The sensible policy seems (to me) to be to try to honor the user's request for thread-safety if possible. If not, we print a warning and continue to build in thread-unsafe mode. Thinking about it a bit more, maybe we should make it a hard error if the user explicitly asked for thread-safety on an unsupported target, and a warning if it's just thread-safety-as-default. >b) I'm pretty sure that you don't need the [] around the values - at >least not for AC_SUBST and AC_DEFINE. I have no idea. I just copied and pasted from elsewhere. :-) --Owen From echristo at apple.com Mon May 18 18:35:33 2009 From: echristo at apple.com (Eric Christopher) Date: Mon, 18 May 2009 16:35:33 -0700 Subject: [llvm-commits] [PATCH] Detect GCC atomic builtins in configure In-Reply-To: <148449344759468636145448259517377278506-Webmail@me.com> References: <7FDB65CF-9461-4DA6-B206-FD2F5EEFA615@mac.com> <39E5492E-0BA1-465F-8A42-BAA459433D4B@mac.com> <73637BEF-61A8-4BA9-88FB-985D955108FF@mac.com> <7296517323013093458502609274541346967-Webmail@me.com> <26BF1D56-5396-4B37-9D07-C51DE955D79A@apple.com> <148449344759468636145448259517377278506-Webmail@me.com> Message-ID: <2DEEB59B-0AAB-485A-96FB-D2E75033D8EC@apple.com> On May 18, 2009, at 4:29 PM, Owen Anderson wrote: > On Monday, May 18, 2009, at 06:06PM, "Eric Christopher" > wrote: > >> Quite a better, couple of questions/comments: >> >> >> >> a) If you're doing this then why the configure flag? Shouldn't >> >> something just fail to link ultimately if this is wrong? >> > > LLVM can be built in threads-disabled mode, which turns mutexes into > no-ops, etc. > The sensible policy seems (to me) to be to try to honor the user's > request for > thread-safety if possible. If not, we print a warning and continue > to build > in thread-unsafe mode. > > Thinking about it a bit more, maybe we should make it a hard error > if the > user explicitly asked for thread-safety on an unsupported target, and > a warning if it's just thread-safety-as-default. > Don't know how you'd guess target though since llvm is multi-arch at build time. Honestly I think you get what you ask for it might be much more simple to just mark which targets work and then have a preprocessor flag that sees if it's set and the native platform. *shrug* :) > >> b) I'm pretty sure that you don't need the [] around the values - at >> >> least not for AC_SUBST and AC_DEFINE. >> > > I have no idea. I just copied and pasted from elsewhere. :-) > Aaah. I don't believe you need it. -eric From resistor at mac.com Mon May 18 18:46:37 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 18 May 2009 18:46:37 -0500 Subject: [llvm-commits] [PATCH] Detect GCC atomic builtins in configure In-Reply-To: <2DEEB59B-0AAB-485A-96FB-D2E75033D8EC@apple.com> References: <7FDB65CF-9461-4DA6-B206-FD2F5EEFA615@mac.com> <39E5492E-0BA1-465F-8A42-BAA459433D4B@mac.com> <73637BEF-61A8-4BA9-88FB-985D955108FF@mac.com> <7296517323013093458502609274541346967-Webmail@me.com> <26BF1D56-5396-4B37-9D07-C51DE955D79A@apple.com> <148449344759468636145448259517377278506-Webmail@me.com> <2DEEB59B-0AAB-485A-96FB-D2E75033D8EC@apple.com> Message-ID: <79026032486662333965431321961251389077-Webmail@me.com> On Monday, May 18, 2009, at 06:35PM, "Eric Christopher" wrote: >Don't know how you'd guess target though since llvm is multi-arch at >build time. > >Honestly I think you get what you ask for it might be much more simple >to >just mark which targets work and then have a preprocessor flag that sees >if it's set and the native platform. > >*shrug* :) > I'm adding support for threading LLVM itself, nothing to do with the code that it generates. For LLVM itself to be thread-safe, we need to have access to certain atomic intrinsics on the target for which LLVM is being built. I think the current solution handles that, and should work just fine on a cross-compiled system now that I've switched to link-testing rather than run-testing. Right? --Owen From echristo at apple.com Mon May 18 18:52:26 2009 From: echristo at apple.com (Eric Christopher) Date: Mon, 18 May 2009 16:52:26 -0700 Subject: [llvm-commits] [PATCH] Detect GCC atomic builtins in configure In-Reply-To: <79026032486662333965431321961251389077-Webmail@me.com> References: <7FDB65CF-9461-4DA6-B206-FD2F5EEFA615@mac.com> <39E5492E-0BA1-465F-8A42-BAA459433D4B@mac.com> <73637BEF-61A8-4BA9-88FB-985D955108FF@mac.com> <7296517323013093458502609274541346967-Webmail@me.com> <26BF1D56-5396-4B37-9D07-C51DE955D79A@apple.com> <148449344759468636145448259517377278506-Webmail@me.com> <2DEEB59B-0AAB-485A-96FB-D2E75033D8EC@apple.com> <79026032486662333965431321961251389077-Webmail@me.com> Message-ID: > > I think the current solution handles that, and should work just fine > on a cross-compiled system now that I've switched to link-testing > rather than run-testing. Right? link should be fine. I'd probably do this as a test on the target and a switch statement, but that's just me :) patch looks fine now. -eric From resistor at mac.com Mon May 18 18:58:52 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 18 May 2009 23:58:52 -0000 Subject: [llvm-commits] [llvm] r72075 - in /llvm/trunk: autoconf/configure.ac configure Message-ID: <200905182358.n4INwrhS004191@zion.cs.uiuc.edu> Author: resistor Date: Mon May 18 18:58:51 2009 New Revision: 72075 URL: http://llvm.org/viewvc/llvm-project?rev=72075&view=rev Log: Test for the presence of GCC atomic builtins at configure time. If not found, disable building LLVM in thread-safe mode and print a nice warning. Regenerate configure for these changes. Modified: llvm/trunk/autoconf/configure.ac llvm/trunk/configure Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=72075&r1=72074&r2=72075&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Mon May 18 18:58:51 2009 @@ -372,7 +372,6 @@ default) AC_SUBST(ENABLE_THREADS,[1]) ;; *) AC_MSG_ERROR([Invalid setting for --enable-threads. Use "yes" or "no"]) ;; esac -AC_DEFINE_UNQUOTED([ENABLE_THREADS],$ENABLE_THREADS,[Define if threads enabled]) dnl Allow building without position independent code AC_ARG_ENABLE(pic, @@ -897,6 +896,26 @@ fi fi +dnl atomic builtins are required for threading support. +if test "$ENABLE_THREADS" -eq 1 ; then + AC_MSG_CHECKING(for GCC atomic builtins) + AC_LINK_IFELSE( + AC_LANG_SOURCE( + [[int main() { + volatile unsigned long val = 1; + __sync_synchronize(); + __sync_val_compare_and_swap(&val, 1, 0); + return 0; + } + ]]), + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no) + AC_SUBST(ENABLE_THREADS, [0]) + AC_MSG_WARN([Threading support disabled because atomic builtins are missing])) +fi + +AC_DEFINE_UNQUOTED([ENABLE_THREADS],$ENABLE_THREADS,[Define if threads enabled]) + dnl===-----------------------------------------------------------------------=== dnl=== dnl=== SECTION 9: Additional checks, variables, etc. Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=72075&r1=72074&r2=72075&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Mon May 18 18:58:51 2009 @@ -4870,11 +4870,6 @@ { (exit 1); exit 1; }; } ;; esac -cat >>confdefs.h <<_ACEOF -#define ENABLE_THREADS $ENABLE_THREADS -_ACEOF - - # Check whether --enable-pic was given. if test "${enable_pic+set}" = set; then enableval=$enable_pic; @@ -10575,7 +10570,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext + echo '#line 12717 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -14437,11 +14432,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14440: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14435: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14444: \$? = $ac_status" >&5 + echo "$as_me:14439: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14705,11 +14700,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14708: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14703: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14712: \$? = $ac_status" >&5 + echo "$as_me:14707: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14809,11 +14804,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14812: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14807: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14816: \$? = $ac_status" >&5 + echo "$as_me:14811: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17261,7 +17256,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:19727: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:19736: \$? = $ac_status" >&5 + echo "$as_me:19731: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -19833,11 +19828,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:19836: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19831: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:19840: \$? = $ac_status" >&5 + echo "$as_me:19835: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -21403,11 +21398,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21406: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21401: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:21410: \$? = $ac_status" >&5 + echo "$as_me:21405: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -21507,11 +21502,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21510: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21505: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:21514: \$? = $ac_status" >&5 + echo "$as_me:21509: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -23742,11 +23737,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:23745: $lt_compile\"" >&5) + (eval echo "\"\$as_me:23740: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:23749: \$? = $ac_status" >&5 + echo "$as_me:23744: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24010,11 +24005,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24013: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24008: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24017: \$? = $ac_status" >&5 + echo "$as_me:24012: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24114,11 +24109,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24117: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24112: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:24121: \$? = $ac_status" >&5 + echo "$as_me:24116: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -33607,6 +33602,81 @@ fi fi +if test "$ENABLE_THREADS" -eq 1 ; then + { echo "$as_me:$LINENO: checking for GCC atomic builtins" >&5 +echo $ECHO_N "checking for GCC atomic builtins... $ECHO_C" >&6; } + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +int main() { + volatile unsigned long val = 1; + __sync_synchronize(); + __sync_val_compare_and_swap(&val, 1, 0); + return 0; + } + +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + ENABLE_THREADS=0 + + { echo "$as_me:$LINENO: WARNING: Threading support disabled because atomic builtins are missing" >&5 +echo "$as_me: WARNING: Threading support disabled because atomic builtins are missing" >&2;} +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi + + +cat >>confdefs.h <<_ACEOF +#define ENABLE_THREADS $ENABLE_THREADS +_ACEOF + + for ac_func in __dso_handle From resistor at mac.com Mon May 18 19:08:29 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 19 May 2009 00:08:29 -0000 Subject: [llvm-commits] [llvm] r72077 - in /llvm/trunk: LICENSE.TXT include/llvm/System/Atomic.h Message-ID: <200905190008.n4J08TuW004524@zion.cs.uiuc.edu> Author: resistor Date: Mon May 18 19:08:29 2009 New Revision: 72077 URL: http://llvm.org/viewvc/llvm-project?rev=72077&view=rev Log: Now that we have atomics support properly detected by configure, use it to implement Atomic.h. This expunges the code previously imported from libatomic_ops. Modified: llvm/trunk/LICENSE.TXT llvm/trunk/include/llvm/System/Atomic.h Modified: llvm/trunk/LICENSE.TXT URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/LICENSE.TXT?rev=72077&r1=72076&r2=72077&view=diff ============================================================================== --- llvm/trunk/LICENSE.TXT (original) +++ llvm/trunk/LICENSE.TXT Mon May 18 19:08:29 2009 @@ -67,4 +67,3 @@ llvm/projects/sample/autoconf CellSPU backend llvm/lib/Target/CellSPU/README.txt Google Test llvm/utils/unittest/googletest -Atomics Library llvm/include/llvm/System/Atomic.h \ No newline at end of file Modified: llvm/trunk/include/llvm/System/Atomic.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Atomic.h?rev=72077&r1=72076&r2=72077&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Atomic.h (original) +++ llvm/trunk/include/llvm/System/Atomic.h Mon May 18 19:08:29 2009 @@ -9,197 +9,64 @@ // // This file declares the llvm::sys atomic operations. // -// Portions of this file use code from libatomic_ops, for which the following -// license applies: -// -// Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// //===----------------------------------------------------------------------===// #ifndef LLVM_SYSTEM_ATOMIC_H #define LLVM_SYSTEM_ATOMIC_H -#include - -#if defined(_HPUX_SOURCE) && defined(__ia64) -#include -#elif defined(_MSC_VER) +#if defined(_MSC_VER) #include -#endif // defined(_HPUX_SOURCE) && defined(__ia64) +#endif namespace llvm { namespace sys { - inline void CompilerFence() { -#if defined(__GNUC__) && !defined(__INTEL_COMPILER) + inline void MemoryFence() { +#if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0 +# if defined(__GNUC__) __asm__ __volatile__("" : : : "memory"); -#elif defined(_MSC_VER) +# elif defined(_MSC_VER) __asm { }; -#elif defined(__INTEL_COMPILER) - __memory_barrier(); /* Too strong? IA64-only? */ +# else +# error No memory fence implementation for your platform! +# endif #else - /* We conjecture that the following usually gives us the right */ - /* semantics or an error. */ - asm(""); -#endif // defined(__GNUC__) && !defined(__INTEL_COMPILER) +# if defined(__GNUC__) + __sync_synchronize(); +# elif defined(_MSC_VER) + MemoryBarrier(); +# else +# error No memory fence implementation for your platform! +# endif +#endif } #if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0 - inline void MemoryFence() { - CompilerFence(); - } - - typedef uint32_t cas_flag; + typedef unsigned long cas_flag; inline cas_flag CompareAndSwap(cas_flag* dest, cas_flag exc, cas_flag c) { cas_flag result = *dest; if (result == c) *dest = exc; return result; } - #elif defined(__GNUC__) - - inline void MemoryFence() { -# if defined(__i386__) || defined(__x86_64__) -# if defined(__SSE2__) - __asm__ __volatile__("mfence" : : : "memory"); -# else - unsigned char dummy = 0; - volatile unsigned char* addr = &dummy; - unsigned char oldval; - __asm __ __volatile__("xchgb %0, %1" : "=r"(oldval), - "=m"(*addr), "0"(0xff), "m"(*addr) : "memory"); -# endif // defined(__SSE2__) -# elif defined(__ia64__) - __asm__ __volatile__("mf" : : : "memory"); -# elif defined(__alpha__) - __asm__ __volatile__("mb" : : : "memory"); -# elif defined(__sparc__) - __asm__ __volatile__("membar #StoreStore | #LoadStore | #LoadLoad | #StoreLoad"); -# elif defined(__powerpc__) || defined(__ppc__) - __asm__ __volatile__("sync" : : : "memory"); -# elif defined(__arm__) - __asm__ __volatile__ ("mcr p15, 0, r0, c7, c10, 5 @ dmb"); -# endif - } // defined(__i386__) || defined(__x86_64__) - typedef unsigned long cas_flag; inline cas_flag CompareAndSwap(cas_flag* ptr, cas_flag new_value, cas_flag old_value) { - cas_flag prev; -# if defined(__i386__) || defined(__x86_64__) - __asm__ __volatile__("lock; cmpxchgl %1,%2" - : "=a" (prev) - : "q" (new_value), "m" (*ptr), "0" (old_value) - : "memory"); -# elif defined(__ia64__) - MemoryFence(); -# if defined(_ILP32) - __asm__("zxt4 %1=%1": "=r"(prev) : "0"(prev)); - __asm__ __volatile__("addp4 %1=0,%1;;\n" - "mov ar.ccv=%[old] ;; cmpxchg 4" - ".acq %0=[%1],%[new_val],ar.ccv" - : "=r"(prev) "1"(addr), - : "=r"(addr), [new_value]"r"(new_value), [old_value]"r"(old_value) - : "memory"); -# else - __asm__ __volatile__( - "mov ar.ccv=%[old] ;; cmpxchg 8" - ".acq %0=[%1],%[new_val],ar.ccv" - : "=r"(prev) - : "r"(ptr), [new_value]"r"(new_value), - [old_value]"r"(old_value) - : "memory"); -# endif // defined(_ILP32) -# elif defined(__alpha__) - cas_flag was_equal; - __asm__ __volatile__( - "1: ldq_l %0,%1\n" - " cmpeq %0,%4,%2\n" - " mov %3,%0\n" - " beq %2,2f\n" - " stq_c %0,%1\n" - " beq %0,1b\n" - "2:\n" - :"=&r" (prev), "=m" (*ptr), "=&r" (was_equal) - : "r" (new_value), "Ir" (old_value) - :"memory"); -#elif defined(__sparc__) -#error No CAS implementation for SPARC yet. -#elif defined(__powerpc__) || defined(__ppc__) - int result = 0; - __asm__ __volatile__( - "1:lwarx %0,0,%2\n" /* load and reserve */ - "cmpw %0, %4\n" /* if load is not equal to */ - "bne 2f\n" /* old, fail */ - "stwcx. %3,0,%2\n" /* else store conditional */ - "bne- 1b\n" /* retry if lost reservation */ - "li %1,1\n" /* result = 1; */ - "2:\n" - : "=&r"(prev), "=&r"(result) - : "r"(ptr), "r"(new_value), "r"(old_value), "1"(result) - : "memory", "cc"); -#elif defined(__arm__) - int result; - __asm__ __volatile__ ( - "\n" - "0:\t" - "ldr %1,[%2] \n\t" - "mov %0,#0 \n\t" - "cmp %1,%4 \n\t" - "bne 1f \n\t" - "swp %0,%3,[%2] \n\t" - "cmp %1,%0 \n\t" - "swpne %1,%0,[%2] \n\t" - "bne 0b \n\t" - "mov %0,#1 \n" - "1:\n\t" - "" - : "=&r"(result), "=&r"(prev) - : "r" ptr), "r" (new_value), "r" (old_value) - : "cc", "memory"); -#endif // defined(__i386__) - return prev; + return __sync_val_compare_and_swap(ptr, old_value, new_value); } - #elif defined(_MSC_VER) && _M_IX86 > 400 - inline void MemoryFence() { - LONG dummy = 0; - InterlockedExchanged((LONG volatile *)&dummy, (LONG)0); - } - - typedef DWORD cas_flag; + typedef LONG cas_flag; inline cas_flag CompareAndSwap(cas_flag* ptr, cas_flag new_value, cas_flag old_value) { - /* FIXME - This is nearly useless on win64. */ - /* Use InterlockedCompareExchange64 for win64? */ - return InterlockedCompareExchange((DWORD volatile *)addr, - (DWORD)new_value, (DWORD) old_value) + return InterlockedCompareExchange(addr, new_value, old_value); } #else -#error No atomics implementation found for your platform. -#endif // !defined(ENABLE_THREADS) || ENABLE_THREADS == 0 +# error No compare-and-swap implementation for your platform! +#endif } } From echristo at apple.com Mon May 18 19:16:07 2009 From: echristo at apple.com (Eric Christopher) Date: Mon, 18 May 2009 17:16:07 -0700 Subject: [llvm-commits] [llvm] r72077 - in /llvm/trunk: LICENSE.TXT include/llvm/System/Atomic.h In-Reply-To: <200905190008.n4J08TuW004524@zion.cs.uiuc.edu> References: <200905190008.n4J08TuW004524@zion.cs.uiuc.edu> Message-ID: <70ABE7D9-1463-4CF9-B08D-183B3F601C40@apple.com> On May 18, 2009, at 5:08 PM, Owen Anderson wrote: > +#if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0 > Since it's going to be defined either way how about #if ENABLE_THREADS == 0 or perhaps even better let DCE handle it: if (!ENABLE_THREADS) :) -eric From mrs at apple.com Mon May 18 19:18:14 2009 From: mrs at apple.com (Mike Stump) Date: Tue, 19 May 2009 00:18:14 -0000 Subject: [llvm-commits] [llvm] r72078 - in /llvm/trunk/lib/CodeGen: AsmPrinter/CMakeLists.txt CMakeLists.txt Message-ID: <200905190018.n4J0IGIo004888@zion.cs.uiuc.edu> Author: mrs Date: Mon May 18 19:18:14 2009 New Revision: 72078 URL: http://llvm.org/viewvc/llvm-project?rev=72078&view=rev Log: Fix cmake builds. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt llvm/trunk/lib/CodeGen/CMakeLists.txt Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt?rev=72078&r1=72077&r2=72078&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt Mon May 18 19:18:14 2009 @@ -1,5 +1,10 @@ add_llvm_library(LLVMAsmPrinter AsmPrinter.cpp + DIE.cpp + DwarfDebug.cpp + DwarfException.cpp + DwarfLabel.cpp + DwarfPrinter.cpp DwarfWriter.cpp OcamlGCPrinter.cpp ) Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=72078&r1=72077&r2=72078&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/CMakeLists.txt Mon May 18 19:18:14 2009 @@ -49,6 +49,7 @@ ShadowStackGC.cpp ShrinkWrapping.cpp SimpleRegisterCoalescing.cpp + Spiller.cpp StackProtector.cpp StackSlotColoring.cpp StrongPHIElimination.cpp From dalej at apple.com Mon May 18 19:46:45 2009 From: dalej at apple.com (Dale Johannesen) Date: Tue, 19 May 2009 00:46:45 -0000 Subject: [llvm-commits] [llvm] r72083 - /llvm/trunk/lib/Target/CBackend/CBackend.cpp Message-ID: <200905190046.n4J0kkBb005953@zion.cs.uiuc.edu> Author: johannes Date: Mon May 18 19:46:42 2009 New Revision: 72083 URL: http://llvm.org/viewvc/llvm-project?rev=72083&view=rev Log: Spacing fix. 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=72083&r1=72082&r2=72083&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Mon May 18 19:46:42 2009 @@ -1127,7 +1127,7 @@ Out << CI->getZExtValue() << 'u'; else Out << CI->getSExtValue(); - Out << ')'; + Out << ')'; } return; } From resistor at mac.com Mon May 18 20:02:27 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 19 May 2009 01:02:27 -0000 Subject: [llvm-commits] [llvm] r72086 - /llvm/trunk/include/llvm/System/Atomic.h Message-ID: <200905190102.n4J12RRh006490@zion.cs.uiuc.edu> Author: resistor Date: Mon May 18 20:02:27 2009 New Revision: 72086 URL: http://llvm.org/viewvc/llvm-project?rev=72086&view=rev Log: Template CompareAndSwap function. Modified: llvm/trunk/include/llvm/System/Atomic.h Modified: llvm/trunk/include/llvm/System/Atomic.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Atomic.h?rev=72086&r1=72085&r2=72086&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Atomic.h (original) +++ llvm/trunk/include/llvm/System/Atomic.h Mon May 18 20:02:27 2009 @@ -44,24 +44,27 @@ #if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0 typedef unsigned long cas_flag; - inline cas_flag CompareAndSwap(cas_flag* dest, cas_flag exc, cas_flag c) { - cas_flag result = *dest; + template + inline T CompareAndSwap(volatile T* dest, + T exc, T c) { + T result = *dest; if (result == c) *dest = exc; return result; } #elif defined(__GNUC__) typedef unsigned long cas_flag; - inline cas_flag CompareAndSwap(cas_flag* ptr, - cas_flag new_value, - cas_flag old_value) { + template + inline T CompareAndSwap(volatile T* ptr, + T new_value, + T old_value) { return __sync_val_compare_and_swap(ptr, old_value, new_value); } -#elif defined(_MSC_VER) && _M_IX86 > 400 +#elif defined(_MSC_VER) typedef LONG cas_flag; - inline cas_flag CompareAndSwap(cas_flag* ptr, - cas_flag new_value, - cas_flag old_value) { + inline T CompareAndSwap(volatile T* ptr, + T new_value, + T old_value) { return InterlockedCompareExchange(addr, new_value, old_value); } #else From resistor at mac.com Mon May 18 20:07:40 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 19 May 2009 01:07:40 -0000 Subject: [llvm-commits] [llvm] r72087 - /llvm/trunk/include/llvm/System/Atomic.h Message-ID: <200905190107.n4J17f3A006679@zion.cs.uiuc.edu> Author: resistor Date: Mon May 18 20:07:40 2009 New Revision: 72087 URL: http://llvm.org/viewvc/llvm-project?rev=72087&view=rev Log: Fix up the Windows portion of Atomic.h. This is untested, but it is my best understanding of what should work. I'd be much obliged if someone on MSVC++ could try this out and let me know if it works. Modified: llvm/trunk/include/llvm/System/Atomic.h Modified: llvm/trunk/include/llvm/System/Atomic.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Atomic.h?rev=72087&r1=72086&r2=72087&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Atomic.h (original) +++ llvm/trunk/include/llvm/System/Atomic.h Mon May 18 20:07:40 2009 @@ -62,11 +62,24 @@ } #elif defined(_MSC_VER) typedef LONG cas_flag; + template inline T CompareAndSwap(volatile T* ptr, T new_value, T old_value) { - return InterlockedCompareExchange(addr, new_value, old_value); + if (sizeof(T) == 4) + return InterlockedCompareExchange(ptr, new_value, old_value); + else + return InterlockedCompareExchange64(ptr, new_value, old_value); } + + template + inline T* CompareAndSwap(volatile T** ptr, + T* new_value, + T* old_value) { + return InterlockedCompareExchangePtr(ptr, new_value, old_value); + } + + #else # error No compare-and-swap implementation for your platform! #endif From resistor at mac.com Mon May 18 20:08:36 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 19 May 2009 01:08:36 -0000 Subject: [llvm-commits] [llvm] r72088 - /llvm/trunk/include/llvm/System/Atomic.h Message-ID: <200905190108.n4J18afK006720@zion.cs.uiuc.edu> Author: resistor Date: Mon May 18 20:08:36 2009 New Revision: 72088 URL: http://llvm.org/viewvc/llvm-project?rev=72088&view=rev Log: Make using an unsupported CAS size a hard error on Windows. Modified: llvm/trunk/include/llvm/System/Atomic.h Modified: llvm/trunk/include/llvm/System/Atomic.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Atomic.h?rev=72088&r1=72087&r2=72088&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Atomic.h (original) +++ llvm/trunk/include/llvm/System/Atomic.h Mon May 18 20:08:36 2009 @@ -68,8 +68,10 @@ T old_value) { if (sizeof(T) == 4) return InterlockedCompareExchange(ptr, new_value, old_value); - else + else if (sizeof(T) == 8) return InterlockedCompareExchange64(ptr, new_value, old_value); + else + assert(0 && "Unsupported compare-and-swap size!"); } template From resistor at mac.com Mon May 18 20:25:38 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 18 May 2009 20:25:38 -0500 Subject: [llvm-commits] [PATCH] Thread-safe ManagedStatic In-Reply-To: <200905190107.n4J17f3A006679@zion.cs.uiuc.edu> References: <200905190107.n4J17f3A006679@zion.cs.uiuc.edu> Message-ID: <5464957333051772950217202212009693918-Webmail@me.com> So, now that we have the basic infrastructure more or less in place, here's another attempt at making a thread-safe version of ManagedStatic based on double-checked locking with explicit fences. It also proved necessary to provide atomic update facilities for the global StaticList as well. Please see the included block comment for more details on exactly what safety guarantees this code provides. --Owen -------------- next part -------------- A non-text attachment was scrubbed... Name: ManagedStatic.diff Type: application/octet-stream Size: 4719 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090518/0f336639/attachment.obj From gohman at apple.com Mon May 18 20:52:46 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 19 May 2009 01:52:46 -0000 Subject: [llvm-commits] [llvm] r72091 - /llvm/trunk/include/llvm/Analysis/LoopInfo.h Message-ID: <200905190152.n4J1qk2x008083@zion.cs.uiuc.edu> Author: djg Date: Mon May 18 20:52:46 2009 New Revision: 72091 URL: http://llvm.org/viewvc/llvm-project?rev=72091&view=rev Log: Add some comments noting how IndVarSimplify facilitates LoopInfo functionality. Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfo.h?rev=72091&r1=72090&r2=72091&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Mon May 18 20:52:46 2009 @@ -351,6 +351,9 @@ /// by one each time through the loop. If so, return the phi node that /// corresponds to it. /// + /// The IndVarSimplify pass transforms loops to have a canonical induction + /// variable. + /// inline PHINode *getCanonicalInductionVariable() const { BlockT *H = getHeader(); @@ -406,6 +409,9 @@ /// of the loop executes N-1 times. If the trip-count cannot be determined, /// this returns null. /// + /// The IndVarSimplify pass transforms loops to have a form that this + /// function easily understands. + /// inline Value *getTripCount() const { // Canonical loops will end with a 'cmp ne I, V', where I is the incremented // canonical induction variable and V is the trip count of the loop. From gohman at apple.com Mon May 18 21:15:55 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 19 May 2009 02:15:55 -0000 Subject: [llvm-commits] [llvm] r72093 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h include/llvm/Analysis/ScalarEvolutionExpander.h lib/Analysis/ScalarEvolution.cpp lib/Analysis/ScalarEvolutionExpander.cpp lib/Transforms/Scalar/IndVarSimplify.cpp lib/Transforms/Scalar/LoopStrengthReduce.cpp lib/Transforms/Utils/AddrModeMatcher.cpp test/Transforms/IndVarSimplify/preserve-gep.ll test/Transforms/LoopStrengthReduce/2009-04-28-no-reduce-mul.ll Message-ID: <200905190215.n4J2FuCD009024@zion.cs.uiuc.edu> Author: djg Date: Mon May 18 21:15:55 2009 New Revision: 72093 URL: http://llvm.org/viewvc/llvm-project?rev=72093&view=rev Log: Teach SCEVExpander to expand arithmetic involving pointers into GEP instructions. It attempts to create high-level multi-operand GEPs, though in cases where this isn't possible it falls back to casting the pointer to i8* and emitting a GEP with that. Using GEP instructions instead of ptrtoint+arithmetic+inttoptr helps pointer analyses that don't use ScalarEvolution, such as BasicAliasAnalysis. Also, make the AddrModeMatcher more aggressive in handling GEPs. Previously it assumed that operand 0 of a GEP would require a register in almost all cases. It now does extra checking and can do more matching if operand 0 of the GEP is foldable. This fixes a problem that was exposed by SCEVExpander using GEPs. Added: llvm/trunk/test/Transforms/IndVarSimplify/preserve-gep.ll Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp llvm/trunk/lib/Transforms/Utils/AddrModeMatcher.cpp llvm/trunk/test/Transforms/LoopStrengthReduce/2009-04-28-no-reduce-mul.ll Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=72093&r1=72092&r2=72093&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Mon May 18 21:15:55 2009 @@ -213,6 +213,7 @@ /// class ScalarEvolution : public FunctionPass { friend class SCEVCallbackVH; + friend class SCEVExpander; /// F - The function we are analyzing. /// Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h?rev=72093&r1=72092&r2=72093&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h Mon May 18 21:15:55 2009 @@ -28,7 +28,6 @@ /// memory. struct SCEVExpander : public SCEVVisitor { ScalarEvolution &SE; - LoopInfo &LI; std::map InsertedExpressions; std::set InsertedValues; @@ -36,10 +35,8 @@ friend struct SCEVVisitor; public: - SCEVExpander(ScalarEvolution &se, LoopInfo &li) - : SE(se), LI(li) {} - - LoopInfo &getLoopInfo() const { return LI; } + explicit SCEVExpander(ScalarEvolution &se) + : SE(se) {} /// clear - Erase the contents of the InsertedExpressions map so that users /// trying to expand the same expression into multiple BasicBlocks or @@ -83,8 +80,9 @@ /// expandCodeFor - Insert code to directly compute the specified SCEV /// expression into the program. The inserted code is inserted into the - /// SCEVExpander's current insertion point. - Value *expandCodeFor(SCEVHandle SH, const Type *Ty); + /// SCEVExpander's current insertion point. If a type is specified, the + /// result will be expanded to have that type, with a cast if necessary. + Value *expandCodeFor(SCEVHandle SH, const Type *Ty = 0); /// expandCodeFor - Insert code to directly compute the specified SCEV /// expression into the program. The inserted code is inserted into the @@ -110,6 +108,11 @@ Value *RHS, BasicBlock::iterator InsertPt); private: + /// expandAddToGEP - Expand a SCEVAddExpr with a pointer type into a GEP + /// instead of using ptrtoint+arithmetic+inttoptr. + Value *expandAddToGEP(const SCEVAddExpr *S, const PointerType *PTy, + const Type *Ty, Value *V); + Value *expand(const SCEV *S); Value *visitConstant(const SCEVConstant *S) { Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=72093&r1=72092&r2=72093&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon May 18 21:15:55 2009 @@ -456,6 +456,13 @@ if (const SCEVUnknown *LU = dyn_cast(LHS)) { const SCEVUnknown *RU = cast(RHS); + // Order pointer values after integer values. This helps SCEVExpander + // form GEPs. + if (isa(LU->getType()) && !isa(RU->getType())) + return false; + if (isa(RU->getType()) && !isa(LU->getType())) + return true; + // Compare getValueID values. if (LU->getValue()->getValueID() != RU->getValue()->getValueID()) return LU->getValue()->getValueID() < RU->getValue()->getValueID(); Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=72093&r1=72092&r2=72093&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Mon May 18 21:15:55 2009 @@ -15,6 +15,7 @@ #include "llvm/Analysis/ScalarEvolutionExpander.h" #include "llvm/Analysis/LoopInfo.h" +#include "llvm/Target/TargetData.h" using namespace llvm; /// InsertCastOfTo - Insert a cast of V to the specified type, doing what @@ -130,10 +131,9 @@ BasicBlock::iterator IP = InsertPt; --IP; for (; ScanLimit; --IP, --ScanLimit) { - if (BinaryOperator *BinOp = dyn_cast(IP)) - if (BinOp->getOpcode() == Opcode && BinOp->getOperand(0) == LHS && - BinOp->getOperand(1) == RHS) - return BinOp; + if (IP->getOpcode() == (unsigned)Opcode && IP->getOperand(0) == LHS && + IP->getOperand(1) == RHS) + return IP; if (IP == BlockBegin) break; } } @@ -144,9 +144,156 @@ return BO; } +/// expandAddToGEP - Expand a SCEVAddExpr with a pointer type into a GEP +/// instead of using ptrtoint+arithmetic+inttoptr. +Value *SCEVExpander::expandAddToGEP(const SCEVAddExpr *S, + const PointerType *PTy, + const Type *Ty, + Value *V) { + const Type *ElTy = PTy->getElementType(); + SmallVector GepIndices; + std::vector Ops = S->getOperands(); + bool AnyNonZeroIndices = false; + Ops.pop_back(); + + // Decend down the pointer's type and attempt to convert the other + // operands into GEP indices, at each level. The first index in a GEP + // indexes into the array implied by the pointer operand; the rest of + // the indices index into the element or field type selected by the + // preceding index. + for (;;) { + APInt ElSize = APInt(SE.getTypeSizeInBits(Ty), + ElTy->isSized() ? SE.TD->getTypeAllocSize(ElTy) : 0); + std::vector NewOps; + std::vector ScaledOps; + for (unsigned i = 0, e = Ops.size(); i != e; ++i) { + if (ElSize != 0) { + if (const SCEVConstant *C = dyn_cast(Ops[i])) + if (!C->getValue()->getValue().srem(ElSize)) { + ConstantInt *CI = + ConstantInt::get(C->getValue()->getValue().sdiv(ElSize)); + SCEVHandle Div = SE.getConstant(CI); + ScaledOps.push_back(Div); + continue; + } + if (const SCEVMulExpr *M = dyn_cast(Ops[i])) + if (const SCEVConstant *C = dyn_cast(M->getOperand(0))) + if (C->getValue()->getValue() == ElSize) { + for (unsigned j = 1, f = M->getNumOperands(); j != f; ++j) + ScaledOps.push_back(M->getOperand(j)); + continue; + } + if (const SCEVUnknown *U = dyn_cast(Ops[i])) + if (BinaryOperator *BO = dyn_cast(U->getValue())) + if (BO->getOpcode() == Instruction::Mul) + if (ConstantInt *CI = dyn_cast(BO->getOperand(1))) + if (CI->getValue() == ElSize) { + ScaledOps.push_back(SE.getUnknown(BO->getOperand(0))); + continue; + } + if (ElSize == 1) { + ScaledOps.push_back(Ops[i]); + continue; + } + } + NewOps.push_back(Ops[i]); + } + Ops = NewOps; + AnyNonZeroIndices |= !ScaledOps.empty(); + Value *Scaled = ScaledOps.empty() ? + Constant::getNullValue(Ty) : + expandCodeFor(SE.getAddExpr(ScaledOps), Ty); + GepIndices.push_back(Scaled); + + // Collect struct field index operands. + if (!Ops.empty()) + while (const StructType *STy = dyn_cast(ElTy)) { + if (const SCEVConstant *C = dyn_cast(Ops[0])) + if (SE.getTypeSizeInBits(C->getType()) <= 64) { + const StructLayout &SL = *SE.TD->getStructLayout(STy); + uint64_t FullOffset = C->getValue()->getZExtValue(); + if (FullOffset < SL.getSizeInBytes()) { + unsigned ElIdx = SL.getElementContainingOffset(FullOffset); + GepIndices.push_back(ConstantInt::get(Type::Int32Ty, ElIdx)); + ElTy = STy->getTypeAtIndex(ElIdx); + Ops[0] = + SE.getConstant(ConstantInt::get(Ty, + FullOffset - + SL.getElementOffset(ElIdx))); + AnyNonZeroIndices = true; + continue; + } + } + break; + } + + if (const ArrayType *ATy = dyn_cast(ElTy)) { + ElTy = ATy->getElementType(); + continue; + } + break; + } + + // If none of the operands were convertable to proper GEP indices, cast + // the base to i8* and do an ugly getelementptr with that. It's still + // better than ptrtoint+arithmetic+inttoptr at least. + if (!AnyNonZeroIndices) { + V = InsertNoopCastOfTo(V, + Type::Int8Ty->getPointerTo(PTy->getAddressSpace())); + Value *Idx = expand(SE.getAddExpr(Ops)); + Idx = InsertNoopCastOfTo(Idx, Ty); + + // Fold a GEP with constant operands. + if (Constant *CLHS = dyn_cast(V)) + if (Constant *CRHS = dyn_cast(Idx)) + return ConstantExpr::get(Instruction::GetElementPtr, CLHS, CRHS); + + // Do a quick scan to see if we have this GEP nearby. If so, reuse it. + unsigned ScanLimit = 6; + BasicBlock::iterator BlockBegin = InsertPt->getParent()->begin(); + if (InsertPt != BlockBegin) { + // Scanning starts from the last instruction before InsertPt. + BasicBlock::iterator IP = InsertPt; + --IP; + for (; ScanLimit; --IP, --ScanLimit) { + if (IP->getOpcode() == Instruction::GetElementPtr && + IP->getOperand(0) == V && IP->getOperand(1) == Idx) + return IP; + if (IP == BlockBegin) break; + } + } + + Value *GEP = GetElementPtrInst::Create(V, Idx, "scevgep", InsertPt); + InsertedValues.insert(GEP); + return GEP; + } + + // Insert a pretty getelementptr. + Value *GEP = GetElementPtrInst::Create(V, + GepIndices.begin(), + GepIndices.end(), + "scevgep", InsertPt); + Ops.push_back(SE.getUnknown(GEP)); + InsertedValues.insert(GEP); + return expand(SE.getAddExpr(Ops)); +} + Value *SCEVExpander::visitAddExpr(const SCEVAddExpr *S) { const Type *Ty = SE.getEffectiveSCEVType(S->getType()); Value *V = expand(S->getOperand(S->getNumOperands()-1)); + + // Turn things like ptrtoint+arithmetic+inttoptr into GEP. This helps + // BasicAliasAnalysis analyze the result. However, it suffers from the + // underlying bug described in PR2831. Addition in LLVM currently always + // has two's complement wrapping guaranteed. However, the semantics for + // getelementptr overflow are ambiguous. In the common case though, this + // expansion gets used when a GEP in the original code has been converted + // into integer arithmetic, in which case the resulting code will be no + // more undefined than it was originally. + if (SE.TD) + if (const PointerType *PTy = dyn_cast(V->getType())) + return expandAddToGEP(S, PTy, Ty, V); + V = InsertNoopCastOfTo(V, Ty); // Emit a bunch of add instructions @@ -157,7 +304,7 @@ } return V; } - + Value *SCEVExpander::visitMulExpr(const SCEVMulExpr *S) { const Type *Ty = SE.getEffectiveSCEVType(S->getType()); int FirstOp = 0; // Set if we should emit a subtract. @@ -206,15 +353,10 @@ // {X,+,F} --> X + {0,+,F} if (!S->getStart()->isZero()) { - Value *Start = expand(S->getStart()); - Start = InsertNoopCastOfTo(Start, Ty); - std::vector NewOps(S->op_begin(), S->op_end()); + std::vector NewOps(S->getOperands()); NewOps[0] = SE.getIntegerSCEV(0, Ty); Value *Rest = expand(SE.getAddRecExpr(NewOps, L)); - Rest = InsertNoopCastOfTo(Rest, Ty); - - // FIXME: look for an existing add to use. - return InsertBinop(Instruction::Add, Rest, Start, InsertPt); + return expand(SE.getAddExpr(S->getStart(), SE.getUnknown(Rest))); } // {0,+,1} --> Insert a canonical induction variable into the loop! @@ -265,7 +407,7 @@ // point loop. If we can, move the multiply to the outer most loop that it // is safe to be in. BasicBlock::iterator MulInsertPt = getInsertionPoint(); - Loop *InsertPtLoop = LI.getLoopFor(MulInsertPt->getParent()); + Loop *InsertPtLoop = SE.LI->getLoopFor(MulInsertPt->getParent()); if (InsertPtLoop != L && InsertPtLoop && L->contains(InsertPtLoop->getHeader())) { do { @@ -363,10 +505,13 @@ Value *SCEVExpander::expandCodeFor(SCEVHandle SH, const Type *Ty) { // Expand the code for this SCEV. - assert(SE.getTypeSizeInBits(Ty) == SE.getTypeSizeInBits(SH->getType()) && - "non-trivial casts should be done with the SCEVs directly!"); Value *V = expand(SH); - return InsertNoopCastOfTo(V, Ty); + if (Ty) { + assert(SE.getTypeSizeInBits(Ty) == SE.getTypeSizeInBits(SH->getType()) && + "non-trivial casts should be done with the SCEVs directly!"); + V = InsertNoopCastOfTo(V, Ty); + } + return V; } Value *SCEVExpander::expand(const SCEV *S) { Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=72093&r1=72092&r2=72093&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Mon May 18 21:15:55 2009 @@ -172,7 +172,7 @@ // Expand the code for the iteration count into the preheader of the loop. BasicBlock *Preheader = L->getLoopPreheader(); - Value *ExitCnt = Rewriter.expandCodeFor(RHS, IndVar->getType(), + Value *ExitCnt = Rewriter.expandCodeFor(RHS, CmpIndVar->getType(), Preheader->getTerminator()); // Insert a new icmp_ne or icmp_eq instruction before the branch. @@ -218,7 +218,7 @@ // Scan all of the instructions in the loop, looking at those that have // extra-loop users and which are recurrences. - SCEVExpander Rewriter(*SE, *LI); + SCEVExpander Rewriter(*SE); // We insert the code into the preheader of the loop if the loop contains // multiple exit blocks, or in the exit block if there is exactly one. @@ -386,7 +386,7 @@ } // Create a rewriter object which we'll use to transform the code with. - SCEVExpander Rewriter(*SE, *LI); + SCEVExpander Rewriter(*SE); // Now that we know the largest of of the induction variable expressions // in this loop, insert a canonical induction variable of the largest size. @@ -478,7 +478,7 @@ BasicBlock::iterator I = Rewriter.getInsertionPoint(); // Expand loop-invariant values in the loop preheader. They will // be sunk to the exit block later, if possible. - NewVal = + NewVal = Rewriter.expandCodeFor(AR, LargestType, L->getLoopPreheader()->getTerminator()); Rewriter.setInsertionPoint(I); @@ -523,7 +523,7 @@ NewAR = SE->getAddExpr(NewAR, PromotedOffset); // Expand the addrec into instructions. - Value *V = Rewriter.expandCodeFor(NewAR, LargestType); + Value *V = Rewriter.expandCodeFor(NewAR); // Insert an explicit cast if necessary to truncate the value // down to the original stride type. This is done outside of @@ -533,7 +533,7 @@ if (SE->getTypeSizeInBits(IVTy) != SE->getTypeSizeInBits(LargestType)) NewAR = SE->getTruncateExpr(NewAR, IVTy); if (Rewriter.isInsertedExpression(NewAR)) - V = Rewriter.expandCodeFor(NewAR, IVTy); + V = Rewriter.expandCodeFor(NewAR); else { V = Rewriter.InsertCastOfTo(CastInst::getCastOpcode(V, false, IVTy, false), Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=72093&r1=72092&r2=72093&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Mon May 18 21:15:55 2009 @@ -367,12 +367,14 @@ void RewriteInstructionToUseNewBase(const SCEVHandle &NewBase, Instruction *InsertPt, SCEVExpander &Rewriter, Loop *L, Pass *P, + LoopInfo &LI, SmallVectorImpl &DeadInsts); Value *InsertCodeForBaseAtPosition(const SCEVHandle &NewBase, const Type *Ty, SCEVExpander &Rewriter, - Instruction *IP, Loop *L); + Instruction *IP, Loop *L, + LoopInfo &LI); void dump() const; }; } @@ -386,12 +388,12 @@ Value *BasedUser::InsertCodeForBaseAtPosition(const SCEVHandle &NewBase, const Type *Ty, SCEVExpander &Rewriter, - Instruction *IP, Loop *L) { + Instruction *IP, Loop *L, + LoopInfo &LI) { // Figure out where we *really* want to insert this code. In particular, if // the user is inside of a loop that is nested inside of L, we really don't // want to insert this expression before the user, we'd rather pull it out as // many loops as possible. - LoopInfo &LI = Rewriter.getLoopInfo(); Instruction *BaseInsertPt = IP; // Figure out the most-nested loop that IP is in. @@ -405,8 +407,7 @@ InsertLoop = InsertLoop->getParentLoop(); } - Value *Base = Rewriter.expandCodeFor(NewBase, NewBase->getType(), - BaseInsertPt); + Value *Base = Rewriter.expandCodeFor(NewBase, 0, BaseInsertPt); SCEVHandle NewValSCEV = SE->getUnknown(Base); @@ -439,6 +440,7 @@ void BasedUser::RewriteInstructionToUseNewBase(const SCEVHandle &NewBase, Instruction *NewBasePt, SCEVExpander &Rewriter, Loop *L, Pass *P, + LoopInfo &LI, SmallVectorImpl &DeadInsts) { if (!isa(Inst)) { // By default, insert code at the user instruction. @@ -468,7 +470,7 @@ } Value *NewVal = InsertCodeForBaseAtPosition(NewBase, OperandValToReplace->getType(), - Rewriter, InsertPt, L); + Rewriter, InsertPt, L, LI); // Replace the use of the operand Value with the new Phi we just created. Inst->replaceUsesOfWith(OperandValToReplace, NewVal); @@ -527,7 +529,7 @@ PN->getIncomingBlock(i)->getTerminator() : OldLoc->getParent()->getTerminator(); Code = InsertCodeForBaseAtPosition(NewBase, PN->getType(), - Rewriter, InsertPt, L); + Rewriter, InsertPt, L, LI); DOUT << " Changing PHI use to "; DEBUG(WriteAsOperand(*DOUT, Code, /*PrintType=*/false)); @@ -1580,8 +1582,8 @@ << *Stride << ":\n" << " Common base: " << *CommonExprs << "\n"; - SCEVExpander Rewriter(*SE, *LI); - SCEVExpander PreheaderRewriter(*SE, *LI); + SCEVExpander Rewriter(*SE); + SCEVExpander PreheaderRewriter(*SE); BasicBlock *Preheader = L->getLoopPreheader(); Instruction *PreInsertPt = Preheader->getTerminator(); @@ -1636,8 +1638,7 @@ // Emit the code for Base into the preheader. Value *BaseV = 0; if (!Base->isZero()) { - BaseV = PreheaderRewriter.expandCodeFor(Base, Base->getType(), - PreInsertPt); + BaseV = PreheaderRewriter.expandCodeFor(Base, 0, PreInsertPt); DOUT << " INSERTING code for BASE = " << *Base << ":"; if (BaseV->hasName()) @@ -1758,7 +1759,7 @@ RewriteExpr = SE->getAddExpr(RewriteExpr, SE->getUnknown(BaseV)); User.RewriteInstructionToUseNewBase(RewriteExpr, NewBasePt, - Rewriter, L, this, + Rewriter, L, this, *LI, DeadInsts); // Mark old value we replaced as possibly dead, so that it is eliminated Modified: llvm/trunk/lib/Transforms/Utils/AddrModeMatcher.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/AddrModeMatcher.cpp?rev=72093&r1=72092&r2=72093&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/AddrModeMatcher.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/AddrModeMatcher.cpp Mon May 18 21:15:55 2009 @@ -255,43 +255,44 @@ // Save the valid addressing mode in case we can't match. ExtAddrMode BackupAddrMode = AddrMode; - - // Check that this has no base reg yet. If so, we won't have a place to - // put the base of the GEP (assuming it is not a null ptr). - bool SetBaseReg = true; - if (isa(AddrInst->getOperand(0))) - SetBaseReg = false; // null pointer base doesn't need representation. - else if (AddrMode.HasBaseReg) - return false; // Base register already specified, can't match GEP. - else { - // Otherwise, we'll use the GEP base as the BaseReg. + unsigned OldSize = AddrModeInsts.size(); + + // See if the scale and offset amount is valid for this target. + AddrMode.BaseOffs += ConstantOffset; + + // Match the base operand of the GEP. + if (!MatchAddr(AddrInst->getOperand(0), Depth+1)) { + // If it couldn't be matched, just stuff the value in a register. + if (AddrMode.HasBaseReg) { + AddrMode = BackupAddrMode; + AddrModeInsts.resize(OldSize); + return false; + } AddrMode.HasBaseReg = true; AddrMode.BaseReg = AddrInst->getOperand(0); } - - // See if the scale and offset amount is valid for this target. - AddrMode.BaseOffs += ConstantOffset; - + + // Match the remaining variable portion of the GEP. if (!MatchScaledValue(AddrInst->getOperand(VariableOperand), VariableScale, Depth)) { + // If it couldn't be matched, try stuffing the base into a register + // instead of matching it, and retrying the match of the scale. AddrMode = BackupAddrMode; - return false; + AddrModeInsts.resize(OldSize); + if (AddrMode.HasBaseReg) + return false; + AddrMode.HasBaseReg = true; + AddrMode.BaseReg = AddrInst->getOperand(0); + AddrMode.BaseOffs += ConstantOffset; + if (!MatchScaledValue(AddrInst->getOperand(VariableOperand), + VariableScale, Depth)) { + // If even that didn't work, bail. + AddrMode = BackupAddrMode; + AddrModeInsts.resize(OldSize); + return false; + } } - - // If we have a null as the base of the GEP, folding in the constant offset - // plus variable scale is all we can do. - if (!SetBaseReg) return true; - - // If this match succeeded, we know that we can form an address with the - // GepBase as the basereg. Match the base pointer of the GEP more - // aggressively by zeroing out BaseReg and rematching. If the base is - // (for example) another GEP, this allows merging in that other GEP into - // the addressing mode we're forming. - AddrMode.HasBaseReg = false; - AddrMode.BaseReg = 0; - bool Success = MatchAddr(AddrInst->getOperand(0), Depth+1); - assert(Success && "MatchAddr should be able to fill in BaseReg!"); - Success=Success; + return true; } } Added: llvm/trunk/test/Transforms/IndVarSimplify/preserve-gep.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/preserve-gep.ll?rev=72093&view=auto ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/preserve-gep.ll (added) +++ llvm/trunk/test/Transforms/IndVarSimplify/preserve-gep.ll Mon May 18 21:15:55 2009 @@ -0,0 +1,39 @@ +; RUN: llvm-as < %s | opt -indvars | llvm-dis > %t +; RUN: not grep ptrtoint %t +; RUN: not grep inttoptr %t +; RUN: grep getelementptr %t | count 1 + +; Indvars shouldn't leave getelementptrs expanded out as +; inttoptr+ptrtoint in its output in common cases. + +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" + %struct.Foo = type { i32, i32, [10 x i32], i32 } + +define void @me(%struct.Foo* nocapture %Bar) nounwind { +entry: + br i1 false, label %return, label %bb.nph + +bb.nph: ; preds = %entry + br label %bb + +bb: ; preds = %bb1, %bb.nph + %i.01 = phi i64 [ %4, %bb1 ], [ 0, %bb.nph ] ; [#uses=3] + %0 = getelementptr %struct.Foo* %Bar, i64 %i.01, i32 2, i64 3 ; [#uses=1] + %1 = load i32* %0, align 4 ; [#uses=1] + %2 = mul i32 %1, 113 ; [#uses=1] + %3 = getelementptr %struct.Foo* %Bar, i64 %i.01, i32 2, i64 3 ; [#uses=1] + store i32 %2, i32* %3, align 4 + %4 = add i64 %i.01, 1 ; [#uses=2] + br label %bb1 + +bb1: ; preds = %bb + %phitmp = icmp sgt i64 %4, 19999 ; [#uses=1] + br i1 %phitmp, label %bb1.return_crit_edge, label %bb + +bb1.return_crit_edge: ; preds = %bb1 + br label %return + +return: ; preds = %bb1.return_crit_edge, %entry + ret void +} 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=72093&r1=72092&r2=72093&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 May 18 21:15:55 2009 @@ -1,4 +1,5 @@ -; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | grep {mul.*%lsr.iv} | count 2 +; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis \ +; RUN: | grep {getelementptr.*%lsr.iv.*%lsr.iv.*} ; 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 = '' From gohman at apple.com Mon May 18 21:19:57 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 19 May 2009 02:19:57 -0000 Subject: [llvm-commits] [llvm] r72094 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200905190219.n4J2JwED009203@zion.cs.uiuc.edu> Author: djg Date: Mon May 18 21:19:57 2009 New Revision: 72094 URL: http://llvm.org/viewvc/llvm-project?rev=72094&view=rev Log: Remove the #ifndef NDEBUG from the FastISel debugging options. This fixes dejagnu tests that use these options. 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=72094&r1=72093&r2=72094&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon May 18 21:19:57 2009 @@ -54,7 +54,6 @@ static cl::opt DisableLegalizeTypes("disable-legalize-types", cl::Hidden); -#ifndef NDEBUG static cl::opt EnableFastISelVerbose("fast-isel-verbose", cl::Hidden, cl::desc("Enable verbose messages in the \"fast\" " @@ -62,10 +61,6 @@ static cl::opt EnableFastISelAbort("fast-isel-abort", cl::Hidden, cl::desc("Enable abort calls when \"fast\" instruction fails")); -#else -static const bool EnableFastISelVerbose = false, - EnableFastISelAbort = false; -#endif static cl::opt SchedLiveInCopies("schedule-livein-copies", cl::desc("Schedule copies of livein registers"), From bob.wilson at apple.com Tue May 19 00:53:43 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 19 May 2009 05:53:43 -0000 Subject: [llvm-commits] [llvm] r72105 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/2009-05-18-InlineAsmMem.ll Message-ID: <200905190553.n4J5rhoI017012@zion.cs.uiuc.edu> Author: bwilson Date: Tue May 19 00:53:42 2009 New Revision: 72105 URL: http://llvm.org/viewvc/llvm-project?rev=72105&view=rev Log: Fix pr4091: Add support for "m" constraint in ARM inline assembly. Added: llvm/trunk/test/CodeGen/ARM/2009-05-18-InlineAsmMem.ll Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=72105&r1=72104&r2=72105&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Tue May 19 00:53:42 2009 @@ -89,6 +89,13 @@ // Include the pieces autogenerated from the target description. #include "ARMGenDAGISel.inc" + +private: + /// SelectInlineAsmMemoryOperand - Implement addressing mode selection for + /// inline asm expressions. + virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op, + char ConstraintCode, + std::vector &OutOps); }; } @@ -881,6 +888,21 @@ return SelectCode(Op); } +bool ARMDAGToDAGISel:: +SelectInlineAsmMemoryOperand(const SDValue &Op, char ConstraintCode, + std::vector &OutOps) { + assert(ConstraintCode == 'm' && "unexpected asm memory constraint"); + + SDValue Base, Offset, Opc; + if (!SelectAddrMode2(Op, Op, Base, Offset, Opc)) + return true; + + OutOps.push_back(Base); + OutOps.push_back(Offset); + OutOps.push_back(Opc); + return false; +} + /// createARMISelDag - This pass converts a legalized DAG into a /// ARM-specific DAG, ready for instruction scheduling. /// 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=72105&r1=72104&r2=72105&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Tue May 19 00:53:42 2009 @@ -124,6 +124,9 @@ virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode); + virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, + unsigned AsmVariant, + const char *ExtraCode); void printModuleLevelGV(const GlobalVariable* GVar); bool printInstruction(const MachineInstr *MI); // autogenerated. @@ -769,6 +772,15 @@ return false; } +bool ARMAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, + unsigned OpNo, unsigned AsmVariant, + const char *ExtraCode) { + if (ExtraCode && ExtraCode[0]) + return true; // Unknown modifier. + printAddrMode2Operand(MI, OpNo); + return false; +} + void ARMAsmPrinter::printMachineInstruction(const MachineInstr *MI) { ++EmittedInsts; Added: llvm/trunk/test/CodeGen/ARM/2009-05-18-InlineAsmMem.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-05-18-InlineAsmMem.ll?rev=72105&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-05-18-InlineAsmMem.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-05-18-InlineAsmMem.ll Tue May 19 00:53:42 2009 @@ -0,0 +1,7 @@ +; RUN: llvm-as < %s | llc -march=arm | grep swp +; PR4091 + +define void @foo(i32 %i, i32* %p) nounwind { + %asmtmp = call i32 asm sideeffect "swp $0, $2, $3", "=&r,=*m,r,*m,~{memory}"(i32* %p, i32 %i, i32* %p) nounwind + ret void +} From nicolas.geoffray at lip6.fr Tue May 19 04:25:00 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 19 May 2009 11:25:00 +0200 Subject: [llvm-commits] [llvm] r72045 - /llvm/trunk/lib/Target/X86/X86InstrInfo.td In-Reply-To: <200905182142.n4ILgWgP031346@zion.cs.uiuc.edu> References: <200905182142.n4ILgWgP031346@zion.cs.uiuc.edu> Message-ID: <4A127AEC.1070608@lip6.fr> Hi Dale, Dale Johannesen wrote: > Author: johannes > Date: Mon May 18 16:41:59 2009 > New Revision: 72045 > > URL: http://llvm.org/viewvc/llvm-project?rev=72045&view=rev > Log: > Add OpSize to 16-bit ADC and SBB. > What is OpSize? This patch is causing lots of memory errors in VMKit, I'm not sure why. Does the JIT in LLVM understand OpSize? Thanks, Nicolas > > 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=72045&r1=72044&r2=72045&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) > +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon May 18 16:41:59 2009 > @@ -2280,7 +2280,7 @@ > def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst), > (ins GR16:$src1, GR16:$src2), > "adc{w}\t{$src2, $dst|$dst, $src2}", > - [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>; > + [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize; > def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), > (ins GR32:$src1, GR32:$src2), > "adc{l}\t{$src2, $dst|$dst, $src2}", > @@ -2293,7 +2293,8 @@ > def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst), > (ins GR16:$src1, i16mem:$src2), > "adc{w}\t{$src2, $dst|$dst, $src2}", > - [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>; > + [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>, > + OpSize; > def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), > (ins GR32:$src1, i32mem:$src2), > "adc{l}\t{$src2, $dst|$dst, $src2}", > @@ -2304,11 +2305,12 @@ > def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst), > (ins GR16:$src1, i16imm:$src2), > "adc{w}\t{$src2, $dst|$dst, $src2}", > - [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>; > + [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize; > def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst), > (ins GR16:$src1, i16i8imm:$src2), > "adc{w}\t{$src2, $dst|$dst, $src2}", > - [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>; > + [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>, > + OpSize; > def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), > (ins GR32:$src1, i32imm:$src2), > "adc{l}\t{$src2, $dst|$dst, $src2}", > @@ -2324,7 +2326,8 @@ > [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>; > def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), > "adc{w}\t{$src2, $dst|$dst, $src2}", > - [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>; > + [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>, > + OpSize; > def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), > "adc{l}\t{$src2, $dst|$dst, $src2}", > [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>; > @@ -2333,10 +2336,12 @@ > [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>; > def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2), > "adc{w}\t{$src2, $dst|$dst, $src2}", > - [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>; > + [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>, > + OpSize; > def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2), > "adc{w}\t{$src2, $dst|$dst, $src2}", > - [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>; > + [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>, > + OpSize; > def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2), > "adc{l}\t{$src2, $dst|$dst, $src2}", > [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>; > @@ -2452,7 +2457,7 @@ > def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst), > (ins GR16:$src1, GR16:$src2), > "sbb{w}\t{$src2, $dst|$dst, $src2}", > - [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>; > + [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize; > def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), > (ins GR32:$src1, GR32:$src2), > "sbb{l}\t{$src2, $dst|$dst, $src2}", > @@ -2464,7 +2469,8 @@ > [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>; > def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), > "sbb{w}\t{$src2, $dst|$dst, $src2}", > - [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>; > + [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>, > + OpSize; > def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), > "sbb{l}\t{$src2, $dst|$dst, $src2}", > [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>; > @@ -2473,10 +2479,12 @@ > [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>; > def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2), > "sbb{w}\t{$src2, $dst|$dst, $src2}", > - [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>; > + [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>, > + OpSize; > def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2), > "sbb{w}\t{$src2, $dst|$dst, $src2}", > - [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>; > + [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>, > + OpSize; > def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2), > "sbb{l}\t{$src2, $dst|$dst, $src2}", > [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>; > @@ -2490,7 +2498,8 @@ > def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst), > (ins GR16:$src1, i16mem:$src2), > "sbb{w}\t{$src2, $dst|$dst, $src2}", > - [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>; > + [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>, > + OpSize; > def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), > (ins GR32:$src1, i32mem:$src2), > "sbb{l}\t{$src2, $dst|$dst, $src2}", > @@ -2501,11 +2510,12 @@ > def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst), > (ins GR16:$src1, i16imm:$src2), > "sbb{w}\t{$src2, $dst|$dst, $src2}", > - [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>; > + [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize; > def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst), > (ins GR16:$src1, i16i8imm:$src2), > "sbb{w}\t{$src2, $dst|$dst, $src2}", > - [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>; > + [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>, > + OpSize; > def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), > (ins GR32:$src1, i32imm:$src2), > "sbb{l}\t{$src2, $dst|$dst, $src2}", > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From cristic at cs.stanford.edu Mon May 18 20:56:09 2009 From: cristic at cs.stanford.edu (Cristian Cadar) Date: Tue, 19 May 2009 01:56:09 -0000 Subject: [llvm-commits] [llvm] r72092 - /llvm/trunk/docs/doxygen.cfg.in Message-ID: <200905190156.n4J1u9h2008184@zion.cs.uiuc.edu> Author: cristic Date: Mon May 18 20:56:08 2009 New Revision: 72092 URL: http://llvm.org/viewvc/llvm-project?rev=72092&view=rev Log: Test commit. Modified: llvm/trunk/docs/doxygen.cfg.in Modified: llvm/trunk/docs/doxygen.cfg.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/doxygen.cfg.in?rev=72092&r1=72091&r2=72092&view=diff ============================================================================== --- llvm/trunk/docs/doxygen.cfg.in (original) +++ llvm/trunk/docs/doxygen.cfg.in Mon May 18 20:56:08 2009 @@ -11,7 +11,7 @@ # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- -# Project related configuration options +# Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file From howard0su at gmail.com Tue May 19 04:44:18 2009 From: howard0su at gmail.com (Howard Su) Date: Tue, 19 May 2009 17:44:18 +0800 Subject: [llvm-commits] [PATCH] Fix C2888 compile error in VS2008 Message-ID: The attached patch to fix two compiler error C2888 when compiling under VS2008. -- -Howard -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090519/36ea9100/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: build_under_vs8.patch Type: application/octet-stream Size: 675 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090519/36ea9100/attachment.obj From bob.wilson at apple.com Tue May 19 05:02:41 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 19 May 2009 10:02:41 -0000 Subject: [llvm-commits] [llvm] r72106 - in /llvm/trunk: lib/Target/ARM/ARMCallingConv.td test/CodeGen/ARM/arguments-nosplit-double.ll test/CodeGen/ARM/arguments-nosplit-i64.ll Message-ID: <200905191002.n4JA2gVE005722@zion.cs.uiuc.edu> Author: bwilson Date: Tue May 19 05:02:36 2009 New Revision: 72106 URL: http://llvm.org/viewvc/llvm-project?rev=72106&view=rev Log: Fix pr4058 and pr4059. Do not split i64 or double arguments between r3 and the stack. Patch by Sandeep Patel. Added: llvm/trunk/test/CodeGen/ARM/arguments-nosplit-double.ll llvm/trunk/test/CodeGen/ARM/arguments-nosplit-i64.ll Modified: llvm/trunk/lib/Target/ARM/ARMCallingConv.td Modified: llvm/trunk/lib/Target/ARM/ARMCallingConv.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCallingConv.td?rev=72106&r1=72105&r2=72106&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCallingConv.td (original) +++ llvm/trunk/lib/Target/ARM/ARMCallingConv.td Tue May 19 05:02:36 2009 @@ -51,11 +51,14 @@ // i64/f64 is passed in even pairs of GPRs // i64 is 8-aligned i32 here, so we may need to eat R1 as a pad register + // (and the same is true for f64 if VFP is not enabled) CCIfType<[i32], CCIfAlign<"8", CCAssignToRegWithShadow<[R0, R2], [R0, R1]>>>, CCIfType<[f64], CCCustom<"CC_ARM_AAPCS_Custom_f64">>, CCIfType<[f32], CCBitConvertToType>, - CCIfType<[i32], CCAssignToReg<[R0, R1, R2, R3]>>, + CCIfType<[i32], CCIf<"State.getNextStackOffset() == 0 &&" + "ArgFlags.getOrigAlign() != 8", + CCAssignToReg<[R0, R1, R2, R3]>>>, CCIfType<[i32], CCAssignToStack<4, 4>>, CCIfType<[f64], CCAssignToStack<8, 8>> Added: llvm/trunk/test/CodeGen/ARM/arguments-nosplit-double.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/arguments-nosplit-double.ll?rev=72106&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/arguments-nosplit-double.ll (added) +++ llvm/trunk/test/CodeGen/ARM/arguments-nosplit-double.ll Tue May 19 05:02:36 2009 @@ -0,0 +1,9 @@ +; RUN: llvm-as < %s | llc -mtriple=arm-linux-gnueabi | not grep r3 +; PR4059 + +define i32 @f(i64 %z, i32 %a, double %b) { + %tmp = call i32 @g(double %b) + ret i32 %tmp +} + +declare i32 @g(double) Added: llvm/trunk/test/CodeGen/ARM/arguments-nosplit-i64.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/arguments-nosplit-i64.ll?rev=72106&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/arguments-nosplit-i64.ll (added) +++ llvm/trunk/test/CodeGen/ARM/arguments-nosplit-i64.ll Tue May 19 05:02:36 2009 @@ -0,0 +1,9 @@ +; RUN: llvm-as < %s | llc -mtriple=arm-linux-gnueabi | not grep r3 +; PR4058 + +define i32 @f(i64 %z, i32 %a, i64 %b) { + %tmp = call i32 @g(i64 %b) + ret i32 %tmp +} + +declare i32 @g(i64) From clattner at apple.com Tue May 19 05:08:30 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 19 May 2009 03:08:30 -0700 Subject: [llvm-commits] [PATCH] Thread-safe ManagedStatic In-Reply-To: <5464957333051772950217202212009693918-Webmail@me.com> References: <200905190107.n4J17f3A006679@zion.cs.uiuc.edu> <5464957333051772950217202212009693918-Webmail@me.com> Message-ID: On May 18, 2009, at 6:25 PM, Owen Anderson wrote: > So, now that we have the basic infrastructure more or less in place, > here's another attempt at making a thread-safe version of > ManagedStatic based on double-checked locking with explicit fences. > It also proved necessary to provide atomic update facilities for the > global StaticList as well. > > Please see the included block comment for more details on exactly > what safety guarantees this code provides. The basic algorithm looks fine, however: 1. Please move the meat of the code for LazyInit out of line somehow. Only the case when tmp != 0 should be inline ideally. 2. Again, we only need a single global lock, we do not need a mutex per ManagedStatic. 3. Why do you create your own mutex out of atomic operations instead of just using a pthreads lock? spinning is not always an efficient solution to contention, particularly if your machine really only has one cpu! (in which case you end up spinning away the rest of your timeslice) 4. Instead of going through the trouble to make the locking more efficient, I think it would be good to special case the scenario when there is only one LLVM thread. Why not make clients explicitly opt-in to multithreaded llvm, by making an explicit llvm_multithread call? If multithreading is disabled, this call should return an error. If enabled, it would set a global. All the various "locking" clients could just check the global before taking potential heavy-weight locks. -Chris From resistor at mac.com Tue May 19 06:26:12 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 19 May 2009 04:26:12 -0700 Subject: [llvm-commits] [PATCH] Thread-safe ManagedStatic In-Reply-To: References: <200905190107.n4J17f3A006679@zion.cs.uiuc.edu> <5464957333051772950217202212009693918-Webmail@me.com> Message-ID: <358F1AAC-7DF4-4ABD-87DC-4B3B581B1EA7@mac.com> On May 19, 2009, at 3:08 AM, Chris Lattner wrote: > The basic algorithm looks fine, however: > > 1. Please move the meat of the code for LazyInit out of line somehow. > Only the case when tmp != 0 should be inline ideally. Done. > 2. Again, we only need a single global lock, we do not need a mutex > per ManagedStatic. Conversely, why have only one? Also, see my answer to #3. > 3. Why do you create your own mutex out of atomic operations instead > of just using a pthreads lock? spinning is not always an efficient > solution to contention, particularly if your machine really only has > one cpu! (in which case you end up spinning away the rest of your > timeslice) Portability. llvm::sys::Mutex _cannot_ be made to work, because on Windows it has to have a non-trivial constructor. Also, this is pretty much the ideal case for spinlocks. Initialization only happens once and we're using a separate mutex for each object, so we don't expect significant contention over the life of the program. Plus, the initialization itself should be fairly fast. This means that the spinning thread can continue immediately after the lock is released, rather than having to wait for the OS to wake it up. > 4. Instead of going through the trouble to make the locking more > efficient, I think it would be good to special case the scenario when > there is only one LLVM thread. Why not make clients explicitly opt-in > to multithreaded llvm, by making an explicit llvm_multithread call? > If multithreading is disabled, this call should return an error. If > enabled, it would set a global. All the various "locking" clients > could just check the global before taking potential heavy-weight > locks. We already handle this in a somewhat different way. When threading is disabled, llvm::sys::Mutex operations are turned into no-ops, and MemoryFence() and CompareAndSwap() are given non-atomic implementations. --Owen -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2620 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090519/f543b925/attachment.bin From resistor at mac.com Tue May 19 06:29:05 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 19 May 2009 04:29:05 -0700 Subject: [llvm-commits] [PATCH] Thread-safe ManagedStatic In-Reply-To: <358F1AAC-7DF4-4ABD-87DC-4B3B581B1EA7@mac.com> References: <200905190107.n4J17f3A006679@zion.cs.uiuc.edu> <5464957333051772950217202212009693918-Webmail@me.com> <358F1AAC-7DF4-4ABD-87DC-4B3B581B1EA7@mac.com> Message-ID: <5841C435-F5D5-4C62-A17B-1E406A9C8374@mac.com> On May 19, 2009, at 4:26 AM, Owen Anderson wrote: >> 3. Why do you create your own mutex out of atomic operations instead >> of just using a pthreads lock? spinning is not always an efficient >> solution to contention, particularly if your machine really only has >> one cpu! (in which case you end up spinning away the rest of your >> timeslice) > > Portability. llvm::sys::Mutex _cannot_ be made to work, because on > Windows > it has to have a non-trivial constructor. To build on my own comment, this is also the reason behind having one lock per object. Since we have to write our own mutex implementation for this to work on Windows, we are free to write one that uses zero as the unlocked state, and can thus be put within each ManagedStatic, reducing lock contention. Basically, given that we need to implement our own mutex, making one- per-object seems like the natural next step. --Owen -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2620 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090519/3998a26d/attachment.bin From sebastian.redl at getdesigned.at Tue May 19 08:59:56 2009 From: sebastian.redl at getdesigned.at (Sebastian Redl) Date: Tue, 19 May 2009 15:59:56 +0200 Subject: [llvm-commits] [llvm] r72087 - /llvm/trunk/include/llvm/System/Atomic.h In-Reply-To: <200905190107.n4J17f3A006679@zion.cs.uiuc.edu> References: <200905190107.n4J17f3A006679@zion.cs.uiuc.edu> Message-ID: <4A12BB5C.9040200@getdesigned.at> Owen Anderson wrote: > Author: resistor > Date: Mon May 18 20:07:40 2009 > New Revision: 72087 > > URL: http://llvm.org/viewvc/llvm-project?rev=72087&view=rev > Log: > Fix up the Windows portion of Atomic.h. This is untested, but it is my best understanding of what should work. > I'd be much obliged if someone on MSVC++ could try this out and let me know if it works. > > Modified: > llvm/trunk/include/llvm/System/Atomic.h > > Modified: llvm/trunk/include/llvm/System/Atomic.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Atomic.h?rev=72087&r1=72086&r2=72087&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/System/Atomic.h (original) > +++ llvm/trunk/include/llvm/System/Atomic.h Mon May 18 20:07:40 2009 > @@ -62,11 +62,24 @@ > } > #elif defined(_MSC_VER) > typedef LONG cas_flag; > + template > inline T CompareAndSwap(volatile T* ptr, > T new_value, > T old_value) { > - return InterlockedCompareExchange(addr, new_value, old_value); > + if (sizeof(T) == 4) > + return InterlockedCompareExchange(ptr, new_value, old_value); > + else > + return InterlockedCompareExchange64(ptr, new_value, old_value); > } > I'm not booted into Windows, but this cannot possibly compile. An if must have all branches valid even if the condition is a compile-time constant. You could force some casts, or you could specialize the function on 4-byte types. Eh, you'll need the casts anyway, because the WinAPI sucks. > + else > + assert(0 && "Unsupported compare-and-swap size!"); > However, it would be really nice to catch this at compile time. And another thing, the function is called InterlockedCompareExchangePointer. The code below is untested, but should do the Right Thing. template struct CompareAndSwapImpl; template struct CompareAndSwapImpl { static T DoCAS(volatile T* ptr, T n, T o) { return InterlockedCompareExchange(reinterpret_cast(ptr), n, o); } } template struct CompareAndSwapImpl { static T DoCAS(volatile T* ptr, T n, T o) { return InterlockedCompareExchange64(reinterpret_cast(ptr), n, o); } } template struct CompareAndSwapImpl { static T DoCAS(T* volatile* ptr, T* n, T* o) { return InterlockedCompareExchangePointer(reinterpret_cast(ptr), n, o); } } template inline T CompareAndSwap(T volatile *ptr, T new_value, T old_value) { return CompareAndSwapImpl::DoCAS(ptr, new_value, old_value); } Sebastian From dalej at apple.com Tue May 19 11:51:05 2009 From: dalej at apple.com (Dale Johannesen) Date: Tue, 19 May 2009 09:51:05 -0700 Subject: [llvm-commits] [llvm] r72045 - /llvm/trunk/lib/Target/X86/X86InstrInfo.td In-Reply-To: <4A127AEC.1070608@lip6.fr> References: <200905182142.n4ILgWgP031346@zion.cs.uiuc.edu> <4A127AEC.1070608@lip6.fr> Message-ID: <8AD27C27-C211-4F58-A924-05FAF49952F0@apple.com> On May 19, 2009, at 2:25 AMPDT, Nicolas Geoffray wrote: > Hi Dale, > > Dale Johannesen wrote: >> Author: johannes >> Date: Mon May 18 16:41:59 2009 >> New Revision: 72045 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=72045&view=rev >> Log: >> Add OpSize to 16-bit ADC and SBB. >> > > What is OpSize? This patch is causing lots of memory errors in VMKit, > I'm not sure why. It indicates the operand size prefix, 0x66, should be emitted. It is normal on 16-bit operations. > Does the JIT in LLVM understand OpSize? Yes, in fact it's entirely for use by the JIT. See XCodeEmitter. Are you sure it's this patch? I'd be surprised if these new patterns were getting matched at all right now. > Thanks, > Nicolas > >> >> 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=72045&r1=72044&r2=72045&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) >> +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon May 18 16:41:59 >> 2009 >> @@ -2280,7 +2280,7 @@ >> def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst), >> (ins GR16:$src1, GR16:$src2), >> "adc{w}\t{$src2, $dst|$dst, $src2}", >> - [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>; >> + [(set GR16:$dst, (adde GR16:$src1, >> GR16:$src2))]>, OpSize; >> def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), >> (ins GR32:$src1, GR32:$src2), >> "adc{l}\t{$src2, $dst|$dst, $src2}", >> @@ -2293,7 +2293,8 @@ >> def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst), >> (ins GR16:$src1, i16mem:$src2), >> "adc{w}\t{$src2, $dst|$dst, $src2}", >> - [(set GR16:$dst, (adde GR16:$src1, (load addr: >> $src2)))]>; >> + [(set GR16:$dst, (adde GR16:$src1, (load addr: >> $src2)))]>, >> + OpSize; >> def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), >> (ins GR32:$src1, i32mem:$src2), >> "adc{l}\t{$src2, $dst|$dst, $src2}", >> @@ -2304,11 +2305,12 @@ >> def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst), >> (ins GR16:$src1, i16imm:$src2), >> "adc{w}\t{$src2, $dst|$dst, $src2}", >> - [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>; >> + [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, >> OpSize; >> def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst), >> (ins GR16:$src1, i16i8imm:$src2), >> "adc{w}\t{$src2, $dst|$dst, $src2}", >> - [(set GR16:$dst, (adde GR16:$src1, >> i16immSExt8:$src2))]>; >> + [(set GR16:$dst, (adde GR16:$src1, >> i16immSExt8:$src2))]>, >> + OpSize; >> def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), >> (ins GR32:$src1, i32imm:$src2), >> "adc{l}\t{$src2, $dst|$dst, $src2}", >> @@ -2324,7 +2326,8 @@ >> [(store (adde (load addr:$dst), GR8:$src2), addr: >> $dst)]>; >> def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, >> GR16:$src2), >> "adc{w}\t{$src2, $dst|$dst, $src2}", >> - [(store (adde (load addr:$dst), GR16:$src2), >> addr:$dst)]>; >> + [(store (adde (load addr:$dst), GR16:$src2), >> addr:$dst)]>, >> + OpSize; >> def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, >> GR32:$src2), >> "adc{l}\t{$src2, $dst|$dst, $src2}", >> [(store (adde (load addr:$dst), GR32:$src2), >> addr:$dst)]>; >> @@ -2333,10 +2336,12 @@ >> [(store (adde (loadi8 addr:$dst), imm:$src2), >> addr:$dst)]>; >> def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm: >> $src2), >> "adc{w}\t{$src2, $dst|$dst, $src2}", >> - [(store (adde (loadi16 addr:$dst), imm:$src2), >> addr:$dst)]>; >> + [(store (adde (loadi16 addr:$dst), imm:$src2), >> addr:$dst)]>, >> + OpSize; >> def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, >> i16i8imm :$src2), >> "adc{w}\t{$src2, $dst|$dst, $src2}", >> - [(store (adde (load addr:$dst), i16immSExt8:$src2), >> addr:$dst)]>; >> + [(store (adde (load addr:$dst), i16immSExt8:$src2), >> addr:$dst)]>, >> + OpSize; >> def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm: >> $src2), >> "adc{l}\t{$src2, $dst|$dst, $src2}", >> [(store (adde (loadi32 addr:$dst), imm:$src2), >> addr:$dst)]>; >> @@ -2452,7 +2457,7 @@ >> def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst), >> (ins GR16:$src1, GR16:$src2), >> "sbb{w}\t{$src2, $dst|$dst, $src2}", >> - [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>; >> + [(set GR16:$dst, (sube GR16:$src1, >> GR16:$src2))]>, OpSize; >> def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), >> (ins GR32:$src1, GR32:$src2), >> "sbb{l}\t{$src2, $dst|$dst, $src2}", >> @@ -2464,7 +2469,8 @@ >> [(store (sube (load addr:$dst), GR8:$src2), addr: >> $dst)]>; >> def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, >> GR16:$src2), >> "sbb{w}\t{$src2, $dst|$dst, $src2}", >> - [(store (sube (load addr:$dst), GR16:$src2), >> addr:$dst)]>; >> + [(store (sube (load addr:$dst), GR16:$src2), >> addr:$dst)]>, >> + OpSize; >> def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, >> GR32:$src2), >> "sbb{l}\t{$src2, $dst|$dst, $src2}", >> [(store (sube (load addr:$dst), GR32:$src2), >> addr:$dst)]>; >> @@ -2473,10 +2479,12 @@ >> [(store (sube (loadi8 addr:$dst), imm:$src2), >> addr:$dst)]>; >> def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm: >> $src2), >> "sbb{w}\t{$src2, $dst|$dst, $src2}", >> - [(store (sube (loadi16 addr:$dst), imm:$src2), >> addr:$dst)]>; >> + [(store (sube (loadi16 addr:$dst), imm:$src2), >> addr:$dst)]>, >> + OpSize; >> def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, >> i16i8imm :$src2), >> "sbb{w}\t{$src2, $dst|$dst, $src2}", >> - [(store (sube (load addr:$dst), i16immSExt8:$src2), >> addr:$dst)]>; >> + [(store (sube (load addr:$dst), i16immSExt8:$src2), >> addr:$dst)]>, >> + OpSize; >> def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm: >> $src2), >> "sbb{l}\t{$src2, $dst|$dst, $src2}", >> [(store (sube (loadi32 addr:$dst), imm:$src2), >> addr:$dst)]>; >> @@ -2490,7 +2498,8 @@ >> def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst), >> (ins GR16:$src1, i16mem:$src2), >> "sbb{w}\t{$src2, $dst|$dst, $src2}", >> - [(set GR16:$dst, (sube GR16:$src1, (load addr: >> $src2)))]>; >> + [(set GR16:$dst, (sube GR16:$src1, (load addr: >> $src2)))]>, >> + OpSize; >> def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), >> (ins GR32:$src1, i32mem:$src2), >> "sbb{l}\t{$src2, $dst|$dst, $src2}", >> @@ -2501,11 +2510,12 @@ >> def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst), >> (ins GR16:$src1, i16imm:$src2), >> "sbb{w}\t{$src2, $dst|$dst, $src2}", >> - [(set GR16:$dst, (sube GR16:$src1, imm: >> $src2))]>; >> + [(set GR16:$dst, (sube GR16:$src1, imm: >> $src2))]>, OpSize; >> def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst), >> (ins GR16:$src1, i16i8imm:$src2), >> "sbb{w}\t{$src2, $dst|$dst, $src2}", >> - [(set GR16:$dst, (sube GR16:$src1, >> i16immSExt8:$src2))]>; >> + [(set GR16:$dst, (sube GR16:$src1, >> i16immSExt8:$src2))]>, >> + OpSize; >> def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), >> (ins GR32:$src1, i32imm:$src2), >> "sbb{l}\t{$src2, $dst|$dst, $src2}", >> >> >> _______________________________________________ >> 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 isanbard at gmail.com Tue May 19 12:47:47 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 19 May 2009 10:47:47 -0700 Subject: [llvm-commits] [PATCH] Fix C2888 compile error in VS2008 In-Reply-To: References: Message-ID: <16e5fdf90905191047u270571fcrf695e4427beb73ca@mail.gmail.com> "struct LiveInterva"? :-) -bw On Tue, May 19, 2009 at 2:44 AM, Howard Su wrote: > The attached patch to fix two compiler error C2888?when compiling under > VS2008. > > -- > -Howard > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From isanbard at gmail.com Tue May 19 12:50:19 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 19 May 2009 17:50:19 -0000 Subject: [llvm-commits] [llvm] r72112 - /llvm/trunk/lib/CodeGen/Spiller.h Message-ID: <200905191750.n4JHoJZP022112@zion.cs.uiuc.edu> Author: void Date: Tue May 19 12:50:18 2009 New Revision: 72112 URL: http://llvm.org/viewvc/llvm-project?rev=72112&view=rev Log: Fix to compile on VS2008. Modified: llvm/trunk/lib/CodeGen/Spiller.h Modified: llvm/trunk/lib/CodeGen/Spiller.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.h?rev=72112&r1=72111&r2=72112&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Spiller.h (original) +++ llvm/trunk/lib/CodeGen/Spiller.h Tue May 19 12:50:18 2009 @@ -13,6 +13,7 @@ #include namespace llvm { + struct LiveInterval; /// Spiller interface. /// @@ -21,7 +22,7 @@ class Spiller { public: virtual ~Spiller() = 0; - virtual std::vector spill(class LiveInterval *li) = 0; + virtual std::vector spill(class LiveInterval *li) = 0; }; /// Create and return a spiller object, as specified on the command line. From isanbard at gmail.com Tue May 19 12:50:32 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 19 May 2009 10:50:32 -0700 Subject: [llvm-commits] [PATCH] Fix C2888 compile error in VS2008 In-Reply-To: References: Message-ID: <16e5fdf90905191050i642307e6j2084e1c02aedb989@mail.gmail.com> I applied a modified version of your patch. Thanks! -bw On Tue, May 19, 2009 at 2:44 AM, Howard Su wrote: > The attached patch to fix two compiler error C2888?when compiling under > VS2008. > > -- > -Howard > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From isanbard at gmail.com Tue May 19 12:51:27 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 19 May 2009 17:51:27 -0000 Subject: [llvm-commits] [llvm] r72113 - /llvm/trunk/lib/CodeGen/Spiller.h Message-ID: <200905191751.n4JHpRl7022152@zion.cs.uiuc.edu> Author: void Date: Tue May 19 12:51:26 2009 New Revision: 72113 URL: http://llvm.org/viewvc/llvm-project?rev=72113&view=rev Log: Remove 'class' specifier. Modified: llvm/trunk/lib/CodeGen/Spiller.h Modified: llvm/trunk/lib/CodeGen/Spiller.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.h?rev=72113&r1=72112&r2=72113&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Spiller.h (original) +++ llvm/trunk/lib/CodeGen/Spiller.h Tue May 19 12:51:26 2009 @@ -22,12 +22,12 @@ class Spiller { public: virtual ~Spiller() = 0; - virtual std::vector spill(class LiveInterval *li) = 0; + virtual std::vector spill(LiveInterval *li) = 0; }; /// Create and return a spiller object, as specified on the command line. - Spiller* createSpiller(class MachineFunction *mf, class LiveIntervals *li, - class VirtRegMap *vrm); + Spiller* createSpiller(MachineFunction *mf, LiveIntervals *li, + VirtRegMap *vrm); } #endif From isanbard at gmail.com Tue May 19 12:52:32 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 19 May 2009 17:52:32 -0000 Subject: [llvm-commits] [llvm] r72114 - /llvm/trunk/lib/CodeGen/Spiller.h Message-ID: <200905191752.n4JHqWOS022197@zion.cs.uiuc.edu> Author: void Date: Tue May 19 12:52:31 2009 New Revision: 72114 URL: http://llvm.org/viewvc/llvm-project?rev=72114&view=rev Log: Forward decls. Modified: llvm/trunk/lib/CodeGen/Spiller.h Modified: llvm/trunk/lib/CodeGen/Spiller.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.h?rev=72114&r1=72113&r2=72114&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Spiller.h (original) +++ llvm/trunk/lib/CodeGen/Spiller.h Tue May 19 12:52:31 2009 @@ -14,6 +14,9 @@ namespace llvm { struct LiveInterval; + class LiveIntervals; + class MachineFunction; + class VirtRegMap; /// Spiller interface. /// From bob.wilson at apple.com Tue May 19 13:33:35 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 19 May 2009 18:33:35 -0000 Subject: [llvm-commits] [llvm] r72115 - /llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp Message-ID: <200905191833.n4JIXb9F023834@zion.cs.uiuc.edu> Author: bwilson Date: Tue May 19 13:33:02 2009 New Revision: 72115 URL: http://llvm.org/viewvc/llvm-project?rev=72115&view=rev Log: Follow up on new support for memory operands in ARM inline assembly. This fixes pr4233. Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp?rev=72115&r1=72114&r2=72115&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp Tue May 19 13:33:02 2009 @@ -688,6 +688,10 @@ unsigned AddrMode = (Desc.TSFlags & ARMII::AddrModeMask); bool isSub = false; + // Memory operands in inline assembly always use AddrMode2. + if (Opcode == ARM::INLINEASM) + AddrMode = ARMII::AddrMode2; + if (Opcode == ARM::ADDri) { Offset += MI.getOperand(i+1).getImm(); if (Offset == 0) { From gohman at apple.com Tue May 19 14:18:45 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 19 May 2009 19:18:45 -0000 Subject: [llvm-commits] [llvm] r72120 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Message-ID: <200905191918.n4JJItIS025462@zion.cs.uiuc.edu> Author: djg Date: Tue May 19 14:18:01 2009 New Revision: 72120 URL: http://llvm.org/viewvc/llvm-project?rev=72120&view=rev Log: Create ConstantExpr GEPs the correct way. This fixes MultiSource/Benchmarks/Prolangs-C/football and a variety of other failures. Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=72120&r1=72119&r2=72120&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Tue May 19 14:18:01 2009 @@ -246,7 +246,7 @@ // Fold a GEP with constant operands. if (Constant *CLHS = dyn_cast(V)) if (Constant *CRHS = dyn_cast(Idx)) - return ConstantExpr::get(Instruction::GetElementPtr, CLHS, CRHS); + return ConstantExpr::getGetElementPtr(CLHS, &CRHS, 1); // Do a quick scan to see if we have this GEP nearby. If so, reuse it. unsigned ScanLimit = 6; From criswell at uiuc.edu Tue May 19 14:22:02 2009 From: criswell at uiuc.edu (John Criswell) Date: Tue, 19 May 2009 19:22:02 -0000 Subject: [llvm-commits] [poolalloc] r72121 - /poolalloc/branches/SVA/lib/DSA/TopDownClosure.cpp Message-ID: <200905191922.n4JJM7A3025609@zion.cs.uiuc.edu> Author: criswell Date: Tue May 19 14:21:46 2009 New Revision: 72121 URL: http://llvm.org/viewvc/llvm-project?rev=72121&view=rev Log: Added code to merge metapools together for objects allocated out of the same kmem_cache_t. Re-ordered header files per LLVM coding standards. Modified: poolalloc/branches/SVA/lib/DSA/TopDownClosure.cpp Modified: poolalloc/branches/SVA/lib/DSA/TopDownClosure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/branches/SVA/lib/DSA/TopDownClosure.cpp?rev=72121&r1=72120&r2=72121&view=diff ============================================================================== --- poolalloc/branches/SVA/lib/DSA/TopDownClosure.cpp (original) +++ poolalloc/branches/SVA/lib/DSA/TopDownClosure.cpp Tue May 19 14:21:46 2009 @@ -14,14 +14,18 @@ // //===----------------------------------------------------------------------===// -#include "dsa/DataStructure.h" -#include "llvm/Module.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Instructions.h" #include "llvm/DerivedTypes.h" -#include "dsa/DSGraph.h" +#include "llvm/Module.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Timer.h" -#include "llvm/ADT/Statistic.h" + +#include "dsa/DataStructure.h" +#include "dsa/DSGraph.h" + #include + using namespace llvm; #if 0 @@ -149,7 +153,57 @@ ii != ee; ++ii) ii->getMP()->addFlags(ii->getNodeFlags()); } - + +#ifdef LLVA_KERNEL + // + // Ugly hack: + // + // Memory objects returned from kmem_cache_alloc() alias if they are + // allocated from the same kernel pool. This code forces them to have the + // same MetaPool. + // + Function* KMA = M.getNamedFunction("kmem_cache_alloc"); + if (KMA) { + // Map from kmem_cache_t's metapool to the metapool of its return value + std::map locs; + + for (Value::use_iterator ii = KMA->use_begin(), ee = KMA->use_end(); + ii != ee; ++ii) { + CallInst* CI = dyn_cast(*ii); + if ((CI) && (CI->getCalledFunction() == KMA)) { + // Function in which the call statement resides + Function * F = CI->getParent()->getParent(); + + // The pointer to the kmem_cache_t + Value* CacheT = CI->getOperand(1); + + // + // Get the metapool for the kmem_cache_t + // + DSNodeHandle DSCacheT = DSInfo[F]->getNodeForValue(CacheT); + MetaPoolHandle MPCacheT (DSCacheT.getNode()->getMP()); + + // + // Get the DSNode handle of the object being allocated. + // + DSNodeHandle DSH = DSInfo[F]->getNodeForValue(CI); + MetaPoolHandle MPNode (DSH.getNode()->getMP()); + + // + // If the allocated object does not belong to the same metapool as + // other objects allocated from this kmem_cache_t, merge their + // metapools so that they do. + // + if (locs[MPCacheT.getPool()] != MPNode.getPool()) { + std::cerr << "kmem_cache_alloc recovered merge\n"; + DSH.getNode()->getMP()->merge(locs[MPCacheT.getPool()]); + } + locs[MPCacheT.getPool()] = DSH.getNode()->getMP(); + } + } + } +#endif + return false; } From gohman at apple.com Tue May 19 14:22:49 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 19 May 2009 19:22:49 -0000 Subject: [llvm-commits] [llvm] r72122 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h lib/Analysis/ScalarEvolution.cpp Message-ID: <200905191922.n4JJMoKw025685@zion.cs.uiuc.edu> Author: djg Date: Tue May 19 14:22:47 2009 New Revision: 72122 URL: http://llvm.org/viewvc/llvm-project?rev=72122&view=rev Log: Make SCEVCallbackVH a private nested class inside ScalarEvolution, as it's an implementation detail. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=72122&r1=72121&r2=72122&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Tue May 19 14:22:47 2009 @@ -145,16 +145,6 @@ static bool classof(const SCEV *S); }; - /// SCEVCallbackVH - A CallbackVH to arrange for ScalarEvolution to be - /// notified whenever a Value is deleted. - class SCEVCallbackVH : public CallbackVH { - ScalarEvolution *SE; - virtual void deleted(); - virtual void allUsesReplacedWith(Value *New); - public: - SCEVCallbackVH(Value *V, ScalarEvolution *SE = 0); - }; - /// SCEVHandle - This class is used to maintain the SCEV object's refcounts, /// freeing the objects when the last reference is dropped. class SCEVHandle { @@ -212,6 +202,16 @@ /// they must ask this class for services. /// class ScalarEvolution : public FunctionPass { + /// SCEVCallbackVH - A CallbackVH to arrange for ScalarEvolution to be + /// notified whenever a Value is deleted. + class SCEVCallbackVH : public CallbackVH { + ScalarEvolution *SE; + virtual void deleted(); + virtual void allUsesReplacedWith(Value *New); + public: + SCEVCallbackVH(Value *V, ScalarEvolution *SE = 0); + }; + friend class SCEVCallbackVH; friend class SCEVExpander; Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=72122&r1=72121&r2=72122&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue May 19 14:22:47 2009 @@ -3674,7 +3674,7 @@ // SCEVCallbackVH Class Implementation //===----------------------------------------------------------------------===// -void SCEVCallbackVH::deleted() { +void ScalarEvolution::SCEVCallbackVH::deleted() { assert(SE && "SCEVCallbackVH called with a non-null ScalarEvolution!"); if (PHINode *PN = dyn_cast(getValPtr())) SE->ConstantEvolutionLoopExitValue.erase(PN); @@ -3684,7 +3684,7 @@ // this now dangles! } -void SCEVCallbackVH::allUsesReplacedWith(Value *) { +void ScalarEvolution::SCEVCallbackVH::allUsesReplacedWith(Value *) { assert(SE && "SCEVCallbackVH called with a non-null ScalarEvolution!"); // Forget all the expressions associated with users of the old value, @@ -3724,7 +3724,7 @@ // this may dangle! } -SCEVCallbackVH::SCEVCallbackVH(Value *V, ScalarEvolution *se) +ScalarEvolution::SCEVCallbackVH::SCEVCallbackVH(Value *V, ScalarEvolution *se) : CallbackVH(V), SE(se) {} //===----------------------------------------------------------------------===// From luked at cs.rochester.edu Tue May 19 09:55:10 2009 From: luked at cs.rochester.edu (Luke Dalessandro) Date: Tue, 19 May 2009 10:55:10 -0400 Subject: [llvm-commits] [PATCH] Thread-safe ManagedStatic In-Reply-To: <358F1AAC-7DF4-4ABD-87DC-4B3B581B1EA7@mac.com> References: <200905190107.n4J17f3A006679@zion.cs.uiuc.edu> <5464957333051772950217202212009693918-Webmail@me.com> <358F1AAC-7DF4-4ABD-87DC-4B3B581B1EA7@mac.com> Message-ID: <4A12C84E.3010203@cs.rochester.edu> Owen Anderson wrote: > > On May 19, 2009, at 3:08 AM, Chris Lattner wrote: >> The basic algorithm looks fine, however: >> >> 3. Why do you create your own mutex out of atomic operations instead >> of just using a pthreads lock? spinning is not always an efficient >> solution to contention, particularly if your machine really only has >> one cpu! (in which case you end up spinning away the rest of your >> timeslice) > > Portability. llvm::sys::Mutex _cannot_ be made to work, because on Windows > it has to have a non-trivial constructor. If there was just one static lock for the class, could you stick it inside the LazyInit() routine and get the non-trivial constructor to be threadsafe on Windows? void LazyInit() const { static sys::Mutex lock(false); etc... } I'm actually curious about the answer. What does windows do here? Does it default to the equivalent of gcc's -fno-threadsafe-statics? Luke > > Also, this is pretty much the ideal case for spinlocks. Initialization > only happens once and > we're using a separate mutex for each object, so we don't expect > significant contention over > the life of the program. Plus, the initialization itself should be > fairly fast. This means that > the spinning thread can continue immediately after the lock is > released, rather than having > to wait for the OS to wake it up. > >> 4. Instead of going through the trouble to make the locking more >> efficient, I think it would be good to special case the scenario when >> there is only one LLVM thread. Why not make clients explicitly opt-in >> to multithreaded llvm, by making an explicit llvm_multithread call? >> If multithreading is disabled, this call should return an error. If >> enabled, it would set a global. All the various "locking" clients >> could just check the global before taking potential heavy-weight locks. > > We already handle this in a somewhat different way. When threading is > disabled, > llvm::sys::Mutex operations are turned into no-ops, and MemoryFence() and > CompareAndSwap() are given non-atomic implementations. > > --Owen > > > ------------------------------------------------------------------------ > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From cristic at cs.stanford.edu Tue May 19 14:29:19 2009 From: cristic at cs.stanford.edu (Cristian Cadar) Date: Tue, 19 May 2009 19:29:19 -0000 Subject: [llvm-commits] [klee] r72123 - /klee/trunk/www/tutorials.html Message-ID: <200905191929.n4JJTKmV025902@zion.cs.uiuc.edu> Author: cristic Date: Tue May 19 14:29:16 2009 New Revision: 72123 URL: http://llvm.org/viewvc/llvm-project?rev=72123&view=rev Log: Added empty www/tutorials.html page (test commit to klee repository). Added: klee/trunk/www/tutorials.html Added: klee/trunk/www/tutorials.html URL: http://llvm.org/viewvc/llvm-project/klee/trunk/www/tutorials.html?rev=72123&view=auto ============================================================================== --- klee/trunk/www/tutorials.html (added) +++ klee/trunk/www/tutorials.html Tue May 19 14:29:16 2009 @@ -0,0 +1,20 @@ + + + + + + The klee Symbolic Virtual Machine + + + + + +
+ +

KLEE Tutorials

+ + +
+ + From criswell at uiuc.edu Tue May 19 14:36:08 2009 From: criswell at uiuc.edu (John Criswell) Date: Tue, 19 May 2009 19:36:08 -0000 Subject: [llvm-commits] [poolalloc] r72124 - /poolalloc/branches/SVA/lib/DSA/Local.cpp Message-ID: <200905191936.n4JJaAel026115@zion.cs.uiuc.edu> Author: criswell Date: Tue May 19 14:35:52 2009 New Revision: 72124 URL: http://llvm.org/viewvc/llvm-project?rev=72124&view=rev Log: Moved the kmem_cache_alloc() hack from the local DSA pass to the Top-Down DSA pass (where more aliasing information is available). Modified: poolalloc/branches/SVA/lib/DSA/Local.cpp Modified: poolalloc/branches/SVA/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/branches/SVA/lib/DSA/Local.cpp?rev=72124&r1=72123&r2=72124&view=diff ============================================================================== --- poolalloc/branches/SVA/lib/DSA/Local.cpp (original) +++ poolalloc/branches/SVA/lib/DSA/Local.cpp Tue May 19 14:35:52 2009 @@ -1911,33 +1911,6 @@ EliminateUsesOfECGlobals(*I->second, ECGlobals); } -#ifdef LLVA_KERNEL - - // Ugly hack. kmem_cache_allocs are in the same pool also if the kmem_cache_t's are the same - // this only works on global kmem_cache_ts - Function* KMA = M.getNamedFunction("kmem_cache_alloc"); - if (KMA) { - for (Value::use_iterator ii = KMA->use_begin(), ee = KMA->use_end(); - ii != ee; ++ii) { - std::map locs; - if (CallInst* CI = dyn_cast(*ii)) { - if (CI->getCalledFunction() == KMA && isa(CI->getOperand(1))) { - Value* V = CI->getOperand(1); //the kmem_cache_alloc - DSNodeHandle DSH = DSInfo[CI->getParent()->getParent()]->getNodeForValue(CI); - MetaPoolHandle L(locs[V]), N(DSH.getNode()->getMP()); - if (L.getPool() != N.getPool()) { - std::cerr << "kmem_cache_alloc recovered merge\n"; - MetaPoolHandle L(locs[V]), N(DSH.getNode()->getMP()); - DSH.getNode()->getMP()->merge(locs[V]); - } - locs[V] = DSH.getNode()->getMP(); - } - } - } - } - -#endif - return true; } From clattner at apple.com Tue May 19 14:41:25 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 19 May 2009 12:41:25 -0700 Subject: [llvm-commits] [PATCH] Thread-safe ManagedStatic In-Reply-To: <358F1AAC-7DF4-4ABD-87DC-4B3B581B1EA7@mac.com> References: <200905190107.n4J17f3A006679@zion.cs.uiuc.edu> <5464957333051772950217202212009693918-Webmail@me.com> <358F1AAC-7DF4-4ABD-87DC-4B3B581B1EA7@mac.com> Message-ID: <8DD69FC6-D713-4451-899D-C8FE8D508E75@apple.com> >> 2. Again, we only need a single global lock, we do not need a mutex >> per ManagedStatic. > > Conversely, why have only one? Also, see my answer to #3. Because it takes less space. >> 3. Why do you create your own mutex out of atomic operations instead >> of just using a pthreads lock? spinning is not always an efficient >> solution to contention, particularly if your machine really only has >> one cpu! (in which case you end up spinning away the rest of your >> timeslice) > > Portability. llvm::sys::Mutex _cannot_ be made to work, because on > Windows > it has to have a non-trivial constructor. This is irrelevant. We are going to have a bunch of "global" state for all the stuff that uniques stuff. The managed static is just the first piece of it. When the app calls llvm_start_multithread_mode(), this function can set up the global mutex and do whatever else it wants to do, while the app is still single threaded. This means that it is perfectly safe to have: Mutex *TheGlobalMutex; and use: TheGlobalMutex->lock(); places, because you know that TheGlobalMutex will be allocated and initialized when the app is single threaded. > Also, this is pretty much the ideal case for spinlocks. > Initialization only happens once and > we're using a separate mutex for each object, so we don't expect > significant contention over > the life of the program. Plus, the initialization itself should be > fairly fast. This means that > the spinning thread can continue immediately after the lock is > released, rather than having > to wait for the OS to wake it up. ManagedStatic is a generic class, meaning that it can take an arbitrary amount of time to initialize. One initialization can potentially also cause initialization of other objects: make sure the global mutex is recursive. >> >> efficient, I think it would be good to special case the scenario when >> there is only one LLVM thread. Why not make clients explicitly opt- >> in >> to multithreaded llvm, by making an explicit llvm_multithread call? >> If multithreading is disabled, this call should return an error. If >> enabled, it would set a global. All the various "locking" clients >> could just check the global before taking potential heavy-weight >> locks. > > We already handle this in a somewhat different way. When threading > is disabled, > llvm::sys::Mutex operations are turned into no-ops, and > MemoryFence() and > CompareAndSwap() are given non-atomic implementations. You are confusing the case when llvm is compiled without multithreading support with the case where it is compiled with threading support but that app is not using it. -Chris From resistor at mac.com Tue May 19 15:18:07 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 19 May 2009 15:18:07 -0500 Subject: [llvm-commits] [PATCH] Thread-safe ManagedStatic In-Reply-To: <4A12C84E.3010203@cs.rochester.edu> References: <200905190107.n4J17f3A006679@zion.cs.uiuc.edu> <5464957333051772950217202212009693918-Webmail@me.com> <358F1AAC-7DF4-4ABD-87DC-4B3B581B1EA7@mac.com> <4A12C84E.3010203@cs.rochester.edu> Message-ID: <87525340677602673349810574238295973857-Webmail@me.com> On Tuesday, May 19, 2009, at 09:55AM, "Luke Dalessandro" wrote: > >If there was just one static lock for the class, could you stick it >inside the LazyInit() routine and get the non-trivial constructor to be >threadsafe on Windows? > > void LazyInit() const { > static sys::Mutex lock(false); > etc... > } Unfortunately, we're not implementing Singletons here. There can well be more than one static instance of the class. --Owen From resistor at mac.com Tue May 19 15:20:48 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 19 May 2009 15:20:48 -0500 Subject: [llvm-commits] [PATCH] Thread-safe ManagedStatic In-Reply-To: <8DD69FC6-D713-4451-899D-C8FE8D508E75@apple.com> References: <200905190107.n4J17f3A006679@zion.cs.uiuc.edu> <5464957333051772950217202212009693918-Webmail@me.com> <358F1AAC-7DF4-4ABD-87DC-4B3B581B1EA7@mac.com> <8DD69FC6-D713-4451-899D-C8FE8D508E75@apple.com> Message-ID: <16551545510839478801965352385268027480-Webmail@me.com> Alright, is this something more like what you had in mind? --Owen -------------- next part -------------- A non-text attachment was scrubbed... Name: ManagedStatic2.diff Type: application/octet-stream Size: 6466 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090519/d23ae220/attachment.obj From gohman at apple.com Tue May 19 15:35:26 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 19 May 2009 20:35:26 -0000 Subject: [llvm-commits] [llvm] r72130 - in /llvm/trunk/lib/Transforms/Scalar: IndVarSimplify.cpp LoopStrengthReduce.cpp Message-ID: <200905192035.n4JKZQ8S028161@zion.cs.uiuc.edu> Author: djg Date: Tue May 19 15:35:26 2009 New Revision: 72130 URL: http://llvm.org/viewvc/llvm-project?rev=72130&view=rev Log: Trim unneeded #includes. Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=72130&r1=72129&r2=72130&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Tue May 19 15:35:26 2009 @@ -51,12 +51,10 @@ #include "llvm/Support/CFG.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" -#include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Support/CommandLine.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/SetVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" using namespace llvm; Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=72130&r1=72129&r2=72130&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue May 19 15:35:26 2009 @@ -27,7 +27,6 @@ #include "llvm/Transforms/Utils/AddrModeMatcher.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Local.h" -#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/CFG.h" #include "llvm/Support/Debug.h" From gohman at apple.com Tue May 19 15:37:36 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 19 May 2009 20:37:36 -0000 Subject: [llvm-commits] [llvm] r72131 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200905192037.n4JKbaL7028343@zion.cs.uiuc.edu> Author: djg Date: Tue May 19 15:37:36 2009 New Revision: 72131 URL: http://llvm.org/viewvc/llvm-project?rev=72131&view=rev Log: Add some more comments to the top of this file. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=72131&r1=72130&r2=72131&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue May 19 15:37:36 2009 @@ -7,8 +7,15 @@ // //===----------------------------------------------------------------------===// // +// This transformation analyzes and transforms the induction variables (and +// computations derived from them) into forms suitable for efficient execution +// on the target. +// // This pass performs a strength reduction on array references inside loops that -// have as one or more of their components the loop induction variable. +// have as one or more of their components the loop induction variable, it +// rewrites expressions to take advantage of scaled-index addressing modes +// available on the target, and it performs a variety of other optimizations +// related to loop induction variables. // //===----------------------------------------------------------------------===// From gohman at apple.com Tue May 19 15:38:47 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 19 May 2009 20:38:47 -0000 Subject: [llvm-commits] [llvm] r72132 - /llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <200905192038.n4JKclu7028417@zion.cs.uiuc.edu> Author: djg Date: Tue May 19 15:38:47 2009 New Revision: 72132 URL: http://llvm.org/viewvc/llvm-project?rev=72132&view=rev Log: Remove an irrelevant comment. Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=72132&r1=72131&r2=72132&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Tue May 19 15:38:47 2009 @@ -31,9 +31,7 @@ // expression, this transformation will make the loop dead. // // This transformation should be followed by strength reduction after all of the -// desired loop transformations have been performed. Additionally, on targets -// where it is profitable, the loop could be transformed to count down to zero -// (the "do loop" optimization). +// desired loop transformations have been performed. // //===----------------------------------------------------------------------===// From nicolas.geoffray at lip6.fr Tue May 19 15:37:19 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 19 May 2009 22:37:19 +0200 Subject: [llvm-commits] [llvm] r72045 - /llvm/trunk/lib/Target/X86/X86InstrInfo.td In-Reply-To: <8AD27C27-C211-4F58-A924-05FAF49952F0@apple.com> References: <200905182142.n4ILgWgP031346@zion.cs.uiuc.edu> <4A127AEC.1070608@lip6.fr> <8AD27C27-C211-4F58-A924-05FAF49952F0@apple.com> Message-ID: <4A13187F.4040306@lip6.fr> Apologies Dale, your patch didn't cause my errors. I realized it's the new atomics checks that cause them. Sorry for the noise. Nicolas Dale Johannesen wrote: > On May 19, 2009, at 2:25 AMPDT, Nicolas Geoffray wrote: > > >> Hi Dale, >> >> Dale Johannesen wrote: >> >>> Author: johannes >>> Date: Mon May 18 16:41:59 2009 >>> New Revision: 72045 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=72045&view=rev >>> Log: >>> Add OpSize to 16-bit ADC and SBB. >>> >>> >> What is OpSize? This patch is causing lots of memory errors in VMKit, >> I'm not sure why. >> > > It indicates the operand size prefix, 0x66, should be emitted. It is > normal on 16-bit operations. > > >> Does the JIT in LLVM understand OpSize? >> > > Yes, in fact it's entirely for use by the JIT. See XCodeEmitter. > > Are you sure it's this patch? I'd be surprised if these new patterns > were getting matched at all right now. > > >> Thanks, >> Nicolas >> >> >>> 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=72045&r1=72044&r2=72045&view=diff >>> >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ===================================================================== >>> --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) >>> +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon May 18 16:41:59 >>> 2009 >>> @@ -2280,7 +2280,7 @@ >>> def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst), >>> (ins GR16:$src1, GR16:$src2), >>> "adc{w}\t{$src2, $dst|$dst, $src2}", >>> - [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>; >>> + [(set GR16:$dst, (adde GR16:$src1, >>> GR16:$src2))]>, OpSize; >>> def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), >>> (ins GR32:$src1, GR32:$src2), >>> "adc{l}\t{$src2, $dst|$dst, $src2}", >>> @@ -2293,7 +2293,8 @@ >>> def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst), >>> (ins GR16:$src1, i16mem:$src2), >>> "adc{w}\t{$src2, $dst|$dst, $src2}", >>> - [(set GR16:$dst, (adde GR16:$src1, (load addr: >>> $src2)))]>; >>> + [(set GR16:$dst, (adde GR16:$src1, (load addr: >>> $src2)))]>, >>> + OpSize; >>> def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), >>> (ins GR32:$src1, i32mem:$src2), >>> "adc{l}\t{$src2, $dst|$dst, $src2}", >>> @@ -2304,11 +2305,12 @@ >>> def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst), >>> (ins GR16:$src1, i16imm:$src2), >>> "adc{w}\t{$src2, $dst|$dst, $src2}", >>> - [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>; >>> + [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, >>> OpSize; >>> def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst), >>> (ins GR16:$src1, i16i8imm:$src2), >>> "adc{w}\t{$src2, $dst|$dst, $src2}", >>> - [(set GR16:$dst, (adde GR16:$src1, >>> i16immSExt8:$src2))]>; >>> + [(set GR16:$dst, (adde GR16:$src1, >>> i16immSExt8:$src2))]>, >>> + OpSize; >>> def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), >>> (ins GR32:$src1, i32imm:$src2), >>> "adc{l}\t{$src2, $dst|$dst, $src2}", >>> @@ -2324,7 +2326,8 @@ >>> [(store (adde (load addr:$dst), GR8:$src2), addr: >>> $dst)]>; >>> def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, >>> GR16:$src2), >>> "adc{w}\t{$src2, $dst|$dst, $src2}", >>> - [(store (adde (load addr:$dst), GR16:$src2), >>> addr:$dst)]>; >>> + [(store (adde (load addr:$dst), GR16:$src2), >>> addr:$dst)]>, >>> + OpSize; >>> def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, >>> GR32:$src2), >>> "adc{l}\t{$src2, $dst|$dst, $src2}", >>> [(store (adde (load addr:$dst), GR32:$src2), >>> addr:$dst)]>; >>> @@ -2333,10 +2336,12 @@ >>> [(store (adde (loadi8 addr:$dst), imm:$src2), >>> addr:$dst)]>; >>> def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm: >>> $src2), >>> "adc{w}\t{$src2, $dst|$dst, $src2}", >>> - [(store (adde (loadi16 addr:$dst), imm:$src2), >>> addr:$dst)]>; >>> + [(store (adde (loadi16 addr:$dst), imm:$src2), >>> addr:$dst)]>, >>> + OpSize; >>> def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, >>> i16i8imm :$src2), >>> "adc{w}\t{$src2, $dst|$dst, $src2}", >>> - [(store (adde (load addr:$dst), i16immSExt8:$src2), >>> addr:$dst)]>; >>> + [(store (adde (load addr:$dst), i16immSExt8:$src2), >>> addr:$dst)]>, >>> + OpSize; >>> def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm: >>> $src2), >>> "adc{l}\t{$src2, $dst|$dst, $src2}", >>> [(store (adde (loadi32 addr:$dst), imm:$src2), >>> addr:$dst)]>; >>> @@ -2452,7 +2457,7 @@ >>> def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst), >>> (ins GR16:$src1, GR16:$src2), >>> "sbb{w}\t{$src2, $dst|$dst, $src2}", >>> - [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>; >>> + [(set GR16:$dst, (sube GR16:$src1, >>> GR16:$src2))]>, OpSize; >>> def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), >>> (ins GR32:$src1, GR32:$src2), >>> "sbb{l}\t{$src2, $dst|$dst, $src2}", >>> @@ -2464,7 +2469,8 @@ >>> [(store (sube (load addr:$dst), GR8:$src2), addr: >>> $dst)]>; >>> def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, >>> GR16:$src2), >>> "sbb{w}\t{$src2, $dst|$dst, $src2}", >>> - [(store (sube (load addr:$dst), GR16:$src2), >>> addr:$dst)]>; >>> + [(store (sube (load addr:$dst), GR16:$src2), >>> addr:$dst)]>, >>> + OpSize; >>> def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, >>> GR32:$src2), >>> "sbb{l}\t{$src2, $dst|$dst, $src2}", >>> [(store (sube (load addr:$dst), GR32:$src2), >>> addr:$dst)]>; >>> @@ -2473,10 +2479,12 @@ >>> [(store (sube (loadi8 addr:$dst), imm:$src2), >>> addr:$dst)]>; >>> def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm: >>> $src2), >>> "sbb{w}\t{$src2, $dst|$dst, $src2}", >>> - [(store (sube (loadi16 addr:$dst), imm:$src2), >>> addr:$dst)]>; >>> + [(store (sube (loadi16 addr:$dst), imm:$src2), >>> addr:$dst)]>, >>> + OpSize; >>> def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, >>> i16i8imm :$src2), >>> "sbb{w}\t{$src2, $dst|$dst, $src2}", >>> - [(store (sube (load addr:$dst), i16immSExt8:$src2), >>> addr:$dst)]>; >>> + [(store (sube (load addr:$dst), i16immSExt8:$src2), >>> addr:$dst)]>, >>> + OpSize; >>> def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm: >>> $src2), >>> "sbb{l}\t{$src2, $dst|$dst, $src2}", >>> [(store (sube (loadi32 addr:$dst), imm:$src2), >>> addr:$dst)]>; >>> @@ -2490,7 +2498,8 @@ >>> def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst), >>> (ins GR16:$src1, i16mem:$src2), >>> "sbb{w}\t{$src2, $dst|$dst, $src2}", >>> - [(set GR16:$dst, (sube GR16:$src1, (load addr: >>> $src2)))]>; >>> + [(set GR16:$dst, (sube GR16:$src1, (load addr: >>> $src2)))]>, >>> + OpSize; >>> def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), >>> (ins GR32:$src1, i32mem:$src2), >>> "sbb{l}\t{$src2, $dst|$dst, $src2}", >>> @@ -2501,11 +2510,12 @@ >>> def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst), >>> (ins GR16:$src1, i16imm:$src2), >>> "sbb{w}\t{$src2, $dst|$dst, $src2}", >>> - [(set GR16:$dst, (sube GR16:$src1, imm: >>> $src2))]>; >>> + [(set GR16:$dst, (sube GR16:$src1, imm: >>> $src2))]>, OpSize; >>> def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst), >>> (ins GR16:$src1, i16i8imm:$src2), >>> "sbb{w}\t{$src2, $dst|$dst, $src2}", >>> - [(set GR16:$dst, (sube GR16:$src1, >>> i16immSExt8:$src2))]>; >>> + [(set GR16:$dst, (sube GR16:$src1, >>> i16immSExt8:$src2))]>, >>> + OpSize; >>> def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), >>> (ins GR32:$src1, i32imm:$src2), >>> "sbb{l}\t{$src2, $dst|$dst, $src2}", >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> >>> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From bob.wilson at apple.com Tue May 19 16:27:58 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 19 May 2009 21:27:58 -0000 Subject: [llvm-commits] [llvm] r72138 - /llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Message-ID: <200905192127.n4JLRwG2030089@zion.cs.uiuc.edu> Author: bwilson Date: Tue May 19 16:27:57 2009 New Revision: 72138 URL: http://llvm.org/viewvc/llvm-project?rev=72138&view=rev Log: Fix pr4227: Handle large immediate values in inline assembly. 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=72138&r1=72137&r2=72138&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Tue May 19 16:27:57 2009 @@ -294,7 +294,7 @@ if (!Modifier || strcmp(Modifier, "no_hash") != 0) O << "#"; - O << (int)MO.getImm(); + O << MO.getImm(); break; } case MachineOperand::MO_MachineBasicBlock: From resistor at mac.com Tue May 19 17:18:56 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 19 May 2009 22:18:56 -0000 Subject: [llvm-commits] [llvm] r72140 - in /llvm/trunk: autoconf/configure.ac configure include/llvm/System/Atomic.h Message-ID: <200905192218.n4JMIv6n031660@zion.cs.uiuc.edu> Author: resistor Date: Tue May 19 17:18:56 2009 New Revision: 72140 URL: http://llvm.org/viewvc/llvm-project?rev=72140&view=rev Log: Split the ENABLE_THREADS #define in two. Now ENABLE_THREADS indicates the ability to run multiple threads at once in the JIT, and requires only mutex support. LLVM_MULTITHREADED indicates (or will indicate) the ability to run LLVM itself across multiple threads, and requires atomics support. Modified: llvm/trunk/autoconf/configure.ac llvm/trunk/configure llvm/trunk/include/llvm/System/Atomic.h Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=72140&r1=72139&r2=72140&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Tue May 19 17:18:56 2009 @@ -372,6 +372,7 @@ default) AC_SUBST(ENABLE_THREADS,[1]) ;; *) AC_MSG_ERROR([Invalid setting for --enable-threads. Use "yes" or "no"]) ;; esac +AC_DEFINE_UNQUOTED([ENABLE_THREADS],$ENABLE_THREADS,[Define if threads enabled]) dnl Allow building without position independent code AC_ARG_ENABLE(pic, @@ -897,24 +898,22 @@ fi dnl atomic builtins are required for threading support. -if test "$ENABLE_THREADS" -eq 1 ; then - AC_MSG_CHECKING(for GCC atomic builtins) - AC_LINK_IFELSE( - AC_LANG_SOURCE( - [[int main() { - volatile unsigned long val = 1; - __sync_synchronize(); - __sync_val_compare_and_swap(&val, 1, 0); - return 0; - } - ]]), - AC_MSG_RESULT(yes), - AC_MSG_RESULT(no) - AC_SUBST(ENABLE_THREADS, [0]) - AC_MSG_WARN([Threading support disabled because atomic builtins are missing])) -fi +AC_MSG_CHECKING(for GCC atomic builtins) +AC_LINK_IFELSE( + AC_LANG_SOURCE( + [[int main() { + volatile unsigned long val = 1; + __sync_synchronize(); + __sync_val_compare_and_swap(&val, 1, 0); + return 0; + } + ]]), + AC_MSG_RESULT(yes) + AC_DEFINE(LLVM_MULTITHREADED, 1, Build multithreading support into LLVM), + AC_MSG_RESULT(no) + AC_DEFINE(LLVM_MULTITHREADED, 0, Build multithreading support into LLVM) + AC_MSG_WARN([LLVM will be built thread-unsafe because atomic builtins are missing])) -AC_DEFINE_UNQUOTED([ENABLE_THREADS],$ENABLE_THREADS,[Define if threads enabled]) dnl===-----------------------------------------------------------------------=== dnl=== Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=72140&r1=72139&r2=72140&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Tue May 19 17:18:56 2009 @@ -4870,6 +4870,11 @@ { (exit 1); exit 1; }; } ;; esac +cat >>confdefs.h <<_ACEOF +#define ENABLE_THREADS $ENABLE_THREADS +_ACEOF + + # Check whether --enable-pic was given. if test "${enable_pic+set}" = set; then enableval=$enable_pic; @@ -10570,7 +10575,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext + echo '#line 12722 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -14432,11 +14437,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14435: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14440: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14439: \$? = $ac_status" >&5 + echo "$as_me:14444: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14700,11 +14705,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14703: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14708: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14707: \$? = $ac_status" >&5 + echo "$as_me:14712: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14804,11 +14809,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14807: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14812: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14811: \$? = $ac_status" >&5 + echo "$as_me:14816: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17256,7 +17261,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:19732: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:19731: \$? = $ac_status" >&5 + echo "$as_me:19736: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -19828,11 +19833,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:19831: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19836: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:19835: \$? = $ac_status" >&5 + echo "$as_me:19840: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -21398,11 +21403,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21401: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21406: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:21405: \$? = $ac_status" >&5 + echo "$as_me:21410: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -21502,11 +21507,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21505: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21510: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:21509: \$? = $ac_status" >&5 + echo "$as_me:21514: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -23737,11 +23742,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:23740: $lt_compile\"" >&5) + (eval echo "\"\$as_me:23745: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:23744: \$? = $ac_status" >&5 + echo "$as_me:23749: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24005,11 +24010,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24008: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24013: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24012: \$? = $ac_status" >&5 + echo "$as_me:24017: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24109,11 +24114,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24112: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24117: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:24116: \$? = $ac_status" >&5 + echo "$as_me:24121: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -33602,21 +33607,20 @@ fi fi -if test "$ENABLE_THREADS" -eq 1 ; then - { echo "$as_me:$LINENO: checking for GCC atomic builtins" >&5 +{ echo "$as_me:$LINENO: checking for GCC atomic builtins" >&5 echo $ECHO_N "checking for GCC atomic builtins... $ECHO_C" >&6; } - cat >conftest.$ac_ext <<_ACEOF +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main() { - volatile unsigned long val = 1; - __sync_synchronize(); - __sync_val_compare_and_swap(&val, 1, 0); - return 0; - } + volatile unsigned long val = 1; + __sync_synchronize(); + __sync_val_compare_and_swap(&val, 1, 0); + return 0; + } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext @@ -33655,26 +33659,28 @@ (exit $ac_status); }; }; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define LLVM_MULTITHREADED 1 +_ACEOF + else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } - ENABLE_THREADS=0 - { echo "$as_me:$LINENO: WARNING: Threading support disabled because atomic builtins are missing" >&5 -echo "$as_me: WARNING: Threading support disabled because atomic builtins are missing" >&2;} +cat >>confdefs.h <<\_ACEOF +#define LLVM_MULTITHREADED 0 +_ACEOF + + { echo "$as_me:$LINENO: WARNING: LLVM will be built thread-unsafe because atomic builtins are missing" >&5 +echo "$as_me: WARNING: LLVM will be built thread-unsafe because atomic builtins are missing" >&2;} fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext -fi - - -cat >>confdefs.h <<_ACEOF -#define ENABLE_THREADS $ENABLE_THREADS -_ACEOF Modified: llvm/trunk/include/llvm/System/Atomic.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Atomic.h?rev=72140&r1=72139&r2=72140&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Atomic.h (original) +++ llvm/trunk/include/llvm/System/Atomic.h Tue May 19 17:18:56 2009 @@ -23,14 +23,8 @@ namespace sys { inline void MemoryFence() { -#if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0 -# if defined(__GNUC__) - __asm__ __volatile__("" : : : "memory"); -# elif defined(_MSC_VER) - __asm { }; -# else -# error No memory fence implementation for your platform! -# endif +#if LLVM_MULTITHREADED==0 + return; #else # if defined(__GNUC__) __sync_synchronize(); @@ -42,7 +36,7 @@ #endif } -#if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0 +#if LLVM_MULTITHREADED==0 typedef unsigned long cas_flag; template inline T CompareAndSwap(volatile T* dest, From resistor at mac.com Tue May 19 17:25:56 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 19 May 2009 22:25:56 -0000 Subject: [llvm-commits] [llvm] r72141 - /llvm/trunk/include/llvm/Config/config.h.in Message-ID: <200905192225.n4JMPu2s032032@zion.cs.uiuc.edu> Author: resistor Date: Tue May 19 17:25:55 2009 New Revision: 72141 URL: http://llvm.org/viewvc/llvm-project?rev=72141&view=rev Log: Forgot this file in my last commit. Modified: llvm/trunk/include/llvm/Config/config.h.in Modified: llvm/trunk/include/llvm/Config/config.h.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.in?rev=72141&r1=72140&r2=72141&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.in (original) +++ llvm/trunk/include/llvm/Config/config.h.in Tue May 19 17:25:55 2009 @@ -470,6 +470,9 @@ /* Installation directory for man pages */ #undef LLVM_MANDIR +/* Build multithreading support into LLVM */ +#undef LLVM_MULTITHREADED + /* Define if this is Unixish platform */ #undef LLVM_ON_UNIX From resistor at mac.com Tue May 19 19:31:29 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 20 May 2009 00:31:29 -0000 Subject: [llvm-commits] [llvm] r72148 - /llvm/trunk/include/llvm/System/Atomic.h Message-ID: <200905200031.n4K0VTjb003694@zion.cs.uiuc.edu> Author: resistor Date: Tue May 19 19:31:29 2009 New Revision: 72148 URL: http://llvm.org/viewvc/llvm-project?rev=72148&view=rev Log: We need to include config.h here so that the #defines are set properly. Modified: llvm/trunk/include/llvm/System/Atomic.h Modified: llvm/trunk/include/llvm/System/Atomic.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Atomic.h?rev=72148&r1=72147&r2=72148&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Atomic.h (original) +++ llvm/trunk/include/llvm/System/Atomic.h Tue May 19 19:31:29 2009 @@ -14,6 +14,8 @@ #ifndef LLVM_SYSTEM_ATOMIC_H #define LLVM_SYSTEM_ATOMIC_H +#include "llvm/Config/config.h" + #if defined(_MSC_VER) #include #endif From gohman at apple.com Tue May 19 19:34:08 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 20 May 2009 00:34:08 -0000 Subject: [llvm-commits] [llvm] r72149 - in /llvm/trunk: lib/Transforms/Scalar/LoopStrengthReduce.cpp test/Transforms/LoopStrengthReduce/dont_reverse.ll Message-ID: <200905200034.n4K0Y8KL003792@zion.cs.uiuc.edu> Author: djg Date: Tue May 19 19:34:08 2009 New Revision: 72149 URL: http://llvm.org/viewvc/llvm-project?rev=72149&view=rev Log: Suppress the IV reversal transformation in the case that the RHS of the comparison is defined inside the loop. This fixes a use-before-def problem, because the transformation puts a use of the RHS outside the loop. Added: llvm/trunk/test/Transforms/LoopStrengthReduce/dont_reverse.ll Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=72149&r1=72148&r2=72149&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue May 19 19:34:08 2009 @@ -2456,6 +2456,11 @@ SCEVHandle One = SE->getIntegerSCEV(1, BackedgeTakenCount->getType()); if (!AR || !AR->isAffine() || AR->getStepRecurrence(*SE) != One) return; + // If the RHS of the comparison is defined inside the loop, the rewrite + // cannot be done. + if (Instruction *CR = dyn_cast(Cond->getOperand(1))) + if (L->contains(CR->getParent())) + return; // Make sure the IV is only used for counting. Value may be preinc or // postinc; 2 uses in either case. Added: llvm/trunk/test/Transforms/LoopStrengthReduce/dont_reverse.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/dont_reverse.ll?rev=72149&view=auto ============================================================================== --- llvm/trunk/test/Transforms/LoopStrengthReduce/dont_reverse.ll (added) +++ llvm/trunk/test/Transforms/LoopStrengthReduce/dont_reverse.ll Tue May 19 19:34:08 2009 @@ -0,0 +1,21 @@ +; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis \ +; RUN: | grep {icmp eq i2 %lsr.iv.next, %xmp4344} + +; Don't reverse the iteration if the rhs of the compare is defined +; inside the loop. + +define void @Fill_Buffer() 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 + %xmp104 = icmp eq i2 %indvar3451, %xmp4344 + %indvar.next35 = add i32 %indvar34, 1 + br i1 %xmp104, label %bb10, label %bb8 + +bb10: + unreachable +} From resistor at mac.com Tue May 19 19:39:26 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 20 May 2009 00:39:26 -0000 Subject: [llvm-commits] [llvm] r72151 - in /llvm/trunk: include/llvm/Support/ManagedStatic.h lib/Support/ManagedStatic.cpp Message-ID: <200905200039.n4K0dRtm003968@zion.cs.uiuc.edu> Author: resistor Date: Tue May 19 19:39:20 2009 New Revision: 72151 URL: http://llvm.org/viewvc/llvm-project?rev=72151&view=rev Log: Add llvm_start_multithreaded(), which starts up the LLVM internals in thread-safe mode. Provide double-check locking initialization of ManagedStatic's when running in thread-safe mode. Modified: llvm/trunk/include/llvm/Support/ManagedStatic.h llvm/trunk/lib/Support/ManagedStatic.cpp Modified: llvm/trunk/include/llvm/Support/ManagedStatic.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ManagedStatic.h?rev=72151&r1=72150&r2=72151&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ManagedStatic.h (original) +++ llvm/trunk/include/llvm/Support/ManagedStatic.h Tue May 19 19:39:20 2009 @@ -14,8 +14,16 @@ #ifndef LLVM_SUPPORT_MANAGED_STATIC_H #define LLVM_SUPPORT_MANAGED_STATIC_H +#include "llvm/System/Atomic.h" + namespace llvm { +/// object_creator - Helper method for ManagedStatic. +template +void* object_creator() { + return new C(); +} + /// object_deleter - Helper method for ManagedStatic. /// template @@ -32,7 +40,7 @@ mutable void (*DeleterFn)(void*); mutable const ManagedStaticBase *Next; - void RegisterManagedStatic(void *ObjPtr, void (*deleter)(void*)) const; + void RegisterManagedStatic(void *(*creator)(), void (*deleter)(void*)) const; public: /// isConstructed - Return true if this object has not been created yet. bool isConstructed() const { return Ptr != 0; } @@ -51,25 +59,32 @@ // Accessors. C &operator*() { - if (!Ptr) LazyInit(); + void* tmp = Ptr; + sys::MemoryFence(); + if (!tmp) RegisterManagedStatic(object_creator, object_deleter); + return *static_cast(Ptr); } C *operator->() { - if (!Ptr) LazyInit(); + void* tmp = Ptr; + sys::MemoryFence(); + if (!tmp) RegisterManagedStatic(object_creator, object_deleter); + return static_cast(Ptr); } const C &operator*() const { - if (!Ptr) LazyInit(); + void* tmp = Ptr; + sys::MemoryFence(); + if (!tmp) RegisterManagedStatic(object_creator, object_deleter); + return *static_cast(Ptr); } const C *operator->() const { - if (!Ptr) LazyInit(); - return static_cast(Ptr); - } + void* tmp = Ptr; + sys::MemoryFence(); + if (!tmp) RegisterManagedStatic(object_creator, object_deleter); -public: - void LazyInit() const { - RegisterManagedStatic(new C(), object_deleter); + return static_cast(Ptr); } }; @@ -80,6 +95,10 @@ }; +/// llvm_start_multithreaded - Allocate and initialize structures needed to +/// make LLVM safe for multithreading. +void llvm_start_multithreaded(); + /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables. void llvm_shutdown(); @@ -87,7 +106,10 @@ /// llvm_shutdown_obj - This is a simple helper class that calls /// llvm_shutdown() when it is destroyed. struct llvm_shutdown_obj { - llvm_shutdown_obj() {} + llvm_shutdown_obj() { } + explicit llvm_shutdown_obj(bool multithreaded) { + if (multithreaded) llvm_start_multithreaded(); + } ~llvm_shutdown_obj() { llvm_shutdown(); } }; Modified: llvm/trunk/lib/Support/ManagedStatic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ManagedStatic.cpp?rev=72151&r1=72150&r2=72151&view=diff ============================================================================== --- llvm/trunk/lib/Support/ManagedStatic.cpp (original) +++ llvm/trunk/lib/Support/ManagedStatic.cpp Tue May 19 19:39:20 2009 @@ -12,21 +12,44 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/ManagedStatic.h" +#include "llvm/Config/config.h" +#include "llvm/System/Atomic.h" +#include "llvm/System/Mutex.h" #include using namespace llvm; static const ManagedStaticBase *StaticList = 0; -void ManagedStaticBase::RegisterManagedStatic(void *ObjPtr, +static sys::Mutex* ManagedStaticMutex = 0; + +void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(), void (*Deleter)(void*)) const { - assert(Ptr == 0 && DeleterFn == 0 && Next == 0 && - "Partially init static?"); - Ptr = ObjPtr; - DeleterFn = Deleter; + if (ManagedStaticMutex) { + ManagedStaticMutex->acquire(); + + if (Ptr == 0) { + void* tmp = Creator ? Creator() : 0; + + sys::MemoryFence(); + Ptr = tmp; + DeleterFn = Deleter; + + // Add to list of managed statics. + Next = StaticList; + StaticList = this; + } + + ManagedStaticMutex->release(); + } else { + assert(Ptr == 0 && DeleterFn == 0 && Next == 0 && + "Partially initialized ManagedStatic!?"); + Ptr = Creator ? Creator() : 0; + DeleterFn = Deleter; - // Add to list of managed statics. - Next = StaticList; - StaticList = this; + // Add to list of managed statics. + Next = StaticList; + StaticList = this; + } } void ManagedStaticBase::destroy() const { @@ -45,9 +68,23 @@ DeleterFn = 0; } +void llvm::llvm_start_multithreaded() { +#if LLVM_MULTITHREADED + assert(ManagedStaticMutex == 0 && "Multithreaded LLVM already initialized!"); + ManagedStaticMutex = new sys::Mutex(true); +#else + assert(0 && "LLVM built without multithreading support!"); +#endif +} + /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables. void llvm::llvm_shutdown() { while (StaticList) StaticList->destroy(); + + if (ManagedStaticMutex) { + delete ManagedStaticMutex; + ManagedStaticMutex = 0; + } } From gohman at apple.com Tue May 19 20:01:26 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 20 May 2009 01:01:26 -0000 Subject: [llvm-commits] [llvm] r72152 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <200905200101.n4K11QHS004778@zion.cs.uiuc.edu> Author: djg Date: Tue May 19 20:01:24 2009 New Revision: 72152 URL: http://llvm.org/viewvc/llvm-project?rev=72152&view=rev Log: Teach SCEV::isLoopInvariant and SCEV::hasComputableLoopEvolution about the convention from LoopInfo that a null Loop* means the entire function body. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=72152&r1=72151&r2=72152&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue May 19 20:01:24 2009 @@ -388,7 +388,9 @@ bool SCEVAddRecExpr::isLoopInvariant(const Loop *QueryLoop) const { // This recurrence is invariant w.r.t to QueryLoop iff QueryLoop doesn't // contain L and if the start is invariant. - return !QueryLoop->contains(L->getHeader()) && + // Add recurrences are never invariant in the function-body (null loop). + return QueryLoop && + !QueryLoop->contains(L->getHeader()) && getOperand(0)->isLoopInvariant(QueryLoop); } @@ -410,8 +412,10 @@ bool SCEVUnknown::isLoopInvariant(const Loop *L) const { // All non-instruction values are loop invariant. All instructions are loop // invariant if they are not contained in the specified loop. + // Instructions are never considered invariant in the function body + // (null loop) because they are defined within the "loop". if (Instruction *I = dyn_cast(V)) - return !L->contains(I->getParent()); + return L && !L->contains(I->getParent()); return true; } From evan.cheng at apple.com Tue May 19 20:11:00 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 20 May 2009 01:11:00 -0000 Subject: [llvm-commits] [llvm] r72154 - in /llvm/trunk: lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/call-imm.ll Message-ID: <200905200111.n4K1B0QC005085@zion.cs.uiuc.edu> Author: evancheng Date: Tue May 19 20:11:00 2009 New Revision: 72154 URL: http://llvm.org/viewvc/llvm-project?rev=72154&view=rev Log: Cannot use immediate as call absolute target in PIC mode. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td llvm/trunk/test/CodeGen/X86/call-imm.ll Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=72154&r1=72153&r2=72154&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Tue May 19 20:11:00 2009 @@ -234,6 +234,7 @@ def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">; def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">; def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">; +def IsNotPIC : Predicate<"TM.getRelocationModel() != Reloc::PIC_">; def OptForSpeed : Predicate<"!OptForSize">; def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">; @@ -562,7 +563,7 @@ Uses = [ESP] in { def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops), "call\t${dst:call}", [(X86call imm:$dst)]>, - Requires<[In32BitMode]>; + Requires<[In32BitMode, IsNotPIC]>; def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops), "call\t{*}$dst", [(X86call GR32:$dst)]>; def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops), Modified: llvm/trunk/test/CodeGen/X86/call-imm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/call-imm.ll?rev=72154&r1=72153&r2=72154&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/call-imm.ll (original) +++ llvm/trunk/test/CodeGen/X86/call-imm.ll Tue May 19 20:11:00 2009 @@ -1,4 +1,5 @@ ; RUN: llvm-as < %s | llc -march=x86 | grep {call.*12345678} +; RUN: llvm-as < %s | llc -march=x86 -relocation-model=pic | not grep {call.*12345678} ; Call to immediate is not safe on x86-64 unless we *know* that the ; call will be within 32-bits pcrel from the dest immediate. @@ -7,6 +8,7 @@ ; PR3666 ; PR3773 +; rdar://6904453 define i32 @main() nounwind { entry: From gohman at apple.com Tue May 19 20:41:43 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 19 May 2009 18:41:43 -0700 Subject: [llvm-commits] [llvm] r72154 - in /llvm/trunk: lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/call-imm.ll In-Reply-To: <200905200111.n4K1B0QC005085@zion.cs.uiuc.edu> References: <200905200111.n4K1B0QC005085@zion.cs.uiuc.edu> Message-ID: <33592CC8-4FA5-486B-88A4-C218B929C699@apple.com> On May 19, 2009, at 6:11 PM, Evan Cheng wrote: > Author: evancheng > Date: Tue May 19 20:11:00 2009 > New Revision: 72154 > > URL: http://llvm.org/viewvc/llvm-project?rev=72154&view=rev > Log: > Cannot use immediate as call absolute target in PIC mode. > > Modified: > llvm/trunk/lib/Target/X86/X86InstrInfo.td > llvm/trunk/test/CodeGen/X86/call-imm.ll > > Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=72154&r1=72153&r2=72154&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) > +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Tue May 19 20:11:00 2009 > @@ -234,6 +234,7 @@ > def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">; > def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">; > def IsStatic : Predicate<"TM.getRelocationModel() == > Reloc::Static">; > +def IsNotPIC : Predicate<"TM.getRelocationModel() != > Reloc::PIC_">; > def OptForSpeed : Predicate<"!OptForSize">; > def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">; > > @@ -562,7 +563,7 @@ > Uses = [ESP] in { > def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm: > $dst,variable_ops), > "call\t${dst:call}", [(X86call imm:$dst)]>, > - Requires<[In32BitMode]>; > + Requires<[In32BitMode, IsNotPIC]>; This looks like it says that CALLpcrel32 is valid only for PIC, which isn't true. It looks like the (X86call imm:$dst) pattern should be moved out into a "def : Pat" like the other patterns for CALLpcrel32, so that the Requires<[IsNotPIC]> can apply to just that pattern, not the instruction itself. Also, it looks like the Darwin linker rejects "call 12345678" in dynamic-no-pic mode as well as PIC mode. Dan From evan.cheng at apple.com Tue May 19 22:10:50 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 19 May 2009 20:10:50 -0700 Subject: [llvm-commits] [llvm] r72154 - in /llvm/trunk: lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/call-imm.ll In-Reply-To: <33592CC8-4FA5-486B-88A4-C218B929C699@apple.com> References: <200905200111.n4K1B0QC005085@zion.cs.uiuc.edu> <33592CC8-4FA5-486B-88A4-C218B929C699@apple.com> Message-ID: On May 19, 2009, at 6:41 PM, Dan Gohman wrote: >> >> >> @@ -562,7 +563,7 @@ >> Uses = [ESP] in { >> def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm: >> $dst,variable_ops), >> "call\t${dst:call}", [(X86call imm:$dst)]>, >> - Requires<[In32BitMode]>; >> + Requires<[In32BitMode, IsNotPIC]>; > > This looks like it says that CALLpcrel32 is valid only for PIC, > which isn't true. It looks like the (X86call imm:$dst) pattern > should be moved out into a "def : Pat" like the other patterns > for CALLpcrel32, so that the Requires<[IsNotPIC]> can apply to > just that pattern, not the instruction itself. The requirement does only apply for the pattern. I agree it reads a bit funny. I can move it to a def : Pat. > > Also, it looks like the Darwin linker rejects "call 12345678" in > dynamic-no-pic mode as well as PIC mode. Ah right. I'll fix. Evan > > Dan > > _______________________________________________ > 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 Tue May 19 22:12:37 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 19 May 2009 20:12:37 -0700 Subject: [llvm-commits] [llvm] r72154 - in /llvm/trunk: lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/call-imm.ll In-Reply-To: References: <200905200111.n4K1B0QC005085@zion.cs.uiuc.edu> <33592CC8-4FA5-486B-88A4-C218B929C699@apple.com> Message-ID: On May 19, 2009, at 8:10 PM, Evan Cheng wrote: > > On May 19, 2009, at 6:41 PM, Dan Gohman wrote: > >>> >>> >>> @@ -562,7 +563,7 @@ >>> Uses = [ESP] in { >>> def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm: >>> $dst,variable_ops), >>> "call\t${dst:call}", [(X86call imm:$dst)]>, >>> - Requires<[In32BitMode]>; >>> + Requires<[In32BitMode, IsNotPIC]>; >> >> This looks like it says that CALLpcrel32 is valid only for PIC, >> which isn't true. It looks like the (X86call imm:$dst) pattern >> should be moved out into a "def : Pat" like the other patterns >> for CALLpcrel32, so that the Requires<[IsNotPIC]> can apply to >> just that pattern, not the instruction itself. > > The requirement does only apply for the pattern. I agree it reads a > bit funny. I can move it to a def : Pat. > >> >> Also, it looks like the Darwin linker rejects "call 12345678" in >> dynamic-no-pic mode as well as PIC mode. Is it only Darwin linker that rejects this? Evan > > Ah right. I'll fix. > > Evan > >> >> Dan >> >> _______________________________________________ >> 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 eli.friedman at gmail.com Tue May 19 22:54:53 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 19 May 2009 20:54:53 -0700 Subject: [llvm-commits] [llvm] r72154 - in /llvm/trunk: lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/call-imm.ll In-Reply-To: References: <200905200111.n4K1B0QC005085@zion.cs.uiuc.edu> <33592CC8-4FA5-486B-88A4-C218B929C699@apple.com> Message-ID: On Tue, May 19, 2009 at 8:12 PM, Evan Cheng wrote: >>> Also, it looks like the Darwin linker rejects "call 12345678" in >>> dynamic-no-pic mode as well as PIC mode. > > Is it only Darwin linker that rejects this? I'm not sure if it's supported reliably outside of Linux. I just tried with mingw binutils, and it crashes with an assertion failure there. -Eli From evan.cheng at apple.com Tue May 19 23:53:59 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 20 May 2009 04:53:59 -0000 Subject: [llvm-commits] [llvm] r72160 - in /llvm/trunk: lib/Target/X86/X86InstrInfo.td lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Subtarget.h test/CodeGen/X86/call-imm.ll Message-ID: <200905200453.n4K4rxIL012191@zion.cs.uiuc.edu> Author: evancheng Date: Tue May 19 23:53:57 2009 New Revision: 72160 URL: http://llvm.org/viewvc/llvm-project?rev=72160&view=rev Log: Try again. Allow call to immediate address for ELF or when in static relocation mode. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td llvm/trunk/lib/Target/X86/X86Subtarget.cpp llvm/trunk/lib/Target/X86/X86Subtarget.h llvm/trunk/test/CodeGen/X86/call-imm.ll Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=72160&r1=72159&r2=72160&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Tue May 19 23:53:57 2009 @@ -234,9 +234,9 @@ def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">; def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">; def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">; -def IsNotPIC : Predicate<"TM.getRelocationModel() != Reloc::PIC_">; def OptForSpeed : Predicate<"!OptForSize">; def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">; +def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">; //===----------------------------------------------------------------------===// // X86 Instruction Format Definitions. @@ -562,8 +562,7 @@ XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS], Uses = [ESP] in { def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops), - "call\t${dst:call}", [(X86call imm:$dst)]>, - Requires<[In32BitMode, IsNotPIC]>; + "call\t${dst:call}", []>; def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops), "call\t{*}$dst", [(X86call GR32:$dst)]>; def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops), @@ -3342,6 +3341,8 @@ (CALLpcrel32 tglobaladdr:$dst)>; def : Pat<(X86call (i32 texternalsym:$dst)), (CALLpcrel32 texternalsym:$dst)>; +def : Pat<(X86call (i32 imm:$dst)), + (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>; // X86 specific add which produces a flag. def : Pat<(addc GR32:$src1, GR32:$src2), Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=72160&r1=72159&r2=72160&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Tue May 19 23:53:57 2009 @@ -74,8 +74,8 @@ /// cases where GVRequiresExtraLoad is true. Some variations of PIC require /// a register, but not an extra load. bool X86Subtarget::GVRequiresRegister(const GlobalValue *GV, - const TargetMachine& TM, - bool isDirectCall) const + const TargetMachine& TM, + bool isDirectCall) const { if (GVRequiresExtraLoad(GV, TM, isDirectCall)) return true; @@ -99,6 +99,14 @@ return 0; } +/// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls +/// to immediate address. +bool X86Subtarget::IsLegalToCallImmediateAddr(const TargetMachine &TM) const { + if (Is64Bit) + return false; + return isTargetELF() || TM.getRelocationModel() == Reloc::Static; +} + /// getSpecialAddressLatency - For targets where it is beneficial to /// backschedule instructions that compute addresses, return a value /// indicating the number of scheduling cycles of backscheduling that Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=72160&r1=72159&r2=72160&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Tue May 19 23:53:57 2009 @@ -189,6 +189,10 @@ bool GVRequiresRegister(const GlobalValue* GV, const TargetMachine& TM, bool isDirectCall) const; + /// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls + /// to immediate address. + bool IsLegalToCallImmediateAddr(const TargetMachine &TM) const; + /// This function returns the name of a function which has an interface /// like the non-standard bzero function, if such a function exists on /// the current subtarget and it is considered prefereable over Modified: llvm/trunk/test/CodeGen/X86/call-imm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/call-imm.ll?rev=72160&r1=72159&r2=72160&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/call-imm.ll (original) +++ llvm/trunk/test/CodeGen/X86/call-imm.ll Tue May 19 23:53:57 2009 @@ -1,4 +1,5 @@ -; RUN: llvm-as < %s | llc -march=x86 | grep {call.*12345678} +; RUN: llvm-as < %s | llc -mtriple=i386-darwin-apple -relocation-model=static | grep {call.*12345678} +; RUN: llvm-as < %s | llc -mtriple=i386-pc-linux -relocation-model=dynamic-no-pic | grep {call.*12345678} ; RUN: llvm-as < %s | llc -march=x86 -relocation-model=pic | not grep {call.*12345678} ; Call to immediate is not safe on x86-64 unless we *know* that the From evan.cheng at apple.com Wed May 20 00:45:37 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 20 May 2009 05:45:37 -0000 Subject: [llvm-commits] [llvm] r72161 - /llvm/trunk/test/CodeGen/X86/call-imm.ll Message-ID: <200905200545.n4K5jbnr013806@zion.cs.uiuc.edu> Author: evancheng Date: Wed May 20 00:45:36 2009 New Revision: 72161 URL: http://llvm.org/viewvc/llvm-project?rev=72161&view=rev Log: Fix test on non-darwin hosts. Modified: llvm/trunk/test/CodeGen/X86/call-imm.ll Modified: llvm/trunk/test/CodeGen/X86/call-imm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/call-imm.ll?rev=72161&r1=72160&r2=72161&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/call-imm.ll (original) +++ llvm/trunk/test/CodeGen/X86/call-imm.ll Wed May 20 00:45:36 2009 @@ -1,6 +1,6 @@ ; RUN: llvm-as < %s | llc -mtriple=i386-darwin-apple -relocation-model=static | grep {call.*12345678} +; RUN: llvm-as < %s | llc -mtriple=i386-darwin-apple -relocation-model=pic | not grep {call.*12345678} ; RUN: llvm-as < %s | llc -mtriple=i386-pc-linux -relocation-model=dynamic-no-pic | grep {call.*12345678} -; RUN: llvm-as < %s | llc -march=x86 -relocation-model=pic | not grep {call.*12345678} ; Call to immediate is not safe on x86-64 unless we *know* that the ; call will be within 32-bits pcrel from the dest immediate. From eli.friedman at gmail.com Wed May 20 01:02:09 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 20 May 2009 06:02:09 -0000 Subject: [llvm-commits] [llvm] r72162 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp test/CodeGen/MSP430/2009-05-19-DoubleSplit.ll test/CodeGen/XCore/fneg.ll Message-ID: <200905200602.n4K62Ab6014388@zion.cs.uiuc.edu> Author: efriedma Date: Wed May 20 01:02:09 2009 New Revision: 72162 URL: http://llvm.org/viewvc/llvm-project?rev=72162&view=rev Log: Fix for PR4235: to build a floating-point value from integer parts, build an integer and cast that to a float. This fixes a crash caused by trying to split an f32 into two f16's. This changes the behavior in test/CodeGen/XCore/fneg.ll because that testcase now triggers a DAGCombine which converts the fneg into an integer operation. If someone is interested, it's probably possible to tweak the test to generate an actual fneg. Added: llvm/trunk/test/CodeGen/MSP430/2009-05-19-DoubleSplit.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/test/CodeGen/XCore/fneg.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=72162&r1=72161&r2=72162&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Wed May 20 01:02:09 2009 @@ -426,7 +426,7 @@ if (NumParts > 1) { // Assemble the value from multiple parts. - if (!ValueVT.isVector()) { + if (!ValueVT.isVector() && ValueVT.isInteger()) { unsigned PartBits = PartVT.getSizeInBits(); unsigned ValueBits = ValueVT.getSizeInBits(); @@ -438,9 +438,7 @@ ValueVT : MVT::getIntegerVT(RoundBits); SDValue Lo, Hi; - MVT HalfVT = ValueVT.isInteger() ? - MVT::getIntegerVT(RoundBits/2) : - MVT::getFloatingPointVT(RoundBits/2); + MVT HalfVT = MVT::getIntegerVT(RoundBits/2); if (RoundParts > 2) { Lo = getCopyFromParts(DAG, dl, Parts, RoundParts/2, PartVT, HalfVT); @@ -473,7 +471,7 @@ Lo = DAG.getNode(ISD::ZERO_EXTEND, dl, TotalVT, Lo); Val = DAG.getNode(ISD::OR, dl, TotalVT, Lo, Hi); } - } else { + } else if (ValueVT.isVector()) { // Handle a multi-element vector. MVT IntermediateVT, RegisterVT; unsigned NumIntermediates; @@ -510,6 +508,22 @@ Val = DAG.getNode(IntermediateVT.isVector() ? ISD::CONCAT_VECTORS : ISD::BUILD_VECTOR, dl, ValueVT, &Ops[0], NumIntermediates); + } else if (PartVT.isFloatingPoint()) { + // FP split into multiple FP parts (for ppcf128) + assert(ValueVT == MVT(MVT::ppcf128) && PartVT == MVT(MVT::f64) && + "Unexpected split"); + SDValue Lo, Hi; + Lo = DAG.getNode(ISD::BIT_CONVERT, dl, MVT(MVT::f64), Parts[0]); + Hi = DAG.getNode(ISD::BIT_CONVERT, dl, MVT(MVT::f64), Parts[1]); + if (TLI.isBigEndian()) + std::swap(Lo, Hi); + Val = DAG.getNode(ISD::BUILD_PAIR, dl, ValueVT, Lo, Hi); + } else { + // FP split into integer parts (soft fp) + assert(ValueVT.isFloatingPoint() && PartVT.isInteger() && + !PartVT.isVector() && "Unexpected split"); + MVT IntVT = MVT::getIntegerVT(ValueVT.getSizeInBits()); + Val = getCopyFromParts(DAG, dl, Parts, NumParts, PartVT, IntVT); } } Added: llvm/trunk/test/CodeGen/MSP430/2009-05-19-DoubleSplit.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/2009-05-19-DoubleSplit.ll?rev=72162&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/2009-05-19-DoubleSplit.ll (added) +++ llvm/trunk/test/CodeGen/MSP430/2009-05-19-DoubleSplit.ll Wed May 20 01:02:09 2009 @@ -0,0 +1,11 @@ +; RUN: llvm-as < %s | llc -march=msp430 + +define i16 @test(double %d) nounwind { +entry: + %add = add double %d, 1.000000e+00 + %call = tail call i16 @funct(double %add) nounwind + ret i16 %call +} + +declare i16 @funct(double) + Modified: llvm/trunk/test/CodeGen/XCore/fneg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/XCore/fneg.ll?rev=72162&r1=72161&r2=72162&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/XCore/fneg.ll (original) +++ llvm/trunk/test/CodeGen/XCore/fneg.ll Wed May 20 01:02:09 2009 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | llc -march=xcore > %t1.s -; RUN: grep "bl __subdf3" %t1.s | count 1 +; RUN: grep "xor" %t1.s | count 1 define i1 @test(double %F) nounwind { entry: %0 = sub double -0.000000e+00, %F From cristic at cs.stanford.edu Wed May 20 01:29:36 2009 From: cristic at cs.stanford.edu (Cristian Cadar) Date: Wed, 20 May 2009 06:29:36 -0000 Subject: [llvm-commits] [klee] r72163 - in /klee/trunk/www: bugs.html content.css index.html install.html menu.html.incl Message-ID: <200905200629.n4K6Tbis015243@zion.cs.uiuc.edu> Author: cristic Date: Wed May 20 01:29:36 2009 New Revision: 72163 URL: http://llvm.org/viewvc/llvm-project?rev=72163&view=rev Log: Web page changes. Added a nice way to format code (div.code) in our CSS file. Added download and install instructions, and a bug report page. Added: klee/trunk/www/bugs.html klee/trunk/www/install.html Modified: klee/trunk/www/content.css klee/trunk/www/index.html klee/trunk/www/menu.html.incl Added: klee/trunk/www/bugs.html URL: http://llvm.org/viewvc/llvm-project/klee/trunk/www/bugs.html?rev=72163&view=auto ============================================================================== --- klee/trunk/www/bugs.html (added) +++ klee/trunk/www/bugs.html Wed May 20 01:29:36 2009 @@ -0,0 +1,25 @@ + + + + + + The KLEE Symbolic Virtual Machine + + + + + +
+ +

KLEE Bug Reports

+ + + Please report any bugs in KLEE to + the klee-dev + mailing list. You need to be subscribe to the list in order to + send your report. + +
+ + Modified: klee/trunk/www/content.css URL: http://llvm.org/viewvc/llvm-project/klee/trunk/www/content.css?rev=72163&r1=72162&r2=72163&view=diff ============================================================================== --- klee/trunk/www/content.css (original) +++ klee/trunk/www/content.css Wed May 20 01:29:36 2009 @@ -23,3 +23,12 @@ /* Tables */ tr { vertical-align:top } + +/* Code */ +div.code{ + border: 1px solid LightSteelBlue ; + font-family: Courier New; + background-color: #E3E3E3; + padding: 7px; + margin: 7px; +} Modified: klee/trunk/www/index.html URL: http://llvm.org/viewvc/llvm-project/klee/trunk/www/index.html?rev=72163&r1=72162&r2=72163&view=diff ============================================================================== --- klee/trunk/www/index.html (original) +++ klee/trunk/www/index.html Wed May 20 01:29:36 2009 @@ -4,7 +4,7 @@ - The klee Symbolic Virtual Machine + The KLEE Symbolic Virtual Machine @@ -12,10 +12,10 @@
-

The klee Symbolic Virtual Machine

+

The KLEE Symbolic Virtual Machine

-

klee is a symbolic virtual machine built on top of +

KLEE is a symbolic virtual machine built on top of the LLVM compiler infrastructure.

Stay tuned for more information on public availability. For now, @@ -28,5 +28,6 @@ 2008 paper.

+ Added: klee/trunk/www/install.html URL: http://llvm.org/viewvc/llvm-project/klee/trunk/www/install.html?rev=72163&view=auto ============================================================================== --- klee/trunk/www/install.html (added) +++ klee/trunk/www/install.html Wed May 20 01:29:36 2009 @@ -0,0 +1,72 @@ + + + + + + The KLEE Symbolic Virtual Machine + + + + + +
+ +

KLEE Installation Guide

+ + +

Minimal Installation

+
    +
  1. Obtain the current version + of LLVM via + SVN. Build the release version of LLVM and install the GCC + front end as well. Follow the instructions + at Getting + Started with the LLVM System.
  2. + +
  3. Obtain the current version of KLEE via SVN (readonly access): +
    svn co http://llvm.org/svn/llvm-project/klee/trunk klee
    +
  4. + +
  5. Configure KLEE: +
    + ./configure --with-llvm=path/to/llvm ENABLE_OPTIMIZED=1 +
    + +

    This assumes that you compiled LLVM in-place. If you used a + different directory for the object files then use: +

    + ./configure --with-llvmsrc=path/to/llvm/src--with-llvmobj=path/to/llvm/obj +
    +
  6. + +
  7. Build the release version of KLEE: +
    + make +
    +
  8. + +
  9. Run the test suite. You should have no unexpected failures.but + please report any such failures. +
    + make test +
    +
  10. + +
  11. You're ready to go! Go to the Tutorials page to try KLEE.
  12. +
+ + + + + + + + + + + + +
+ + Modified: klee/trunk/www/menu.html.incl URL: http://llvm.org/viewvc/llvm-project/klee/trunk/www/menu.html.incl?rev=72163&r1=72162&r2=72163&view=diff ============================================================================== --- klee/trunk/www/menu.html.incl (original) +++ klee/trunk/www/menu.html.incl Wed May 20 01:29:36 2009 @@ -6,6 +6,7 @@