From isanbard at gmail.com Mon May 5 00:35:24 2008 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 05 May 2008 05:35:24 -0000 Subject: [llvm-commits] [llvm] r50636 - /llvm/tags/Apple/llvmCore-2039/ Message-ID: <200805050535.m455ZOtq031618@zion.cs.uiuc.edu> Author: void Date: Mon May 5 00:35:24 2008 New Revision: 50636 URL: http://llvm.org/viewvc/llvm-project?rev=50636&view=rev Log: Creating llvmCore-2039 from Tak branch Added: llvm/tags/Apple/llvmCore-2039/ - copied from r50635, llvm/branches/Apple/Tak/ From isanbard at gmail.com Mon May 5 00:35:54 2008 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 05 May 2008 05:35:54 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50637 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2039/ Message-ID: <200805050535.m455ZsFr031641@zion.cs.uiuc.edu> Author: void Date: Mon May 5 00:35:53 2008 New Revision: 50637 URL: http://llvm.org/viewvc/llvm-project?rev=50637&view=rev Log: Creating llvmgcc42-2039 from Tak branch Added: llvm-gcc-4.2/tags/Apple/llvmgcc42-2039/ - copied from r50636, llvm-gcc-4.2/branches/Apple/Tak/ From evan.cheng at apple.com Mon May 5 02:15:31 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 5 May 2008 00:15:31 -0700 Subject: [llvm-commits] [llvm] r50630 - in /llvm/trunk/lib/Target/X86: X86ATTAsmPrinter.cpp X86ISelLowering.cpp X86Instr64bit.td X86InstrInfo.td In-Reply-To: <200805042136.m44LaX0W015127@zion.cs.uiuc.edu> References: <200805042136.m44LaX0W015127@zion.cs.uiuc.edu> Message-ID: <8B2F03DB-F78A-4F39-826E-AF2EA091EDF3@apple.com> On May 4, 2008, at 2:36 PM, Anton Korobeynikov wrote: > > +// > = > = > = > ----------------------------------------------------------------------= > ==// > +// Thread Local Storage Instructions > +// > = > = > = > ----------------------------------------------------------------------= > ==// > + > +def TLS_addr64 : I<0, Pseudo, (outs GR64:$dst), (ins i64imm:$sym), > + ".byte\t0x66; leaq\t${sym:mem}(%rip), $dst; .word > \t0x6666; rex64", > + [(set GR64:$dst, (X86tlsaddr tglobaltlsaddr: > $sym))]>; Hi Anton, I know the X86 td files have its share of 80 column violations but please avoid adding new ones. :-) Thanks, Evan From baldrick at free.fr Mon May 5 02:17:20 2008 From: baldrick at free.fr (Duncan Sands) Date: Mon, 5 May 2008 09:17:20 +0200 Subject: [llvm-commits] [llvm] r50634 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/CodeGen/AsmPrinter.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Subtarget.h lib/Target/X86/X86TargetAsmInfo.cpp test/CodeGen/X86/xor_not.ll In-Reply-To: <200805050028.m450Sd8J021018@zion.cs.uiuc.edu> References: <200805050028.m450Sd8J021018@zion.cs.uiuc.edu> Message-ID: <200805050917.21605.baldrick@free.fr> Hi Dan, > Add AsmPrinter support for emitting a directive to declare that > the code being generated does not require an executable stack. presumably you found a linux distribution that needs this. I'm curious to know which one (ubuntu doesn't). Ciao, Duncan. From nicolas.geoffray at lip6.fr Mon May 5 02:37:05 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 05 May 2008 07:37:05 -0000 Subject: [llvm-commits] [vmkit] r50640 - /vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Message-ID: <200805050737.m457b5JI006220@zion.cs.uiuc.edu> Author: geoffray Date: Mon May 5 02:37:04 2008 New Revision: 50640 URL: http://llvm.org/viewvc/llvm-project?rev=50640&view=rev Log: Do not put the flags of the baseclass to an array class. Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=50640&r1=50639&r2=50640&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Mon May 5 02:37:04 2008 @@ -380,7 +380,6 @@ ClassArray* arrayCl = (ClassArray*)cl; CommonClass* baseClass = arrayCl->baseClass(); baseClass->resolveClass(doClinit); - cl->access = cl->access | baseClass->access; cl->status = resolved; } else { readClass((Class*)cl); From nicolas.geoffray at lip6.fr Mon May 5 04:28:15 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 05 May 2008 09:28:15 -0000 Subject: [llvm-commits] [vmkit] r50642 - in /vmkit/trunk/lib/N3: Makefile.am VMCore/PNetLib.cpp Message-ID: <200805050928.m459SFOq014364@zion.cs.uiuc.edu> Author: geoffray Date: Mon May 5 04:28:14 2008 New Revision: 50642 URL: http://llvm.org/viewvc/llvm-project?rev=50642&view=rev Log: Fake termcap symbols, so that N3 does not need to link with libtermcap. Modified: vmkit/trunk/lib/N3/Makefile.am vmkit/trunk/lib/N3/VMCore/PNetLib.cpp Modified: vmkit/trunk/lib/N3/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Makefile.am?rev=50642&r1=50641&r2=50642&view=diff ============================================================================== --- vmkit/trunk/lib/N3/Makefile.am (original) +++ vmkit/trunk/lib/N3/Makefile.am Mon May 5 04:28:14 2008 @@ -7,5 +7,5 @@ main_CXXFLAGS = -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2 main_LDADD = VMCore/.libs/libN3.a @GC_LIBS@ @GCTHREAD_LIBS@ @LLVMDYLIB@ @pnetlocalprefix@/engine/libILEngine.a @pnetlocalprefix@/image/libILImage.a @pnetlocalprefix@/support/libILSupport.a \ - @pnetlocalprefix@/libffi/.libs/libffi.a @pnetlocalprefix@/dumpasm/libILDumpAsm.a /usr/lib/libtermcap.a + @pnetlocalprefix@/libffi/.libs/libffi.a @pnetlocalprefix@/dumpasm/libILDumpAsm.a main_LDFLAGS = @rdynamic@ Modified: vmkit/trunk/lib/N3/VMCore/PNetLib.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/PNetLib.cpp?rev=50642&r1=50641&r2=50642&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/PNetLib.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/PNetLib.cpp Mon May 5 04:28:14 2008 @@ -91,6 +91,41 @@ void GC_set_max_heap_size(void) {} void GC_malloc_atomic(void) {} #endif + +// Fake termcap symbols +void tigetstr(void) { + abort(); +} +void tgetstr(void) { + abort(); +} +void setupterm(void) { + abort(); +} +void tigetnum(void) { + abort(); +} +void tgetnum(void) { + abort(); +} +void tigetflag(void) { + abort(); +} +void tparm(void) { + abort(); +} +void tgetent(void) { + abort(); +} +void tputs(void) { + abort(); +} +void tgoto(void) { + abort(); +} +void tgetflag(void) { + abort(); +} } From nicolas.geoffray at lip6.fr Mon May 5 04:09:55 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 05 May 2008 09:09:55 -0000 Subject: [llvm-commits] [vmkit] r50641 - in /vmkit/trunk/lib: JnJVM/VMCore/JavaJIT.cpp Mvm/JIT.cpp N3/VMCore/Opcodes.cpp Message-ID: <200805050909.m4599tf7013752@zion.cs.uiuc.edu> Author: geoffray Date: Mon May 5 04:09:53 2008 New Revision: 50641 URL: http://llvm.org/viewvc/llvm-project?rev=50641&view=rev Log: Use new APFloat interface. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp vmkit/trunk/lib/Mvm/JIT.cpp vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=50641&r1=50640&r2=50641&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Mon May 5 04:09:53 2008 @@ -1053,7 +1053,7 @@ mvm::jit::unprotectConstants();//->unlock(); } else if (type == JavaCtpInfo::ConstantDouble) { mvm::jit::protectConstants();//->lock(); - push(ConstantFP::get(Type::DoubleTy, APFloat(ctpInfo->DoubleAt(index))), + push(ConstantFP::get(Type::DoubleTy, ctpInfo->DoubleAt(index)), AssessorDesc::dDouble); mvm::jit::unprotectConstants();//->unlock(); } else if (type == JavaCtpInfo::ConstantInteger) { @@ -1063,7 +1063,7 @@ mvm::jit::unprotectConstants();//->unlock(); } else if (type == JavaCtpInfo::ConstantFloat) { mvm::jit::protectConstants();//->lock(); - push(ConstantFP::get(Type::FloatTy, APFloat(ctpInfo->FloatAt(index))), + push(ConstantFP::get(Type::FloatTy, ctpInfo->FloatAt(index)), AssessorDesc::dFloat); mvm::jit::unprotectConstants();//->unlock(); } else if (type == JavaCtpInfo::ConstantClass) { Modified: vmkit/trunk/lib/Mvm/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/JIT.cpp?rev=50641&r1=50640&r2=50641&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/JIT.cpp Mon May 5 04:09:53 2008 @@ -529,26 +529,26 @@ constantMaxInt = ConstantInt::get(Type::Int32Ty, MaxInt); constantMinLong = ConstantInt::get(Type::Int64Ty, MinLong); constantMaxLong = ConstantInt::get(Type::Int64Ty, MaxLong); - constantFloatZero = ConstantFP::get(Type::FloatTy, APFloat(0.0f)); - constantFloatOne = ConstantFP::get(Type::FloatTy, APFloat(1.0f)); - constantFloatTwo = ConstantFP::get(Type::FloatTy, APFloat(2.0f)); - constantDoubleZero = ConstantFP::get(Type::DoubleTy, APFloat(0.0)); - constantDoubleOne = ConstantFP::get(Type::DoubleTy, APFloat(1.0)); - constantMaxIntFloat = ConstantFP::get(Type::FloatTy, APFloat(MaxIntFloat)); - constantMinIntFloat = ConstantFP::get(Type::FloatTy, APFloat(MinIntFloat)); - constantMinLongFloat = ConstantFP::get(Type::FloatTy, APFloat(MinLongFloat)); - constantMinLongDouble = ConstantFP::get(Type::DoubleTy, APFloat(MinLongDouble)); - constantMaxLongFloat = ConstantFP::get(Type::FloatTy, APFloat(MaxLongFloat)); - constantMaxIntDouble = ConstantFP::get(Type::DoubleTy, APFloat(MaxIntDouble)); - constantMinIntDouble = ConstantFP::get(Type::DoubleTy, APFloat(MinIntDouble)); - constantMaxLongDouble = ConstantFP::get(Type::DoubleTy, APFloat(MaxLongDouble)); - constantMaxLongDouble = ConstantFP::get(Type::DoubleTy, APFloat(MaxLongDouble)); - constantFloatInfinity = ConstantFP::get(Type::FloatTy, APFloat(MaxFloat)); - constantFloatMinusInfinity = ConstantFP::get(Type::FloatTy, APFloat(MinFloat)); - constantDoubleInfinity = ConstantFP::get(Type::DoubleTy, APFloat(MaxDouble)); - constantDoubleMinusInfinity = ConstantFP::get(Type::DoubleTy, APFloat(MinDouble)); - constantDoubleMinusZero = ConstantFP::get(Type::DoubleTy, APFloat(-0.0)); - constantFloatMinusZero = ConstantFP::get(Type::FloatTy, APFloat(-0.0f)); + constantFloatZero = ConstantFP::get(Type::FloatTy, 0.0f); + constantFloatOne = ConstantFP::get(Type::FloatTy, 1.0f); + constantFloatTwo = ConstantFP::get(Type::FloatTy, 2.0f); + constantDoubleZero = ConstantFP::get(Type::DoubleTy, 0.0); + constantDoubleOne = ConstantFP::get(Type::DoubleTy, 1.0); + constantMaxIntFloat = ConstantFP::get(Type::FloatTy, MaxIntFloat); + constantMinIntFloat = ConstantFP::get(Type::FloatTy, MinIntFloat); + constantMinLongFloat = ConstantFP::get(Type::FloatTy, MinLongFloat); + constantMinLongDouble = ConstantFP::get(Type::DoubleTy, MinLongDouble); + constantMaxLongFloat = ConstantFP::get(Type::FloatTy, MaxLongFloat); + constantMaxIntDouble = ConstantFP::get(Type::DoubleTy, MaxIntDouble); + constantMinIntDouble = ConstantFP::get(Type::DoubleTy, MinIntDouble); + constantMaxLongDouble = ConstantFP::get(Type::DoubleTy, MaxLongDouble); + constantMaxLongDouble = ConstantFP::get(Type::DoubleTy, MaxLongDouble); + constantFloatInfinity = ConstantFP::get(Type::FloatTy, MaxFloat); + constantFloatMinusInfinity = ConstantFP::get(Type::FloatTy, MinFloat); + constantDoubleInfinity = ConstantFP::get(Type::DoubleTy, MaxDouble); + constantDoubleMinusInfinity = ConstantFP::get(Type::DoubleTy, MinDouble); + constantDoubleMinusZero = ConstantFP::get(Type::DoubleTy, -0.0); + constantFloatMinusZero = ConstantFP::get(Type::FloatTy, -0.0f); constantPtrNull = Constant::getNullValue(ptrType); arrayPtrType = PointerType::getUnqual(ArrayType::get(Type::Int8Ty, 0)); Modified: vmkit/trunk/lib/N3/VMCore/Opcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Opcodes.cpp?rev=50641&r1=50640&r2=50641&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/Opcodes.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Mon May 5 04:09:53 2008 @@ -768,14 +768,14 @@ case LDC_R4 : { mvm::jit::protectConstants(); - push(ConstantFP::get(Type::FloatTy, APFloat(readFloat(bytecodes, i)))); + push(ConstantFP::get(Type::FloatTy, readFloat(bytecodes, i))); mvm::jit::unprotectConstants(); break; } case LDC_R8 : { mvm::jit::protectConstants(); - push(ConstantFP::get(Type::DoubleTy, APFloat(readDouble(bytecodes, i)))); + push(ConstantFP::get(Type::DoubleTy, readDouble(bytecodes, i))); mvm::jit::unprotectConstants(); break; } From nicolas.geoffray at lip6.fr Mon May 5 07:33:28 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 05 May 2008 12:33:28 -0000 Subject: [llvm-commits] [vmkit] r50643 - in /vmkit/trunk/lib/JnJVM: Classpath/ClasspathVMStackWalker.cpp Classpath/ClasspathVMThrowable.cpp VMCore/JavaBacktrace.cpp VMCore/JavaJIT.h Message-ID: <200805051233.m45CXT7Y020229@zion.cs.uiuc.edu> Author: geoffray Date: Mon May 5 07:33:18 2008 New Revision: 50643 URL: http://llvm.org/viewvc/llvm-project?rev=50643&view=rev Log: Implement a glibc-like backtrace function. Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp?rev=50643&r1=50642&r2=50643&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp Mon May 5 07:33:18 2008 @@ -8,7 +8,6 @@ // //===----------------------------------------------------------------------===// -#include #include #include "types.h" @@ -52,7 +51,7 @@ #endif ) { int* ips[100]; - int real_size = backtrace((void**)(void*)ips, 100); + int real_size = JavaJIT::getBacktrace((void**)(void*)ips, 100); int i = 0; int first = 0; CommonClass* cl = Classpath::vmStackWalker; Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp?rev=50643&r1=50642&r2=50643&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp Mon May 5 07:33:18 2008 @@ -27,11 +27,8 @@ #include "NativeUtil.h" #include "Reader.h" -#include - using namespace jnjvm; -extern "C" int backtrace_fp(int** ips, int size, int**); extern "C" JavaMethod* ip_to_meth(int* ip); extern "C" { @@ -44,13 +41,11 @@ jobject throwable) { //int** fp = (int**)__builtin_frame_address(0); Jnjvm* vm = JavaThread::get()->isolate; - int** stack = (int**)alloca(sizeof(int*) * 100); - int real_size = backtrace((void**)stack, 100); - ArrayUInt32* obj = ArrayUInt32::acons(real_size, JavaArray::ofInt, vm); - memcpy(obj->elements, stack, real_size * sizeof(int)); - JavaObject* vmThrowable = (*Classpath::newVMThrowable)(vm); - Classpath::initVMThrowable->invokeIntSpecial(vm, vmThrowable); - (*Classpath::vmDataVMThrowable)(vmThrowable, obj); + int** stack = (int**)malloc(sizeof(int*) * 100); + int real_size = JavaJIT::getBacktrace((void**)stack, 100); + stack[real_size] = 0; + JavaObject* vmThrowable = Classpath::newVMThrowable->doNew(vm); + ((JavaObject**)((uint64)vmThrowable + Classpath::vmDataVMThrowable->ptrOffset))[0] = (JavaObject*)stack; return (jobject)vmThrowable; } @@ -80,9 +75,9 @@ return res; } -ArrayObject* recGetStackTrace(int** stack, uint32 size, uint32 first, uint32 rec) { +ArrayObject* recGetStackTrace(int** stack, uint32 first, uint32 rec) { Jnjvm* vm = JavaThread::get()->isolate; - if (size != first) { + if (stack[first] != 0) { #ifdef MULTIPLE_GC int *begIp = (int*)mvm::Thread::get()->GC->begOf(stack[first]); #else @@ -90,11 +85,11 @@ #endif JavaMethod* meth = ip_to_meth(begIp); if (meth) { - ArrayObject* res = recGetStackTrace(stack, size, first + 1, rec + 1); + ArrayObject* res = recGetStackTrace(stack, first + 1, rec + 1); res->setAt(rec, consStackElement(meth, stack[first])); return res; } else { - return recGetStackTrace(stack, size, first + 1, rec); + return recGetStackTrace(stack, first + 1, rec); } } else { return ArrayObject::acons(rec, JavaArray::ofObject, vm); @@ -106,13 +101,12 @@ JNIEnv *env, #endif jobject vmthrow, jobject throwable) { - ArrayUInt32* array = (ArrayUInt32*)(*Classpath::vmDataVMThrowable)((JavaObject*)vmthrow).PointerVal; - uint32* stack = array->elements; + int** stack = (int**)(ArrayUInt32*)(*Classpath::vmDataVMThrowable)((JavaObject*)vmthrow).PointerVal; CommonClass* cl = ((JavaObject*)throwable)->classOf; uint32 first = 0; sint32 i = 0; - while (i < array->size) { + while (stack[i] != 0) { #ifdef MULTIPLE_GC int *begIp = (int*)mvm::Thread::get()->GC->begOf((void*)stack[i++]); #else @@ -124,7 +118,8 @@ break; } } - return (jobject)recGetStackTrace((int**)(uint32**)stack, array->size, first, 0); + free(stack); + return (jobject)recGetStackTrace((int**)(uint32**)stack, first, 0); } } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp?rev=50643&r1=50642&r2=50643&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp Mon May 5 07:33:18 2008 @@ -9,7 +9,6 @@ #include #include -#include #include "llvm/Function.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" @@ -38,9 +37,26 @@ return 0; } +#if defined(__MACH__) && !defined(__i386__) +#define FRAME_IP(fp) (fp[2]) +#else +#define FRAME_IP(fp) (fp[1]) +#endif + + +int JavaJIT::getBacktrace(void** stack, int size) { + void** blah = (void**)__builtin_frame_address(1); + int cpt = 0; + while (blah && cpt < size) { + stack[cpt++] = (void**)FRAME_IP(blah); + blah = (void**)blah[0]; + } + return cpt; +} + void JavaJIT::printBacktrace() { int* ips[100]; - int real_size = backtrace((void**)(void*)ips, 100); + int real_size = getBacktrace((void**)(void*)ips, 100); int n = 0; while (n < real_size) { mvm::Code* code = mvm::Code::getCodeFromPointer(ips[n++]); @@ -72,7 +88,7 @@ Class* JavaJIT::getCallingClass() { int* ips[10]; - int real_size = backtrace((void**)(void*)ips, 10); + int real_size = getBacktrace((void**)(void*)ips, 10); int n = 0; int i = 0; while (n < real_size) { @@ -94,7 +110,7 @@ Class* JavaJIT::getCallingClassWalker() { int* ips[10]; - int real_size = backtrace((void**)(void*)ips, 10); + int real_size = getBacktrace((void**)(void*)ips, 10); int n = 0; int i = 0; while (n < real_size) { Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h?rev=50643&r1=50642&r2=50643&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Mon May 5 07:33:18 2008 @@ -276,6 +276,7 @@ static Class* getCallingClassWalker(); static JavaObject* getCallingClassLoader(); static void printBacktrace(); + static int getBacktrace(void** array, int size); #ifdef WITH_TRACER static llvm::Function* markAndTraceLLVM; From ggreif at gmail.com Mon May 5 08:41:20 2008 From: ggreif at gmail.com (Gabor Greif) Date: Mon, 05 May 2008 13:41:20 -0000 Subject: [llvm-commits] [llvm] r50644 - /llvm/branches/ggreif/use-diet/include/llvm/Use.h Message-ID: <200805051341.m45DfKaj022544@zion.cs.uiuc.edu> Author: ggreif Date: Mon May 5 08:41:18 2008 New Revision: 50644 URL: http://llvm.org/viewvc/llvm-project?rev=50644&view=rev Log: Back out getUserFast(). Although it speeds things up, I do not think it is worth the effort. May be reconsidered in the future. Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Use.h?rev=50644&r1=50643&r2=50644&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Mon May 5 08:41:18 2008 @@ -96,14 +96,6 @@ operator Value*() const { return Val; } Value *get() const { return Val; } User *getUser() const; - inline User *getUserFast() const { - unsigned t = extractTag(Prev); - if (t == fullStopTag) { - if (extractTag(this[1].Val)) - return reinterpret_cast(stripTag(this[1].Val)); - else return (User*)(this + 1); - } else return getUser(); // fallback - } const Use* getImpliedUser() const; static Use *initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0); static void zap(Use *Start, const Use *Stop, bool del = false); @@ -200,7 +192,7 @@ // Retrieve a reference to the current SCC UserTy *operator*() const { assert(U && "Cannot dereference end iterator!"); - return U->getUserFast(); + return U->getUser(); } UserTy *operator->() const { return operator*(); } From kremenek at apple.com Mon May 5 09:02:40 2008 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 05 May 2008 14:02:40 -0000 Subject: [llvm-commits] [llvm] r50645 - /llvm/tags/checker/checker-20/ Message-ID: <200805051402.m45E2fkW023418@zion.cs.uiuc.edu> Author: kremenek Date: Mon May 5 09:02:38 2008 New Revision: 50645 URL: http://llvm.org/viewvc/llvm-project?rev=50645&view=rev Log: Tagging checker-20. Added: llvm/tags/checker/checker-20/ - copied from r50644, llvm/trunk/ From criswell at cs.uiuc.edu Mon May 5 09:08:06 2008 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon, 5 May 2008 09:08:06 -0500 Subject: [llvm-commits] CVS: llvm-www/pubs/2006-DSN-DanglingPointers.html 2006-DSN-DanglingPointers.pdf Message-ID: <200805051408.m45E86wS029105@maute.cs.uiuc.edu> Changes in directory llvm-www/pubs: 2006-DSN-DanglingPointers.html added (r1.1) 2006-DSN-DanglingPointers.pdf added (r1.1) --- Log message: Adding Dinakar's DSN paper. --- Diffs of the changes: (+82 -0) 2006-DSN-DanglingPointers.html | 82 +++++++++++++++++++++++++++++++++++++++++ 2006-DSN-DanglingPointers.pdf | 0 2 files changed, 82 insertions(+) Index: llvm-www/pubs/2006-DSN-DanglingPointers.html diff -c /dev/null llvm-www/pubs/2006-DSN-DanglingPointers.html:1.1 *** /dev/null Mon May 5 09:07:29 2008 --- llvm-www/pubs/2006-DSN-DanglingPointers.html Mon May 5 09:07:18 2008 *************** *** 0 **** --- 1,82 ---- + + + + + + + Efficiently Detecting All Dangling Pointer Uses in Production Servers + + + + +
+ Efficiently Detecting All Dangling Pointer Uses in Production Servers +
+
+ Dinakar Dhurjati and + Vikram Adve +
+ +

Abstract:

+
+ In this paper, we propose a novel technique to detect all + dangling pointer uses at run-time that is efficient enough + for production use in server codes. One idea (previously + used by Electric Fence, PageHeap) is to use a new virtual + page for each allocation of the program and rely on page + protection mechanisms to check dangling pointer accesses. + This naive approach has two limitations that makes it im- + practical to use in production software: increased physical + memory usage and increased address space usage. We pro- + pose two key improvements that alleviate both these prob- + lems. First, we use a new virtual page for each allocation + of the program but map it to the same physical page as the + original allocator. This allows using nearly identical physi- + cal memory as the original program while still retaining the + dangling pointer detection capability. We also show how to + implement this idea without requiring any changes to the + underlying memory allocator. Our second idea alleviates + the problem of virtual address space exhaustion by using + a previously developed compiler transformation called Au- + tomatic Pool Allocation to reuse many virtual pages. The + transformation partitions the memory of the program based + on their lifetimes and allows us to reuse virtual pages when + portions of memory become inaccessible. Experimentally + we find that the run-time overhead for five unix servers is + less than 4%, for other unix utilities less than 15%. How- + ever, in case of allocation intensive benchmarks, we find our + overheads are much worse (up to 11x slowdown). +
+ +

Download:

+

Paper:

+ + +

BibTeX Entry:

+
+ @inproceedings{1135707,
+  author = {Dinakar Dhurjati and Vikram Adve},
+  title = {Efficiently Detecting All Dangling Pointer Uses in Production Servers},
+  booktitle = {DSN '06: Proceedings of the International Conference on Dependable Systems and Networks},
+  year = {2006},
+  isbn = {0-7695-2607-1},
+  pages = {269--280},
+  doi = {http://dx.doi.org/10.1109/DSN.2006.31},
+  publisher = {IEEE Computer Society},
+  address = {Washington, DC, USA},
+ }
+ 
+ + +
+ Valid CSS! + Valid HTML 4.01! + + + Index: llvm-www/pubs/2006-DSN-DanglingPointers.pdf From criswell at cs.uiuc.edu Mon May 5 09:18:53 2008 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon, 5 May 2008 09:18:53 -0500 Subject: [llvm-commits] CVS: llvm-www/pubs/index.html Message-ID: <200805051418.m45EIrGS029870@maute.cs.uiuc.edu> Changes in directory llvm-www/pubs: index.html updated: 1.70 -> 1.71 --- Log message: Added Dinakar's 2006 DSN paper. --- Diffs of the changes: (+3 -0) index.html | 3 +++ 1 files changed, 3 insertions(+) Index: llvm-www/pubs/index.html diff -u llvm-www/pubs/index.html:1.70 llvm-www/pubs/index.html:1.71 --- llvm-www/pubs/index.html:1.70 Sun May 4 16:26:44 2008 +++ llvm-www/pubs/index.html Mon May 5 09:18:09 2008 @@ -107,6 +107,9 @@ J. Cong, Y. Fan, G. Han, W. Jiang, and Z. Zhang
Proceedings of IEEE International SOC Conference, pp. 199-202, Austin, Texas, Sept. 2006. +
  • "Efficiently Detecting All Dangling Pointer Uses in Production Servers"
    Dinakar Dhurjati and Vikram Adve.
    +roceedings of the International Conference on Dependable Systems and Networks (DSN '06), Philadelphia, Pennsylvania, 2006.
  • +
  • "A Virtual Instruction Set Interface for Operating System Kernels"
    John Criswell, Brent Monroe, and Vikram Adve.
    Workshop on the Interaction between Operating Systems and Computer Architecture (WIOSCA '06), Boston, Massachusetts, 2006.
  • From criswell at cs.uiuc.edu Mon May 5 09:28:10 2008 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon, 5 May 2008 09:28:10 -0500 Subject: [llvm-commits] CVS: llvm-www/pubs/2006-DSN-DanglingPointers.html Message-ID: <200805051428.m45ESAEx030107@maute.cs.uiuc.edu> Changes in directory llvm-www/pubs: 2006-DSN-DanglingPointers.html updated: 1.1 -> 1.2 --- Log message: Fixed link to paper. --- Diffs of the changes: (+1 -1) 2006-DSN-DanglingPointers.html | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-www/pubs/2006-DSN-DanglingPointers.html diff -u llvm-www/pubs/2006-DSN-DanglingPointers.html:1.1 llvm-www/pubs/2006-DSN-DanglingPointers.html:1.2 --- llvm-www/pubs/2006-DSN-DanglingPointers.html:1.1 Mon May 5 09:07:18 2008 +++ llvm-www/pubs/2006-DSN-DanglingPointers.html Mon May 5 09:27:28 2008 @@ -51,7 +51,7 @@

    Download:

    Paper:

    From criswell at cs.uiuc.edu Mon May 5 09:29:17 2008 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon, 5 May 2008 09:29:17 -0500 Subject: [llvm-commits] CVS: llvm-www/pubs/2006-05-12-PLDI-SAFECode.html 2006-05-12-PLDI-SAFECode.pdf Message-ID: <200805051429.m45ETH8C030163@maute.cs.uiuc.edu> Changes in directory llvm-www/pubs: 2006-05-12-PLDI-SAFECode.html added (r1.1) 2006-05-12-PLDI-SAFECode.pdf added (r1.1) --- Log message: Adding Dinakar's, Sumant's, and Vikram's 2006 PLDI paper. --- Diffs of the changes: (+83 -0) 2006-05-12-PLDI-SAFECode.html | 83 ++++++++++++++++++++++++++++++++++++++++++ 2006-05-12-PLDI-SAFECode.pdf | 0 2 files changed, 83 insertions(+) Index: llvm-www/pubs/2006-05-12-PLDI-SAFECode.html diff -c /dev/null llvm-www/pubs/2006-05-12-PLDI-SAFECode.html:1.1 *** /dev/null Mon May 5 09:28:46 2008 --- llvm-www/pubs/2006-05-12-PLDI-SAFECode.html Mon May 5 09:28:35 2008 *************** *** 0 **** --- 1,83 ---- + + + + + + + SAFECode: Enforcing Alias Analysis for Weakly Typed Languages + + + + +
    + SAFECode: Enforcing Alias Analysis for Weakly Typed Languages +
    +
    + Dinakar Dhurjati, + Sumant Kowshik, + and + Vikram Adve +
    + +

    Abstract:

    +
    + Static analysis of programs in weakly typed languages such as C and C++ is + generally not sound because of possible memory errors due to dangling pointer + references, uninitialized pointers, and array bounds overflow. We describe a + compilation strategy for standard C programs that guarantees that aggressive + interprocedural pointer analysis (or less precise ones), a call graph, and type + information for a subset of memory, are never invalidated by any possible + memory errors. We formalize our approach as a new type system with the + necessary run-time checks in operational semantics and prove the correctness of + our approach for a subset of C. Our semantics provide the foundation for other + sophisticated static analyses to be applied to C programs with a guarantee of + soundness. Our work builds on a previously published transformation called + Automatic Pool Allocation to ensure that hard-to-detect memory errors (dangling + pointer references and certain array bounds errors) cannot invalidate the call + graph, points-to information or type information. The key insight behind our + approach is that pool allocation can be used to create a run-time partitioning + of memory that matches the compile-time memory partitioning in a points-to + graph, and efficient checks can be used to isolate the run-time partitions. + Furthermore, we show that the sound analysis information enables static + checking techniques that eliminate many run-time checks. Our approach requires + no source code changes, allows memory to be managedexplicitly, and does not use + meta-data on pointers or individual tag bits for memory. Using several + benchmark s and system codes, we show experimentally that the run-time + overheads are low (less than 10% in nearly all cases and 30% in the worst case + we have seen).We also show the effectiveness of static analyses in eliminating + run-time checks. +
    + +

    Download:

    +

    Paper:

    + + +

    BibTeX Entry:

    +
    + @inproceedings{1133999,
    +  author = {Dinakar Dhurjati and Sumant Kowshik and Vikram Adve},
    +  title = {SAFECode: enforcing alias analysis for weakly typed languages},
    +  booktitle = {PLDI '06: Proceedings of the 2006 ACM SIGPLAN conference on Programming language design and implementation},
    +  year = {2006},
    +  isbn = {1-59593-320-4},
    +  pages = {144--157},
    +  location = {Ottawa, Ontario, Canada},
    +  doi = {http://doi.acm.org/10.1145/1133981.1133999},
    +  publisher = {ACM},
    +  address = {New York, NY, USA},
    + }
    + 
    + + +
    + Valid CSS! + Valid HTML 4.01! + + + Index: llvm-www/pubs/2006-05-12-PLDI-SAFECode.pdf From criswell at cs.uiuc.edu Mon May 5 09:33:17 2008 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon, 5 May 2008 09:33:17 -0500 Subject: [llvm-commits] CVS: llvm-www/pubs/index.html Message-ID: <200805051433.m45EXHKQ030273@maute.cs.uiuc.edu> Changes in directory llvm-www/pubs: index.html updated: 1.71 -> 1.72 --- Log message: Corrected HTML error. --- Diffs of the changes: (+1 -1) index.html | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-www/pubs/index.html diff -u llvm-www/pubs/index.html:1.71 llvm-www/pubs/index.html:1.72 --- llvm-www/pubs/index.html:1.71 Mon May 5 09:18:09 2008 +++ llvm-www/pubs/index.html Mon May 5 09:32:35 2008 @@ -118,7 +118,7 @@
    By Dinakar Dhurjati and Vikram Adve,
    Proceedings of the 28th International Conference on Software Engineering (ICSE '06), -Shanghai, China, 2006. +Shanghai, China, 2006.
  • "Vector LLVA: A Virtual Vector Instruction Set for Media Processing"
    Robert L. Bocchino Jr. and Vikram S. Adve.
    Proc. of the Second International Conference on Virtual Execution Environments (VEE'06), Ottawa, Canada, 2006.
  • From criswell at cs.uiuc.edu Mon May 5 09:39:17 2008 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon, 5 May 2008 09:39:17 -0500 Subject: [llvm-commits] CVS: llvm-www/pubs/2006-06-12-PLDI-SAFECode.html 2006-06-12-PLDI-SAFECode.pdf Message-ID: <200805051439.m45EdHsL030464@maute.cs.uiuc.edu> Changes in directory llvm-www/pubs: 2006-06-12-PLDI-SAFECode.html added (r1.1) 2006-06-12-PLDI-SAFECode.pdf added (r1.1) --- Log message: Renaming Dinakar's PLDI paper so that the month is correct. --- Diffs of the changes: (+83 -0) 2006-06-12-PLDI-SAFECode.html | 83 ++++++++++++++++++++++++++++++++++++++++++ 2006-06-12-PLDI-SAFECode.pdf | 0 2 files changed, 83 insertions(+) Index: llvm-www/pubs/2006-06-12-PLDI-SAFECode.html diff -c /dev/null llvm-www/pubs/2006-06-12-PLDI-SAFECode.html:1.1 *** /dev/null Mon May 5 09:38:46 2008 --- llvm-www/pubs/2006-06-12-PLDI-SAFECode.html Mon May 5 09:38:35 2008 *************** *** 0 **** --- 1,83 ---- + + + + + + + SAFECode: Enforcing Alias Analysis for Weakly Typed Languages + + + + +
    + SAFECode: Enforcing Alias Analysis for Weakly Typed Languages +
    +
    + Dinakar Dhurjati, + Sumant Kowshik, + and + Vikram Adve +
    + +

    Abstract:

    +
    + Static analysis of programs in weakly typed languages such as C and C++ is + generally not sound because of possible memory errors due to dangling pointer + references, uninitialized pointers, and array bounds overflow. We describe a + compilation strategy for standard C programs that guarantees that aggressive + interprocedural pointer analysis (or less precise ones), a call graph, and type + information for a subset of memory, are never invalidated by any possible + memory errors. We formalize our approach as a new type system with the + necessary run-time checks in operational semantics and prove the correctness of + our approach for a subset of C. Our semantics provide the foundation for other + sophisticated static analyses to be applied to C programs with a guarantee of + soundness. Our work builds on a previously published transformation called + Automatic Pool Allocation to ensure that hard-to-detect memory errors (dangling + pointer references and certain array bounds errors) cannot invalidate the call + graph, points-to information or type information. The key insight behind our + approach is that pool allocation can be used to create a run-time partitioning + of memory that matches the compile-time memory partitioning in a points-to + graph, and efficient checks can be used to isolate the run-time partitions. + Furthermore, we show that the sound analysis information enables static + checking techniques that eliminate many run-time checks. Our approach requires + no source code changes, allows memory to be managedexplicitly, and does not use + meta-data on pointers or individual tag bits for memory. Using several + benchmark s and system codes, we show experimentally that the run-time + overheads are low (less than 10% in nearly all cases and 30% in the worst case + we have seen).We also show the effectiveness of static analyses in eliminating + run-time checks. +
    + +

    Download:

    +

    Paper:

    + + +

    BibTeX Entry:

    +
    + @inproceedings{1133999,
    +  author = {Dinakar Dhurjati and Sumant Kowshik and Vikram Adve},
    +  title = {SAFECode: enforcing alias analysis for weakly typed languages},
    +  booktitle = {PLDI '06: Proceedings of the 2006 ACM SIGPLAN conference on Programming language design and implementation},
    +  year = {2006},
    +  isbn = {1-59593-320-4},
    +  pages = {144--157},
    +  location = {Ottawa, Ontario, Canada},
    +  doi = {http://doi.acm.org/10.1145/1133981.1133999},
    +  publisher = {ACM},
    +  address = {New York, NY, USA},
    + }
    + 
    + + +
    + Valid CSS! + Valid HTML 4.01! + + + Index: llvm-www/pubs/2006-06-12-PLDI-SAFECode.pdf From criswell at cs.uiuc.edu Mon May 5 09:45:18 2008 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon, 5 May 2008 09:45:18 -0500 Subject: [llvm-commits] CVS: llvm-www/pubs/index.html Message-ID: <200805051445.m45EjIXh030686@maute.cs.uiuc.edu> Changes in directory llvm-www/pubs: index.html updated: 1.72 -> 1.73 --- Log message: Fixed typo. Added entry for Dinakar's 2006 PLDI paper. --- Diffs of the changes: (+4 -1) index.html | 5 ++++- 1 files changed, 4 insertions(+), 1 deletion(-) Index: llvm-www/pubs/index.html diff -u llvm-www/pubs/index.html:1.72 llvm-www/pubs/index.html:1.73 --- llvm-www/pubs/index.html:1.72 Mon May 5 09:32:35 2008 +++ llvm-www/pubs/index.html Mon May 5 09:44:36 2008 @@ -108,11 +108,14 @@ Proceedings of IEEE International SOC Conference, pp. 199-202, Austin, Texas, Sept. 2006.
  • "Efficiently Detecting All Dangling Pointer Uses in Production Servers"
    Dinakar Dhurjati and Vikram Adve.
    -roceedings of the International Conference on Dependable Systems and Networks (DSN '06), Philadelphia, Pennsylvania, 2006.
  • +Proceedings of the International Conference on Dependable Systems and Networks (DSN '06), Philadelphia, Pennsylvania, 2006.
  • "A Virtual Instruction Set Interface for Operating System Kernels"
    John Criswell, Brent Monroe, and Vikram Adve.
    Workshop on the Interaction between Operating Systems and Computer Architecture (WIOSCA '06), Boston, Massachusetts, 2006.
  • +
  • "SAFECode: Enforcing Alias Analysis for Weakly Typed Languages"
    Dinakar Dhurjati, Sumant, Kowshik, and Vikram Adve.
    +Proceedings of the 2006 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI '06), Ottawa, Canada, 2006.
  • +
  • " Backwards-Compatible Array Bounds Checking for C with Very Low Overhead"
    By Dinakar Dhurjati and Vikram Adve, From criswell at cs.uiuc.edu Mon May 5 09:51:33 2008 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon, 5 May 2008 09:51:33 -0500 Subject: [llvm-commits] CVS: llvm-www/pubs/index.html Message-ID: <200805051451.m45EpXZT030860@maute.cs.uiuc.edu> Changes in directory llvm-www/pubs: index.html updated: 1.73 -> 1.74 --- Log message: Fixed link. --- Diffs of the changes: (+1 -1) index.html | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-www/pubs/index.html diff -u llvm-www/pubs/index.html:1.73 llvm-www/pubs/index.html:1.74 --- llvm-www/pubs/index.html:1.73 Mon May 5 09:44:36 2008 +++ llvm-www/pubs/index.html Mon May 5 09:50:51 2008 @@ -107,7 +107,7 @@ J. Cong, Y. Fan, G. Han, W. Jiang, and Z. Zhang
    Proceedings of IEEE International SOC Conference, pp. 199-202, Austin, Texas, Sept. 2006.
  • -
  • "Efficiently Detecting All Dangling Pointer Uses in Production Servers"
    Dinakar Dhurjati and Vikram Adve.
    +
  • "Efficiently Detecting All Dangling Pointer Uses in Production Servers"
    Dinakar Dhurjati and Vikram Adve.
    Proceedings of the International Conference on Dependable Systems and Networks (DSN '06), Philadelphia, Pennsylvania, 2006.
  • "A Virtual Instruction Set Interface for Operating System Kernels"
    John Criswell, Brent Monroe, and Vikram Adve.
    From romix.llvm at googlemail.com Mon May 5 09:52:21 2008 From: romix.llvm at googlemail.com (Roman Levenstein) Date: Mon, 5 May 2008 16:52:21 +0200 Subject: [llvm-commits] Speeding up RegAllocLinearScan on big test-cases Message-ID: Hi, I have found out that RegAllocLinearScan is very inefficient on very big test-cases, where there are thousands of live intervals. Even in the release build (which is optimized), the function assignRegOrStackSlotAtInterval may consume up to 60-90% of the total compilation time according to the profiler. The reason for this bad performance is the following snippet of code in that function: for (unsigned i = 0, e = handled_.size(); i != e; ++i) { LiveInterval *HI = handled_[i]; if (!HI->expiredAt(earliestStart) && HI->expiredAt(cur->beginNumber())) { DOUT << "\t\t\tundo changes for: " << *HI << '\n'; active_.push_back(std::make_pair(HI, HI->begin())); assert(!TargetRegisterInfo::isPhysicalRegister(HI->reg)); prt_->addRegUse(vrm_->getPhys(HI->reg)); } } It looks quite innocent, but imagine that handled_ vector contains thousands of elements and that we do backtracking rather often, which is the case if you have a lot of overlapping live intervals. Therefore, this loop should be implemented more efficiently. Basically, we need to find intervals whose endNumber() is between earliestStart and cur->beginNumber(). The easiest way to do that is to have a dedicated data structure where all intervals are sorted in the increasing order if their endNumber(). This is exactly what I do with this patch. Initially, I tried with the std::set approach and it worked. But since I know how much you both like the std::set :-), I decided to implement something similar that does not produce so many dynamic memory allocations. So, I used vectors and used std::sort to keep them sorted. But that non std::set based approach was significantly slower than std::set-based one. Therefore, I decided to go with the std::set-based approach. With this patch, the bottleneck is completely removed and my profiler does not even show this function as time-consuming (i.e. it is more than an order of magnitude speed-up). On small use-cases the impact is virtually invisible, since the number of elements in the handled_ set is rather small. All dejagnu tests pass without problems. Please review it and tell if it is OK for committing. -Roman -------------- next part -------------- A non-text attachment was scrubbed... Name: RegAllocLinearScan.cpp.patch Type: text/x-diff Size: 3972 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080505/ac064d08/attachment.bin From gohman at apple.com Mon May 5 10:55:01 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 5 May 2008 08:55:01 -0700 (PDT) Subject: [llvm-commits] [llvm] r50634 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/CodeGen/AsmPrinter.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Subtarget.h lib/Target/X86/X86TargetAsmInfo.cpp test/CodeGen/X86/xor_not.ll In-Reply-To: <200805050917.21605.baldrick@free.fr> References: <200805050028.m450Sd8J021018@zion.cs.uiuc.edu> <200805050917.21605.baldrick@free.fr> Message-ID: <8367.76.126.213.14.1210002901.squirrel@webmail.apple.com> On Mon, May 5, 2008 12:17 am, Duncan Sands wrote: > Hi Dan, > >> Add AsmPrinter support for emitting a directive to declare that >> the code being generated does not require an executable stack. > > presumably you found a linux distribution that needs this. > I'm curious to know which one (ubuntu doesn't). Those using Exec-Shield or similar security measures do. Under some, executables or libraries without this still run, but without the benefit of a non-executable stack. Dan From baldrick at free.fr Mon May 5 11:06:35 2008 From: baldrick at free.fr (Duncan Sands) Date: Mon, 5 May 2008 18:06:35 +0200 Subject: [llvm-commits] [llvm] r50634 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/CodeGen/AsmPrinter.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Subtarget.h lib/Target/X86/X86TargetAsmInfo.cpp test/CodeGen/X86/xor_not.ll In-Reply-To: <8367.76.126.213.14.1210002901.squirrel@webmail.apple.com> References: <200805050028.m450Sd8J021018@zion.cs.uiuc.edu> <200805050917.21605.baldrick@free.fr> <8367.76.126.213.14.1210002901.squirrel@webmail.apple.com> Message-ID: <200805051806.36379.baldrick@free.fr> > >> Add AsmPrinter support for emitting a directive to declare that > >> the code being generated does not require an executable stack. > > > > presumably you found a linux distribution that needs this. > > I'm curious to know which one (ubuntu doesn't). > > Those using Exec-Shield or similar security measures do. Under > some, executables or libraries without this still run, but > without the benefit of a non-executable stack. Thanks for doing this - it was always clear that the executability of the stack was going to be an issue for someone someday (gcc has some hooks for dealing with this), but since none of the machines I have access to have problems with it I didn't try to tackle this when I added trampoline support. Ciao, Duncan. From baldrick at free.fr Mon May 5 11:10:26 2008 From: baldrick at free.fr (Duncan Sands) Date: Mon, 05 May 2008 16:10:26 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50648 - /llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Message-ID: <200805051610.m45GAQqn027436@zion.cs.uiuc.edu> Author: baldrick Date: Mon May 5 11:10:26 2008 New Revision: 50648 URL: http://llvm.org/viewvc/llvm-project?rev=50648&view=rev Log: Fix comment typo. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=50648&r1=50647&r2=50648&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Mon May 5 11:10:26 2008 @@ -1230,7 +1230,7 @@ IRBuilder &Builder) { Value *Loc = NULL; L = Builder.CreateBitCast(L, PointerType::getUnqual(llvm::Type::Int8Ty), "bc"); - // Load eacy byte individually. + // Load each byte individually. for (unsigned i = 0; i < RealSize; ++i) { Value *V = Builder.CreateLoad(L, "val"); Value *V2 = Builder.CreateZExt(V, LLVMTy); From gohman at apple.com Mon May 5 11:11:31 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 05 May 2008 16:11:31 -0000 Subject: [llvm-commits] [llvm] r50649 - in /llvm/trunk/lib/Target/X86: X86Subtarget.cpp X86Subtarget.h X86TargetAsmInfo.cpp Message-ID: <200805051611.m45GBWDZ027480@zion.cs.uiuc.edu> Author: djg Date: Mon May 5 11:11:31 2008 New Revision: 50649 URL: http://llvm.org/viewvc/llvm-project?rev=50649&view=rev Log: Use a dedicated IsLinux flag instead of an ELFLinux TargetType. Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp llvm/trunk/lib/Target/X86/X86Subtarget.h llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=50649&r1=50648&r2=50649&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Mon May 5 11:11:31 2008 @@ -279,7 +279,9 @@ else DarwinVers = 8; // Minimum supported darwin is Tiger. } else if (TT.find("linux") != std::string::npos) { - TargetType = isELFLinux; + // Linux doesn't imply ELF, but we don't currently support anything else. + TargetType = isELF; + IsLinux = true; } else if (TT.find("cygwin") != std::string::npos) { TargetType = isCygwin; } else if (TT.find("mingw") != std::string::npos) { @@ -306,7 +308,8 @@ TargetType = isWindows; #elif defined(__linux__) // Linux doesn't imply ELF, but we don't currently support anything else. - TargetType = isELFLinux; + TargetType = isELF; + IsLinux = true; #endif } Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=50649&r1=50648&r2=50649&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Mon May 5 11:11:31 2008 @@ -67,7 +67,10 @@ /// DarwinVers - Nonzero if this is a darwin platform: the numeric /// version of the platform, e.g. 8 = 10.4 (Tiger), 9 = 10.5 (Leopard), etc. - unsigned char DarwinVers; // Is any darwin-ppc platform. + unsigned char DarwinVers; // Is any darwin-x86 platform. + + /// isLinux - true if this is a "linux" platform. + bool IsLinux; /// stackAlignment - The minimum alignment known to hold of the stack frame on /// entry to the function and which must be maintained by every function. @@ -84,7 +87,7 @@ public: enum { - isELF, isELFLinux, isCygwin, isDarwin, isWindows, isMingw + isELF, isCygwin, isDarwin, isWindows, isMingw } TargetType; /// This constructor initializes the data members to match that @@ -133,10 +136,7 @@ bool isTargetDarwin() const { return TargetType == isDarwin; } bool isTargetELF() const { - return TargetType == isELF || TargetType == isELFLinux; - } - bool isTargetLinux() const { - return TargetType == isELFLinux; + return TargetType == isELF; } bool isTargetWindows() const { return TargetType == isWindows; } bool isTargetMingw() const { return TargetType == isMingw; } @@ -169,6 +169,9 @@ /// getDarwinVers - Return the darwin version number, 8 = tiger, 9 = leopard. unsigned getDarwinVers() const { return DarwinVers; } + /// isLinux - Return true if the target is "Linux". + bool isLinux() const { return IsLinux; } + /// True if accessing the GV requires an extra load. For Windows, dllimported /// symbols are indirect, loading the value at address GV rather then the /// value of GV itself. This means that the GlobalAddress must be in the base Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp?rev=50649&r1=50648&r2=50649&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Mon May 5 11:11:31 2008 @@ -128,7 +128,6 @@ break; case X86Subtarget::isELF: - case X86Subtarget::isELFLinux: ReadOnlySection = "\t.section\t.rodata"; FourByteConstantSection = "\t.section\t.rodata.cst4,\"aM\", at progbits,4"; EightByteConstantSection = "\t.section\t.rodata.cst8,\"aM\", at progbits,8"; @@ -231,7 +230,7 @@ } // On Linux we must declare when we can use a non-executable stack. - if (Subtarget->isTargetLinux()) + if (Subtarget->isLinux()) NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\", at progbits"; AssemblerDialect = Subtarget->getAsmFlavor(); From nicolas.geoffray at lip6.fr Mon May 5 11:20:25 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 05 May 2008 16:20:25 -0000 Subject: [llvm-commits] [vmkit] r50650 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaCache.cpp JavaJIT.cpp JavaJIT.h JavaJITInitialise.cpp JavaRuntimeJIT.cpp LowerArrayLength.cpp LowerConstantCalls.cpp Makefile.am Message-ID: <200805051620.m45GKPjn027787@zion.cs.uiuc.edu> Author: geoffray Date: Mon May 5 11:20:25 2008 New Revision: 50650 URL: http://llvm.org/viewvc/llvm-project?rev=50650&view=rev Log: Perform constant calls (ie fake readnone) as much as possible. Added: vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Removed: vmkit/trunk/lib/JnJVM/VMCore/LowerArrayLength.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/Makefile.am Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp?rev=50650&r1=50649&r2=50650&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp Mon May 5 11:20:25 2008 @@ -111,14 +111,7 @@ "", currentBlock); Value* cache = new LoadInst(cachePtr, "", currentBlock); - std::vector args2; - args2.push_back(zero); - args2.push_back(JavaObject::classOffset()); - Value* classPtr = GetElementPtrInst::Create(args[0], args2.begin(), - args2.end(), "", - currentBlock); - - Value* cl = new LoadInst(classPtr, "", currentBlock); + Value* cl = CallInst::Create(getClassLLVM, args[0], "", currentBlock); std::vector args3; args3.push_back(zero); args3.push_back(two); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=50650&r1=50649&r2=50650&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Mon May 5 11:20:25 2008 @@ -121,13 +121,7 @@ JITVerifyNull(args[0]); - std::vector indexes; //[3]; - indexes.push_back(zero); - indexes.push_back(zero); - Value* VTPtr = GetElementPtrInst::Create(args[0], indexes.begin(), - indexes.end(), "", currentBlock); - - Value* VT = new LoadInst(VTPtr, "", currentBlock); + Value* VT = CallInst::Create(getVTLLVM, args[0], "", currentBlock); std::vector indexes2; //[3]; if (meth) { indexes2.push_back(meth->offset); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h?rev=50650&r1=50649&r2=50650&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Mon May 5 11:20:25 2008 @@ -270,6 +270,8 @@ static llvm::Function* getStaticInstanceLLVM; static llvm::Function* getClassDelegateeLLVM; static llvm::Function* arrayLengthLLVM; + static llvm::Function* getVTLLVM; + static llvm::Function* getClassLLVM; static Class* getCallingClass(); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp?rev=50650&r1=50649&r2=50650&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Mon May 5 11:20:25 2008 @@ -319,6 +319,44 @@ arrayLengthLLVM->setParamAttrs(func_toto_PAL); } + // Create getVTLLVM + { + std::vector args; + args.push_back(JavaObject::llvmType); + const FunctionType* type = FunctionType::get( + PointerType::getUnqual(PointerType::getUnqual(Type::Int32Ty)), + args, false); + + getVTLLVM = Function::Create(type, GlobalValue::ExternalLinkage, + "getVT", + module); + PAListPtr func_toto_PAL; + SmallVector Attrs; + ParamAttrsWithIndex PAWI; + PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone; + Attrs.push_back(PAWI); + func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end()); + getVTLLVM->setParamAttrs(func_toto_PAL); + } + + // Create getClassLLVM + { + std::vector args; + args.push_back(JavaObject::llvmType); + const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args, false); + + getClassLLVM = Function::Create(type, GlobalValue::ExternalLinkage, + "getVT", + module); + PAListPtr func_toto_PAL; + SmallVector Attrs; + ParamAttrsWithIndex PAWI; + PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone; + Attrs.push_back(PAWI); + func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end()); + getClassLLVM->setParamAttrs(func_toto_PAL); + } + // Create newLookupLLVM { std::vector args; @@ -643,7 +681,7 @@ namespace mvm { llvm::FunctionPass* createEscapeAnalysisPass(llvm::Function*, llvm::Function*); -llvm::FunctionPass* createLowerArrayLengthPass(); +llvm::FunctionPass* createLowerConstantCallsPass(); //llvm::FunctionPass* createArrayChecksPass(); } @@ -701,6 +739,6 @@ addPass(PM, llvm::createDeadStoreEliminationPass()); // Delete dead stores addPass(PM, llvm::createAggressiveDCEPass()); // SSA based 'Aggressive DCE' addPass(PM, llvm::createCFGSimplificationPass()); // Merge & remove BBs - addPass(PM, mvm::createLowerArrayLengthPass()); + addPass(PM, mvm::createLowerConstantCallsPass()); } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=50650&r1=50649&r2=50650&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Mon May 5 11:20:25 2008 @@ -71,6 +71,8 @@ llvm::Function* JavaJIT::getStaticInstanceLLVM = 0; llvm::Function* JavaJIT::getClassDelegateeLLVM = 0; llvm::Function* JavaJIT::arrayLengthLLVM = 0; +llvm::Function* JavaJIT::getVTLLVM = 0; +llvm::Function* JavaJIT::getClassLLVM = 0; #ifdef SERVICE_VM llvm::Function* JavaJIT::aquireObjectInSharedDomainLLVM = 0; Removed: vmkit/trunk/lib/JnJVM/VMCore/LowerArrayLength.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LowerArrayLength.cpp?rev=50649&view=auto ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/LowerArrayLength.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/LowerArrayLength.cpp (removed) @@ -1,68 +0,0 @@ -//===----- LowerArrayLength.cpp - Changes arrayLength calls --------------===// -// -// JnJVM -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - - -#include "llvm/Pass.h" -#include "llvm/Function.h" -#include "llvm/Instructions.h" -#include "llvm/Support/Compiler.h" -#include "llvm/Support/Debug.h" - -#include "mvm/JIT.h" - -#include "JavaArray.h" -#include "JavaJIT.h" - -using namespace llvm; - -namespace mvm { - - class VISIBILITY_HIDDEN LowerArrayLength : public FunctionPass { - public: - static char ID; - LowerArrayLength() : FunctionPass((intptr_t)&ID) { } - - virtual bool runOnFunction(Function &F); - private: - }; - char LowerArrayLength::ID = 0; - RegisterPass X("LowerArrayLength", "Lower Array length"); - -bool LowerArrayLength::runOnFunction(Function& F) { - bool Changed = false; - for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; BI++) { - BasicBlock *Cur = BI; - for (BasicBlock::iterator II = Cur->begin(), IE = Cur->end(); II != IE;) { - Instruction *I = II; - II++; - if (CallInst *CI = dyn_cast(I)) { - if (CI->getOperand(0) == jnjvm::JavaJIT::arrayLengthLLVM) { - Changed = true; - Value* val = CI->getOperand(1); // get the array - Value* array = new BitCastInst(val, jnjvm::JavaArray::llvmType, "", CI); - std::vector args; //size= 2 - args.push_back(mvm::jit::constantZero); - args.push_back(jnjvm::JavaArray::sizeOffset()); - Value* ptr = GetElementPtrInst::Create(array, args.begin(), args.end(), - "", CI); - Value* load = new LoadInst(ptr, "", CI); - CI->replaceAllUsesWith(load); - CI->eraseFromParent(); - } - } - } - } - return Changed; -} - - -FunctionPass* createLowerArrayLengthPass() { - return new LowerArrayLength(); -} -} Added: vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp?rev=50650&view=auto ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp (added) +++ vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Mon May 5 11:20:25 2008 @@ -0,0 +1,92 @@ +//===----- LowerConstantCalls.cpp - Changes arrayLength calls --------------===// +// +// JnJVM +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + + +#include "llvm/Pass.h" +#include "llvm/Function.h" +#include "llvm/Instructions.h" +#include "llvm/Support/Compiler.h" +#include "llvm/Support/Debug.h" + +#include "mvm/JIT.h" + +#include "JavaArray.h" +#include "JavaJIT.h" + +using namespace llvm; + +namespace mvm { + + class VISIBILITY_HIDDEN LowerConstantCalls : public FunctionPass { + public: + static char ID; + LowerConstantCalls() : FunctionPass((intptr_t)&ID) { } + + virtual bool runOnFunction(Function &F); + private: + }; + char LowerConstantCalls::ID = 0; + RegisterPass X("LowerArrayLength", "Lower Array length"); + +bool LowerConstantCalls::runOnFunction(Function& F) { + bool Changed = false; + for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; BI++) { + BasicBlock *Cur = BI; + for (BasicBlock::iterator II = Cur->begin(), IE = Cur->end(); II != IE;) { + Instruction *I = II; + II++; + if (CallInst *CI = dyn_cast(I)) { + Value* V = CI->getOperand(0); + if (V == jnjvm::JavaJIT::arrayLengthLLVM) { + Changed = true; + Value* val = CI->getOperand(1); // get the array + Value* array = new BitCastInst(val, jnjvm::JavaArray::llvmType, "", CI); + std::vector args; //size= 2 + args.push_back(mvm::jit::constantZero); + args.push_back(jnjvm::JavaArray::sizeOffset()); + Value* ptr = GetElementPtrInst::Create(array, args.begin(), args.end(), + "", CI); + Value* load = new LoadInst(ptr, "", CI); + CI->replaceAllUsesWith(load); + CI->eraseFromParent(); + } else if (V == jnjvm::JavaJIT::getVTLLVM) { + Changed = true; + Value* val = CI->getOperand(1); // get the object + std::vector indexes; //[3]; + indexes.push_back(mvm::jit::constantZero); + indexes.push_back(mvm::jit::constantZero); + Value* VTPtr = GetElementPtrInst::Create(val, indexes.begin(), + indexes.end(), "", CI); + Value* VT = new LoadInst(VTPtr, "", CI); + CI->replaceAllUsesWith(VT); + CI->eraseFromParent(); + } else if (V == jnjvm::JavaJIT::getClassLLVM) { + Changed = true; + Value* val = CI->getOperand(1); // get the object + std::vector args2; + args2.push_back(mvm::jit::constantZero); + args2.push_back(jnjvm::JavaObject::classOffset()); + Value* classPtr = GetElementPtrInst::Create(val, args2.begin(), + args2.end(), "", + CI); + Value* cl = new LoadInst(classPtr, "", CI); + CI->replaceAllUsesWith(cl); + CI->eraseFromParent(); + } + } + } + } + return Changed; +} + + +FunctionPass* createLowerConstantCallsPass() { + return new LowerConstantCalls(); +} +} Modified: vmkit/trunk/lib/JnJVM/VMCore/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Makefile.am?rev=50650&r1=50649&r2=50650&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Makefile.am (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Makefile.am Mon May 5 11:20:25 2008 @@ -13,7 +13,7 @@ JavaBacktrace.cpp NativeUtil.h NativeUtil.cpp Jni.cpp \ JavaCache.h JavaCache.cpp JavaUpcalls.h JavaUpcalls.cpp \ JnjvmModuleProvider.h JnjvmModuleProvider.cpp JavaRuntimeJIT.cpp JavaMetaJIT.cpp JavaJITInitialise.cpp \ - LowerArrayLength.cpp + LowerConstantCalls.cpp if SERVICE_BUILD libJnJVM_la_SOURCES += ServiceDomain.cpp From baldrick at free.fr Mon May 5 11:37:33 2008 From: baldrick at free.fr (Duncan Sands) Date: Mon, 05 May 2008 16:37:33 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50651 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200805051637.m45GbX0i028422@zion.cs.uiuc.edu> Author: baldrick Date: Mon May 5 11:37:33 2008 New Revision: 50651 URL: http://llvm.org/viewvc/llvm-project?rev=50651&view=rev Log: In this context, LocStack should only be accessed using the getValue and getAddress methods. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=50651&r1=50650&r2=50651&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon May 5 11:37:33 2008 @@ -2516,7 +2516,7 @@ unsigned RealSize = 0) { Value *Loc = NULL; if (RealSize) { - Value *L = LocStack.back(); + Value *L = getAddress(); Loc = LLVM_LOAD_SCALAR_ARGUMENT(L,LLVMTy,RealSize,Builder); } else Loc = getValue(LLVMTy); From evan.cheng at apple.com Mon May 5 11:37:51 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 5 May 2008 09:37:51 -0700 Subject: [llvm-commits] Speeding up RegAllocLinearScan on big test-cases In-Reply-To: References: Message-ID: <149F341F-BD78-4D7D-86D9-9A8B63015DA5@apple.com> Hi Roman, Thanks for working on this. I think the idea is workable. But I worry about your fixation on std::set. It can't be healthy?! :-) + /// IntrvalEndsComparator - Weak Ordering operator for ordering + /// intervals in increasing order according to their endNuber value. + struct IntrvalEndsComparator { + bool operator() (const LiveInterval *L, const LiveInterval *R) const { + if (L->endNumber() < R->endNumber()) + return true; + if (L->endNumber() == R->endNumber()) + return L->beginNumber() < R->beginNumber(); + + return false; + } + }; Please fix the inconsistent indentation. + iBeginNumber.addRange(LiveRange(cur->beginNumber()-1, cur- >beginNumber(), NULL)); Please avoid 80 col. violation. Have you run through at least MultiSource? Can you tell what impact it has on compile time of medium sized apps like kimwitu++? Thanks, Evan On May 5, 2008, at 7:52 AM, Roman Levenstein wrote: > Hi, > > I have found out that RegAllocLinearScan is very inefficient on very > big test-cases, where there are thousands of live intervals. > Even in the release build (which is optimized), the function > assignRegOrStackSlotAtInterval may consume up to 60-90% of the total > compilation time according to the profiler. > > The reason for this bad performance is the following snippet of code > in that function: > > for (unsigned i = 0, e = handled_.size(); i != e; ++i) { > LiveInterval *HI = handled_[i]; > if (!HI->expiredAt(earliestStart) && > HI->expiredAt(cur->beginNumber())) { > DOUT << "\t\t\tundo changes for: " << *HI << '\n'; > active_.push_back(std::make_pair(HI, HI->begin())); > assert(!TargetRegisterInfo::isPhysicalRegister(HI->reg)); > prt_->addRegUse(vrm_->getPhys(HI->reg)); > } > } > > It looks quite innocent, but imagine that handled_ vector contains > thousands of elements and that we do backtracking rather often, which > is > the case if you have a lot of overlapping live intervals. > > Therefore, this loop should be implemented more efficiently. > Basically, we need to find intervals whose endNumber() is between > earliestStart and cur->beginNumber(). > The easiest way to do that is to have a dedicated data structure where > all intervals are sorted in the increasing order if their endNumber(). > > This is exactly what I do with this patch. Initially, I tried with the > std::set approach and it worked. But since I know how much you both > like the std::set :-), > I decided to implement something similar that does not produce so many > dynamic memory allocations. So, I used vectors and used std::sort to > keep them sorted. But that non std::set based approach was > significantly slower than std::set-based one. Therefore, I decided to > go with the std::set-based approach. > > With this patch, the bottleneck is completely removed and my profiler > does not even show this function as time-consuming (i.e. it is more > than an order of magnitude speed-up). On small use-cases the impact is > virtually invisible, since the number of elements in the handled_ set > is rather small. > > All dejagnu tests pass without problems. > > Please review it and tell if it is OK for committing. > > -Roman > < > RegAllocLinearScan > .cpp.patch>_______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From gohman at apple.com Mon May 5 11:48:33 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 05 May 2008 16:48:33 -0000 Subject: [llvm-commits] [llvm] r50652 - /llvm/trunk/lib/CodeGen/ELFWriter.cpp Message-ID: <200805051648.m45GmXq8028877@zion.cs.uiuc.edu> Author: djg Date: Mon May 5 11:48:32 2008 New Revision: 50652 URL: http://llvm.org/viewvc/llvm-project?rev=50652&view=rev Log: Fix a bug in the ELF writer that caused it to produce malformed ELF headers. The ELF writer still isn't generally usable though. Modified: llvm/trunk/lib/CodeGen/ELFWriter.cpp Modified: llvm/trunk/lib/CodeGen/ELFWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ELFWriter.cpp?rev=50652&r1=50651&r2=50652&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ELFWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/ELFWriter.cpp Mon May 5 11:48:32 2008 @@ -229,7 +229,7 @@ // This should change for shared objects. FHOut.outhalf(1); // e_type = ET_REL - FHOut.outword(TM.getELFWriterInfo()->getEMachine()); // target-defined + FHOut.outhalf(TM.getELFWriterInfo()->getEMachine()); // target-defined FHOut.outword(1); // e_version = 1 FHOut.outaddr(0); // e_entry = 0 -> no entry point in .o file FHOut.outaddr(0); // e_phoff = 0 -> no program header for .o From asl at math.spbu.ru Mon May 5 12:08:59 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 05 May 2008 17:08:59 -0000 Subject: [llvm-commits] [llvm] r50654 - /llvm/trunk/lib/Target/X86/X86Instr64bit.td Message-ID: <200805051709.m45H90OY029547@zion.cs.uiuc.edu> Author: asl Date: Mon May 5 12:08:59 2008 New Revision: 50654 URL: http://llvm.org/viewvc/llvm-project?rev=50654&view=rev Log: Fix 80col violation Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=50654&r1=50653&r2=50654&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Mon May 5 12:08:59 2008 @@ -1107,7 +1107,7 @@ //===----------------------------------------------------------------------===// def TLS_addr64 : I<0, Pseudo, (outs GR64:$dst), (ins i64imm:$sym), - ".byte\t0x66; leaq\t${sym:mem}(%rip), $dst; .word\t0x6666; rex64", + ".byte\t0x66; leaq\t${sym:mem}(%rip), $dst; .word\t0x6666; rex64", [(set GR64:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>; //===----------------------------------------------------------------------===// From clattner at apple.com Mon May 5 12:27:26 2008 From: clattner at apple.com (Chris Lattner) Date: Mon, 5 May 2008 10:27:26 -0700 Subject: [llvm-commits] [llvm] r50649 - in /llvm/trunk/lib/Target/X86: X86Subtarget.cpp X86Subtarget.h X86TargetAsmInfo.cpp In-Reply-To: <200805051611.m45GBWDZ027480@zion.cs.uiuc.edu> References: <200805051611.m45GBWDZ027480@zion.cs.uiuc.edu> Message-ID: <54FD7941-2D93-4F46-88AF-EFDD73B802DC@apple.com> On May 5, 2008, at 9:11 AM, Dan Gohman wrote: > Author: djg > Date: Mon May 5 11:11:31 2008 > New Revision: 50649 > > URL: http://llvm.org/viewvc/llvm-project?rev=50649&view=rev > Log: > Use a dedicated IsLinux flag instead of an ELFLinux TargetType. Thanks Dan, -Chris From evan.cheng at apple.com Mon May 5 12:41:04 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 05 May 2008 17:41:04 -0000 Subject: [llvm-commits] [llvm] r50655 - /llvm/trunk/include/llvm/Instructions.h Message-ID: <200805051741.m45Hf4p4030606@zion.cs.uiuc.edu> Author: evancheng Date: Mon May 5 12:41:03 2008 New Revision: 50655 URL: http://llvm.org/viewvc/llvm-project?rev=50655&view=rev Log: Fix 80 column violations. 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=50655&r1=50654&r2=50655&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Mon May 5 12:41:03 2008 @@ -935,14 +935,19 @@ CallInst(Value *F, const std::string &Name, BasicBlock *InsertAtEnd); public: template - static CallInst *Create(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, - const std::string &Name = "", Instruction *InsertBefore = 0) { - return new(ArgEnd - ArgBegin + 1) CallInst(Func, ArgBegin, ArgEnd, Name, InsertBefore); + static CallInst *Create(Value *Func, InputIterator ArgBegin, + InputIterator ArgEnd, + const std::string &Name = "", + Instruction *InsertBefore = 0) { + return new(ArgEnd - ArgBegin + 1) + CallInst(Func, ArgBegin, ArgEnd, Name, InsertBefore); } template - static CallInst *Create(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, - const std::string &Name, BasicBlock *InsertAtEnd) { - return new(ArgEnd - ArgBegin + 1) CallInst(Func, ArgBegin, ArgEnd, Name, InsertAtEnd); + static CallInst *Create(Value *Func, InputIterator ArgBegin, + InputIterator ArgEnd, const std::string &Name, + BasicBlock *InsertAtEnd) { + return new(ArgEnd - ArgBegin + 1) + CallInst(Func, ArgBegin, ArgEnd, Name, InsertAtEnd); } static CallInst *Create(Value *F, Value *Actual, const std::string& Name = "", Instruction *InsertBefore = 0) { @@ -1078,12 +1083,13 @@ setName(Name); } public: - static SelectInst *Create(Value *C, Value *S1, Value *S2, const std::string &Name = "", - Instruction *InsertBefore = 0) { + static SelectInst *Create(Value *C, Value *S1, Value *S2, + const std::string &Name = "", + Instruction *InsertBefore = 0) { return new(3) SelectInst(C, S1, S2, Name, InsertBefore); } - static SelectInst *Create(Value *C, Value *S1, Value *S2, const std::string &Name, - BasicBlock *InsertAtEnd) { + static SelectInst *Create(Value *C, Value *S1, Value *S2, + const std::string &Name, BasicBlock *InsertAtEnd) { return new(3) SelectInst(C, S1, S2, Name, InsertAtEnd); } @@ -1235,16 +1241,21 @@ return new(3) InsertElementInst(Vec, NewElt, Idx, Name, InsertBefore); } static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx, - const std::string &Name = "",Instruction *InsertBefore = 0) { - return new(3/*FIXME*/) InsertElementInst(Vec, NewElt, Idx, Name, InsertBefore); + const std::string &Name = "", + Instruction *InsertBefore = 0) { + return new(3/*FIXME*/) + InsertElementInst(Vec, NewElt, Idx, Name, InsertBefore); } static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx, - const std::string &Name, BasicBlock *InsertAtEnd) { + const std::string &Name, + BasicBlock *InsertAtEnd) { return new(3) InsertElementInst(Vec, NewElt, Idx, Name, InsertAtEnd); } static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx, - const std::string &Name, BasicBlock *InsertAtEnd) { - return new(3/*FIXME*/) InsertElementInst(Vec, NewElt, Idx, Name, InsertAtEnd); + const std::string &Name, + BasicBlock *InsertAtEnd) { + return new(3/*FIXME*/) + InsertElementInst(Vec, NewElt, Idx, Name, InsertAtEnd); } /// isValidOperands - Return true if an insertelement instruction can be @@ -1380,7 +1391,8 @@ Instruction *InsertBefore = 0) { return new PHINode(Ty, Name, InsertBefore); } - static PHINode *Create(const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) { + static PHINode *Create(const Type *Ty, const std::string &Name, + BasicBlock *InsertAtEnd) { return new PHINode(Ty, Name, InsertAtEnd); } ~PHINode(); @@ -1532,10 +1544,12 @@ static ReturnInst* Create(Value * const* retVals, unsigned N) { return new(N) ReturnInst(retVals, N); } - static ReturnInst* Create(Value * const* retVals, unsigned N, Instruction *InsertBefore) { + static ReturnInst* Create(Value * const* retVals, unsigned N, + Instruction *InsertBefore) { return new(N) ReturnInst(retVals, N, InsertBefore); } - static ReturnInst* Create(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd) { + static ReturnInst* Create(Value * const* retVals, unsigned N, + BasicBlock *InsertAtEnd) { return new(N) ReturnInst(retVals, N, InsertAtEnd); } static ReturnInst* Create(BasicBlock *InsertAtEnd) { @@ -1710,11 +1724,13 @@ public: static SwitchInst *Create(Value *Value, BasicBlock *Default, unsigned NumCases, Instruction *InsertBefore = 0) { - return new(NumCases/*FIXME*/) SwitchInst(Value, Default, NumCases, InsertBefore); + return new(NumCases/*FIXME*/) + SwitchInst(Value, Default, NumCases, InsertBefore); } static SwitchInst *Create(Value *Value, BasicBlock *Default, unsigned NumCases, BasicBlock *InsertAtEnd) { - return new(NumCases/*FIXME*/) SwitchInst(Value, Default, NumCases, InsertAtEnd); + return new(NumCases/*FIXME*/) + SwitchInst(Value, Default, NumCases, InsertAtEnd); } ~SwitchInst(); @@ -1880,16 +1896,21 @@ } public: template - static InvokeInst *Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, + static InvokeInst *Create(Value *Func, BasicBlock *IfNormal, + BasicBlock *IfException, InputIterator ArgBegin, InputIterator ArgEnd, - const std::string &Name = "", Instruction *InsertBefore = 0) { - return new(ArgEnd - ArgBegin + 3) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, InsertBefore); + const std::string &Name = "", + Instruction *InsertBefore = 0) { + return new(ArgEnd - ArgBegin + 3) + InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, InsertBefore); } template - static InvokeInst *Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, + static InvokeInst *Create(Value *Func, BasicBlock *IfNormal, + BasicBlock *IfException, InputIterator ArgBegin, InputIterator ArgEnd, const std::string &Name, BasicBlock *InsertAtEnd) { - return new(ArgEnd - ArgBegin + 3) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, InsertAtEnd); + return new(ArgEnd - ArgBegin + 3) + InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, InsertAtEnd); } ~InvokeInst(); From dpatel at apple.com Mon May 5 12:49:49 2008 From: dpatel at apple.com (Devang Patel) Date: Mon, 05 May 2008 17:49:49 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50656 - /llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/asm-function-20.C Message-ID: <200805051749.m45HnnAt030863@zion.cs.uiuc.edu> Author: dpatel Date: Mon May 5 12:49:48 2008 New Revision: 50656 URL: http://llvm.org/viewvc/llvm-project?rev=50656&view=rev Log: Remove inliner warning check. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/asm-function-20.C Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/asm-function-20.C URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/asm-function-20.C?rev=50656&r1=50655&r2=50656&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/asm-function-20.C (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/asm-function-20.C Mon May 5 12:49:48 2008 @@ -7,7 +7,7 @@ inline int numberFive (void); asm int numberFive (void) /* { dg-warning "can never be inlined" } */ { - /* { dg-warning "inlining failed in call" "" { target *-*-* } 8 } */ + /* LLVM LOCAL remove warning test */ li r3, 1 } From sabre at nondot.org Mon May 5 13:24:33 2008 From: sabre at nondot.org (Chris Lattner) Date: Mon, 05 May 2008 18:24:33 -0000 Subject: [llvm-commits] [llvm] r50658 - /llvm/trunk/test/CodeGen/X86/2007-07-03-GR64ToVR64.ll Message-ID: <200805051824.m45IOXHj032275@zion.cs.uiuc.edu> Author: lattner Date: Mon May 5 13:24:33 2008 New Revision: 50658 URL: http://llvm.org/viewvc/llvm-project?rev=50658&view=rev Log: no need for eh info Modified: llvm/trunk/test/CodeGen/X86/2007-07-03-GR64ToVR64.ll Modified: llvm/trunk/test/CodeGen/X86/2007-07-03-GR64ToVR64.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-07-03-GR64ToVR64.ll?rev=50658&r1=50657&r2=50658&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2007-07-03-GR64ToVR64.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-07-03-GR64ToVR64.ll Mon May 5 13:24:33 2008 @@ -4,7 +4,7 @@ @R = external global <1 x i64> ; <<1 x i64>*> [#uses=1] -define void @foo(<1 x i64> %A, <1 x i64> %B) { +define void @foo(<1 x i64> %A, <1 x i64> %B) nounwind { entry: %tmp4 = bitcast <1 x i64> %B to <4 x i16> ; <<4 x i16>> [#uses=1] %tmp6 = bitcast <1 x i64> %A to <4 x i16> ; <<4 x i16>> [#uses=1] From evan.cheng at apple.com Mon May 5 13:30:59 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 05 May 2008 18:30:59 -0000 Subject: [llvm-commits] [llvm] r50659 - in /llvm/trunk: include/llvm/ include/llvm/ADT/ include/llvm/Analysis/ include/llvm/Bitcode/ include/llvm/CodeGen/ include/llvm/Debugger/ include/llvm/Support/ include/llvm/System/ include/llvm/Target/ lib/Support/ lib/System/ lib/System/Unix/ Message-ID: <200805051831.m45IV1Fe032569@zion.cs.uiuc.edu> Author: evancheng Date: Mon May 5 13:30:58 2008 New Revision: 50659 URL: http://llvm.org/viewvc/llvm-project?rev=50659&view=rev Log: Fix more -Wshorten-64-to-32 warnings. Modified: llvm/trunk/include/llvm/ADT/BitVector.h llvm/trunk/include/llvm/ADT/SmallPtrSet.h llvm/trunk/include/llvm/ADT/SmallVector.h llvm/trunk/include/llvm/ADT/StringExtras.h llvm/trunk/include/llvm/ADT/StringMap.h llvm/trunk/include/llvm/ADT/UniqueVector.h llvm/trunk/include/llvm/Analysis/AliasSetTracker.h llvm/trunk/include/llvm/Analysis/CallGraph.h llvm/trunk/include/llvm/Analysis/DominatorInternals.h llvm/trunk/include/llvm/Analysis/Dominators.h llvm/trunk/include/llvm/Analysis/LoopInfo.h llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h llvm/trunk/include/llvm/Bitcode/Archive.h llvm/trunk/include/llvm/Bitcode/BitCodes.h llvm/trunk/include/llvm/Bitcode/BitstreamReader.h llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h llvm/trunk/include/llvm/CodeGen/LiveInterval.h llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h llvm/trunk/include/llvm/CodeGen/MachineFunction.h llvm/trunk/include/llvm/CodeGen/MachineInstr.h llvm/trunk/include/llvm/CodeGen/MachineJumpTableInfo.h llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h llvm/trunk/include/llvm/CodeGen/SelectionDAG.h llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h llvm/trunk/include/llvm/Debugger/Debugger.h llvm/trunk/include/llvm/Debugger/SourceFile.h llvm/trunk/include/llvm/Instructions.h llvm/trunk/include/llvm/ParameterAttributes.h llvm/trunk/include/llvm/PassManagers.h llvm/trunk/include/llvm/Support/AlignOf.h llvm/trunk/include/llvm/Support/Allocator.h llvm/trunk/include/llvm/Support/CommandLine.h llvm/trunk/include/llvm/Support/GraphWriter.h llvm/trunk/include/llvm/Support/MemoryBuffer.h llvm/trunk/include/llvm/Support/OutputBuffer.h llvm/trunk/include/llvm/System/Path.h llvm/trunk/include/llvm/Target/TargetRegisterInfo.h llvm/trunk/include/llvm/User.h llvm/trunk/lib/Support/Allocator.cpp llvm/trunk/lib/Support/CommandLine.cpp llvm/trunk/lib/Support/FileUtilities.cpp llvm/trunk/lib/Support/FoldingSet.cpp llvm/trunk/lib/Support/MemoryBuffer.cpp llvm/trunk/lib/Support/Statistic.cpp llvm/trunk/lib/Support/StringExtras.cpp llvm/trunk/lib/System/Path.cpp llvm/trunk/lib/System/Unix/Memory.inc llvm/trunk/lib/System/Unix/Path.inc llvm/trunk/lib/System/Unix/Program.inc llvm/trunk/lib/System/Unix/Signals.inc Modified: llvm/trunk/include/llvm/ADT/BitVector.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/BitVector.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/BitVector.h (original) +++ llvm/trunk/include/llvm/ADT/BitVector.h Mon May 5 13:30:58 2008 @@ -25,7 +25,7 @@ class BitVector { typedef unsigned long BitWord; - enum { BITWORD_SIZE = sizeof(BitWord) * 8 }; + enum { BITWORD_SIZE = (unsigned)sizeof(BitWord) * 8 }; BitWord *Bits; // Actual bits. unsigned Size; // Size of bitvector in bits. @@ -103,7 +103,7 @@ unsigned NumBits = 0; for (unsigned i = 0; i < NumBitWords(size()); ++i) if (sizeof(BitWord) == 4) - NumBits += CountPopulation_32(Bits[i]); + NumBits += CountPopulation_32((uint32_t)Bits[i]); else if (sizeof(BitWord) == 8) NumBits += CountPopulation_64(Bits[i]); else @@ -130,7 +130,7 @@ for (unsigned i = 0; i < NumBitWords(size()); ++i) if (Bits[i] != 0) { if (sizeof(BitWord) == 4) - return i * BITWORD_SIZE + CountTrailingZeros_32(Bits[i]); + return i * BITWORD_SIZE + CountTrailingZeros_32((uint32_t)Bits[i]); else if (sizeof(BitWord) == 8) return i * BITWORD_SIZE + CountTrailingZeros_64(Bits[i]); else @@ -154,7 +154,7 @@ if (Copy != 0) { if (sizeof(BitWord) == 4) - return WordPos * BITWORD_SIZE + CountTrailingZeros_32(Copy); + return WordPos * BITWORD_SIZE + CountTrailingZeros_32((uint32_t)Copy); else if (sizeof(BitWord) == 8) return WordPos * BITWORD_SIZE + CountTrailingZeros_64(Copy); else @@ -165,7 +165,7 @@ for (unsigned i = WordPos+1; i < NumBitWords(size()); ++i) if (Bits[i] != 0) { if (sizeof(BitWord) == 4) - return i * BITWORD_SIZE + CountTrailingZeros_32(Bits[i]); + return i * BITWORD_SIZE + CountTrailingZeros_32((uint32_t)Bits[i]); else if (sizeof(BitWord) == 8) return i * BITWORD_SIZE + CountTrailingZeros_64(Bits[i]); else Modified: llvm/trunk/include/llvm/ADT/SmallPtrSet.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallPtrSet.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/SmallPtrSet.h (original) +++ llvm/trunk/include/llvm/ADT/SmallPtrSet.h Mon May 5 13:30:58 2008 @@ -121,7 +121,7 @@ bool isSmall() const { return CurArray == &SmallArray[0]; } unsigned Hash(const void *Ptr) const { - return ((uintptr_t)Ptr >> 4) & (CurArraySize-1); + return static_cast(((uintptr_t)Ptr >> 4) & (CurArraySize-1)); } const void * const *FindBucketFor(const void *Ptr) const; void shrink_and_clear(); Modified: llvm/trunk/include/llvm/ADT/SmallVector.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallVector.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/SmallVector.h (original) +++ llvm/trunk/include/llvm/ADT/SmallVector.h Mon May 5 13:30:58 2008 @@ -190,7 +190,7 @@ /// template void append(in_iter in_start, in_iter in_end) { - unsigned NumInputs = std::distance(in_start, in_end); + size_type NumInputs = std::distance(in_start, in_end); // Grow allocated space if needed. if (End+NumInputs > Capacity) grow(size()+NumInputs); @@ -242,7 +242,7 @@ *I = Elt; return I; } - unsigned EltNo = I-Begin; + size_t EltNo = I-Begin; grow(); I = Begin+EltNo; goto Retry; @@ -255,12 +255,12 @@ return end()-1; } - unsigned NumToInsert = std::distance(From, To); + size_t NumToInsert = std::distance(From, To); // Convert iterator to elt# to avoid invalidating iterator when we reserve() - unsigned InsertElt = I-begin(); + size_t InsertElt = I-begin(); // Ensure there is enough space. - reserve(size() + NumToInsert); + reserve(static_cast(size() + NumToInsert)); // Uninvalidate the iterator. I = begin()+InsertElt; @@ -285,7 +285,7 @@ // Copy over the elements that we're about to overwrite. T *OldEnd = End; End += NumToInsert; - unsigned NumOverwritten = OldEnd-I; + size_t NumOverwritten = OldEnd-I; std::uninitialized_copy(I, OldEnd, End-NumOverwritten); // Replace the overwritten part. @@ -318,7 +318,7 @@ /// grow - double the size of the allocated memory, guaranteeing space for at /// least one more element or MinSize if specified. - void grow(unsigned MinSize = 0); + void grow(size_type MinSize = 0); void construct_range(T *S, T *E, const T &Elt) { for (; S != E; ++S) @@ -335,10 +335,10 @@ // Define this out-of-line to dissuade the C++ compiler from inlining it. template -void SmallVectorImpl::grow(unsigned MinSize) { - unsigned CurCapacity = unsigned(Capacity-Begin); - unsigned CurSize = unsigned(size()); - unsigned NewCapacity = 2*CurCapacity; +void SmallVectorImpl::grow(size_t MinSize) { + size_t CurCapacity = Capacity-Begin; + size_t CurSize = size(); + size_t NewCapacity = 2*CurCapacity; if (NewCapacity < MinSize) NewCapacity = MinSize; T *NewElts = reinterpret_cast(new char[NewCapacity*sizeof(T)]); @@ -375,20 +375,20 @@ RHS.grow(size()); // Swap the shared elements. - unsigned NumShared = size(); + size_t NumShared = size(); if (NumShared > RHS.size()) NumShared = RHS.size(); - for (unsigned i = 0; i != NumShared; ++i) + for (unsigned i = 0; i != static_cast(NumShared); ++i) std::swap(Begin[i], RHS[i]); // Copy over the extra elts. if (size() > RHS.size()) { - unsigned EltDiff = size() - RHS.size(); + size_t EltDiff = size() - RHS.size(); std::uninitialized_copy(Begin+NumShared, End, RHS.End); RHS.End += EltDiff; destroy_range(Begin+NumShared, End); End = Begin+NumShared; } else if (RHS.size() > size()) { - unsigned EltDiff = RHS.size() - size(); + size_t EltDiff = RHS.size() - size(); std::uninitialized_copy(RHS.Begin+NumShared, RHS.End, End); End += EltDiff; destroy_range(RHS.Begin+NumShared, RHS.End); @@ -458,7 +458,9 @@ typedef typename SmallVectorImpl::U U; enum { // MinUs - The number of U's require to cover N T's. - MinUs = (sizeof(T)*N+sizeof(U)-1)/sizeof(U), + MinUs = (static_cast(sizeof(T))*N + + static_cast(sizeof(U)) - 1) / + static_cast(sizeof(U)), // NumInlineEltsElts - The number of elements actually in this array. There // is already one in the parent class, and we have to round up to avoid @@ -467,7 +469,8 @@ // NumTsAvailable - The number of T's we actually have space for, which may // be more than N due to rounding. - NumTsAvailable = (NumInlineEltsElts+1)*sizeof(U) / sizeof(T) + NumTsAvailable = (NumInlineEltsElts+1)*static_cast(sizeof(U))/ + static_cast(sizeof(T)) }; U InlineElts[NumInlineEltsElts]; public: Modified: llvm/trunk/include/llvm/ADT/StringExtras.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringExtras.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringExtras.h (original) +++ llvm/trunk/include/llvm/ADT/StringExtras.h Mon May 5 13:30:58 2008 @@ -126,7 +126,7 @@ static inline bool StringsEqualNoCase(const std::string &LHS, const std::string &RHS) { if (LHS.size() != RHS.size()) return false; - for (unsigned i = 0, e = LHS.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(LHS.size()); i != e; ++i) if (tolower(LHS[i]) != tolower(RHS[i])) return false; return true; } @@ -135,7 +135,7 @@ /// case. static inline bool StringsEqualNoCase(const std::string &LHS, const char *RHS) { - for (unsigned i = 0, e = LHS.size(); i != e; ++i) { + for (unsigned i = 0, e = static_cast(LHS.size()); i != e; ++i) { if (RHS[i] == 0) return false; // RHS too short. if (tolower(LHS[i]) != tolower(RHS[i])) return false; } Modified: llvm/trunk/include/llvm/ADT/StringMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringMap.h (original) +++ llvm/trunk/include/llvm/ADT/StringMap.h Mon May 5 13:30:58 2008 @@ -153,13 +153,14 @@ static StringMapEntry *Create(const char *KeyStart, const char *KeyEnd, AllocatorTy &Allocator, InitType InitVal) { - unsigned KeyLength = KeyEnd-KeyStart; + unsigned KeyLength = static_cast(KeyEnd-KeyStart); // Okay, the item doesn't already exist, and 'Bucket' is the bucket to fill // in. Allocate a new item with space for the string at the end and a null // terminator. - unsigned AllocSize = sizeof(StringMapEntry)+KeyLength+1; + unsigned AllocSize = static_cast(sizeof(StringMapEntry))+ + KeyLength+1; unsigned Alignment = alignof(); StringMapEntry *NewItem = @@ -236,9 +237,9 @@ AllocatorTy Allocator; typedef StringMapEntry MapEntryTy; public: - StringMap() : StringMapImpl(sizeof(MapEntryTy)) {} + StringMap() : StringMapImpl(static_cast(sizeof(MapEntryTy))) {} explicit StringMap(unsigned InitialSize) - : StringMapImpl(InitialSize, sizeof(MapEntryTy)) {} + : StringMapImpl(InitialSize, static_cast(sizeof(MapEntryTy))) {} AllocatorTy &getAllocator() { return Allocator; } const AllocatorTy &getAllocator() const { return Allocator; } Modified: llvm/trunk/include/llvm/ADT/UniqueVector.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/UniqueVector.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/UniqueVector.h (original) +++ llvm/trunk/include/llvm/ADT/UniqueVector.h Mon May 5 13:30:58 2008 @@ -41,7 +41,7 @@ if (Val) return Val; // Compute ID for entry. - Val = Vector.size() + 1; + Val = static_cast(Vector.size()) + 1; // Insert in vector. Vector.push_back(Entry); Modified: llvm/trunk/include/llvm/Analysis/AliasSetTracker.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/AliasSetTracker.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/AliasSetTracker.h (original) +++ llvm/trunk/include/llvm/Analysis/AliasSetTracker.h Mon May 5 13:30:58 2008 @@ -232,7 +232,7 @@ bool KnownMustAlias = false); void addCallSite(CallSite CS, AliasAnalysis &AA); void removeCallSite(CallSite CS) { - for (unsigned i = 0, e = CallSites.size(); i != e; ++i) + for (size_t i = 0, e = CallSites.size(); i != e; ++i) if (CallSites[i].getInstruction() == CS.getInstruction()) { CallSites[i] = CallSites.back(); CallSites.pop_back(); Modified: llvm/trunk/include/llvm/Analysis/CallGraph.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CallGraph.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/CallGraph.h (original) +++ llvm/trunk/include/llvm/Analysis/CallGraph.h Mon May 5 13:30:58 2008 @@ -191,7 +191,7 @@ inline const_iterator begin() const { return CalledFunctions.begin(); } inline const_iterator end() const { return CalledFunctions.end(); } inline bool empty() const { return CalledFunctions.empty(); } - inline unsigned size() const { return CalledFunctions.size(); } + inline unsigned size() const { return (unsigned)CalledFunctions.size(); } // Subscripting operator - Return the i'th called function... // Modified: llvm/trunk/include/llvm/Analysis/DominatorInternals.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DominatorInternals.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DominatorInternals.h (original) +++ llvm/trunk/include/llvm/Analysis/DominatorInternals.h Mon May 5 13:30:58 2008 @@ -248,7 +248,8 @@ // Step #1: Number blocks in depth-first order and initialize variables used // in later stages of the algorithm. - for (unsigned i = 0, e = DT.Roots.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(DT.Roots.size()); + i != e; ++i) N = DFSPass(DT, DT.Roots[i], N); // it might be that some blocks did not get a DFS number (e.g., blocks of Modified: llvm/trunk/include/llvm/Analysis/Dominators.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Dominators.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/Dominators.h (original) +++ llvm/trunk/include/llvm/Analysis/Dominators.h Mon May 5 13:30:58 2008 @@ -237,7 +237,7 @@ bool NewBBDominatesNewBBSucc = true; { typename GraphT::NodeType* OnePred = PredBlocks[0]; - unsigned i = 1, e = PredBlocks.size(); + size_t i = 1, e = PredBlocks.size(); for (i = 1; !DT.isReachableFromEntry(OnePred); ++i) { assert(i != e && "Didn't find reachable pred?"); OnePred = PredBlocks[i]; @@ -567,7 +567,7 @@ SmallVector*, typename DomTreeNodeBase::iterator>, 32> WorkStack; - for (unsigned i = 0, e = this->Roots.size(); i != e; ++i) { + for (unsigned i = 0, e = (unsigned)this->Roots.size(); i != e; ++i) { DomTreeNodeBase *ThisRoot = getNode(this->Roots[i]); WorkStack.push_back(std::make_pair(ThisRoot, ThisRoot->begin())); ThisRoot->DFSNumIn = DFSNum++; Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfo.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Mon May 5 13:30:58 2008 @@ -80,7 +80,7 @@ /// Loop ctor - This creates an empty loop. LoopBase() : ParentLoop(0) {} ~LoopBase() { - for (unsigned i = 0, e = SubLoops.size(); i != e; ++i) + for (size_t i = 0, e = SubLoops.size(); i != e; ++i) delete SubLoops[i]; } @@ -847,7 +847,8 @@ "This loop should not be inserted here!"); // Check to see if it belongs in a child loop... - for (unsigned i = 0, e = Parent->SubLoops.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(Parent->SubLoops.size()); + i != e; ++i) if (Parent->SubLoops[i]->contains(LHeader)) { InsertLoopInto(L, Parent->SubLoops[i]); return; Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h Mon May 5 13:30:58 2008 @@ -229,7 +229,7 @@ ~SCEVCommutativeExpr(); public: - unsigned getNumOperands() const { return Operands.size(); } + unsigned getNumOperands() const { return (unsigned)Operands.size(); } const SCEVHandle &getOperand(unsigned i) const { assert(i < Operands.size() && "Operand index out of range!"); return Operands[i]; @@ -387,7 +387,7 @@ SCEVAddRecExpr(const std::vector &ops, const Loop *l) : SCEV(scAddRecExpr), Operands(ops), L(l) { - for (unsigned i = 0, e = Operands.size(); i != e; ++i) + for (size_t i = 0, e = Operands.size(); i != e; ++i) assert(Operands[i]->isLoopInvariant(l) && "Operands of AddRec must be loop-invariant!"); } @@ -397,7 +397,7 @@ op_iterator op_begin() const { return Operands.begin(); } op_iterator op_end() const { return Operands.end(); } - unsigned getNumOperands() const { return Operands.size(); } + unsigned getNumOperands() const { return (unsigned)Operands.size(); } const SCEVHandle &getOperand(unsigned i) const { return Operands[i]; } const SCEVHandle &getStart() const { return Operands[0]; } const Loop *getLoop() const { return L; } Modified: llvm/trunk/include/llvm/Bitcode/Archive.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Archive.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/Archive.h (original) +++ llvm/trunk/include/llvm/Bitcode/Archive.h Mon May 5 13:30:58 2008 @@ -254,7 +254,7 @@ inline reverse_iterator rend () { return members.rend(); } inline const_reverse_iterator rend () const { return members.rend(); } - inline unsigned size() const { return members.size(); } + inline size_t size() const { return members.size(); } inline bool empty() const { return members.empty(); } inline const ArchiveMember& front() const { return members.front(); } inline ArchiveMember& front() { return members.front(); } Modified: llvm/trunk/include/llvm/Bitcode/BitCodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitCodes.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitCodes.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitCodes.h Mon May 5 13:30:58 2008 @@ -165,7 +165,9 @@ void addRef() { ++RefCount; } void dropRef() { if (--RefCount == 0) delete this; } - unsigned getNumOperandInfos() const { return OperandList.size(); } + unsigned getNumOperandInfos() const { + return static_cast(OperandList.size()); + } const BitCodeAbbrevOp &getOperandInfo(unsigned N) const { return OperandList[N]; } Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamReader.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitstreamReader.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Mon May 5 13:30:58 2008 @@ -85,12 +85,15 @@ ~BitstreamReader() { // Abbrevs could still exist if the stream was broken. If so, don't leak // them. - for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(CurAbbrevs.size()); + i != e; ++i) CurAbbrevs[i]->dropRef(); - for (unsigned S = 0, e = BlockScope.size(); S != e; ++S) { + for (unsigned S = 0, e = static_cast(BlockScope.size()); + S != e; ++S) { std::vector &Abbrevs = BlockScope[S].PrevAbbrevs; - for (unsigned i = 0, e = Abbrevs.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(Abbrevs.size()); + i != e; ++i) Abbrevs[i]->dropRef(); } @@ -98,7 +101,8 @@ while (!BlockInfoRecords.empty()) { BlockInfo &Info = BlockInfoRecords.back(); // Free blockinfo abbrev info. - for (unsigned i = 0, e = Info.Abbrevs.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(Info.Abbrevs.size()); + i != e; ++i) Info.Abbrevs[i]->dropRef(); BlockInfoRecords.pop_back(); } @@ -127,7 +131,7 @@ // Skip over any bits that are already consumed. if (WordBitNo) { NextChar -= 4; - Read(WordBitNo); + Read(static_cast(WordBitNo)); } } @@ -237,7 +241,8 @@ if (!BlockInfoRecords.empty() && BlockInfoRecords.back().BlockID == BlockID) return &BlockInfoRecords.back(); - for (unsigned i = 0, e = BlockInfoRecords.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(BlockInfoRecords.size()); + i != e; ++i) if (BlockInfoRecords[i].BlockID == BlockID) return &BlockInfoRecords[i]; return 0; @@ -282,7 +287,8 @@ // Add the abbrevs specific to this block to the CurAbbrevs list. if (BlockInfo *Info = getBlockInfo(BlockID)) { - for (unsigned i = 0, e = Info->Abbrevs.size(); i != e; ++i) { + for (unsigned i = 0, e = static_cast(Info->Abbrevs.size()); + i != e; ++i) { CurAbbrevs.push_back(Info->Abbrevs[i]); CurAbbrevs.back()->addRef(); } @@ -317,7 +323,8 @@ CurCodeSize = BlockScope.back().PrevCodeSize; // Delete abbrevs from popped scope. - for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(CurAbbrevs.size()); + i != e; ++i) CurAbbrevs[i]->dropRef(); BlockScope.back().PrevAbbrevs.swap(CurAbbrevs); Modified: llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h Mon May 5 13:30:58 2008 @@ -70,7 +70,8 @@ while (!BlockInfoRecords.empty()) { BlockInfo &Info = BlockInfoRecords.back(); // Free blockinfo abbrev info. - for (unsigned i = 0, e = Info.Abbrevs.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(Info.Abbrevs.size()); + i != e; ++i) Info.Abbrevs[i]->dropRef(); BlockInfoRecords.pop_back(); } @@ -167,7 +168,8 @@ if (!BlockInfoRecords.empty() && BlockInfoRecords.back().BlockID == BlockID) return &BlockInfoRecords.back(); - for (unsigned i = 0, e = BlockInfoRecords.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(BlockInfoRecords.size()); + i != e; ++i) if (BlockInfoRecords[i].BlockID == BlockID) return &BlockInfoRecords[i]; return 0; @@ -181,7 +183,7 @@ EmitVBR(CodeLen, bitc::CodeLenWidth); FlushToWord(); - unsigned BlockSizeWordLoc = Out.size(); + unsigned BlockSizeWordLoc = static_cast(Out.size()); unsigned OldCodeSize = CurCodeSize; // Emit a placeholder, which will be replaced when the block is popped. @@ -197,7 +199,8 @@ // If there is a blockinfo for this BlockID, add all the predefined abbrevs // to the abbrev list. if (BlockInfo *Info = getBlockInfo(BlockID)) { - for (unsigned i = 0, e = Info->Abbrevs.size(); i != e; ++i) { + for (unsigned i = 0, e = static_cast(Info->Abbrevs.size()); + i != e; ++i) { CurAbbrevs.push_back(Info->Abbrevs[i]); Info->Abbrevs[i]->addRef(); } @@ -208,7 +211,8 @@ assert(!BlockScope.empty() && "Block scope imbalance!"); // Delete all abbrevs. - for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(CurAbbrevs.size()); + i != e; ++i) CurAbbrevs[i]->dropRef(); const Block &B = BlockScope.back(); @@ -219,7 +223,7 @@ FlushToWord(); // Compute the size of the block, in words, not counting the size field. - unsigned SizeInWords = Out.size()/4-B.StartSizeWord - 1; + unsigned SizeInWords= static_cast(Out.size())/4-B.StartSizeWord-1; unsigned ByteNo = B.StartSizeWord*4; // Update the block size field in the header of this sub-block. @@ -283,7 +287,8 @@ Vals.insert(Vals.begin(), Code); unsigned RecordIdx = 0; - for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) { + for (unsigned i = 0, e = static_cast(Abbv->getNumOperandInfos()); + i != e; ++i) { const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); if (Op.isLiteral() || Op.getEncoding() != BitCodeAbbrevOp::Array) { assert(RecordIdx < Vals.size() && "Invalid abbrev/record"); @@ -295,7 +300,7 @@ const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i); // Emit a vbr6 to indicate the number of elements present. - EmitVBR(Vals.size()-RecordIdx, 6); + EmitVBR(static_cast(Vals.size()-RecordIdx), 6); // Emit each field. for (; RecordIdx != Vals.size(); ++RecordIdx) @@ -308,8 +313,8 @@ // form. EmitCode(bitc::UNABBREV_RECORD); EmitVBR(Code, 6); - EmitVBR(Vals.size(), 6); - for (unsigned i = 0, e = Vals.size(); i != e; ++i) + EmitVBR(static_cast(Vals.size()), 6); + for (unsigned i = 0, e = static_cast(Vals.size()); i != e; ++i) EmitVBR64(Vals[i], 6); } } @@ -323,7 +328,8 @@ void EncodeAbbrev(BitCodeAbbrev *Abbv) { EmitCode(bitc::DEFINE_ABBREV); EmitVBR(Abbv->getNumOperandInfos(), 5); - for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) { + for (unsigned i = 0, e = static_cast(Abbv->getNumOperandInfos()); + i != e; ++i) { const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); Emit(Op.isLiteral(), 1); if (Op.isLiteral()) { @@ -343,7 +349,8 @@ // Emit the abbreviation as a record. EncodeAbbrev(Abbv); CurAbbrevs.push_back(Abbv); - return CurAbbrevs.size()-1+bitc::FIRST_APPLICATION_ABBREV; + return static_cast(CurAbbrevs.size())-1 + + bitc::FIRST_APPLICATION_ABBREV; } //===--------------------------------------------------------------------===// Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Mon May 5 13:30:58 2008 @@ -143,7 +143,7 @@ bool containsOneValue() const { return valnos.size() == 1; } - unsigned getNumValNums() const { return valnos.size(); } + unsigned getNumValNums() const { return (unsigned)valnos.size(); } /// getValNumInfo - Returns pointer to the specified val#. /// @@ -168,14 +168,15 @@ VNInfo *getNextValue(unsigned MIIdx, MachineInstr *CopyMI, BumpPtrAllocator &VNInfoAllocator) { #ifdef __GNUC__ - unsigned Alignment = __alignof__(VNInfo); + unsigned Alignment = (unsigned)__alignof__(VNInfo); #else // FIXME: ugly. unsigned Alignment = 8; #endif - VNInfo *VNI= static_cast(VNInfoAllocator.Allocate(sizeof(VNInfo), - Alignment)); - new (VNI) VNInfo(valnos.size(), MIIdx, CopyMI); + VNInfo *VNI = + static_cast(VNInfoAllocator.Allocate((unsigned)sizeof(VNInfo), + Alignment)); + new (VNI) VNInfo((unsigned)valnos.size(), MIIdx, CopyMI); valnos.push_back(VNI); return VNI; } @@ -196,7 +197,8 @@ /// addKills - Add a number of kills into the VNInfo kill vector. If this /// interval is live at a kill point, then the kill is not added. void addKills(VNInfo *VNI, const SmallVector &kills) { - for (unsigned i = 0, e = kills.size(); i != e; ++i) { + for (unsigned i = 0, e = static_cast(kills.size()); + i != e; ++i) { unsigned KillIdx = kills[i]; if (!liveBeforeAndAt(KillIdx)) { SmallVector::iterator Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Mon May 5 13:30:58 2008 @@ -131,7 +131,7 @@ const_iterator end() const { return r2iMap_.end(); } iterator begin() { return r2iMap_.begin(); } iterator end() { return r2iMap_.end(); } - unsigned getNumIntervals() const { return r2iMap_.size(); } + unsigned getNumIntervals() const { return (unsigned)r2iMap_.size(); } LiveInterval &getInterval(unsigned reg) { Reg2IntervalMap::iterator I = r2iMap_.find(reg); Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Mon May 5 13:30:58 2008 @@ -108,7 +108,7 @@ typedef std::reverse_iterator const_reverse_iterator; typedef std::reverse_iterator reverse_iterator; - unsigned size() const { return Insts.size(); } + unsigned size() const { return (unsigned)Insts.size(); } bool empty() const { return Insts.empty(); } MachineInstr& front() { return Insts.front(); } @@ -149,7 +149,9 @@ { return Predecessors.rend(); } const_pred_reverse_iterator pred_rend() const { return Predecessors.rend(); } - unsigned pred_size() const { return Predecessors.size(); } + unsigned pred_size() const { + return (unsigned)Predecessors.size(); + } bool pred_empty() const { return Predecessors.empty(); } succ_iterator succ_begin() { return Successors.begin(); } const_succ_iterator succ_begin() const { return Successors.begin(); } @@ -163,7 +165,9 @@ { return Successors.rend(); } const_succ_reverse_iterator succ_rend() const { return Successors.rend(); } - unsigned succ_size() const { return Successors.size(); } + unsigned succ_size() const { + return (unsigned)Successors.size(); + } bool succ_empty() const { return Successors.empty(); } // LiveIn management methods. Modified: llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h Mon May 5 13:30:58 2008 @@ -168,7 +168,8 @@ /// emitString - This callback is invoked when a String needs to be /// written to the output stream. void emitString(const std::string &String) { - for (unsigned i = 0, N = String.size(); i < N; ++i) { + for (unsigned i = 0, N = static_cast(String.size()); + i < N; ++i) { unsigned char C = String[i]; emitByte(C); } Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Mon May 5 13:30:58 2008 @@ -193,7 +193,7 @@ /// getObjectIndexEnd - Return one past the maximum frame object index... /// - int getObjectIndexEnd() const { return Objects.size()-NumFixedObjects; } + int getObjectIndexEnd() const { return (int)Objects.size()-NumFixedObjects; } /// getObjectSize - Return the size of the specified object /// @@ -311,7 +311,7 @@ int CreateStackObject(uint64_t Size, unsigned Alignment) { assert(Size != 0 && "Cannot allocate zero size stack objects!"); Objects.push_back(StackObject(Size, Alignment, -1)); - return Objects.size()-NumFixedObjects-1; + return (int)Objects.size()-NumFixedObjects-1; } /// RemoveStackObject - Remove or mark dead a statically sized stack object. @@ -333,7 +333,7 @@ int CreateVariableSizedObject() { HasVarSizedObjects = true; Objects.push_back(StackObject(0, 1, -1)); - return Objects.size()-NumFixedObjects-1; + return (int)Objects.size()-NumFixedObjects-1; } /// getCalleeSavedInfo - Returns a reference to call saved info vector for the Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFunction.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h Mon May 5 13:30:58 2008 @@ -165,7 +165,7 @@ /// getNumBlockIDs - Return the number of MBB ID's allocated. /// - unsigned getNumBlockIDs() const { return MBBNumbering.size(); } + unsigned getNumBlockIDs() const { return (unsigned)MBBNumbering.size(); } /// RenumberBlocks - This discards all of the MachineBasicBlock numbers and /// recomputes them. This guarantees that the MBB numbers are sequential, @@ -238,7 +238,7 @@ reverse_iterator rend () { return BasicBlocks.rend(); } const_reverse_iterator rend () const { return BasicBlocks.rend(); } - unsigned size() const { return BasicBlocks.size(); } + unsigned size() const { return (unsigned)BasicBlocks.size();} bool empty() const { return BasicBlocks.empty(); } const MachineBasicBlock &front() const { return BasicBlocks.front(); } MachineBasicBlock &front() { return BasicBlocks.front(); } @@ -254,7 +254,7 @@ /// unsigned addToMBBNumbering(MachineBasicBlock *MBB) { MBBNumbering.push_back(MBB); - return MBBNumbering.size()-1; + return (unsigned)MBBNumbering.size()-1; } /// removeFromMBBNumbering - Remove the specific machine basic block from our Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstr.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineInstr.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineInstr.h Mon May 5 13:30:58 2008 @@ -82,7 +82,7 @@ /// Access to explicit operands of the instruction. /// - unsigned getNumOperands() const { return Operands.size(); } + unsigned getNumOperands() const { return (unsigned)Operands.size(); } const MachineOperand& getOperand(unsigned i) const { assert(i < getNumOperands() && "getOperand() out of range!"); @@ -98,7 +98,7 @@ unsigned getNumExplicitOperands() const; /// Access to memory operands of the instruction - unsigned getNumMemOperands() const { return MemOperands.size(); } + unsigned getNumMemOperands() const { return (unsigned)MemOperands.size(); } const MachineMemOperand& getMemOperand(unsigned i) const { assert(i < getNumMemOperands() && "getMemOperand() out of range!"); Modified: llvm/trunk/include/llvm/CodeGen/MachineJumpTableInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineJumpTableInfo.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineJumpTableInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineJumpTableInfo.h Mon May 5 13:30:58 2008 @@ -70,9 +70,9 @@ bool ReplaceMBBInJumpTables(MachineBasicBlock *Old, MachineBasicBlock *New) { assert(Old != New && "Not making a change?"); bool MadeChange = false; - for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) { + for (size_t i = 0, e = JumpTables.size(); i != e; ++i) { MachineJumpTableEntry &JTE = JumpTables[i]; - for (unsigned j = 0, e = JTE.MBBs.size(); j != e; ++j) + for (size_t j = 0, e = JTE.MBBs.size(); j != e; ++j) if (JTE.MBBs[j] == Old) { JTE.MBBs[j] = New; MadeChange = true; Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Mon May 5 13:30:58 2008 @@ -1100,7 +1100,7 @@ /// NextLabelID - Return the next unique label id. /// unsigned NextLabelID() { - unsigned ID = LabelIDList.size() + 1; + unsigned ID = (unsigned)LabelIDList.size() + 1; LabelIDList.push_back(ID); return ID; } Modified: llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h Mon May 5 13:30:58 2008 @@ -152,7 +152,7 @@ /// getLastVirtReg - Return the highest currently assigned virtual register. /// unsigned getLastVirtReg() const { - return VRegInfo.size()+TargetRegisterInfo::FirstVirtualRegister-1; + return (unsigned)VRegInfo.size()+TargetRegisterInfo::FirstVirtualRegister-1; } Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Mon May 5 13:30:58 2008 @@ -143,7 +143,7 @@ /// not already. This returns true if this is a new pred. bool addPred(SUnit *N, bool isCtrl, bool isSpecial, unsigned PhyReg = 0, int Cost = 1) { - for (unsigned i = 0, e = Preds.size(); i != e; ++i) + for (unsigned i = 0, e = (unsigned)Preds.size(); i != e; ++i) if (Preds[i].Dep == N && Preds[i].isCtrl == isCtrl && Preds[i].isSpecial == isSpecial) return false; @@ -189,14 +189,14 @@ } bool isPred(SUnit *N) { - for (unsigned i = 0, e = Preds.size(); i != e; ++i) + for (unsigned i = 0, e = (unsigned)Preds.size(); i != e; ++i) if (Preds[i].Dep == N) return true; return false; } bool isSucc(SUnit *N) { - for (unsigned i = 0, e = Succs.size(); i != e; ++i) + for (unsigned i = 0, e = (unsigned)Succs.size(); i != e; ++i) if (Succs[i].Dep == N) return true; return false; @@ -293,7 +293,7 @@ /// NewSUnit - Creates a new SUnit and return a ptr to it. /// SUnit *NewSUnit(SDNode *N) { - SUnits.push_back(SUnit(N, SUnits.size())); + SUnits.push_back(SUnit(N, (unsigned)SUnits.size())); return &SUnits.back(); } @@ -452,7 +452,7 @@ static SUnitIterator begin(SUnit *N) { return SUnitIterator(N, 0); } static SUnitIterator end (SUnit *N) { - return SUnitIterator(N, N->Preds.size()); + return SUnitIterator(N, (unsigned)N->Preds.size()); } unsigned getOperand() const { return Operand; } Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Mon May 5 13:30:58 2008 @@ -163,7 +163,7 @@ return getVTList(VT1, VT2, VT3).VTs; } const MVT::ValueType *getNodeValueTypes(std::vector &VTList) { - return getVTList(&VTList[0], VTList.size()).VTs; + return getVTList(&VTList[0], (unsigned)VTList.size()).VTs; } @@ -287,7 +287,7 @@ Ops.push_back(Op2); Ops.push_back(InFlag); return getNode(ISD::CALLSEQ_END, NodeTys, &Ops[0], - Ops.size() - (InFlag.Val == 0 ? 1 : 0)); + (unsigned)Ops.size() - (InFlag.Val == 0 ? 1 : 0)); } /// getNode - Gets or creates the specified node. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Mon May 5 13:30:58 2008 @@ -972,12 +972,12 @@ SDOperandPtr(SDUse * use_ptr) { ptr = &use_ptr->getSDOperand(); - object_size = sizeof(SDUse); + object_size = (int)sizeof(SDUse); } SDOperandPtr(const SDOperand * op_ptr) { ptr = op_ptr; - object_size = sizeof(SDOperand); + object_size = (int)sizeof(SDOperand); } const SDOperand operator *() { return *ptr; } @@ -1107,7 +1107,7 @@ /// getOperandNum - Retrive a number of a current operand. unsigned getOperandNum() const { assert(Op && "Cannot dereference end iterator!"); - return (Op - Op->getUser()->OperandList); + return (unsigned)(Op - Op->getUser()->OperandList); } /// Retrieve a reference to the current operand. Modified: llvm/trunk/include/llvm/Debugger/Debugger.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Debugger/Debugger.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Debugger/Debugger.h (original) +++ llvm/trunk/include/llvm/Debugger/Debugger.h Mon May 5 13:30:58 2008 @@ -67,7 +67,9 @@ void setProgramArguments(It I, It E) { ProgramArguments.assign(I, E); } - unsigned getNumProgramArguments() const { return ProgramArguments.size(); } + unsigned getNumProgramArguments() const { + return static_cast(ProgramArguments.size()); + } const std::string &getProgramArgument(unsigned i) const { return ProgramArguments[i]; } Modified: llvm/trunk/include/llvm/Debugger/SourceFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Debugger/SourceFile.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Debugger/SourceFile.h (original) +++ llvm/trunk/include/llvm/Debugger/SourceFile.h Mon May 5 13:30:58 2008 @@ -74,7 +74,7 @@ /// unsigned getNumLines() const { if (LineOffset.empty()) calculateLineOffsets(); - return LineOffset.size(); + return static_cast(LineOffset.size()); } private: Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Mon May 5 13:30:58 2008 @@ -397,8 +397,7 @@ // This argument ensures that we have an iterator we can // do arithmetic on in constant time std::random_access_iterator_tag) { - typename std::iterator_traits::difference_type NumIdx = - std::distance(IdxBegin, IdxEnd); + unsigned NumIdx = static_cast(std::distance(IdxBegin, IdxEnd)); if (NumIdx > 0) { // This requires that the itoerator points to contiguous memory. @@ -430,8 +429,7 @@ // have an iterator we can do // arithmetic on in constant time std::random_access_iterator_tag) { - typename std::iterator_traits::difference_type NumIdx = - std::distance(IdxBegin, IdxEnd); + unsigned NumIdx = static_cast(std::distance(IdxBegin, IdxEnd)); if (NumIdx > 0) { // This requires that the iterator points to contiguous memory. @@ -961,7 +959,8 @@ Instruction *InsertBefore = 0) { return new(1) CallInst(F, Name, InsertBefore); } - static CallInst *Create(Value *F, const std::string &Name, BasicBlock *InsertAtEnd) { + static CallInst *Create(Value *F, const std::string &Name, + BasicBlock *InsertAtEnd) { return new(1) CallInst(F, Name, InsertAtEnd); } Modified: llvm/trunk/include/llvm/ParameterAttributes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ParameterAttributes.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/ParameterAttributes.h (original) +++ llvm/trunk/include/llvm/ParameterAttributes.h Mon May 5 13:30:58 2008 @@ -124,7 +124,7 @@ template static PAListPtr get(const Iter &I, const Iter &E) { if (I == E) return PAListPtr(); // Empty list. - return get(&*I, E-I); + return get(&*I, static_cast(E-I)); } /// addAttr - Add the specified attribute at the specified index to this Modified: llvm/trunk/include/llvm/PassManagers.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassManagers.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/PassManagers.h (original) +++ llvm/trunk/include/llvm/PassManagers.h Mon May 5 13:30:58 2008 @@ -146,7 +146,7 @@ public: virtual unsigned getNumContainedManagers() { - return PassManagers.size(); + return (unsigned)PassManagers.size(); } /// Schedule pass P for execution. Make sure that passes required by @@ -306,7 +306,7 @@ const std::vector &Set) const; virtual unsigned getNumContainedPasses() { - return PassVector.size(); + return (unsigned)PassVector.size(); } virtual PassManagerType getPassManagerType() const { Modified: llvm/trunk/include/llvm/Support/AlignOf.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/AlignOf.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/AlignOf.h (original) +++ llvm/trunk/include/llvm/Support/AlignOf.h Mon May 5 13:30:58 2008 @@ -34,7 +34,8 @@ /// compile-time constant (e.g., for template instantiation). template struct AlignOf { - enum { Alignment = sizeof(AlignmentCalcImpl) - sizeof(T) }; + enum { Alignment = + static_cast(sizeof(AlignmentCalcImpl) - sizeof(T)) }; enum { Alignment_GreaterEqual_2Bytes = Alignment >= 2 ? 1 : 0 }; enum { Alignment_GreaterEqual_4Bytes = Alignment >= 4 ? 1 : 0 }; Modified: llvm/trunk/include/llvm/Support/Allocator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Allocator.h (original) +++ llvm/trunk/include/llvm/Support/Allocator.h Mon May 5 13:30:58 2008 @@ -25,7 +25,7 @@ ~MallocAllocator() {} void Reset() {} - void *Allocate(unsigned Size, unsigned Alignment) { return malloc(Size); } + void *Allocate(size_t Size, size_t Alignment) { return malloc(Size); } template void *Allocate() { return reinterpret_cast(malloc(sizeof(T))); } @@ -45,7 +45,7 @@ ~BumpPtrAllocator(); void Reset(); - void *Allocate(unsigned Size, unsigned Alignment); + void *Allocate(size_t Size, size_t Alignment); template void *Allocate() { Modified: llvm/trunk/include/llvm/Support/CommandLine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CommandLine.h (original) +++ llvm/trunk/include/llvm/Support/CommandLine.h Mon May 5 13:30:58 2008 @@ -219,12 +219,12 @@ Option *getNextRegisteredOption() const { return NextRegistered; } // Return the width of the option tag for printing... - virtual unsigned getOptionWidth() const = 0; + virtual size_t getOptionWidth() const = 0; // printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // - virtual void printOptionInfo(unsigned GlobalWidth) const = 0; + virtual void printOptionInfo(size_t GlobalWidth) const = 0; virtual void getExtraOptionNames(std::vector &OptionNames) {} @@ -334,7 +334,8 @@ template void apply(Opt &O) const { - for (unsigned i = 0, e = Values.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(Values.size()); + i != e; ++i) O.getParser().addLiteralOption(Values[i].first, Values[i].second.first, Values[i].second.second); } @@ -378,12 +379,12 @@ virtual const char *getDescription(unsigned N) const = 0; // Return the width of the option tag for printing... - virtual unsigned getOptionWidth(const Option &O) const; + virtual size_t getOptionWidth(const Option &O) const; // printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // - virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const; + virtual void printOptionInfo(const Option &O, size_t GlobalWidth) const; void initialize(Option &O) { // All of the modifiers for the option have been processed by now, so the @@ -459,7 +460,8 @@ else ArgVal = ArgName; - for (unsigned i = 0, e = Values.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(Values.size()); + i != e; ++i) if (ArgVal == Values[i].first) { V = Values[i].second.first; return false; @@ -502,12 +504,12 @@ void initialize(Option &O) {} // Return the width of the option tag for printing... - unsigned getOptionWidth(const Option &O) const; + size_t getOptionWidth(const Option &O) const; // printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // - void printOptionInfo(const Option &O, unsigned GlobalWidth) const; + void printOptionInfo(const Option &O, size_t GlobalWidth) const; // getValueName - Overload in subclass to provide a better default value. virtual const char *getValueName() const { return "value"; } @@ -815,8 +817,8 @@ } // Forward printing stuff to the parser... - virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);} - virtual void printOptionInfo(unsigned GlobalWidth) const { + virtual size_t getOptionWidth() const {return Parser.getOptionWidth(*this);} + virtual void printOptionInfo(size_t GlobalWidth) const { Parser.printOptionInfo(*this, GlobalWidth); } @@ -981,8 +983,8 @@ } // Forward printing stuff to the parser... - virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);} - virtual void printOptionInfo(unsigned GlobalWidth) const { + virtual size_t getOptionWidth() const {return Parser.getOptionWidth(*this);} + virtual void printOptionInfo(size_t GlobalWidth) const { Parser.printOptionInfo(*this, GlobalWidth); } @@ -1167,8 +1169,8 @@ } // Forward printing stuff to the parser... - virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);} - virtual void printOptionInfo(unsigned GlobalWidth) const { + virtual size_t getOptionWidth() const {return Parser.getOptionWidth(*this);} + virtual void printOptionInfo(size_t GlobalWidth) const { Parser.printOptionInfo(*this, GlobalWidth); } @@ -1260,8 +1262,8 @@ return AliasFor->handleOccurrence(pos, AliasFor->ArgStr, Arg); } // Handle printing stuff... - virtual unsigned getOptionWidth() const; - virtual void printOptionInfo(unsigned GlobalWidth) const; + virtual size_t getOptionWidth() const; + virtual void printOptionInfo(size_t GlobalWidth) const; void done() { if (!hasArgStr()) Modified: llvm/trunk/include/llvm/Support/GraphWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GraphWriter.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/GraphWriter.h (original) +++ llvm/trunk/include/llvm/Support/GraphWriter.h Mon May 5 13:30:58 2008 @@ -175,8 +175,8 @@ child_iterator TargetIt = DOTTraits::getEdgeTarget(Node, EI); // Figure out which edge this targets... - unsigned Offset = std::distance(GTraits::child_begin(TargetNode), - TargetIt); + unsigned Offset = + (unsigned)std::distance(GTraits::child_begin(TargetNode), TargetIt); DestPort = static_cast(Offset); } Modified: llvm/trunk/include/llvm/Support/MemoryBuffer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MemoryBuffer.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/MemoryBuffer.h (original) +++ llvm/trunk/include/llvm/Support/MemoryBuffer.h Mon May 5 13:30:58 2008 @@ -40,7 +40,7 @@ const char *getBufferStart() const { return BufferStart; } const char *getBufferEnd() const { return BufferEnd; } - unsigned getBufferSize() const { return BufferEnd-BufferStart; } + size_t getBufferSize() const { return BufferEnd-BufferStart; } /// getBufferIdentifier - Return an identifier for this buffer, typically the /// filename it was read from. @@ -71,14 +71,14 @@ /// is completely initialized to zeros. Note that the caller should /// initialize the memory allocated by this method. The memory is owned by /// the MemoryBuffer object. - static MemoryBuffer *getNewMemBuffer(unsigned Size, + static MemoryBuffer *getNewMemBuffer(size_t Size, const char *BufferName = ""); /// getNewUninitMemBuffer - Allocate a new MemoryBuffer of the specified size /// that is not initialized. Note that the caller should initialize the /// memory allocated by this method. The memory is owned by the MemoryBuffer /// object. - static MemoryBuffer *getNewUninitMemBuffer(unsigned Size, + static MemoryBuffer *getNewUninitMemBuffer(size_t Size, const char *BufferName = ""); /// getSTDIN - Read all of stdin into a file buffer, and return it. This Modified: llvm/trunk/include/llvm/Support/OutputBuffer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/OutputBuffer.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/OutputBuffer.h (original) +++ llvm/trunk/include/llvm/Support/OutputBuffer.h Mon May 5 13:30:58 2008 @@ -107,8 +107,10 @@ outxword(X); } void outstring(const std::string &S, unsigned Length) { - unsigned len_to_copy = S.length() < Length ? S.length() : Length; - unsigned len_to_fill = S.length() < Length ? Length - S.length() : 0; + unsigned len_to_copy = static_cast(S.length()) < Length + ? static_cast(S.length()) : Length; + unsigned len_to_fill = static_cast(S.length()) < Length + ? Length - static_cast(S.length()) : 0; for (unsigned i = 0; i < len_to_copy; ++i) outbyte(S[i]); Modified: llvm/trunk/include/llvm/System/Path.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Path.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Path.h (original) +++ llvm/trunk/include/llvm/System/Path.h Mon May 5 13:30:58 2008 @@ -207,14 +207,14 @@ /// @returns true if \p this and \p that refer to the same thing. /// @brief Equality Operator bool operator==(const Path &that) const { - return 0 == path.compare(that.path); + return path == that.path; } /// Compares \p this Path with \p that Path for inequality. /// @returns true if \p this and \p that refer to different things. /// @brief Inequality Operator bool operator!=(const Path &that) const { - return 0 != path.compare(that.path); + return path != that.path; } /// Determines if \p this Path is less than \p that Path. This is required @@ -224,7 +224,7 @@ /// @returns true if \p this path is lexicographically less than \p that. /// @brief Less Than Operator bool operator<(const Path& that) const { - return 0 > path.compare(that.path); + return path < that.path; } /// @} @@ -288,7 +288,7 @@ const char *c_str() const { return path.c_str(); } /// size - Return the length in bytes of this path name. - unsigned size() const { return path.size(); } + size_t size() const { return path.size(); } /// empty - Returns true if the path is empty. unsigned empty() const { return path.empty(); } Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Mon May 5 13:30:58 2008 @@ -99,7 +99,7 @@ /// getNumRegs - Return the number of registers in this class. /// - unsigned getNumRegs() const { return RegsEnd-RegsBegin; } + unsigned getNumRegs() const { return (unsigned)(RegsEnd-RegsBegin); } /// getRegister - Return the specified register in the class. /// @@ -465,7 +465,7 @@ regclass_iterator regclass_end() const { return RegClassEnd; } unsigned getNumRegClasses() const { - return regclass_end()-regclass_begin(); + return (unsigned)(regclass_end()-regclass_begin()); } /// getRegClass - Returns the register class associated with the enumeration Modified: llvm/trunk/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/User.h?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/include/llvm/User.h (original) +++ llvm/trunk/include/llvm/User.h Mon May 5 13:30:58 2008 @@ -39,7 +39,7 @@ /// unsigned NumOperands; - void *operator new(size_t s, unsigned) { + void *operator new(size_t s, size_t) { return ::operator new(s); } User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps) Modified: llvm/trunk/lib/Support/Allocator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/lib/Support/Allocator.cpp (original) +++ llvm/trunk/lib/Support/Allocator.cpp Mon May 5 13:30:58 2008 @@ -45,7 +45,7 @@ /// Allocate - Allocate and return at least the specified number of bytes. /// - void *Allocate(unsigned AllocSize, unsigned Alignment, MemRegion **RegPtr) { + void *Allocate(size_t AllocSize, size_t Alignment, MemRegion **RegPtr) { char* Result = (char*) (((uintptr_t) (NextPtr+Alignment-1)) & ~((uintptr_t) Alignment-1)); @@ -113,7 +113,7 @@ TheMemory = MRP; } -void *BumpPtrAllocator::Allocate(unsigned Size, unsigned Align) { +void *BumpPtrAllocator::Allocate(size_t Size, size_t Align) { MemRegion *MRP = (MemRegion*)TheMemory; void *Ptr = MRP->Allocate(Size, Align, &MRP); TheMemory = MRP; Modified: llvm/trunk/lib/Support/CommandLine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/lib/Support/CommandLine.cpp (original) +++ llvm/trunk/lib/Support/CommandLine.cpp Mon May 5 13:30:58 2008 @@ -115,7 +115,7 @@ OptionNames.push_back(O->ArgStr); // Handle named options. - for (unsigned i = 0, e = OptionNames.size(); i != e; ++i) { + for (size_t i = 0, e = OptionNames.size(); i != e; ++i) { // Add argument to the argument map! if (!OptionsMap.insert(std::pair(OptionNames[i], O)).second) { @@ -223,7 +223,7 @@ // see if there options that satisfy the predicate. If we find one, return it, // otherwise return null. // -static Option *getOptionPred(std::string Name, unsigned &Length, +static Option *getOptionPred(std::string Name, size_t &Length, bool (*Pred)(const Option*), std::map &OptionsMap) { @@ -329,7 +329,7 @@ // Parse the value of the environment variable into a "command line" // and hand it off to ParseCommandLineOptions(). ParseCStringVector(newArgv, envValue); - int newArgc = newArgv.size(); + int newArgc = static_cast(newArgv.size()); ParseCommandLineOptions(newArgc, &newArgv[0], Overview, ReadResponseFiles); // Free all the strdup()ed strings. @@ -391,7 +391,7 @@ newArgv.push_back(strdup(argv[0])); ExpandResponseFiles(argc, argv, newArgv); argv = &newArgv[0]; - argc = newArgv.size(); + argc = static_cast(newArgv.size()); } sys::Path progname(argv[0]); @@ -420,7 +420,7 @@ // Calculate how many positional values are _required_. bool UnboundedFound = false; - for (unsigned i = ConsumeAfterOpt != 0, e = PositionalOpts.size(); + for (size_t i = ConsumeAfterOpt != 0, e = PositionalOpts.size(); i != e; ++i) { Option *Opt = PositionalOpts[i]; if (RequiresValue(Opt)) @@ -525,7 +525,7 @@ if (Handler == 0) { std::string RealName(ArgName); if (RealName.size() > 1) { - unsigned Length = 0; + size_t Length = 0; Option *PGOpt = getOptionPred(RealName, Length, isPrefixedOrGrouping, Opts); @@ -627,8 +627,8 @@ } else if (ConsumeAfterOpt == 0) { // Positional args have already been handled if ConsumeAfter is specified... - unsigned ValNo = 0, NumVals = PositionalVals.size(); - for (unsigned i = 0, e = PositionalOpts.size(); i != e; ++i) { + unsigned ValNo = 0, NumVals = static_cast(PositionalVals.size()); + for (size_t i = 0, e = PositionalOpts.size(); i != e; ++i) { if (RequiresValue(PositionalOpts[i])) { ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo].first, PositionalVals[ValNo].second); @@ -662,7 +662,7 @@ } else { assert(ConsumeAfterOpt && NumPositionalRequired <= PositionalVals.size()); unsigned ValNo = 0; - for (unsigned j = 1, e = PositionalOpts.size(); j != e; ++j) + for (size_t j = 1, e = PositionalOpts.size(); j != e; ++j) if (RequiresValue(PositionalOpts[j])) { ErrorParsing |= ProvidePositionalOption(PositionalOpts[j], PositionalVals[ValNo].first, @@ -775,13 +775,13 @@ // // Return the width of the option tag for printing... -unsigned alias::getOptionWidth() const { +size_t alias::getOptionWidth() const { return std::strlen(ArgStr)+6; } // Print out the option for the alias. -void alias::printOptionInfo(unsigned GlobalWidth) const { - unsigned L = std::strlen(ArgStr); +void alias::printOptionInfo(size_t GlobalWidth) const { + size_t L = std::strlen(ArgStr); cout << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - " << HelpStr << "\n"; } @@ -796,8 +796,8 @@ // // Return the width of the option tag for printing... -unsigned basic_parser_impl::getOptionWidth(const Option &O) const { - unsigned Len = std::strlen(O.ArgStr); +size_t basic_parser_impl::getOptionWidth(const Option &O) const { + size_t Len = std::strlen(O.ArgStr); if (const char *ValName = getValueName()) Len += std::strlen(getValueStr(O, ValName))+3; @@ -808,7 +808,7 @@ // to-be-maintained width is specified. // void basic_parser_impl::printOptionInfo(const Option &O, - unsigned GlobalWidth) const { + size_t GlobalWidth) const { cout << " -" << O.ArgStr; if (const char *ValName = getValueName()) @@ -926,16 +926,16 @@ // Return the width of the option tag for printing... -unsigned generic_parser_base::getOptionWidth(const Option &O) const { +size_t generic_parser_base::getOptionWidth(const Option &O) const { if (O.hasArgStr()) { - unsigned Size = std::strlen(O.ArgStr)+6; + size_t Size = std::strlen(O.ArgStr)+6; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) - Size = std::max(Size, (unsigned)std::strlen(getOption(i))+8); + Size = std::max(Size, std::strlen(getOption(i))+8); return Size; } else { - unsigned BaseSize = 0; + size_t BaseSize = 0; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) - BaseSize = std::max(BaseSize, (unsigned)std::strlen(getOption(i))+8); + BaseSize = std::max(BaseSize, std::strlen(getOption(i))+8); return BaseSize; } } @@ -944,14 +944,14 @@ // to-be-maintained width is specified. // void generic_parser_base::printOptionInfo(const Option &O, - unsigned GlobalWidth) const { + size_t GlobalWidth) const { if (O.hasArgStr()) { - unsigned L = std::strlen(O.ArgStr); + size_t L = std::strlen(O.ArgStr); cout << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ') << " - " << O.HelpStr << "\n"; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { - unsigned NumSpaces = GlobalWidth-strlen(getOption(i))-8; + size_t NumSpaces = GlobalWidth-strlen(getOption(i))-8; cout << " =" << getOption(i) << std::string(NumSpaces, ' ') << " - " << getDescription(i) << "\n"; } @@ -959,7 +959,7 @@ if (O.HelpStr[0]) cout << " " << O.HelpStr << "\n"; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { - unsigned L = std::strlen(getOption(i)); + size_t L = std::strlen(getOption(i)); cout << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ') << " - " << getDescription(i) << "\n"; } @@ -974,7 +974,7 @@ namespace { class HelpPrinter { - unsigned MaxArgLen; + size_t MaxArgLen; const Option *EmptyArg; const bool ShowHidden; @@ -1030,7 +1030,7 @@ PositionalOpts[0]->getNumOccurrencesFlag() == ConsumeAfter) CAOpt = PositionalOpts[0]; - for (unsigned i = CAOpt != 0, e = PositionalOpts.size(); i != e; ++i) { + for (size_t i = CAOpt != 0, e = PositionalOpts.size(); i != e; ++i) { if (PositionalOpts[i]->ArgStr[0]) cout << " --" << PositionalOpts[i]->ArgStr; cout << " " << PositionalOpts[i]->HelpStr; @@ -1043,11 +1043,11 @@ // Compute the maximum argument length... MaxArgLen = 0; - for (unsigned i = 0, e = Opts.size(); i != e; ++i) + for (size_t i = 0, e = Opts.size(); i != e; ++i) MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth()); cout << "OPTIONS:\n"; - for (unsigned i = 0, e = Opts.size(); i != e; ++i) + for (size_t i = 0, e = Opts.size(); i != e; ++i) Opts[i].second->printOptionInfo(MaxArgLen); // Print any extra help the user has declared. Modified: llvm/trunk/lib/Support/FileUtilities.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FileUtilities.cpp?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/lib/Support/FileUtilities.cpp (original) +++ llvm/trunk/lib/Support/FileUtilities.cpp Mon May 5 13:30:58 2008 @@ -98,7 +98,8 @@ if (*F1NumEnd == 'D' || *F1NumEnd == 'd') { // Copy string into tmp buffer to replace the 'D' with an 'e'. SmallString<200> StrTmp(F1P, EndOfNumber(F1NumEnd)+1); - StrTmp[F1NumEnd-F1P] = 'e'; // Strange exponential notation! + // Strange exponential notation! + StrTmp[static_cast(F1NumEnd-F1P)] = 'e'; V1 = strtod(&StrTmp[0], const_cast(&F1NumEnd)); F1NumEnd = F1P + (F1NumEnd-&StrTmp[0]); @@ -107,7 +108,8 @@ if (*F2NumEnd == 'D' || *F2NumEnd == 'd') { // Copy string into tmp buffer to replace the 'D' with an 'e'. SmallString<200> StrTmp(F2P, EndOfNumber(F2NumEnd)+1); - StrTmp[F2NumEnd-F2P] = 'e'; // Strange exponential notation! + // Strange exponential notation! + StrTmp[static_cast(F2NumEnd-F2P)] = 'e'; V2 = strtod(&StrTmp[0], const_cast(&F2NumEnd)); F2NumEnd = F2P + (F2NumEnd-&StrTmp[0]); Modified: llvm/trunk/lib/Support/FoldingSet.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FoldingSet.cpp?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/lib/Support/FoldingSet.cpp (original) +++ llvm/trunk/lib/Support/FoldingSet.cpp Mon May 5 13:30:58 2008 @@ -58,7 +58,7 @@ AddInteger(DoubleToBits(D)); } void FoldingSetNodeID::AddString(const std::string &String) { - unsigned Size = String.size(); + unsigned Size = static_cast(String.size()); Bits.push_back(Size); if (!Size) return; @@ -98,7 +98,7 @@ /// lookup the node in the FoldingSetImpl. unsigned FoldingSetNodeID::ComputeHash() const { // This is adapted from SuperFastHash by Paul Hsieh. - unsigned Hash = Bits.size(); + unsigned Hash = static_cast(Bits.size()); for (const unsigned *BP = &Bits[0], *E = BP+Bits.size(); BP != E; ++BP) { unsigned Data = *BP; Hash += Data & 0xFFFF; Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original) +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Mon May 5 13:30:58 2008 @@ -106,7 +106,7 @@ /// that is completely initialized to zeros. Note that the caller should /// initialize the memory allocated by this method. The memory is owned by /// the MemoryBuffer object. -MemoryBuffer *MemoryBuffer::getNewUninitMemBuffer(unsigned Size, +MemoryBuffer *MemoryBuffer::getNewUninitMemBuffer(size_t Size, const char *BufferName) { char *Buf = new char[Size+1]; Buf[Size] = 0; @@ -120,7 +120,7 @@ /// is completely initialized to zeros. Note that the caller should /// initialize the memory allocated by this method. The memory is owned by /// the MemoryBuffer object. -MemoryBuffer *MemoryBuffer::getNewMemBuffer(unsigned Size, +MemoryBuffer *MemoryBuffer::getNewMemBuffer(size_t Size, const char *BufferName) { MemoryBuffer *SB = getNewUninitMemBuffer(Size, BufferName); memset(const_cast(SB->getBufferStart()), 0, Size+1); @@ -214,7 +214,7 @@ SB.reset(MemoryBuffer::getNewUninitMemBuffer(FileSize, Filename)); char *BufPtr = const_cast(SB->getBufferStart()); - unsigned BytesLeft = FileSize; + size_t BytesLeft = FileSize; while (BytesLeft) { ssize_t NumRead = ::read(FD, BufPtr, BytesLeft); if (NumRead != -1) { Modified: llvm/trunk/lib/Support/Statistic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Statistic.cpp?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/lib/Support/Statistic.cpp (original) +++ llvm/trunk/lib/Support/Statistic.cpp Mon May 5 13:30:58 2008 @@ -90,7 +90,7 @@ // Figure out how long the biggest Value and Name fields are. unsigned MaxNameLen = 0, MaxValLen = 0; - for (unsigned i = 0, e = Stats.size(); i != e; ++i) { + for (size_t i = 0, e = Stats.size(); i != e; ++i) { MaxValLen = std::max(MaxValLen, (unsigned)utostr(Stats[i]->getValue()).size()); MaxNameLen = std::max(MaxNameLen, @@ -106,7 +106,7 @@ << "===" << std::string(73, '-') << "===\n\n"; // Print all of the statistics. - for (unsigned i = 0, e = Stats.size(); i != e; ++i) { + for (size_t i = 0, e = Stats.size(); i != e; ++i) { std::string CountStr = utostr(Stats[i]->getValue()); OutStream << std::string(MaxValLen-CountStr.size(), ' ') << CountStr << " " << Stats[i]->getName() Modified: llvm/trunk/lib/Support/StringExtras.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringExtras.cpp?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringExtras.cpp (original) +++ llvm/trunk/lib/Support/StringExtras.cpp Mon May 5 13:30:58 2008 @@ -22,7 +22,7 @@ /// The Source source string is updated in place to remove the returned string /// and any delimiter prefix from it. std::string llvm::getToken(std::string &Source, const char *Delimiters) { - unsigned NumDelimiters = std::strlen(Delimiters); + size_t NumDelimiters = std::strlen(Delimiters); // Figure out where the token starts. std::string::size_type Start = Modified: llvm/trunk/lib/System/Path.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Path.cpp?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/lib/System/Path.cpp (original) +++ llvm/trunk/lib/System/Path.cpp Mon May 5 13:30:58 2008 @@ -124,7 +124,8 @@ if (canRead()) { std::string Magic; if (getMagicNumber(Magic, 64)) - switch (IdentifyFileType(Magic.c_str(), Magic.length())) { + switch (IdentifyFileType(Magic.c_str(), + static_cast(Magic.length()))) { default: return false; case Mach_O_FixedVirtualMemorySharedLib_FileType: case Mach_O_DynamicallyLinkedSharedLib_FileType: @@ -167,7 +168,7 @@ bool Path::hasMagicNumber(const std::string &Magic) const { std::string actualMagic; - if (getMagicNumber(actualMagic, Magic.size())) + if (getMagicNumber(actualMagic, static_cast(Magic.size()))) return Magic == actualMagic; return false; } @@ -204,7 +205,7 @@ // If the path is all slashes, return a single slash. // Otherwise, remove all trailing slashes. - signed pos = path.size() - 1; + signed pos = static_cast(path.size()) - 1; while (pos >= 0 && path[pos] == Sep) --pos; Modified: llvm/trunk/lib/System/Unix/Memory.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Memory.inc?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Memory.inc (original) +++ llvm/trunk/lib/System/Unix/Memory.inc Mon May 5 13:30:58 2008 @@ -28,7 +28,7 @@ std::string *ErrMsg) { if (NumBytes == 0) return MemoryBlock(); - long pageSize = Process::GetPageSize(); + unsigned pageSize = Process::GetPageSize(); unsigned NumPages = (NumBytes+pageSize-1)/pageSize; int fd = -1; Modified: llvm/trunk/lib/System/Unix/Path.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Path.inc?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Path.inc (original) +++ llvm/trunk/lib/System/Unix/Path.inc Mon May 5 13:30:58 2008 @@ -566,7 +566,7 @@ path.copy(pathname,MAXPATHLEN); // Null-terminate the last component - int lastchar = path.length() - 1 ; + size_t lastchar = path.length() - 1 ; if (pathname[lastchar] != '/') ++lastchar; @@ -639,7 +639,7 @@ // Otherwise, try to just remove the one directory. char pathname[MAXPATHLEN]; path.copy(pathname, MAXPATHLEN); - int lastchar = path.length() - 1 ; + size_t lastchar = path.length() - 1; if (pathname[lastchar] == '/') pathname[lastchar] = 0; else Modified: llvm/trunk/lib/System/Unix/Program.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Program.inc?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Program.inc (original) +++ llvm/trunk/lib/System/Unix/Program.inc Mon May 5 13:30:58 2008 @@ -58,7 +58,7 @@ return Path(); // Now we have a colon separated list of directories to search; try them. - unsigned PathLen = strlen(PathStr); + size_t PathLen = strlen(PathStr); while (PathLen) { // Find the first colon... const char *Colon = std::find(PathStr, PathStr+PathLen, ':'); Modified: llvm/trunk/lib/System/Unix/Signals.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Signals.inc?rev=50659&r1=50658&r2=50659&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Signals.inc (original) +++ llvm/trunk/lib/System/Unix/Signals.inc Mon May 5 13:30:58 2008 @@ -65,7 +65,8 @@ static void PrintStackTrace() { #ifdef HAVE_BACKTRACE // Use backtrace() to output a backtrace on Linux systems with glibc. - int depth = backtrace(StackTrace, array_lengthof(StackTrace)); + int depth = backtrace(StackTrace, + static_cast(array_lengthof(StackTrace))); backtrace_symbols_fd(StackTrace, depth, STDERR_FILENO); #endif } From gohman at apple.com Mon May 5 13:43:07 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 05 May 2008 18:43:07 -0000 Subject: [llvm-commits] [llvm] r50660 - /llvm/trunk/lib/Target/X86/X86Subtarget.cpp Message-ID: <200805051843.m45Ih7OI000460@zion.cs.uiuc.edu> Author: djg Date: Mon May 5 13:43:07 2008 New Revision: 50660 URL: http://llvm.org/viewvc/llvm-project?rev=50660&view=rev Log: Fix IsLinux being uninitialized on non-Linux targets. Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=50660&r1=50659&r2=50660&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Mon May 5 13:43:07 2008 @@ -241,6 +241,7 @@ , X863DNowLevel(NoThreeDNow) , HasX86_64(false) , DarwinVers(0) + , IsLinux(false) , stackAlignment(8) // FIXME: this is a known good value for Yonah. How about others? , MaxInlineSizeThreshold(128) From wangmp at apple.com Mon May 5 14:05:59 2008 From: wangmp at apple.com (Mon P Wang) Date: Mon, 05 May 2008 19:05:59 -0000 Subject: [llvm-commits] [llvm] r50663 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ include/llvm/Target/ lib/CodeGen/ lib/CodeGen/SelectionDAG/ lib/Target/ lib/Target/X86/ test/CodeGen/X86/ Message-ID: <200805051906.m45J60NF001231@zion.cs.uiuc.edu> Author: wangmp Date: Mon May 5 14:05:59 2008 New Revision: 50663 URL: http://llvm.org/viewvc/llvm-project?rev=50663&view=rev Log: Added addition atomic instrinsics and, or, xor, min, and max. Added: llvm/trunk/test/CodeGen/X86/atomic_op.ll Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h llvm/trunk/include/llvm/Intrinsics.td llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp llvm/trunk/lib/Target/TargetSelectionDAG.td llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h llvm/trunk/lib/Target/X86/X86InstrInfo.td llvm/trunk/lib/Target/X86/X86Subtarget.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h?rev=50663&r1=50662&r2=50663&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Mon May 5 14:05:59 2008 @@ -236,6 +236,11 @@ /// succ_iterator removeSuccessor(succ_iterator I); + /// transferSuccessors - Transfers all the successors from MBB to this + /// machine basic block (i.e., copies all the successors fromMBB and + /// remove all the successors fromBB). + void transferSuccessors(MachineBasicBlock *fromMBB); + /// isSuccessor - Return true if the specified MBB is a successor of this /// block. bool isSuccessor(MachineBasicBlock *MBB) const; Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=50663&r1=50662&r2=50663&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Mon May 5 14:05:59 2008 @@ -594,6 +594,24 @@ // the return is always the original value in *ptr ATOMIC_SWAP, + // Val, OUTCHAIN = ATOMIC_LSS(INCHAIN, ptr, amt) + // this corresponds to the atomic.lss intrinsic. + // *ptr - amt is stored to *ptr atomically. + // the return is always the original value in *ptr + ATOMIC_LSS, + + // Val, OUTCHAIN = ATOMIC_L[OpName]S(INCHAIN, ptr, amt) + // this corresponds to the atomic.[OpName] intrinsic. + // op(*ptr, amt) is stored to *ptr atomically. + // the return is always the original value in *ptr + ATOMIC_LOAD_AND, + ATOMIC_LOAD_OR, + ATOMIC_LOAD_XOR, + ATOMIC_LOAD_MIN, + ATOMIC_LOAD_MAX, + ATOMIC_LOAD_UMIN, + ATOMIC_LOAD_UMAX, + // BUILTIN_OP_END - This must be the last enum value in this list. BUILTIN_OP_END }; Modified: llvm/trunk/include/llvm/Intrinsics.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=50663&r1=50662&r2=50663&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.td (original) +++ llvm/trunk/include/llvm/Intrinsics.td Mon May 5 14:05:59 2008 @@ -267,22 +267,62 @@ def int_memory_barrier : Intrinsic<[llvm_void_ty, llvm_i1_ty, llvm_i1_ty, llvm_i1_ty, llvm_i1_ty, llvm_i1_ty], []>; -def int_atomic_lcs : Intrinsic<[llvm_anyint_ty, - LLVMPointerType>, - LLVMMatchType<0>, LLVMMatchType<0>], +def int_atomic_lcs : Intrinsic<[llvm_anyint_ty, + LLVMPointerType>, + LLVMMatchType<0>, LLVMMatchType<0>], + [IntrWriteArgMem]>, + GCCBuiltin<"__sync_val_compare_and_swap">; +def int_atomic_las : Intrinsic<[llvm_anyint_ty, + LLVMPointerType>, + LLVMMatchType<0>], + [IntrWriteArgMem]>, + GCCBuiltin<"__sync_fetch_and_add">; +def int_atomic_swap : Intrinsic<[llvm_anyint_ty, + LLVMPointerType>, + LLVMMatchType<0>], [IntrWriteArgMem]>, - GCCBuiltin<"__sync_val_compare_and_swap">; -def int_atomic_las : Intrinsic<[llvm_anyint_ty, - LLVMPointerType>, - LLVMMatchType<0>], - [IntrWriteArgMem]>, - GCCBuiltin<"__sync_fetch_and_add">; -def int_atomic_swap : Intrinsic<[llvm_anyint_ty, - LLVMPointerType>, - LLVMMatchType<0>], - [IntrWriteArgMem]>, - GCCBuiltin<"__sync_lock_test_and_set">; - + GCCBuiltin<"__sync_lock_test_and_set">; +def int_atomic_lss : Intrinsic<[llvm_anyint_ty, + LLVMPointerType>, + LLVMMatchType<0>], + [IntrWriteArgMem]>, + GCCBuiltin<"__sync_fetch_and_sub">; +def int_atomic_load_and : Intrinsic<[llvm_anyint_ty, + LLVMPointerType>, + LLVMMatchType<0>], + [IntrWriteArgMem]>, + GCCBuiltin<"__sync_fetch_and_and">; +def int_atomic_load_or : Intrinsic<[llvm_anyint_ty, + LLVMPointerType>, + LLVMMatchType<0>], + [IntrWriteArgMem]>, + GCCBuiltin<"__sync_fetch_and_or">; +def int_atomic_load_xor : Intrinsic<[llvm_anyint_ty, + LLVMPointerType>, + LLVMMatchType<0>], + [IntrWriteArgMem]>, + GCCBuiltin<"__sync_fetch_and_xor">; +def int_atomic_load_min : Intrinsic<[llvm_anyint_ty, + LLVMPointerType>, + LLVMMatchType<0>], + [IntrWriteArgMem]>, + GCCBuiltin<"__sync_fetch_and_min">; +def int_atomic_load_max : Intrinsic<[llvm_anyint_ty, + LLVMPointerType>, + LLVMMatchType<0>], + [IntrWriteArgMem]>, + GCCBuiltin<"__sync_fetch_and_max">; +def int_atomic_load_umin : Intrinsic<[llvm_anyint_ty, + LLVMPointerType>, + LLVMMatchType<0>], + [IntrWriteArgMem]>, + GCCBuiltin<"__sync_fetch_and_umin">; +def int_atomic_load_umax : Intrinsic<[llvm_anyint_ty, + LLVMPointerType>, + LLVMMatchType<0>], + [IntrWriteArgMem]>, + GCCBuiltin<"__sync_fetch_and_umax">; + //===-------------------------- Other Intrinsics --------------------------===// // def int_flt_rounds : Intrinsic<[llvm_i32_ty]>, Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=50663&r1=50662&r2=50663&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Mon May 5 14:05:59 2008 @@ -1340,12 +1340,15 @@ /// by the system, this holds the same type (e.g. i32 -> i32). MVT::ValueType TransformToType[MVT::LAST_VALUETYPE]; + // Defines the capacity of the TargetLowering::OpActions table + static const int OpActionsCapacity = 173; + /// OpActions - For each operation and each value type, keep a LegalizeAction /// that indicates how instruction selection should deal with the operation. /// Most operations are Legal (aka, supported natively by the target), but /// operations that are not should be described. Note that operations on /// non-legal value types are not described here. - uint64_t OpActions[156]; + uint64_t OpActions[OpActionsCapacity]; /// LoadXActions - For each load of load extension type and each value type, /// keep a LegalizeAction that indicates how instruction selection should deal @@ -1378,7 +1381,7 @@ /// TargetDAGCombineArray - Targets can specify ISD nodes that they would /// like PerformDAGCombine callbacks for by calling setTargetDAGCombine(), /// which sets a bit in this array. - unsigned char TargetDAGCombineArray[160/(sizeof(unsigned char)*8)]; + unsigned char TargetDAGCombineArray[168/(sizeof(unsigned char)*8)]; /// PromoteToType - For operations that must be promoted to a specific type, /// this holds the destination type. This map should be sparse, so don't hold Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=50663&r1=50662&r2=50663&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Mon May 5 14:05:59 2008 @@ -252,6 +252,19 @@ Predecessors.erase(I); } +void MachineBasicBlock::transferSuccessors(MachineBasicBlock *fromMBB) +{ + if (this == fromMBB) + return; + + for(MachineBasicBlock::succ_iterator iter = fromMBB->succ_begin(), + end = fromMBB->succ_end(); iter != end; ++iter) { + addSuccessor(*iter); + } + while(!fromMBB->succ_empty()) + fromMBB->removeSuccessor(fromMBB->succ_begin()); +} + bool MachineBasicBlock::isSuccessor(MachineBasicBlock *MBB) const { std::vector::const_iterator I = std::find(Successors.begin(), Successors.end(), MBB); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=50663&r1=50662&r2=50663&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Mon May 5 14:05:59 2008 @@ -1235,32 +1235,58 @@ break; } - case ISD::ATOMIC_LCS: + case ISD::ATOMIC_LCS: { + unsigned int num_operands = 4; + assert(Node->getNumOperands() == num_operands && "Invalid Atomic node!"); + SDOperand Ops[4]; + for (unsigned int x = 0; x < num_operands; ++x) + Ops[x] = LegalizeOp(Node->getOperand(x)); + Result = DAG.UpdateNodeOperands(Result, &Ops[0], num_operands); + + switch (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0))) { + default: assert(0 && "This action is not supported yet!"); + case TargetLowering::Custom: + Result = TLI.LowerOperation(Result, DAG); + break; + case TargetLowering::Legal: + break; + } + AddLegalizedOperand(SDOperand(Node, 0), Result.getValue(0)); + AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1)); + return Result.getValue(Op.ResNo); + } case ISD::ATOMIC_LAS: + case ISD::ATOMIC_LSS: + case ISD::ATOMIC_LOAD_AND: + case ISD::ATOMIC_LOAD_OR: + case ISD::ATOMIC_LOAD_XOR: + case ISD::ATOMIC_LOAD_MIN: + case ISD::ATOMIC_LOAD_MAX: + case ISD::ATOMIC_LOAD_UMIN: + case ISD::ATOMIC_LOAD_UMAX: case ISD::ATOMIC_SWAP: { - assert(((Node->getNumOperands() == 4 && Node->getOpcode() == ISD::ATOMIC_LCS) || - (Node->getNumOperands() == 3 && Node->getOpcode() == ISD::ATOMIC_LAS) || - (Node->getNumOperands() == 3 && Node->getOpcode() == ISD::ATOMIC_SWAP)) && - "Invalid Atomic node!"); - int num = Node->getOpcode() == ISD::ATOMIC_LCS ? 4 : 3; - SDOperand Ops[4]; - for (int x = 0; x < num; ++x) + unsigned int num_operands = 3; + assert(Node->getNumOperands() == num_operands && "Invalid Atomic node!"); + SDOperand Ops[3]; + for (unsigned int x = 0; x < num_operands; ++x) Ops[x] = LegalizeOp(Node->getOperand(x)); - Result = DAG.UpdateNodeOperands(Result, &Ops[0], num); + Result = DAG.UpdateNodeOperands(Result, &Ops[0], num_operands); switch (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0))) { default: assert(0 && "This action is not supported yet!"); case TargetLowering::Custom: Result = TLI.LowerOperation(Result, DAG); break; + case TargetLowering::Expand: + Result = SDOperand(TLI.ExpandOperationResult(Op.Val, DAG),0); + break; case TargetLowering::Legal: break; } AddLegalizedOperand(SDOperand(Node, 0), Result.getValue(0)); AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1)); return Result.getValue(Op.ResNo); - } - + } case ISD::Constant: { ConstantSDNode *CN = cast(Node); unsigned opAction = @@ -4242,6 +4268,14 @@ break; } case ISD::ATOMIC_LAS: + case ISD::ATOMIC_LSS: + case ISD::ATOMIC_LOAD_AND: + case ISD::ATOMIC_LOAD_OR: + case ISD::ATOMIC_LOAD_XOR: + case ISD::ATOMIC_LOAD_MIN: + case ISD::ATOMIC_LOAD_MAX: + case ISD::ATOMIC_LOAD_UMIN: + case ISD::ATOMIC_LOAD_UMAX: case ISD::ATOMIC_SWAP: { Tmp2 = PromoteOp(Node->getOperand(2)); Result = DAG.getAtomic(Node->getOpcode(), Node->getOperand(0), Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=50663&r1=50662&r2=50663&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon May 5 14:05:59 2008 @@ -2855,7 +2855,11 @@ SDOperand SelectionDAG::getAtomic(unsigned Opcode, SDOperand Chain, SDOperand Ptr, SDOperand Val, MVT::ValueType VT) { - assert((Opcode == ISD::ATOMIC_LAS || Opcode == ISD::ATOMIC_SWAP) + assert(( Opcode == ISD::ATOMIC_LAS || Opcode == ISD::ATOMIC_LSS + || Opcode == ISD::ATOMIC_SWAP || Opcode == ISD::ATOMIC_LOAD_AND + || Opcode == ISD::ATOMIC_LOAD_OR || Opcode == ISD::ATOMIC_LOAD_XOR + || Opcode == ISD::ATOMIC_LOAD_MIN || Opcode == ISD::ATOMIC_LOAD_MAX + || Opcode == ISD::ATOMIC_LOAD_UMIN || Opcode == ISD::ATOMIC_LOAD_UMAX) && "Invalid Atomic Op"); SDVTList VTs = getVTList(Val.getValueType(), MVT::Other); FoldingSetNodeID ID; @@ -4269,7 +4273,15 @@ case ISD::MEMBARRIER: return "MemBarrier"; case ISD::ATOMIC_LCS: return "AtomicLCS"; case ISD::ATOMIC_LAS: return "AtomicLAS"; - case ISD::ATOMIC_SWAP: return "AtomicSWAP"; + case ISD::ATOMIC_LSS: return "AtomicLSS"; + case ISD::ATOMIC_LOAD_AND: return "AtomicLoadAnd"; + case ISD::ATOMIC_LOAD_OR: return "AtomicLoadOr"; + case ISD::ATOMIC_LOAD_XOR: return "AtomicLoadXor"; + case ISD::ATOMIC_LOAD_MIN: return "AtomicLoadMin"; + case ISD::ATOMIC_LOAD_MAX: return "AtomicLoadMax"; + case ISD::ATOMIC_LOAD_UMIN: return "AtomicLoadUMin"; + case ISD::ATOMIC_LOAD_UMAX: return "AtomicLoadUMax"; + case ISD::ATOMIC_SWAP: return "AtomicSWAP"; case ISD::PCMARKER: return "PCMarker"; case ISD::READCYCLECOUNTER: return "ReadCycleCounter"; case ISD::SRCVALUE: return "SrcValue"; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50663&r1=50662&r2=50663&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon May 5 14:05:59 2008 @@ -732,6 +732,10 @@ assert(0 && "UserOp2 should not exist at instruction selection time!"); abort(); } + +private: + inline const char *implVisitBinaryAtomic(CallInst& I, ISD::NodeType Op); + }; } // end namespace llvm @@ -2769,6 +2773,22 @@ } } + +/// Inlined utility function to implement binary input atomic intrinsics for +// visitIntrinsicCall: I is a call instruction +// Op is the associated NodeType for I +const char * +SelectionDAGLowering::implVisitBinaryAtomic(CallInst& I, ISD::NodeType Op) { + SDOperand Root = getRoot(); + SDOperand O2 = getValue(I.getOperand(2)); + SDOperand L = DAG.getAtomic(Op, Root, + getValue(I.getOperand(1)), + O2, O2.getValueType()); + setValue(&I, L); + DAG.setRoot(L.getValue(1)); + return 0; +} + /// visitIntrinsicCall - Lower the call to the specified intrinsic function. If /// we want to emit this as a call to a named external function, return the name /// otherwise lower it and return null. @@ -3205,27 +3225,26 @@ DAG.setRoot(L.getValue(1)); return 0; } - case Intrinsic::atomic_las: { - SDOperand Root = getRoot(); - SDOperand O2 = getValue(I.getOperand(2)); - SDOperand L = DAG.getAtomic(ISD::ATOMIC_LAS, Root, - getValue(I.getOperand(1)), - O2, O2.getValueType()); - setValue(&I, L); - DAG.setRoot(L.getValue(1)); - return 0; - } - case Intrinsic::atomic_swap: { - SDOperand Root = getRoot(); - SDOperand O2 = getValue(I.getOperand(2)); - SDOperand L = DAG.getAtomic(ISD::ATOMIC_SWAP, Root, - getValue(I.getOperand(1)), - O2, O2.getValueType()); - setValue(&I, L); - DAG.setRoot(L.getValue(1)); - return 0; - } - + case Intrinsic::atomic_las: + return implVisitBinaryAtomic(I, ISD::ATOMIC_LAS); + case Intrinsic::atomic_lss: + return implVisitBinaryAtomic(I, ISD::ATOMIC_LSS); + case Intrinsic::atomic_load_and: + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_AND); + case Intrinsic::atomic_load_or: + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_OR); + case Intrinsic::atomic_load_xor: + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_XOR); + case Intrinsic::atomic_load_min: + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_MIN); + case Intrinsic::atomic_load_max: + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_MAX); + case Intrinsic::atomic_load_umin: + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_UMIN); + case Intrinsic::atomic_load_umax: + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_UMAX); + case Intrinsic::atomic_swap: + return implVisitBinaryAtomic(I, ISD::ATOMIC_SWAP); } } @@ -4519,8 +4538,6 @@ AU.setPreservesAll(); } - - bool SelectionDAGISel::runOnFunction(Function &Fn) { // Get alias analysis for load/store combining. AA = &getAnalysis(); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=50663&r1=50662&r2=50663&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Mon May 5 14:05:59 2008 @@ -165,7 +165,7 @@ TargetLowering::TargetLowering(TargetMachine &tm) : TM(tm), TD(TM.getTargetData()) { - assert(ISD::BUILTIN_OP_END <= 156 && + assert(ISD::BUILTIN_OP_END <= OpActionsCapacity && "Fixed size array in TargetLowering is not large enough!"); // All operations default to being supported. memset(OpActions, 0, sizeof(OpActions)); Modified: llvm/trunk/lib/Target/TargetSelectionDAG.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetSelectionDAG.td?rev=50663&r1=50662&r2=50663&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetSelectionDAG.td (original) +++ llvm/trunk/lib/Target/TargetSelectionDAG.td Mon May 5 14:05:59 2008 @@ -358,6 +358,22 @@ [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>; def atomic_swap : SDNode<"ISD::ATOMIC_SWAP", STDAtomic2, [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>; +def atomic_lss : SDNode<"ISD::ATOMIC_LSS" , STDAtomic2, + [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>; +def atomic_load_and : SDNode<"ISD::ATOMIC_LOAD_AND" , STDAtomic2, + [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>; +def atomic_load_or : SDNode<"ISD::ATOMIC_LOAD_OR" , STDAtomic2, + [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>; +def atomic_load_xor : SDNode<"ISD::ATOMIC_LOAD_XOR" , STDAtomic2, + [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>; +def atomic_load_min : SDNode<"ISD::ATOMIC_LOAD_MIN", STDAtomic2, + [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>; +def atomic_load_max : SDNode<"ISD::ATOMIC_LOAD_MAX", STDAtomic2, + [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>; +def atomic_load_umin : SDNode<"ISD::ATOMIC_LOAD_UMIN", STDAtomic2, + [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>; +def atomic_load_umax : SDNode<"ISD::ATOMIC_LOAD_UMAX", STDAtomic2, + [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>; // Do not use ld, st directly. Use load, extload, sextload, zextload, store, // and truncst (see below). Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=50663&r1=50662&r2=50663&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon May 5 14:05:59 2008 @@ -292,10 +292,12 @@ if (!Subtarget->hasSSE2()) setOperationAction(ISD::MEMBARRIER , MVT::Other, Expand); + // Expand certain atomics setOperationAction(ISD::ATOMIC_LCS , MVT::i8, Custom); setOperationAction(ISD::ATOMIC_LCS , MVT::i16, Custom); setOperationAction(ISD::ATOMIC_LCS , MVT::i32, Custom); setOperationAction(ISD::ATOMIC_LCS , MVT::i64, Custom); + setOperationAction(ISD::ATOMIC_LSS , MVT::i32, Expand); // Use the default ISD::LOCATION, ISD::DECLARE expansion. setOperationAction(ISD::LOCATION, MVT::Other, Expand); @@ -5511,6 +5513,15 @@ return DAG.getNode(ISD::MERGE_VALUES, Tys, ResultVal, cpOutH.getValue(1)).Val; } +SDNode* X86TargetLowering::ExpandATOMIC_LSS(SDNode* Op, SelectionDAG &DAG) { + MVT::ValueType T = cast(Op)->getVT(); + assert (T == MVT::i32 && "Only know how to expand i32 LSS"); + SDOperand negOp = DAG.getNode(ISD::SUB, T, + DAG.getConstant(0, T), Op->getOperand(2)); + return DAG.getAtomic(ISD::ATOMIC_LAS, Op->getOperand(0), + Op->getOperand(1), negOp, T).Val; +} + /// LowerOperation - Provide custom lowering hooks for some operations. /// SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) { @@ -5568,6 +5579,7 @@ case ISD::FP_TO_SINT: return ExpandFP_TO_SINT(N, DAG); case ISD::READCYCLECOUNTER: return ExpandREADCYCLECOUNTER(N, DAG); case ISD::ATOMIC_LCS: return ExpandATOMIC_LCS(N, DAG); + case ISD::ATOMIC_LSS: return ExpandATOMIC_LSS(N,DAG); } } @@ -5732,6 +5744,187 @@ // X86 Scheduler Hooks //===----------------------------------------------------------------------===// +// private utility function +MachineBasicBlock * +X86TargetLowering::EmitAtomicBitwiseWithCustomInserter(MachineInstr *bInstr, + MachineBasicBlock *MBB, + unsigned regOpc, + unsigned immOpc) { + // For the atomic bitwise operator, we generate + // thisMBB: + // newMBB: + // ld EAX = [bitinstr.addr] + // mov t1 = EAX + // op t2 = t1, [bitinstr.val] + // lcs dest = [bitinstr.addr], t2 [EAX is implicit] + // bz newMBB + // fallthrough -->nextMBB + const TargetInstrInfo *TII = getTargetMachine().getInstrInfo(); + const BasicBlock *LLVM_BB = MBB->getBasicBlock(); + ilist::iterator MBBIter = MBB; + ++MBBIter; + + /// First build the CFG + MachineFunction *F = MBB->getParent(); + MachineBasicBlock *thisMBB = MBB; + MachineBasicBlock *newMBB = new MachineBasicBlock(LLVM_BB); + MachineBasicBlock *nextMBB = new MachineBasicBlock(LLVM_BB); + F->getBasicBlockList().insert(MBBIter, newMBB); + F->getBasicBlockList().insert(MBBIter, nextMBB); + + // Move all successors to thisMBB to nextMBB + nextMBB->transferSuccessors(thisMBB); + + // Update thisMBB to fall through to newMBB + thisMBB->addSuccessor(newMBB); + + // newMBB jumps to itself and fall through to nextMBB + newMBB->addSuccessor(nextMBB); + newMBB->addSuccessor(newMBB); + + // Insert instructions into newMBB based on incoming instruction + assert(bInstr->getNumOperands() < 8 && "unexpected number of operands"); + MachineOperand& destOper = bInstr->getOperand(0); + MachineOperand* argOpers[6]; + int numArgs = bInstr->getNumOperands() - 1; + for (int i=0; i < numArgs; ++i) + argOpers[i] = &bInstr->getOperand(i+1); + + // x86 address has 4 operands: base, index, scale, and displacement + int lastAddrIndx = 3; // [0,3] + int valArgIndx = 4; + + MachineInstrBuilder MIB = BuildMI(newMBB, TII->get(X86::MOV32rm), X86::EAX); + for (int i=0; i <= lastAddrIndx; ++i) + (*MIB).addOperand(*argOpers[i]); + + unsigned t1 = F->getRegInfo().createVirtualRegister(X86::GR32RegisterClass); + MIB = BuildMI(newMBB, TII->get(X86::MOV32rr), t1); + MIB.addReg(X86::EAX); + + unsigned t2 = F->getRegInfo().createVirtualRegister(X86::GR32RegisterClass); + assert( (argOpers[valArgIndx]->isReg() || argOpers[valArgIndx]->isImm()) + && "invalid operand"); + if (argOpers[valArgIndx]->isReg()) + MIB = BuildMI(newMBB, TII->get(regOpc), t2); + else + MIB = BuildMI(newMBB, TII->get(immOpc), t2); + MIB.addReg(t1); + (*MIB).addOperand(*argOpers[valArgIndx]); + + MIB = BuildMI(newMBB, TII->get(X86::LCMPXCHG32)); + for (int i=0; i <= lastAddrIndx; ++i) + (*MIB).addOperand(*argOpers[i]); + MIB.addReg(t2); + + MIB = BuildMI(newMBB, TII->get(X86::MOV32rr), destOper.getReg()); + MIB.addReg(X86::EAX); + + // insert branch + BuildMI(newMBB, TII->get(X86::JNE)).addMBB(newMBB); + + delete bInstr; // The pseudo instruction is gone now. + return nextMBB; +} + +// private utility function +MachineBasicBlock * +X86TargetLowering::EmitAtomicMinMaxWithCustomInserter(MachineInstr *mInstr, + MachineBasicBlock *MBB, + unsigned cmovOpc) { + // For the atomic min/max operator, we generate + // thisMBB: + // newMBB: + // ld EAX = [min/max.addr] + // mov t1 = EAX + // mov t2 = [min/max.val] + // cmp t1, t2 + // cmov[cond] t2 = t1 + // lcs dest = [bitinstr.addr], t2 [EAX is implicit] + // bz newMBB + // fallthrough -->nextMBB + // + const TargetInstrInfo *TII = getTargetMachine().getInstrInfo(); + const BasicBlock *LLVM_BB = MBB->getBasicBlock(); + ilist::iterator MBBIter = MBB; + ++MBBIter; + + /// First build the CFG + MachineFunction *F = MBB->getParent(); + MachineBasicBlock *thisMBB = MBB; + MachineBasicBlock *newMBB = new MachineBasicBlock(LLVM_BB); + MachineBasicBlock *nextMBB = new MachineBasicBlock(LLVM_BB); + F->getBasicBlockList().insert(MBBIter, newMBB); + F->getBasicBlockList().insert(MBBIter, nextMBB); + + // Move all successors to thisMBB to nextMBB + nextMBB->transferSuccessors(thisMBB); + + // Update thisMBB to fall through to newMBB + thisMBB->addSuccessor(newMBB); + + // newMBB jumps to newMBB and fall through to nextMBB + newMBB->addSuccessor(nextMBB); + newMBB->addSuccessor(newMBB); + + // Insert instructions into newMBB based on incoming instruction + assert(mInstr->getNumOperands() < 8 && "unexpected number of operands"); + MachineOperand& destOper = mInstr->getOperand(0); + MachineOperand* argOpers[6]; + int numArgs = mInstr->getNumOperands() - 1; + for (int i=0; i < numArgs; ++i) + argOpers[i] = &mInstr->getOperand(i+1); + + // x86 address has 4 operands: base, index, scale, and displacement + int lastAddrIndx = 3; // [0,3] + int valArgIndx = 4; + + MachineInstrBuilder MIB = BuildMI(newMBB, TII->get(X86::MOV32rm), X86::EAX); + for (int i=0; i <= lastAddrIndx; ++i) + (*MIB).addOperand(*argOpers[i]); + + unsigned t1 = F->getRegInfo().createVirtualRegister(X86::GR32RegisterClass); + MIB = BuildMI(newMBB, TII->get(X86::MOV32rr), t1); + MIB.addReg(X86::EAX); + + // We only support register and immediate values + assert( (argOpers[valArgIndx]->isReg() || argOpers[valArgIndx]->isImm()) + && "invalid operand"); + + unsigned t2 = F->getRegInfo().createVirtualRegister(X86::GR32RegisterClass); + if (argOpers[valArgIndx]->isReg()) + MIB = BuildMI(newMBB, TII->get(X86::MOV32rr), t2); + else + MIB = BuildMI(newMBB, TII->get(X86::MOV32rr), t2); + (*MIB).addOperand(*argOpers[valArgIndx]); + + MIB = BuildMI(newMBB, TII->get(X86::CMP32rr)); + MIB.addReg(t1); + MIB.addReg(t2); + + // Generate movc + unsigned t3 = F->getRegInfo().createVirtualRegister(X86::GR32RegisterClass); + MIB = BuildMI(newMBB, TII->get(cmovOpc),t3); + MIB.addReg(t2); + MIB.addReg(t1); + + // Cmp and exchange if none has modified the memory location + MIB = BuildMI(newMBB, TII->get(X86::LCMPXCHG32)); + for (int i=0; i <= lastAddrIndx; ++i) + (*MIB).addOperand(*argOpers[i]); + MIB.addReg(t3); + + MIB = BuildMI(newMBB, TII->get(X86::MOV32rr), destOper.getReg()); + MIB.addReg(X86::EAX); + + // insert branch + BuildMI(newMBB, TII->get(X86::JNE)).addMBB(newMBB); + + delete mInstr; // The pseudo instruction is gone now. + return nextMBB; +} + + MachineBasicBlock * X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI, MachineBasicBlock *BB) { @@ -5766,15 +5959,11 @@ MachineFunction *F = BB->getParent(); F->getBasicBlockList().insert(It, copy0MBB); F->getBasicBlockList().insert(It, sinkMBB); - // Update machine-CFG edges by first adding all successors of the current + // Update machine-CFG edges by transferring all successors of the current // block to the new block which will contain the Phi node for the select. - for(MachineBasicBlock::succ_iterator i = BB->succ_begin(), - e = BB->succ_end(); i != e; ++i) - sinkMBB->addSuccessor(*i); - // Next, remove all successors of the current block, and add the true - // and fallthrough blocks as its successors. - while(!BB->succ_empty()) - BB->removeSuccessor(BB->succ_begin()); + sinkMBB->transferSuccessors(BB); + + // Add the true and fallthrough blocks as its successors. BB->addSuccessor(copy0MBB); BB->addSuccessor(sinkMBB); @@ -5874,6 +6063,23 @@ delete MI; // The pseudo instruction is gone now. return BB; } + case X86::ATOMAND32: + return EmitAtomicBitwiseWithCustomInserter(MI, BB, X86::AND32rr, + X86::AND32ri); + case X86::ATOMOR32: + return EmitAtomicBitwiseWithCustomInserter(MI, BB, X86::OR32rr, + X86::OR32ri); + case X86::ATOMXOR32: + return EmitAtomicBitwiseWithCustomInserter(MI, BB, X86::XOR32rr, + X86::XOR32ri); + case X86::ATOMMIN32: + return EmitAtomicMinMaxWithCustomInserter(MI, BB, X86::CMOVL32rr); + case X86::ATOMMAX32: + return EmitAtomicMinMaxWithCustomInserter(MI, BB, X86::CMOVG32rr); + case X86::ATOMUMIN32: + return EmitAtomicMinMaxWithCustomInserter(MI, BB, X86::CMOVB32rr); + case X86::ATOMUMAX32: + return EmitAtomicMinMaxWithCustomInserter(MI, BB, X86::CMOVA32rr); } } Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=50663&r1=50662&r2=50663&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Mon May 5 14:05:59 2008 @@ -346,6 +346,7 @@ virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI, MachineBasicBlock *MBB); + /// getTargetNodeName - This method returns the name of a target specific /// DAG node. virtual const char *getTargetNodeName(unsigned Opcode) const; @@ -524,7 +525,8 @@ SDNode *ExpandFP_TO_SINT(SDNode *N, SelectionDAG &DAG); SDNode *ExpandREADCYCLECOUNTER(SDNode *N, SelectionDAG &DAG); SDNode *ExpandATOMIC_LCS(SDNode *N, SelectionDAG &DAG); - + SDNode *ExpandATOMIC_LSS(SDNode *N, SelectionDAG &DAG); + SDOperand EmitTargetCodeForMemset(SelectionDAG &DAG, SDOperand Chain, SDOperand Dst, SDOperand Src, @@ -537,6 +539,23 @@ bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff); + + /// Utility function to emit atomic bitwise operations (and, or, xor). + // It takes the bitwise instruction to expand, the associated machine basic + // block, and the associated X86 opcodes for reg/reg and reg/imm. + MachineBasicBlock *EmitAtomicBitwiseWithCustomInserter( + MachineInstr *BInstr, + MachineBasicBlock *BB, + unsigned regOpc, + unsigned immOpc); + + /// Utility function to emit atomic min and max. It takes the min/max + // instruction to expand, the associated basic block, and the associated + // cmov opcode for moving the min or max value. + MachineBasicBlock *EmitAtomicMinMaxWithCustomInserter(MachineInstr *BInstr, + MachineBasicBlock *BB, + unsigned cmovOpc); + }; } Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=50663&r1=50662&r2=50663&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon May 5 14:05:59 2008 @@ -2598,6 +2598,63 @@ TB, LOCK; } +// Atomic exchange and and, or, xor +let Constraints = "$val = $dst", Defs = [EFLAGS], + usesCustomDAGSchedInserter = 1 in { +def ATOMAND32 : I<0xC1, MRMSrcMem,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val), + "#ATOMAND32 PSUEDO!", + [(set GR32:$dst, (atomic_load_and addr:$ptr, GR32:$val))]>, + TB, LOCK; +} + +let Constraints = "$val = $dst", Defs = [EFLAGS], + usesCustomDAGSchedInserter = 1 in { +def ATOMOR32 : I<0xC1, MRMSrcMem, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val), + "#ATOMOR32 PSUEDO!", + [(set GR32:$dst, (atomic_load_or addr:$ptr, GR32:$val))]>, + TB, LOCK; +} + +let Constraints = "$val = $dst", Defs = [EFLAGS], + usesCustomDAGSchedInserter = 1 in { +def ATOMXOR32 : I<0xC1, MRMSrcMem,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val), + "#ATOMXOR32 PSUEDO!", + [(set GR32:$dst, (atomic_load_xor addr:$ptr, GR32:$val))]>, + TB, LOCK; +} + +let Constraints = "$val = $dst", Defs = [EFLAGS], + usesCustomDAGSchedInserter = 1 in { +def ATOMMIN32: I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val), + "#ATOMMIN32 PSUEDO!", + [(set GR32:$dst, (atomic_load_min addr:$ptr, GR32:$val))]>, + TB, LOCK; +} + +let Constraints = "$val = $dst", Defs = [EFLAGS], + usesCustomDAGSchedInserter = 1 in { +def ATOMMAX32: I<0xC1, MRMSrcMem, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val), + "#ATOMMAX32 PSUEDO!", + [(set GR32:$dst, (atomic_load_max addr:$ptr, GR32:$val))]>, + TB, LOCK; +} + +let Constraints = "$val = $dst", Defs = [EFLAGS], + usesCustomDAGSchedInserter = 1 in { +def ATOMUMIN32: I<0xC1, MRMSrcMem,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val), + "#ATOMUMIN32 PSUEDO!", + [(set GR32:$dst, (atomic_load_umin addr:$ptr, GR32:$val))]>, + TB, LOCK; +} + +let Constraints = "$val = $dst", Defs = [EFLAGS], + usesCustomDAGSchedInserter = 1 in { +def ATOMUMAX32: I<0xC1, MRMSrcMem,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val), + "#ATOMUMAX32 PSUEDO!", + [(set GR32:$dst, (atomic_load_umax addr:$ptr, GR32:$val))]>, + TB, LOCK; +} + //===----------------------------------------------------------------------===// // Non-Instruction Patterns //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=50663&r1=50662&r2=50663&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Mon May 5 14:05:59 2008 @@ -247,7 +247,7 @@ , MaxInlineSizeThreshold(128) , Is64Bit(is64Bit) , TargetType(isELF) { // Default to ELF unless otherwise specified. - + // Determine default and user specified characteristics if (!FS.empty()) { // If feature string is not empty, parse features string. Added: llvm/trunk/test/CodeGen/X86/atomic_op.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/atomic_op.ll?rev=50663&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/atomic_op.ll (added) +++ llvm/trunk/test/CodeGen/X86/atomic_op.ll Mon May 5 14:05:59 2008 @@ -0,0 +1,93 @@ +; RUN: llvm-as < %s | llc -march=x86 -o %t1 -f +; RUN: grep "lock xaddl" %t1 | count 4 +; RUN: grep "lock cmpxchgl" %t1 | count 13 +; RUN: grep "xchgl" %t1 | count 14 +; RUN: grep "cmova" %t1 | count 2 +; RUN: grep "cmovb" %t1 | count 2 +; RUN: grep "cmovg" %t1 | count 2 +; RUN: grep "cmovl" %t1 | count 2 + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" + +define void @main(i32 %argc, i8** %argv) { +entry: + %argc.addr = alloca i32 ; [#uses=1] + %argv.addr = alloca i8** ; [#uses=1] + %val1 = alloca i32 ; [#uses=2] + %val2 = alloca i32 ; [#uses=15] + %andt = alloca i32 ; [#uses=2] + %ort = alloca i32 ; [#uses=2] + %xort = alloca i32 ; [#uses=2] + %old = alloca i32 ; [#uses=18] + %temp = alloca i32 ; [#uses=2] + store i32 %argc, i32* %argc.addr + store i8** %argv, i8*** %argv.addr + store i32 0, i32* %val1 + store i32 31, i32* %val2 + store i32 3855, i32* %andt + store i32 3855, i32* %ort + store i32 3855, i32* %xort + store i32 4, i32* %temp + %tmp = load i32* %temp ; [#uses=1] + call i32 @llvm.atomic.las.i32( i32* %val1, i32 %tmp ) ; :0 [#uses=1] + store i32 %0, i32* %old + call i32 @llvm.atomic.lss.i32( i32* %val2, i32 30 ) ; :1 [#uses=1] + store i32 %1, i32* %old + call i32 @llvm.atomic.las.i32( i32* %val2, i32 1 ) ; :2 [#uses=1] + store i32 %2, i32* %old + call i32 @llvm.atomic.lss.i32( i32* %val2, i32 1 ) ; :3 [#uses=1] + store i32 %3, i32* %old + call i32 @llvm.atomic.load.and.i32( i32* %andt, i32 4080 ) ; :4 [#uses=1] + store i32 %4, i32* %old + call i32 @llvm.atomic.load.or.i32( i32* %ort, i32 4080 ) ; :5 [#uses=1] + store i32 %5, i32* %old + call i32 @llvm.atomic.load.xor.i32( i32* %xort, i32 4080 ) ; :6 [#uses=1] + store i32 %6, i32* %old + call i32 @llvm.atomic.load.min.i32( i32* %val2, i32 16 ) ; :7 [#uses=1] + store i32 %7, i32* %old + %neg = sub i32 0, 1 ; [#uses=1] + call i32 @llvm.atomic.load.min.i32( i32* %val2, i32 %neg ) ; :8 [#uses=1] + store i32 %8, i32* %old + call i32 @llvm.atomic.load.max.i32( i32* %val2, i32 1 ) ; :9 [#uses=1] + store i32 %9, i32* %old + call i32 @llvm.atomic.load.max.i32( i32* %val2, i32 0 ) ; :10 [#uses=1] + store i32 %10, i32* %old + call i32 @llvm.atomic.load.umax.i32( i32* %val2, i32 65535 ) ; :11 [#uses=1] + store i32 %11, i32* %old + call i32 @llvm.atomic.load.umax.i32( i32* %val2, i32 10 ) ; :12 [#uses=1] + store i32 %12, i32* %old + call i32 @llvm.atomic.load.umin.i32( i32* %val2, i32 1 ) ; :13 [#uses=1] + store i32 %13, i32* %old + call i32 @llvm.atomic.load.umin.i32( i32* %val2, i32 10 ) ; :14 [#uses=1] + store i32 %14, i32* %old + call i32 @llvm.atomic.swap.i32( i32* %val2, i32 1976 ) ; :15 [#uses=1] + store i32 %15, i32* %old + %neg1 = sub i32 0, 10 ; [#uses=1] + call i32 @llvm.atomic.lcs.i32( i32* %val2, i32 %neg1, i32 1 ) ; :16 [#uses=1] + store i32 %16, i32* %old + call i32 @llvm.atomic.lcs.i32( i32* %val2, i32 1976, i32 1 ) ; :17 [#uses=1] + store i32 %17, i32* %old + ret void +} + +declare i32 @llvm.atomic.las.i32(i32*, i32) nounwind + +declare i32 @llvm.atomic.lss.i32(i32*, i32) nounwind + +declare i32 @llvm.atomic.load.and.i32(i32*, i32) nounwind + +declare i32 @llvm.atomic.load.or.i32(i32*, i32) nounwind + +declare i32 @llvm.atomic.load.xor.i32(i32*, i32) nounwind + +declare i32 @llvm.atomic.load.min.i32(i32*, i32) nounwind + +declare i32 @llvm.atomic.load.max.i32(i32*, i32) nounwind + +declare i32 @llvm.atomic.load.umax.i32(i32*, i32) nounwind + +declare i32 @llvm.atomic.load.umin.i32(i32*, i32) nounwind + +declare i32 @llvm.atomic.swap.i32(i32*, i32) nounwind + +declare i32 @llvm.atomic.lcs.i32(i32*, i32, i32) nounwind From dpatel at apple.com Mon May 5 14:44:16 2008 From: dpatel at apple.com (Devang Patel) Date: Mon, 05 May 2008 19:44:16 -0000 Subject: [llvm-commits] [llvm] r50664 - /llvm/trunk/include/llvm/Analysis/LoopInfo.h Message-ID: <200805051944.m45JiGwj002398@zion.cs.uiuc.edu> Author: dpatel Date: Mon May 5 14:44:16 2008 New Revision: 50664 URL: http://llvm.org/viewvc/llvm-project?rev=50664&view=rev Log: Remove unused function. 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=50664&r1=50663&r2=50664&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Mon May 5 14:44:16 2008 @@ -920,9 +920,6 @@ return LI->isLoopHeader(BB); } - /// isAnalysis - Return true if this pass is implementing an analysis pass. - bool isAnalysis() const { return true; } - /// runOnFunction - Calculate the natural loop information. /// virtual bool runOnFunction(Function &F); From sabre at nondot.org Mon May 5 15:21:22 2008 From: sabre at nondot.org (Chris Lattner) Date: Mon, 05 May 2008 20:21:22 -0000 Subject: [llvm-commits] [llvm] r50667 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/2008-05-05-MRV-Crash.ll Message-ID: <200805052021.m45KLMMe003716@zion.cs.uiuc.edu> Author: lattner Date: Mon May 5 15:21:22 2008 New Revision: 50667 URL: http://llvm.org/viewvc/llvm-project?rev=50667&view=rev Log: Fix a crash when threading a block that includes a MRV call result. DemoteRegToStack doesn't work with MRVs yet, because it relies on the ability to load/store things. This fixes PR2285. Added: llvm/trunk/test/Transforms/JumpThreading/2008-05-05-MRV-Crash.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=50667&r1=50666&r2=50667&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon May 5 15:21:22 2008 @@ -433,12 +433,27 @@ // Jump Threading can not update SSA properties correctly if the values // defined in the duplicated block are used outside of the block itself. For // this reason, we spill all values that are used outside of BB to the stack. - for (BasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) - if (I->isUsedOutsideOfBlock(BB)) { - // We found a use of I outside of BB. Create a new stack slot to - // break this inter-block usage pattern. + for (BasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) { + if (!I->isUsedOutsideOfBlock(BB)) + continue; + + // We found a use of I outside of BB. Create a new stack slot to + // break this inter-block usage pattern. + if (!isa(I->getType())) { DemoteRegToStack(*I); + continue; } + + // Alternatively, I must be a call or invoke that returns multiple retvals. + // We can't use 'DemoteRegToStack' because the at will create loads and + // stores of aggregates which is not valid yet. If I is a call, we can just + // pull all the getresult instructions up to this block. If I is an invoke, + // we are out of luck. + BasicBlock::iterator IP = I; ++IP; + for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); + UI != E; ++UI) + cast(UI)->moveBefore(IP); + } // We are going to have to map operands from the original BB block to the new // copy of the block 'NewBB'. If there are PHI nodes in BB, evaluate them to Added: llvm/trunk/test/Transforms/JumpThreading/2008-05-05-MRV-Crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/2008-05-05-MRV-Crash.ll?rev=50667&view=auto ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/2008-05-05-MRV-Crash.ll (added) +++ llvm/trunk/test/Transforms/JumpThreading/2008-05-05-MRV-Crash.ll Mon May 5 15:21:22 2008 @@ -0,0 +1,25 @@ +; RUN: llvm-as < %s | opt -jump-threading -disable-output +; PR2285 +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.system__secondary_stack__mark_id = type { i64, i64 } + +define void @_ada_c35507b() { +entry: + br label %bb + +bb: ; preds = %bb13, %entry + %ch.0 = phi i8 [ 0, %entry ], [ 0, %bb13 ] ; [#uses=1] + %tmp11 = icmp ugt i8 %ch.0, 31 ; [#uses=1] + %tmp120 = call %struct.system__secondary_stack__mark_id @system__secondary_stack__ss_mark( ) ; <%struct.system__secondary_stack__mark_id> [#uses=1] + br i1 %tmp11, label %bb110, label %bb13 + +bb13: ; preds = %bb + br label %bb + +bb110: ; preds = %bb + %mrv_gr124 = getresult %struct.system__secondary_stack__mark_id %tmp120, 1 ; [#uses=0] + unreachable +} + +declare %struct.system__secondary_stack__mark_id @system__secondary_stack__ss_mark() From isanbard at gmail.com Mon May 5 15:51:59 2008 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 05 May 2008 20:51:59 -0000 Subject: [llvm-commits] [llvm] r50668 - /llvm/trunk/include/llvm/Support/PassNameParser.h Message-ID: <200805052051.m45Kpx7f004857@zion.cs.uiuc.edu> Author: void Date: Mon May 5 15:51:58 2008 New Revision: 50668 URL: http://llvm.org/viewvc/llvm-project?rev=50668&view=rev Log: Using "unsigned" was masking the "size_t" version of this method. Modified: llvm/trunk/include/llvm/Support/PassNameParser.h Modified: llvm/trunk/include/llvm/Support/PassNameParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PassNameParser.h?rev=50668&r1=50667&r2=50668&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/PassNameParser.h (original) +++ llvm/trunk/include/llvm/Support/PassNameParser.h Mon May 5 15:51:58 2008 @@ -82,7 +82,7 @@ // printOptionInfo - Print out information about this option. Override the // default implementation to sort the table before we print... - virtual void printOptionInfo(const cl::Option &O, unsigned GlobalWidth) const{ + virtual void printOptionInfo(const cl::Option &O, size_t GlobalWidth) const { PassNameParser *PNP = const_cast(this); std::sort(PNP->Values.begin(), PNP->Values.end(), ValLessThan); cl::parser::printOptionInfo(O, GlobalWidth); From kremenek at apple.com Mon May 5 15:52:14 2008 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 05 May 2008 20:52:14 -0000 Subject: [llvm-commits] [llvm] r50669 - /llvm/tags/checker/checker-21/ Message-ID: <200805052052.m45KqE8n004876@zion.cs.uiuc.edu> Author: kremenek Date: Mon May 5 15:52:13 2008 New Revision: 50669 URL: http://llvm.org/viewvc/llvm-project?rev=50669&view=rev Log: Tagging checker-21. Added: llvm/tags/checker/checker-21/ - copied from r50668, llvm/trunk/ From tonic at nondot.org Mon May 5 15:52:19 2008 From: tonic at nondot.org (Tanya Lattner) Date: Mon, 05 May 2008 20:52:19 -0000 Subject: [llvm-commits] [nightly-test-server] r50670 - /nightly-test-server/trunk/AcceptTestResults.php Message-ID: <200805052052.m45KqJsF004891@zion.cs.uiuc.edu> Author: tbrethou Date: Mon May 5 15:52:19 2008 New Revision: 50670 URL: http://llvm.org/viewvc/llvm-project?rev=50670&view=rev Log: Fix typo in compare. Modified: nightly-test-server/trunk/AcceptTestResults.php Modified: nightly-test-server/trunk/AcceptTestResults.php URL: http://llvm.org/viewvc/llvm-project/nightly-test-server/trunk/AcceptTestResults.php?rev=50670&r1=50669&r2=50670&view=diff ============================================================================== --- nightly-test-server/trunk/AcceptTestResults.php (original) +++ nightly-test-server/trunk/AcceptTestResults.php Mon May 5 15:52:19 2008 @@ -233,7 +233,7 @@ $jitTime = NULL; $gccRunTime = $results[6]; - if($gccRunTime = "*") + if($gccRunTime == "*") $gccRunTime = NULL; $cbeRunTime = $results[7]; From evan.cheng at apple.com Mon May 5 16:00:12 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 5 May 2008 14:00:12 -0700 Subject: [llvm-commits] [llvm] r50663 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ include/llvm/Target/ lib/CodeGen/ lib/CodeGen/SelectionDAG/ lib/Target/ lib/Target/X86/ test/CodeGen/X86/ In-Reply-To: <200805051906.m45J60NF001231@zion.cs.uiuc.edu> References: <200805051906.m45J60NF001231@zion.cs.uiuc.edu> Message-ID: Hi Mon Ping, Some comments. On May 5, 2008, at 12:05 PM, Mon P Wang wrote: > > @@ -5732,6 +5744,187 @@ > // X86 Scheduler Hooks > // > = > = > = > ----------------------------------------------------------------------= > ==// > > +// private utility function > +MachineBasicBlock * > +X86TargetLowering::EmitAtomicBitwiseWithCustomInserter(MachineInstr > *bInstr, > + > MachineBasicBlock *MBB, > + unsigned > regOpc, > + unsigned > immOpc) { > + // For the atomic bitwise operator, we generate > + // thisMBB: > + // newMBB: > + // ld EAX = [bitinstr.addr] > + // mov t1 = EAX > + // op t2 = t1, [bitinstr.val] I think this is not quite right. lcs implicitly uses EAX so the value should be copied *to* EAX. Also, only forcing the value into EAX just before its use is (slightly) better for register allocation. t1 = ld [addr] t2 = op t1, birinstr.val eax = mov t1 > > + // lcs dest = [bitinstr.addr], t2 [EAX is implicit] > + // bz newMBB > + // fallthrough -->nextMBB > + const TargetInstrInfo *TII = getTargetMachine().getInstrInfo(); > + const BasicBlock *LLVM_BB = MBB->getBasicBlock(); > + ilist::iterator MBBIter = MBB; > + ++MBBIter; > + Also, are you implementing llvm-gcc changes to enable it to generate these intrinsics? Thanks, Evan From isanbard at gmail.com Mon May 5 16:37:59 2008 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 05 May 2008 21:37:59 -0000 Subject: [llvm-commits] [llvm] r50673 - /llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Message-ID: <200805052137.m45LbxjZ006541@zion.cs.uiuc.edu> Author: void Date: Mon May 5 16:37:59 2008 New Revision: 50673 URL: http://llvm.org/viewvc/llvm-project?rev=50673&view=rev Log: Fix: Some classes were derived from a class in an anonymous namespace, but they themselves weren't in the anonymous namespace. Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=50673&r1=50672&r2=50673&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Mon May 5 16:37:59 2008 @@ -454,6 +454,7 @@ // Miscellaneous LibCall Optimizations //===----------------------------------------------------------------------===// +namespace { //===---------------------------------------===// // 'exit' Optimizations @@ -1236,6 +1237,7 @@ } }; +} // end anonymous namespace. //===----------------------------------------------------------------------===// // SimplifyLibCalls Pass Implementation From evan.cheng at apple.com Mon May 5 17:12:23 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 05 May 2008 22:12:23 -0000 Subject: [llvm-commits] [llvm] r50675 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200805052212.m45MCNw3007739@zion.cs.uiuc.edu> Author: evancheng Date: Mon May 5 17:12:23 2008 New Revision: 50675 URL: http://llvm.org/viewvc/llvm-project?rev=50675&view=rev Log: Code clean up. No functionality change. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=50675&r1=50674&r2=50675&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon May 5 17:12:23 2008 @@ -6214,35 +6214,36 @@ MVT::ValueType VT = N->getValueType(0); MVT::ValueType EVT = MVT::getVectorElementType(VT); SDOperand PermMask = N->getOperand(2); - int NumElems = (int)PermMask.getNumOperands(); + unsigned NumElems = PermMask.getNumOperands(); SDNode *Base = NULL; - for (int i = 0; i < NumElems; ++i) { - SDOperand Idx = PermMask.getOperand(i); - if (Idx.getOpcode() == ISD::UNDEF) { - if (!Base) return SDOperand(); - } else { - SDOperand Arg = - getShuffleScalarElt(N, cast(Idx)->getValue(), DAG); - if (!Arg.Val || !ISD::isNON_EXTLoad(Arg.Val)) - return SDOperand(); + for (unsigned i = 0; i < NumElems; ++i) { + SDOperand Elt = PermMask.getOperand(i); + if (Elt.getOpcode() == ISD::UNDEF) { if (!Base) - Base = Arg.Val; - else if (!isConsecutiveLoad(Arg.Val, Base, - i, MVT::getSizeInBits(EVT)/8,MFI)) return SDOperand(); + continue; + } + + unsigned Idx = cast(Elt)->getValue(); + SDOperand Arg = getShuffleScalarElt(N, Idx, DAG); + if (!Arg.Val || !ISD::isNON_EXTLoad(Arg.Val)) + return SDOperand(); + if (!Base) { + Base = Arg.Val; + continue; } + + if (!isConsecutiveLoad(Arg.Val, Base, i, MVT::getSizeInBits(EVT)/8,MFI)) + return SDOperand(); } - bool isAlign16 = isBaseAlignment16(Base->getOperand(1).Val, MFI, Subtarget); LoadSDNode *LD = cast(Base); - if (isAlign16) { + if (isBaseAlignment16(Base->getOperand(1).Val, MFI, Subtarget)) return DAG.getLoad(VT, LD->getChain(), LD->getBasePtr(), LD->getSrcValue(), LD->getSrcValueOffset(), LD->isVolatile()); - } else { - return DAG.getLoad(VT, LD->getChain(), LD->getBasePtr(), LD->getSrcValue(), - LD->getSrcValueOffset(), LD->isVolatile(), - LD->getAlignment()); - } + return DAG.getLoad(VT, LD->getChain(), LD->getBasePtr(), LD->getSrcValue(), + LD->getSrcValueOffset(), LD->isVolatile(), + LD->getAlignment()); } /// PerformSELECTCombine - Do target-specific dag combines on SELECT nodes. From monping at apple.com Mon May 5 17:13:10 2008 From: monping at apple.com (Mon P Wang) Date: Mon, 5 May 2008 15:13:10 -0700 Subject: [llvm-commits] [llvm] r50663 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ include/llvm/Target/ lib/CodeGen/ lib/CodeGen/SelectionDAG/ lib/Target/ lib/Target/X86/ test/CodeGen/X86/ In-Reply-To: References: <200805051906.m45J60NF001231@zion.cs.uiuc.edu> Message-ID: <4DEBF18C-584F-44F8-ADFE-5C3FD6BDC453@apple.com> Hi Evan, I'll make that change that you suggested. As for the llvm-gcc, I'll make that change later when I get some time. I'm currently using clang. Thanks, -- Mon Ping On May 5, 2008, at 2:00 PM, Evan Cheng wrote: > Hi Mon Ping, > > Some comments. > > On May 5, 2008, at 12:05 PM, Mon P Wang wrote: > >> >> @@ -5732,6 +5744,187 @@ >> // X86 Scheduler Hooks >> // >> = >> = >> = >> ----------------------------------------------------------------------= >> ==// >> >> +// private utility function >> +MachineBasicBlock * >> +X86TargetLowering::EmitAtomicBitwiseWithCustomInserter(MachineInstr >> *bInstr, >> + >> MachineBasicBlock *MBB, >> + unsigned >> regOpc, >> + unsigned >> immOpc) { >> + // For the atomic bitwise operator, we generate >> + // thisMBB: >> + // newMBB: >> + // ld EAX = [bitinstr.addr] >> + // mov t1 = EAX >> + // op t2 = t1, [bitinstr.val] > > I think this is not quite right. lcs implicitly uses EAX so the value > should be copied *to* EAX. Also, only forcing the value into EAX just > before its use is (slightly) better for register allocation. > > t1 = ld [addr] > t2 = op t1, birinstr.val > eax = mov t1 > >> >> + // lcs dest = [bitinstr.addr], t2 [EAX is implicit] >> + // bz newMBB >> + // fallthrough -->nextMBB >> + const TargetInstrInfo *TII = getTargetMachine().getInstrInfo(); >> + const BasicBlock *LLVM_BB = MBB->getBasicBlock(); >> + ilist::iterator MBBIter = MBB; >> + ++MBBIter; >> + > > Also, are you implementing llvm-gcc changes to enable it to generate > these intrinsics? > > Thanks, > > Evan > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From wangmp at apple.com Mon May 5 17:56:24 2008 From: wangmp at apple.com (Mon P Wang) Date: Mon, 05 May 2008 22:56:24 -0000 Subject: [llvm-commits] [llvm] r50677 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200805052256.m45MuOqR009488@zion.cs.uiuc.edu> Author: wangmp Date: Mon May 5 17:56:23 2008 New Revision: 50677 URL: http://llvm.org/viewvc/llvm-project?rev=50677&view=rev Log: Improved generated code for atomic operators Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=50677&r1=50676&r2=50677&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon May 5 17:56:23 2008 @@ -5753,9 +5753,9 @@ // For the atomic bitwise operator, we generate // thisMBB: // newMBB: - // ld EAX = [bitinstr.addr] - // mov t1 = EAX - // op t2 = t1, [bitinstr.val] + // ld t1 = [bitinstr.addr] + // op t2 = t1, [bitinstr.val] + // mov EAX = t1 // lcs dest = [bitinstr.addr], t2 [EAX is implicit] // bz newMBB // fallthrough -->nextMBB @@ -5794,14 +5794,11 @@ int lastAddrIndx = 3; // [0,3] int valArgIndx = 4; - MachineInstrBuilder MIB = BuildMI(newMBB, TII->get(X86::MOV32rm), X86::EAX); + unsigned t1 = F->getRegInfo().createVirtualRegister(X86::GR32RegisterClass); + MachineInstrBuilder MIB = BuildMI(newMBB, TII->get(X86::MOV32rm), t1); for (int i=0; i <= lastAddrIndx; ++i) (*MIB).addOperand(*argOpers[i]); - unsigned t1 = F->getRegInfo().createVirtualRegister(X86::GR32RegisterClass); - MIB = BuildMI(newMBB, TII->get(X86::MOV32rr), t1); - MIB.addReg(X86::EAX); - unsigned t2 = F->getRegInfo().createVirtualRegister(X86::GR32RegisterClass); assert( (argOpers[valArgIndx]->isReg() || argOpers[valArgIndx]->isImm()) && "invalid operand"); @@ -5812,6 +5809,9 @@ MIB.addReg(t1); (*MIB).addOperand(*argOpers[valArgIndx]); + MIB = BuildMI(newMBB, TII->get(X86::MOV32rr), X86::EAX); + MIB.addReg(t1); + MIB = BuildMI(newMBB, TII->get(X86::LCMPXCHG32)); for (int i=0; i <= lastAddrIndx; ++i) (*MIB).addOperand(*argOpers[i]); @@ -5835,11 +5835,11 @@ // For the atomic min/max operator, we generate // thisMBB: // newMBB: - // ld EAX = [min/max.addr] - // mov t1 = EAX + // ld t1 = [min/max.addr] // mov t2 = [min/max.val] // cmp t1, t2 // cmov[cond] t2 = t1 + // mov EAX = t1 // lcs dest = [bitinstr.addr], t2 [EAX is implicit] // bz newMBB // fallthrough -->nextMBB @@ -5879,14 +5879,11 @@ int lastAddrIndx = 3; // [0,3] int valArgIndx = 4; - MachineInstrBuilder MIB = BuildMI(newMBB, TII->get(X86::MOV32rm), X86::EAX); + unsigned t1 = F->getRegInfo().createVirtualRegister(X86::GR32RegisterClass); + MachineInstrBuilder MIB = BuildMI(newMBB, TII->get(X86::MOV32rm), t1); for (int i=0; i <= lastAddrIndx; ++i) (*MIB).addOperand(*argOpers[i]); - - unsigned t1 = F->getRegInfo().createVirtualRegister(X86::GR32RegisterClass); - MIB = BuildMI(newMBB, TII->get(X86::MOV32rr), t1); - MIB.addReg(X86::EAX); - + // We only support register and immediate values assert( (argOpers[valArgIndx]->isReg() || argOpers[valArgIndx]->isImm()) && "invalid operand"); @@ -5898,6 +5895,9 @@ MIB = BuildMI(newMBB, TII->get(X86::MOV32rr), t2); (*MIB).addOperand(*argOpers[valArgIndx]); + MIB = BuildMI(newMBB, TII->get(X86::MOV32rr), X86::EAX); + MIB.addReg(t1); + MIB = BuildMI(newMBB, TII->get(X86::CMP32rr)); MIB.addReg(t1); MIB.addReg(t2); From dpatel at apple.com Mon May 5 18:05:59 2008 From: dpatel at apple.com (Devang Patel) Date: Mon, 05 May 2008 23:05:59 -0000 Subject: [llvm-commits] [test-suite] r50678 - in /test-suite/trunk: Makefile.programs TEST.nightly.Makefile TEST.nightly.report Message-ID: <200805052305.m45N5xou009853@zion.cs.uiuc.edu> Author: dpatel Date: Mon May 5 18:05:59 2008 New Revision: 50678 URL: http://llvm.org/viewvc/llvm-project?rev=50678&view=rev Log: Add OPT_BETA support. Now you can do make TEST=nightly ENABLE_OPTBETA=1 OPTBETAOPTIONS="-verify" to see whether -std-comiple-opts passes are worth any dime or not. This command will do $ llvm-gcc -O0 ... $ llvm-gcc -O0 ... $ llvm-ld ... -o linked.rbc $ opt -std-compile-opts linked.rbc -o linked.bc $ llvm-ld ... linked.bc -o foo.llvm $ llc .. foo.llvm.bc -o foo.llc.s $ gcc foo.llc.s -o foo.llc and $ opt $(OPTBETAOPTIONS) linked.rbc -o linked.optbeta.bc $ llvm-ld .. linked.optbeta.bc -o foo.llvm.optbeta $ llc .. foo.llvm.optbeta.bc -o foo.opt-beta.s $ gcc foo.opt-beta.s -o foo.opt-beta Modified: test-suite/trunk/Makefile.programs test-suite/trunk/TEST.nightly.Makefile test-suite/trunk/TEST.nightly.report Modified: test-suite/trunk/Makefile.programs URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.programs?rev=50678&r1=50677&r2=50678&view=diff ============================================================================== --- test-suite/trunk/Makefile.programs (original) +++ test-suite/trunk/Makefile.programs Mon May 5 18:05:59 2008 @@ -44,6 +44,7 @@ .PRECIOUS: Output/%.llvm Output/%.native Output/%.llc Output/%.llc.s .PRECIOUS: Output/%.cbe Output/%.cbe.c Output/%.llvm.bc Output/%.linked.bc +.PRECIOUS: Output/%.linked.optbeta.bc Output/%.llvm.optbeta.bc PROGDIR = $(PROJ_SRC_ROOT) @@ -129,6 +130,7 @@ JITBETADIFFS := $(addsuffix .diff-jit-beta, $(PREFIXED_PROGRAMS_TO_TEST)) LLCDIFFS := $(addsuffix .diff-llc, $(PREFIXED_PROGRAMS_TO_TEST)) LLCBETADIFFS := $(addsuffix .diff-llc-beta, $(PREFIXED_PROGRAMS_TO_TEST)) +OPTBETADIFFS := $(addsuffix .diff-opt-beta, $(PREFIXED_PROGRAMS_TO_TEST)) CBEDIFFS := $(addsuffix .diff-cbe, $(PREFIXED_PROGRAMS_TO_TEST)) # Profiles for the program. @@ -137,11 +139,11 @@ # Build Program outputs: .PRECIOUS: Output/%.out-lli Output/%.out-jit Output/%.out-llc Output/%.out-llc-beta -.PRECIOUS: Output/%.out-nat Output/%.out-cbe +.PRECIOUS: Output/%.out-nat Output/%.out-cbe Output/%.out-opt-beta # Build diffs from the output... -.PRECIOUS: Output/%.diff-lli Output/%.diff-jit -.PRECIOUS: Output/%.diff-llc Output/%.diff-llc-beta Output/%.diff-cbe +.PRECIOUS: Output/%.diff-lli Output/%.diff-jit Output/%.diff-opt-beta +.PRECIOUS: Output/%.diff-llc Output/%.diff-llc-beta Output/%.diff-cbe # Regardless of what other options are specified, build the program's bytecode @@ -259,6 +261,10 @@ Output/%.llvm.stripped.bc: Output/%.llvm.bc $(LOPT) -$(LOPT) -mstrip $< -o $@ -f +$(PROGRAMS_TO_TEST:%=Output/%.linked.optbeta.bc): \ +Output/%.linked.optbeta.bc: Output/%.linked.rbc $(LOPT) + -$(LOPT) $(OPTBETAOPTIONS) -time-passes -info-output-file=$(CURDIR)/$@.info $(STATS) $< -o $@ -f + ifndef DISABLE_FOR_LLVM_PROGRAMS # Rule to produce final program bytecode file from linked, optimized, bytecode. @@ -281,6 +287,14 @@ $(MV) -f $@.tmp $@ endif +$(PROGRAMS_TO_TEST:%=Output/%.llvm.optbeta.bc): \ +Output/%.llvm.optbeta.bc: Output/%.linked.optbeta.bc $(LLVMLDPROG) + -$(LLVMLD) $(STATS) $< $(EXTRA_LINKTIME_OPT_FLAGS) $(LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.llvm.optbeta + +$(PROGRAMS_TO_TEST:%=Output/%.llvm.optbeta): \ +Output/%.llvm.optbeta: Output/%.linked.optbeta.bc $(LLVMLDPROG) + -$(LLVMLD) $(STATS) $< $(LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.llvm.optbeta + $(PROGRAMS_TO_TEST:%=Output/%.noopt-llvm.bc): \ Output/%.noopt-llvm.bc: Output/%.linked.rbc $(LLVMLDPROG) -$(LLVMLD) -disable-opt $(STATS) $(LLVMLD_FLAGS) $< -lc $(LIBS) -o Output/$*.noopt-llvm @@ -359,6 +373,10 @@ Output/%.llc-beta.s: Output/%.llvm.bc $(LLC) -$(LLC) $(LLCFLAGS) -f $(LLCBETAOPTION) $< -o $@ +$(PROGRAMS_TO_TEST:%=Output/%.opt-beta.s): \ +Output/%.opt-beta.s: Output/%.llvm.optbeta.bc $(LLC) + -$(LLC) $(LLCFLAGS) -f $< -o $@ + # On darwin, pass -force_cpusubtype_ALL to allow all ppc instructions. ifeq ($(ARCH),PowerPC) LLCASSEMBLERFLAGS = -force_cpusubtype_ALL @@ -378,6 +396,10 @@ Output/%.llc-beta: Output/%.llc-beta.s -$(LLVMGCCLD) $< -o $@ $(LLCLIBS) $(LLCASSEMBLERFLAGS) $(TARGET_FLAGS) $(LDFLAGS) +$(PROGRAMS_TO_TEST:%=Output/%.opt-beta): \ +Output/%.opt-beta: Output/%.opt-beta.s + -$(LLVMGCCLD) $< -o $@ $(LLCLIBS) $(LLCASSEMBLERFLAGS) $(TARGET_FLAGS) $(LDFLAGS) + # # Rules to execute the program @@ -431,6 +453,10 @@ Output/%.out-llc-beta: Output/%.llc-beta -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) +$(PROGRAMS_TO_TEST:%=Output/%.out-opt-beta): \ +Output/%.out-opt-beta: Output/%.opt-beta + -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) + $(PROGRAMS_TO_TEST:%=Output/%.out-cbe): \ Output/%.out-cbe: Output/%.cbe -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) @@ -491,6 +517,10 @@ Output/%.bugpoint-llc-beta: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat $(LBUGPOINT) $< -run-llc $(BUGPOINT_OPTIONS) $(LLCBETAOPTION) $(BUGPOINT_ARGS) +$(PROGRAMS_TO_TEST:%=Output/%.bugpoint-opt-beta): \ +Output/%.bugpoint-opt-beta: Output/%.llvm.optbeta.bc $(LBUGPOINT) Output/%.out-nat + $(LBUGPOINT) $< -run-llc $(BUGPOINT_OPTIONS) $(LLCBETAOPTION) $(BUGPOINT_ARGS) + $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-jit): \ Output/%.bugpoint-jit: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat $(LBUGPOINT) $< -run-jit $(BUGPOINT_OPTIONS) $(BUGPOINT_ARGS) @@ -561,6 +591,10 @@ Output/%.diff-llc-beta: Output/%.out-nat Output/%.out-llc-beta -$(DIFFPROG) llc-beta $* $(HIDEDIFF) +$(PROGRAMS_TO_TEST:%=Output/%.diff-opt-beta): \ +Output/%.diff-opt-beta: Output/%.out-nat Output/%.out-opt-beta + -$(DIFFPROG) opt-beta $* $(HIDEDIFF) + $(PROGRAMS_TO_TEST:%=Output/%.diff-cbe): \ Output/%.diff-cbe: Output/%.out-nat Output/%.out-cbe -$(DIFFPROG) cbe $* $(HIDEDIFF) @@ -591,6 +625,11 @@ -rm -f $@ -cp $< $@ +$(PROGRAMS_TO_TEST:%=Output/%.exe-opt-beta): \ +Output/%.exe-opt-beta: Output/%.diff-opt-beta + -rm -f $@ + -cp $< $@ + $(PROGRAMS_TO_TEST:%=Output/%.exe-cbe): \ Output/%.exe-cbe: Output/%.diff-cbe -rm -f $@ Modified: test-suite/trunk/TEST.nightly.Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/TEST.nightly.Makefile?rev=50678&r1=50677&r2=50678&view=diff ============================================================================== --- test-suite/trunk/TEST.nightly.Makefile (original) +++ test-suite/trunk/TEST.nightly.Makefile Mon May 5 18:05:59 2008 @@ -22,6 +22,9 @@ ifdef ENABLE_LLCBETA REPORTS_TO_GEN += llc-beta endif +ifdef ENABLE_OPTBETA +REPORTS_TO_GEN += opt-beta +endif REPORTS_SUFFIX := $(addsuffix .report.txt, $(REPORTS_TO_GEN)) @@ -85,7 +88,22 @@ echo "TEST-FAIL: llc-beta $(RELDIR)/$*" >> $@;\ fi - +# OPT experimental tests +$(PROGRAMS_TO_TEST:%=Output/%.nightly.opt-beta.report.txt): \ +Output/%.nightly.opt-beta.report.txt: Output/%.llvm.optbeta.bc Output/%.exe-opt-beta $(LLC) + @echo > $@ + -head -n 100 Output/$*.exe-opt-beta >> $@ + @-if test -f Output/$*.exe-opt-beta; then \ + echo "TEST-PASS: opt-beta $(RELDIR)/$*" >> $@;\ + $(LLC) $< $(LLCFLAGS) -o /dev/null -f $(TIMEOPT) >> $@ 2>&1; \ + printf "TEST-RESULT-opt-beta: " >> $@;\ + grep "Total Execution Time" $@.info >> $@;\ + printf "TEST-RESULT-opt-beta-time: " >> $@;\ + grep "^program" Output/$*.out-opt-beta.time >> $@;\ + echo >> $@;\ + else \ + echo "TEST-FAIL: opt-beta $(RELDIR)/$*" >> $@;\ + fi # CBE tests $(PROGRAMS_TO_TEST:%=Output/%.nightly.cbe.report.txt): \ Modified: test-suite/trunk/TEST.nightly.report URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/TEST.nightly.report?rev=50678&r1=50677&r2=50678&view=diff ============================================================================== --- test-suite/trunk/TEST.nightly.report (original) +++ test-suite/trunk/TEST.nightly.report Mon May 5 18:05:59 2008 @@ -56,6 +56,17 @@ return "-"; } +sub OPTOPT_BETARatio { # OPT/OPT-BETA + my ($Cols, $Col) = @_; + my $LLC = $Cols->[$Col-9]; + my $OPT_BETA = $Cols->[$Col-7]; + return "n/allc" if ($LLC eq "*"); + return "n/aopt" if ($OPT_BETA eq "*"); + return "n/a" if ($LLC eq "*" or $OPT_BETA eq "*"); + return sprintf("%3.2f", $LLC/$OPT_BETA) if ($LLC >= 0.1 and $OPT_BETA >= 0.1); + return "-"; +} + # highlight the RATIO columns with green/red. $HilightColumns{14} = 1; $HilightColumns{15} = 1; @@ -74,16 +85,19 @@ ["Bytecode" , 'TEST-RESULT-compile: *([0-9]+)'], ["LLC compile" , "TEST-RESULT-llc: .*$WallTimeRE"], ["LLC-BETA compile" , "TEST-RESULT-llc-beta: .*$WallTimeRE"], + ["OPT-BETA compile" , "TEST-RESULT-opt-beta: .*$WallTimeRE"], ["JIT codegen" , "TEST-RESULT-jit-comptime: .*$WallTimeRE"], [], ["GCC" , 'TEST-RESULT-nat-time: program\s*([.0-9m:]+)', \&FormatTime], ["CBE" , 'TEST-RESULT-cbe-time: program\s*([.0-9m:]+)', \&FormatTime], ["LLC" , 'TEST-RESULT-llc-time: program\s*([.0-9m:]+)', \&FormatTime], ["LLC-BETA" , 'TEST-RESULT-llc-beta-time: program\s*([.0-9m:]+)',\&FormatTime], + ["OPT-BETA" , 'TEST-RESULT-opt-beta-time: program\s*([.0-9m:]+)',\&FormatTime], ["JIT" , 'TEST-RESULT-jit-time: program\s*([.0-9m:]+)', \&FormatTime], [], ["GCC/CBE" , \&GCCCBERatio], ["GCC/LLC" , \&GCCLLCRatio], ["GCC/LLC-BETA" , \&GCCLLC_BETARatio], - ["LLC/LLC-BETA" , \&LLCLLC_BETARatio] + ["LLC/LLC-BETA" , \&LLCLLC_BETARatio], + ["OPT/OPT-BETA" , \&OPTOPT_BETARatio] ); From sabre at nondot.org Mon May 5 18:19:45 2008 From: sabre at nondot.org (Chris Lattner) Date: Mon, 05 May 2008 23:19:45 -0000 Subject: [llvm-commits] [llvm] r50681 - /llvm/trunk/lib/Target/X86/README.txt Message-ID: <200805052319.m45NJjg9010272@zion.cs.uiuc.edu> Author: lattner Date: Mon May 5 18:19:45 2008 New Revision: 50681 URL: http://llvm.org/viewvc/llvm-project?rev=50681&view=rev Log: add a micro optzn. Modified: llvm/trunk/lib/Target/X86/README.txt Modified: llvm/trunk/lib/Target/X86/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README.txt?rev=50681&r1=50680&r2=50681&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/README.txt (original) +++ llvm/trunk/lib/Target/X86/README.txt Mon May 5 18:19:45 2008 @@ -1691,3 +1691,21 @@ ... //===---------------------------------------------------------------------===// + +We compile: + +int test(int x, int y) { + return x-y-1; +} + +into (-m64): + +_test: + decl %edi + movl %edi, %eax + subl %esi, %eax + ret + +it would be better to codegen as: x+~y (notl+addl) + +//===---------------------------------------------------------------------===// From resistor at mac.com Mon May 5 18:38:07 2008 From: resistor at mac.com (Owen Anderson) Date: Mon, 05 May 2008 23:38:07 -0000 Subject: [llvm-commits] [llvm] r50682 - /llvm/trunk/tools/opt/opt.cpp Message-ID: <200805052338.m45Nc7K5010875@zion.cs.uiuc.edu> Author: resistor Date: Mon May 5 18:38:07 2008 New Revision: 50682 URL: http://llvm.org/viewvc/llvm-project?rev=50682&view=rev Log: Enable dead loop elimination. Modified: llvm/trunk/tools/opt/opt.cpp Modified: llvm/trunk/tools/opt/opt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=50682&r1=50681&r2=50682&view=diff ============================================================================== --- llvm/trunk/tools/opt/opt.cpp (original) +++ llvm/trunk/tools/opt/opt.cpp Mon May 5 18:38:07 2008 @@ -282,6 +282,7 @@ addPass(PM, createLoopIndexSplitPass()); // Index split loops. addPass(PM, createInstructionCombiningPass()); // Clean up after LICM/reassoc addPass(PM, createIndVarSimplifyPass()); // Canonicalize indvars + addPass(PM, createLoopDeletionPass()); // Remove dead loops addPass(PM, createLoopUnrollPass()); // Unroll small loops addPass(PM, createInstructionCombiningPass()); // Clean up after the unroller addPass(PM, createGVNPass()); // Remove redundancies From resistor at mac.com Mon May 5 18:41:12 2008 From: resistor at mac.com (Owen Anderson) Date: Mon, 05 May 2008 23:41:12 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50683 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200805052341.m45NfCtd010968@zion.cs.uiuc.edu> Author: resistor Date: Mon May 5 18:41:11 2008 New Revision: 50683 URL: http://llvm.org/viewvc/llvm-project?rev=50683&view=rev Log: Enable dead loop elimination. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=50683&r1=50682&r2=50683&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon May 5 18:41:11 2008 @@ -379,6 +379,7 @@ PM->add(createLoopIndexSplitPass()); // Split loop index PM->add(createInstructionCombiningPass()); // Clean up after LICM/reassoc PM->add(createIndVarSimplifyPass()); // Canonicalize indvars + PM->add(createLoopDeletionPass()); // Remove dead loops if (flag_unroll_loops) PM->add(createLoopUnrollPass()); // Unroll small loops PM->add(createInstructionCombiningPass()); // Clean up after the unroller From lattner at apple.com Mon May 5 18:49:18 2008 From: lattner at apple.com (Tanya Lattner) Date: Mon, 5 May 2008 16:49:18 -0700 Subject: [llvm-commits] [llvm] r50682 - /llvm/trunk/tools/opt/opt.cpp In-Reply-To: <200805052338.m45Nc7K5010875@zion.cs.uiuc.edu> References: <200805052338.m45Nc7K5010875@zion.cs.uiuc.edu> Message-ID: <2ED3D296-7949-423A-931A-131F5ADA2EE3@apple.com> Did the code owner for opt approve this? If so, thats fine. Enabling optimizations with the code freeze a couple days away is not ideal. -Tanya On May 5, 2008, at 4:38 PM, Owen Anderson wrote: > Author: resistor > Date: Mon May 5 18:38:07 2008 > New Revision: 50682 > > URL: http://llvm.org/viewvc/llvm-project?rev=50682&view=rev > Log: > Enable dead loop elimination. > > Modified: > llvm/trunk/tools/opt/opt.cpp > > Modified: llvm/trunk/tools/opt/opt.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/ > opt.cpp?rev=50682&r1=50681&r2=50682&view=diff > > ====================================================================== > ======== > --- llvm/trunk/tools/opt/opt.cpp (original) > +++ llvm/trunk/tools/opt/opt.cpp Mon May 5 18:38:07 2008 > @@ -282,6 +282,7 @@ > addPass(PM, createLoopIndexSplitPass()); // Index split > loops. > addPass(PM, createInstructionCombiningPass()); // Clean up after > LICM/reassoc > addPass(PM, createIndVarSimplifyPass()); // Canonicalize > indvars > + addPass(PM, createLoopDeletionPass()); // Remove dead loops > addPass(PM, createLoopUnrollPass()); // Unroll small > loops > addPass(PM, createInstructionCombiningPass()); // Clean up after > the unroller > addPass(PM, createGVNPass()); // Remove > redundancies > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From resistor at mac.com Mon May 5 18:55:28 2008 From: resistor at mac.com (Owen Anderson) Date: Mon, 5 May 2008 18:55:28 -0500 Subject: [llvm-commits] [llvm] r50682 - /llvm/trunk/tools/opt/opt.cpp In-Reply-To: <2ED3D296-7949-423A-931A-131F5ADA2EE3@apple.com> References: <200805052338.m45Nc7K5010875@zion.cs.uiuc.edu> <2ED3D296-7949-423A-931A-131F5ADA2EE3@apple.com> Message-ID: <9A0F90BF-1B05-49E8-A72D-E0D585DB3114@mac.com> I've tested it extensively over the last week and a half, and Chris approved enabling it. If it fails anything tonight, I'll disable it. --Owen On May 5, 2008, at 6:49 PM, Tanya Lattner wrote: > Did the code owner for opt approve this? If so, thats fine. > > Enabling optimizations with the code freeze a couple days away is not > ideal. > > -Tanya > > > On May 5, 2008, at 4:38 PM, Owen Anderson wrote: > >> Author: resistor >> Date: Mon May 5 18:38:07 2008 >> New Revision: 50682 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=50682&view=rev >> Log: >> Enable dead loop elimination. >> >> Modified: >> llvm/trunk/tools/opt/opt.cpp >> >> Modified: llvm/trunk/tools/opt/opt.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/ >> opt.cpp?rev=50682&r1=50681&r2=50682&view=diff >> >> = >> ===================================================================== >> ======== >> --- llvm/trunk/tools/opt/opt.cpp (original) >> +++ llvm/trunk/tools/opt/opt.cpp Mon May 5 18:38:07 2008 >> @@ -282,6 +282,7 @@ >> addPass(PM, createLoopIndexSplitPass()); // Index split >> loops. >> addPass(PM, createInstructionCombiningPass()); // Clean up after >> LICM/reassoc >> addPass(PM, createIndVarSimplifyPass()); // Canonicalize >> indvars >> + addPass(PM, createLoopDeletionPass()); // Remove dead >> loops >> addPass(PM, createLoopUnrollPass()); // Unroll small >> loops >> addPass(PM, createInstructionCombiningPass()); // Clean up after >> the unroller >> addPass(PM, createGVNPass()); // Remove >> redundancies >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4260 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080505/8fea33cf/attachment.bin From dpatel at apple.com Mon May 5 18:56:48 2008 From: dpatel at apple.com (Devang Patel) Date: Mon, 5 May 2008 16:56:48 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r50683 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp In-Reply-To: <200805052341.m45NfCtd010968@zion.cs.uiuc.edu> References: <200805052341.m45NfCtd010968@zion.cs.uiuc.edu> Message-ID: Don't forget llvm-linker-hack.cpp :) On May 5, 2008, at 4:41 PM, Owen Anderson wrote: > Author: resistor > Date: Mon May 5 18:41:11 2008 > New Revision: 50683 > > URL: http://llvm.org/viewvc/llvm-project?rev=50683&view=rev > Log: > Enable dead loop elimination. > > Modified: > llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp > > Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=50683&r1=50682&r2=50683&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) > +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon May 5 18:41:11 2008 > @@ -379,6 +379,7 @@ > PM->add(createLoopIndexSplitPass()); // Split loop index > PM->add(createInstructionCombiningPass()); // Clean up after > LICM/reassoc > PM->add(createIndVarSimplifyPass()); // Canonicalize > indvars > + PM->add(createLoopDeletionPass()); // Remove dead loops > if (flag_unroll_loops) > PM->add(createLoopUnrollPass()); // Unroll small loops > PM->add(createInstructionCombiningPass()); // Clean up after > the unroller > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits - Devang From clattner at apple.com Mon May 5 18:57:57 2008 From: clattner at apple.com (Chris Lattner) Date: Mon, 5 May 2008 16:57:57 -0700 Subject: [llvm-commits] [test-suite] r50678 - in /test-suite/trunk: Makefile.programs TEST.nightly.Makefile TEST.nightly.report In-Reply-To: <200805052305.m45N5xou009853@zion.cs.uiuc.edu> References: <200805052305.m45N5xou009853@zion.cs.uiuc.edu> Message-ID: <36944EB0-AC54-4A0B-9E43-D0BCA99A0D23@apple.com> On May 5, 2008, at 4:05 PM, Devang Patel wrote: > URL: http://llvm.org/viewvc/llvm-project?rev=50678&view=rev > Log: > Add OPT_BETA support. > > Now you can do > make TEST=nightly ENABLE_OPTBETA=1 OPTBETAOPTIONS="-verify" > to see whether -std-comiple-opts passes are worth any dime or not. Cool. Did you verify that this does not break the nightly tester? Adding another column to its output could be bad. -Chris > > > This command will do > > $ llvm-gcc -O0 ... > $ llvm-gcc -O0 ... > $ llvm-ld ... -o linked.rbc > $ opt -std-compile-opts linked.rbc -o linked.bc > $ llvm-ld ... linked.bc -o foo.llvm > $ llc .. foo.llvm.bc -o foo.llc.s > $ gcc foo.llc.s -o foo.llc > > and > > $ opt $(OPTBETAOPTIONS) linked.rbc -o linked.optbeta.bc > $ llvm-ld .. linked.optbeta.bc -o foo.llvm.optbeta > $ llc .. foo.llvm.optbeta.bc -o foo.opt-beta.s > $ gcc foo.opt-beta.s -o foo.opt-beta > > > > Modified: > test-suite/trunk/Makefile.programs > test-suite/trunk/TEST.nightly.Makefile > test-suite/trunk/TEST.nightly.report > > Modified: test-suite/trunk/Makefile.programs > URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.programs?rev=50678&r1=50677&r2=50678&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- test-suite/trunk/Makefile.programs (original) > +++ test-suite/trunk/Makefile.programs Mon May 5 18:05:59 2008 > @@ -44,6 +44,7 @@ > > .PRECIOUS: Output/%.llvm Output/%.native Output/%.llc Output/%.llc.s > .PRECIOUS: Output/%.cbe Output/%.cbe.c Output/%.llvm.bc Output/ > %.linked.bc > +.PRECIOUS: Output/%.linked.optbeta.bc Output/%.llvm.optbeta.bc > > PROGDIR = $(PROJ_SRC_ROOT) > > @@ -129,6 +130,7 @@ > JITBETADIFFS := $(addsuffix .diff-jit-beta, $ > (PREFIXED_PROGRAMS_TO_TEST)) > LLCDIFFS := $(addsuffix .diff-llc, $(PREFIXED_PROGRAMS_TO_TEST)) > LLCBETADIFFS := $(addsuffix .diff-llc-beta, $ > (PREFIXED_PROGRAMS_TO_TEST)) > +OPTBETADIFFS := $(addsuffix .diff-opt-beta, $ > (PREFIXED_PROGRAMS_TO_TEST)) > CBEDIFFS := $(addsuffix .diff-cbe, $(PREFIXED_PROGRAMS_TO_TEST)) > > # Profiles for the program. > @@ -137,11 +139,11 @@ > > # Build Program outputs: > .PRECIOUS: Output/%.out-lli Output/%.out-jit Output/%.out-llc Output/ > %.out-llc-beta > -.PRECIOUS: Output/%.out-nat Output/%.out-cbe > +.PRECIOUS: Output/%.out-nat Output/%.out-cbe Output/%.out-opt-beta > > # Build diffs from the output... > -.PRECIOUS: Output/%.diff-lli Output/%.diff-jit > -.PRECIOUS: Output/%.diff-llc Output/%.diff-llc-beta Output/%.diff-cbe > +.PRECIOUS: Output/%.diff-lli Output/%.diff-jit Output/%.diff-opt-beta > +.PRECIOUS: Output/%.diff-llc Output/%.diff-llc-beta Output/%.diff-cbe > > > # Regardless of what other options are specified, build the > program's bytecode > @@ -259,6 +261,10 @@ > Output/%.llvm.stripped.bc: Output/%.llvm.bc $(LOPT) > -$(LOPT) -mstrip $< -o $@ -f > > +$(PROGRAMS_TO_TEST:%=Output/%.linked.optbeta.bc): \ > +Output/%.linked.optbeta.bc: Output/%.linked.rbc $(LOPT) > + -$(LOPT) $(OPTBETAOPTIONS) -time-passes -info-output-file=$ > (CURDIR)/$@.info $(STATS) $< -o $@ -f > + > > ifndef DISABLE_FOR_LLVM_PROGRAMS > # Rule to produce final program bytecode file from linked, > optimized, bytecode. > @@ -281,6 +287,14 @@ > $(MV) -f $@.tmp $@ > endif > > +$(PROGRAMS_TO_TEST:%=Output/%.llvm.optbeta.bc): \ > +Output/%.llvm.optbeta.bc: Output/%.linked.optbeta.bc $(LLVMLDPROG) > + -$(LLVMLD) $(STATS) $< $(EXTRA_LINKTIME_OPT_FLAGS) $ > (LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.llvm.optbeta > + > +$(PROGRAMS_TO_TEST:%=Output/%.llvm.optbeta): \ > +Output/%.llvm.optbeta: Output/%.linked.optbeta.bc $(LLVMLDPROG) > + -$(LLVMLD) $(STATS) $< $(LLVMLD_FLAGS) -lc $(LIBS) -o Output/ > $*.llvm.optbeta > + > $(PROGRAMS_TO_TEST:%=Output/%.noopt-llvm.bc): \ > Output/%.noopt-llvm.bc: Output/%.linked.rbc $(LLVMLDPROG) > -$(LLVMLD) -disable-opt $(STATS) $(LLVMLD_FLAGS) $< -lc $(LIBS) -o > Output/$*.noopt-llvm > @@ -359,6 +373,10 @@ > Output/%.llc-beta.s: Output/%.llvm.bc $(LLC) > -$(LLC) $(LLCFLAGS) -f $(LLCBETAOPTION) $< -o $@ > > +$(PROGRAMS_TO_TEST:%=Output/%.opt-beta.s): \ > +Output/%.opt-beta.s: Output/%.llvm.optbeta.bc $(LLC) > + -$(LLC) $(LLCFLAGS) -f $< -o $@ > + > # On darwin, pass -force_cpusubtype_ALL to allow all ppc instructions. > ifeq ($(ARCH),PowerPC) > LLCASSEMBLERFLAGS = -force_cpusubtype_ALL > @@ -378,6 +396,10 @@ > Output/%.llc-beta: Output/%.llc-beta.s > -$(LLVMGCCLD) $< -o $@ $(LLCLIBS) $(LLCASSEMBLERFLAGS) $ > (TARGET_FLAGS) $(LDFLAGS) > > +$(PROGRAMS_TO_TEST:%=Output/%.opt-beta): \ > +Output/%.opt-beta: Output/%.opt-beta.s > + -$(LLVMGCCLD) $< -o $@ $(LLCLIBS) $(LLCASSEMBLERFLAGS) $ > (TARGET_FLAGS) $(LDFLAGS) > + > > # > # Rules to execute the program > @@ -431,6 +453,10 @@ > Output/%.out-llc-beta: Output/%.llc-beta > -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) > > +$(PROGRAMS_TO_TEST:%=Output/%.out-opt-beta): \ > +Output/%.out-opt-beta: Output/%.opt-beta > + -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) > + > $(PROGRAMS_TO_TEST:%=Output/%.out-cbe): \ > Output/%.out-cbe: Output/%.cbe > -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) > @@ -491,6 +517,10 @@ > Output/%.bugpoint-llc-beta: Output/%.llvm.bc $(LBUGPOINT) Output/ > %.out-nat > $(LBUGPOINT) $< -run-llc $(BUGPOINT_OPTIONS) $(LLCBETAOPTION) $ > (BUGPOINT_ARGS) > > +$(PROGRAMS_TO_TEST:%=Output/%.bugpoint-opt-beta): \ > +Output/%.bugpoint-opt-beta: Output/%.llvm.optbeta.bc $(LBUGPOINT) > Output/%.out-nat > + $(LBUGPOINT) $< -run-llc $(BUGPOINT_OPTIONS) $(LLCBETAOPTION) $ > (BUGPOINT_ARGS) > + > $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-jit): \ > Output/%.bugpoint-jit: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat > $(LBUGPOINT) $< -run-jit $(BUGPOINT_OPTIONS) $(BUGPOINT_ARGS) > @@ -561,6 +591,10 @@ > Output/%.diff-llc-beta: Output/%.out-nat Output/%.out-llc-beta > -$(DIFFPROG) llc-beta $* $(HIDEDIFF) > > +$(PROGRAMS_TO_TEST:%=Output/%.diff-opt-beta): \ > +Output/%.diff-opt-beta: Output/%.out-nat Output/%.out-opt-beta > + -$(DIFFPROG) opt-beta $* $(HIDEDIFF) > + > $(PROGRAMS_TO_TEST:%=Output/%.diff-cbe): \ > Output/%.diff-cbe: Output/%.out-nat Output/%.out-cbe > -$(DIFFPROG) cbe $* $(HIDEDIFF) > @@ -591,6 +625,11 @@ > -rm -f $@ > -cp $< $@ > > +$(PROGRAMS_TO_TEST:%=Output/%.exe-opt-beta): \ > +Output/%.exe-opt-beta: Output/%.diff-opt-beta > + -rm -f $@ > + -cp $< $@ > + > $(PROGRAMS_TO_TEST:%=Output/%.exe-cbe): \ > Output/%.exe-cbe: Output/%.diff-cbe > -rm -f $@ > > Modified: test-suite/trunk/TEST.nightly.Makefile > URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/TEST.nightly.Makefile?rev=50678&r1=50677&r2=50678&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- test-suite/trunk/TEST.nightly.Makefile (original) > +++ test-suite/trunk/TEST.nightly.Makefile Mon May 5 18:05:59 2008 > @@ -22,6 +22,9 @@ > ifdef ENABLE_LLCBETA > REPORTS_TO_GEN += llc-beta > endif > +ifdef ENABLE_OPTBETA > +REPORTS_TO_GEN += opt-beta > +endif > REPORTS_SUFFIX := $(addsuffix .report.txt, $(REPORTS_TO_GEN)) > > > @@ -85,7 +88,22 @@ > echo "TEST-FAIL: llc-beta $(RELDIR)/$*" >> $@;\ > fi > > - > +# OPT experimental tests > +$(PROGRAMS_TO_TEST:%=Output/%.nightly.opt-beta.report.txt): \ > +Output/%.nightly.opt-beta.report.txt: Output/%.llvm.optbeta.bc > Output/%.exe-opt-beta $(LLC) > + @echo > $@ > + -head -n 100 Output/$*.exe-opt-beta >> $@ > + @-if test -f Output/$*.exe-opt-beta; then \ > + echo "TEST-PASS: opt-beta $(RELDIR)/$*" >> $@;\ > + $(LLC) $< $(LLCFLAGS) -o /dev/null -f $(TIMEOPT) >> $@ 2>&1; \ > + printf "TEST-RESULT-opt-beta: " >> $@;\ > + grep "Total Execution Time" $@.info >> $@;\ > + printf "TEST-RESULT-opt-beta-time: " >> $@;\ > + grep "^program" Output/$*.out-opt-beta.time >> $@;\ > + echo >> $@;\ > + else \ > + echo "TEST-FAIL: opt-beta $(RELDIR)/$*" >> $@;\ > + fi > > # CBE tests > $(PROGRAMS_TO_TEST:%=Output/%.nightly.cbe.report.txt): \ > > Modified: test-suite/trunk/TEST.nightly.report > URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/TEST.nightly.report?rev=50678&r1=50677&r2=50678&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- test-suite/trunk/TEST.nightly.report (original) > +++ test-suite/trunk/TEST.nightly.report Mon May 5 18:05:59 2008 > @@ -56,6 +56,17 @@ > return "-"; > } > > +sub OPTOPT_BETARatio { # OPT/OPT-BETA > + my ($Cols, $Col) = @_; > + my $LLC = $Cols->[$Col-9]; > + my $OPT_BETA = $Cols->[$Col-7]; > + return "n/allc" if ($LLC eq "*"); > + return "n/aopt" if ($OPT_BETA eq "*"); > + return "n/a" if ($LLC eq "*" or $OPT_BETA eq "*"); > + return sprintf("%3.2f", $LLC/$OPT_BETA) if ($LLC >= 0.1 and > $OPT_BETA >= 0.1); > + return "-"; > +} > + > # highlight the RATIO columns with green/red. > $HilightColumns{14} = 1; > $HilightColumns{15} = 1; > @@ -74,16 +85,19 @@ > ["Bytecode" , 'TEST-RESULT-compile: *([0-9]+)'], > ["LLC compile" , "TEST-RESULT-llc: .*$WallTimeRE"], > ["LLC-BETA compile" , "TEST-RESULT-llc-beta: .*$WallTimeRE"], > + ["OPT-BETA compile" , "TEST-RESULT-opt-beta: .*$WallTimeRE"], > ["JIT codegen" , "TEST-RESULT-jit-comptime: .*$WallTimeRE"], > [], > ["GCC" , 'TEST-RESULT-nat-time: program\s*([.0-9m:]+)', > \&FormatTime], > ["CBE" , 'TEST-RESULT-cbe-time: program\s*([.0-9m:]+)', > \&FormatTime], > ["LLC" , 'TEST-RESULT-llc-time: program\s*([.0-9m:]+)', > \&FormatTime], > ["LLC-BETA" , 'TEST-RESULT-llc-beta-time: program\s*([.0-9m:]+)', > \&FormatTime], > + ["OPT-BETA" , 'TEST-RESULT-opt-beta-time: program\s*([.0-9m:]+)', > \&FormatTime], > ["JIT" , 'TEST-RESULT-jit-time: program\s*([.0-9m:]+)', > \&FormatTime], > [], > ["GCC/CBE" , \&GCCCBERatio], > ["GCC/LLC" , \&GCCLLCRatio], > ["GCC/LLC-BETA" , \&GCCLLC_BETARatio], > - ["LLC/LLC-BETA" , \&LLCLLC_BETARatio] > + ["LLC/LLC-BETA" , \&LLCLLC_BETARatio], > + ["OPT/OPT-BETA" , \&OPTOPT_BETARatio] > ); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dpatel at apple.com Mon May 5 19:02:06 2008 From: dpatel at apple.com (Devang Patel) Date: Mon, 5 May 2008 17:02:06 -0700 Subject: [llvm-commits] [test-suite] r50678 - in /test-suite/trunk: Makefile.programs TEST.nightly.Makefile TEST.nightly.report In-Reply-To: <36944EB0-AC54-4A0B-9E43-D0BCA99A0D23@apple.com> References: <200805052305.m45N5xou009853@zion.cs.uiuc.edu> <36944EB0-AC54-4A0B-9E43-D0BCA99A0D23@apple.com> Message-ID: <7DEDCD08-3ECF-4F58-A74D-2EC6D5B8B86C@apple.com> On May 5, 2008, at 4:57 PM, Chris Lattner wrote: > On May 5, 2008, at 4:05 PM, Devang Patel wrote: >> URL: http://llvm.org/viewvc/llvm-project?rev=50678&view=rev >> Log: >> Add OPT_BETA support. >> >> Now you can do >> make TEST=nightly ENABLE_OPTBETA=1 OPTBETAOPTIONS="-verify" >> to see whether -std-comiple-opts passes are worth any dime or not. > > Cool. Did you verify that this does not break the nightly tester? > Adding another column to its output could be bad. I'll disable the patch that updates report.html for now. > > > -Chris > >> >> >> This command will do >> >> $ llvm-gcc -O0 ... >> $ llvm-gcc -O0 ... >> $ llvm-ld ... -o linked.rbc >> $ opt -std-compile-opts linked.rbc -o linked.bc >> $ llvm-ld ... linked.bc -o foo.llvm >> $ llc .. foo.llvm.bc -o foo.llc.s >> $ gcc foo.llc.s -o foo.llc >> >> and >> >> $ opt $(OPTBETAOPTIONS) linked.rbc -o linked.optbeta.bc >> $ llvm-ld .. linked.optbeta.bc -o foo.llvm.optbeta >> $ llc .. foo.llvm.optbeta.bc -o foo.opt-beta.s >> $ gcc foo.opt-beta.s -o foo.opt-beta >> >> >> >> Modified: >> test-suite/trunk/Makefile.programs >> test-suite/trunk/TEST.nightly.Makefile >> test-suite/trunk/TEST.nightly.report >> >> Modified: test-suite/trunk/Makefile.programs >> URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.programs?rev=50678&r1=50677&r2=50678&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- test-suite/trunk/Makefile.programs (original) >> +++ test-suite/trunk/Makefile.programs Mon May 5 18:05:59 2008 >> @@ -44,6 +44,7 @@ >> >> .PRECIOUS: Output/%.llvm Output/%.native Output/%.llc Output/%.llc.s >> .PRECIOUS: Output/%.cbe Output/%.cbe.c Output/%.llvm.bc Output/ >> %.linked.bc >> +.PRECIOUS: Output/%.linked.optbeta.bc Output/%.llvm.optbeta.bc >> >> PROGDIR = $(PROJ_SRC_ROOT) >> >> @@ -129,6 +130,7 @@ >> JITBETADIFFS := $(addsuffix .diff-jit-beta, $ >> (PREFIXED_PROGRAMS_TO_TEST)) >> LLCDIFFS := $(addsuffix .diff-llc, $(PREFIXED_PROGRAMS_TO_TEST)) >> LLCBETADIFFS := $(addsuffix .diff-llc-beta, $ >> (PREFIXED_PROGRAMS_TO_TEST)) >> +OPTBETADIFFS := $(addsuffix .diff-opt-beta, $ >> (PREFIXED_PROGRAMS_TO_TEST)) >> CBEDIFFS := $(addsuffix .diff-cbe, $(PREFIXED_PROGRAMS_TO_TEST)) >> >> # Profiles for the program. >> @@ -137,11 +139,11 @@ >> >> # Build Program outputs: >> .PRECIOUS: Output/%.out-lli Output/%.out-jit Output/%.out-llc Output/ >> %.out-llc-beta >> -.PRECIOUS: Output/%.out-nat Output/%.out-cbe >> +.PRECIOUS: Output/%.out-nat Output/%.out-cbe Output/%.out-opt-beta >> >> # Build diffs from the output... >> -.PRECIOUS: Output/%.diff-lli Output/%.diff-jit >> -.PRECIOUS: Output/%.diff-llc Output/%.diff-llc-beta Output/%.diff- >> cbe >> +.PRECIOUS: Output/%.diff-lli Output/%.diff-jit Output/%.diff-opt- >> beta >> +.PRECIOUS: Output/%.diff-llc Output/%.diff-llc-beta Output/%.diff- >> cbe >> >> >> # Regardless of what other options are specified, build the >> program's bytecode >> @@ -259,6 +261,10 @@ >> Output/%.llvm.stripped.bc: Output/%.llvm.bc $(LOPT) >> -$(LOPT) -mstrip $< -o $@ -f >> >> +$(PROGRAMS_TO_TEST:%=Output/%.linked.optbeta.bc): \ >> +Output/%.linked.optbeta.bc: Output/%.linked.rbc $(LOPT) >> + -$(LOPT) $(OPTBETAOPTIONS) -time-passes -info-output-file=$ >> (CURDIR)/$@.info $(STATS) $< -o $@ -f >> + >> >> ifndef DISABLE_FOR_LLVM_PROGRAMS >> # Rule to produce final program bytecode file from linked, >> optimized, bytecode. >> @@ -281,6 +287,14 @@ >> $(MV) -f $@.tmp $@ >> endif >> >> +$(PROGRAMS_TO_TEST:%=Output/%.llvm.optbeta.bc): \ >> +Output/%.llvm.optbeta.bc: Output/%.linked.optbeta.bc $(LLVMLDPROG) >> + -$(LLVMLD) $(STATS) $< $(EXTRA_LINKTIME_OPT_FLAGS) $ >> (LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.llvm.optbeta >> + >> +$(PROGRAMS_TO_TEST:%=Output/%.llvm.optbeta): \ >> +Output/%.llvm.optbeta: Output/%.linked.optbeta.bc $(LLVMLDPROG) >> + -$(LLVMLD) $(STATS) $< $(LLVMLD_FLAGS) -lc $(LIBS) -o Output/ >> $*.llvm.optbeta >> + >> $(PROGRAMS_TO_TEST:%=Output/%.noopt-llvm.bc): \ >> Output/%.noopt-llvm.bc: Output/%.linked.rbc $(LLVMLDPROG) >> -$(LLVMLD) -disable-opt $(STATS) $(LLVMLD_FLAGS) $< -lc $(LIBS) -o >> Output/$*.noopt-llvm >> @@ -359,6 +373,10 @@ >> Output/%.llc-beta.s: Output/%.llvm.bc $(LLC) >> -$(LLC) $(LLCFLAGS) -f $(LLCBETAOPTION) $< -o $@ >> >> +$(PROGRAMS_TO_TEST:%=Output/%.opt-beta.s): \ >> +Output/%.opt-beta.s: Output/%.llvm.optbeta.bc $(LLC) >> + -$(LLC) $(LLCFLAGS) -f $< -o $@ >> + >> # On darwin, pass -force_cpusubtype_ALL to allow all ppc >> instructions. >> ifeq ($(ARCH),PowerPC) >> LLCASSEMBLERFLAGS = -force_cpusubtype_ALL >> @@ -378,6 +396,10 @@ >> Output/%.llc-beta: Output/%.llc-beta.s >> -$(LLVMGCCLD) $< -o $@ $(LLCLIBS) $(LLCASSEMBLERFLAGS) $ >> (TARGET_FLAGS) $(LDFLAGS) >> >> +$(PROGRAMS_TO_TEST:%=Output/%.opt-beta): \ >> +Output/%.opt-beta: Output/%.opt-beta.s >> + -$(LLVMGCCLD) $< -o $@ $(LLCLIBS) $(LLCASSEMBLERFLAGS) $ >> (TARGET_FLAGS) $(LDFLAGS) >> + >> >> # >> # Rules to execute the program >> @@ -431,6 +453,10 @@ >> Output/%.out-llc-beta: Output/%.llc-beta >> -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) >> >> +$(PROGRAMS_TO_TEST:%=Output/%.out-opt-beta): \ >> +Output/%.out-opt-beta: Output/%.opt-beta >> + -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) >> + >> $(PROGRAMS_TO_TEST:%=Output/%.out-cbe): \ >> Output/%.out-cbe: Output/%.cbe >> -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) >> @@ -491,6 +517,10 @@ >> Output/%.bugpoint-llc-beta: Output/%.llvm.bc $(LBUGPOINT) Output/ >> %.out-nat >> $(LBUGPOINT) $< -run-llc $(BUGPOINT_OPTIONS) $(LLCBETAOPTION) $ >> (BUGPOINT_ARGS) >> >> +$(PROGRAMS_TO_TEST:%=Output/%.bugpoint-opt-beta): \ >> +Output/%.bugpoint-opt-beta: Output/%.llvm.optbeta.bc $(LBUGPOINT) >> Output/%.out-nat >> + $(LBUGPOINT) $< -run-llc $(BUGPOINT_OPTIONS) $(LLCBETAOPTION) $ >> (BUGPOINT_ARGS) >> + >> $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-jit): \ >> Output/%.bugpoint-jit: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat >> $(LBUGPOINT) $< -run-jit $(BUGPOINT_OPTIONS) $(BUGPOINT_ARGS) >> @@ -561,6 +591,10 @@ >> Output/%.diff-llc-beta: Output/%.out-nat Output/%.out-llc-beta >> -$(DIFFPROG) llc-beta $* $(HIDEDIFF) >> >> +$(PROGRAMS_TO_TEST:%=Output/%.diff-opt-beta): \ >> +Output/%.diff-opt-beta: Output/%.out-nat Output/%.out-opt-beta >> + -$(DIFFPROG) opt-beta $* $(HIDEDIFF) >> + >> $(PROGRAMS_TO_TEST:%=Output/%.diff-cbe): \ >> Output/%.diff-cbe: Output/%.out-nat Output/%.out-cbe >> -$(DIFFPROG) cbe $* $(HIDEDIFF) >> @@ -591,6 +625,11 @@ >> -rm -f $@ >> -cp $< $@ >> >> +$(PROGRAMS_TO_TEST:%=Output/%.exe-opt-beta): \ >> +Output/%.exe-opt-beta: Output/%.diff-opt-beta >> + -rm -f $@ >> + -cp $< $@ >> + >> $(PROGRAMS_TO_TEST:%=Output/%.exe-cbe): \ >> Output/%.exe-cbe: Output/%.diff-cbe >> -rm -f $@ >> >> Modified: test-suite/trunk/TEST.nightly.Makefile >> URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/TEST.nightly.Makefile?rev=50678&r1=50677&r2=50678&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- test-suite/trunk/TEST.nightly.Makefile (original) >> +++ test-suite/trunk/TEST.nightly.Makefile Mon May 5 18:05:59 2008 >> @@ -22,6 +22,9 @@ >> ifdef ENABLE_LLCBETA >> REPORTS_TO_GEN += llc-beta >> endif >> +ifdef ENABLE_OPTBETA >> +REPORTS_TO_GEN += opt-beta >> +endif >> REPORTS_SUFFIX := $(addsuffix .report.txt, $(REPORTS_TO_GEN)) >> >> >> @@ -85,7 +88,22 @@ >> echo "TEST-FAIL: llc-beta $(RELDIR)/$*" >> $@;\ >> fi >> >> - >> +# OPT experimental tests >> +$(PROGRAMS_TO_TEST:%=Output/%.nightly.opt-beta.report.txt): \ >> +Output/%.nightly.opt-beta.report.txt: Output/%.llvm.optbeta.bc >> Output/%.exe-opt-beta $(LLC) >> + @echo > $@ >> + -head -n 100 Output/$*.exe-opt-beta >> $@ >> + @-if test -f Output/$*.exe-opt-beta; then \ >> + echo "TEST-PASS: opt-beta $(RELDIR)/$*" >> $@;\ >> + $(LLC) $< $(LLCFLAGS) -o /dev/null -f $(TIMEOPT) >> $@ 2>&1; \ >> + printf "TEST-RESULT-opt-beta: " >> $@;\ >> + grep "Total Execution Time" $@.info >> $@;\ >> + printf "TEST-RESULT-opt-beta-time: " >> $@;\ >> + grep "^program" Output/$*.out-opt-beta.time >> $@;\ >> + echo >> $@;\ >> + else \ >> + echo "TEST-FAIL: opt-beta $(RELDIR)/$*" >> $@;\ >> + fi >> >> # CBE tests >> $(PROGRAMS_TO_TEST:%=Output/%.nightly.cbe.report.txt): \ >> >> Modified: test-suite/trunk/TEST.nightly.report >> URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/TEST.nightly.report?rev=50678&r1=50677&r2=50678&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- test-suite/trunk/TEST.nightly.report (original) >> +++ test-suite/trunk/TEST.nightly.report Mon May 5 18:05:59 2008 >> @@ -56,6 +56,17 @@ >> return "-"; >> } >> >> +sub OPTOPT_BETARatio { # OPT/OPT-BETA >> + my ($Cols, $Col) = @_; >> + my $LLC = $Cols->[$Col-9]; >> + my $OPT_BETA = $Cols->[$Col-7]; >> + return "n/allc" if ($LLC eq "*"); >> + return "n/aopt" if ($OPT_BETA eq "*"); >> + return "n/a" if ($LLC eq "*" or $OPT_BETA eq "*"); >> + return sprintf("%3.2f", $LLC/$OPT_BETA) if ($LLC >= 0.1 and >> $OPT_BETA >= 0.1); >> + return "-"; >> +} >> + >> # highlight the RATIO columns with green/red. >> $HilightColumns{14} = 1; >> $HilightColumns{15} = 1; >> @@ -74,16 +85,19 @@ >> ["Bytecode" , 'TEST-RESULT-compile: *([0-9]+)'], >> ["LLC compile" , "TEST-RESULT-llc: .*$WallTimeRE"], >> ["LLC-BETA compile" , "TEST-RESULT-llc-beta: .*$WallTimeRE"], >> + ["OPT-BETA compile" , "TEST-RESULT-opt-beta: .*$WallTimeRE"], >> ["JIT codegen" , "TEST-RESULT-jit-comptime: .*$WallTimeRE"], >> [], >> ["GCC" , 'TEST-RESULT-nat-time: program\s*([.0-9m:]+)', >> \&FormatTime], >> ["CBE" , 'TEST-RESULT-cbe-time: program\s*([.0-9m:]+)', >> \&FormatTime], >> ["LLC" , 'TEST-RESULT-llc-time: program\s*([.0-9m:]+)', >> \&FormatTime], >> ["LLC-BETA" , 'TEST-RESULT-llc-beta-time: program\s*([.0-9m:]+)', >> \&FormatTime], >> + ["OPT-BETA" , 'TEST-RESULT-opt-beta-time: program\s*([.0-9m:]+)', >> \&FormatTime], >> ["JIT" , 'TEST-RESULT-jit-time: program\s*([.0-9m:]+)', >> \&FormatTime], >> [], >> ["GCC/CBE" , \&GCCCBERatio], >> ["GCC/LLC" , \&GCCLLCRatio], >> ["GCC/LLC-BETA" , \&GCCLLC_BETARatio], >> - ["LLC/LLC-BETA" , \&LLCLLC_BETARatio] >> + ["LLC/LLC-BETA" , \&LLCLLC_BETARatio], >> + ["OPT/OPT-BETA" , \&OPTOPT_BETARatio] >> ); >> >> >> _______________________________________________ >> 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 - Devang From clattner at apple.com Mon May 5 19:04:15 2008 From: clattner at apple.com (Chris Lattner) Date: Mon, 5 May 2008 17:04:15 -0700 Subject: [llvm-commits] [test-suite] r50678 - in /test-suite/trunk: Makefile.programs TEST.nightly.Makefile TEST.nightly.report In-Reply-To: <7DEDCD08-3ECF-4F58-A74D-2EC6D5B8B86C@apple.com> References: <200805052305.m45N5xou009853@zion.cs.uiuc.edu> <36944EB0-AC54-4A0B-9E43-D0BCA99A0D23@apple.com> <7DEDCD08-3ECF-4F58-A74D-2EC6D5B8B86C@apple.com> Message-ID: On May 5, 2008, at 5:02 PM, Devang Patel wrote: > > On May 5, 2008, at 4:57 PM, Chris Lattner wrote: > >> On May 5, 2008, at 4:05 PM, Devang Patel wrote: >>> URL: http://llvm.org/viewvc/llvm-project?rev=50678&view=rev >>> Log: >>> Add OPT_BETA support. >>> >>> Now you can do >>> make TEST=nightly ENABLE_OPTBETA=1 OPTBETAOPTIONS="-verify" >>> to see whether -std-comiple-opts passes are worth any dime or not. >> >> Cool. Did you verify that this does not break the nightly tester? >> Adding another column to its output could be bad. > > I'll disable the patch that updates report.html for now. Ideally, the nightly tester would also support this. Until then, please do what it takes to not break this. Even if it means cloning the nightly tester report to something temporary (make test=NIGHTLY2 ... or whatever) if necessary. -Chris From dpatel at apple.com Mon May 5 19:04:33 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 06 May 2008 00:04:33 -0000 Subject: [llvm-commits] [test-suite] r50685 - /test-suite/trunk/TEST.nightly.report Message-ID: <200805060004.m4604XOQ011895@zion.cs.uiuc.edu> Author: dpatel Date: Mon May 5 19:04:32 2008 New Revision: 50685 URL: http://llvm.org/viewvc/llvm-project?rev=50685&view=rev Log: Do not update report.html for OPT_BETA support. Modified: test-suite/trunk/TEST.nightly.report Modified: test-suite/trunk/TEST.nightly.report URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/TEST.nightly.report?rev=50685&r1=50684&r2=50685&view=diff ============================================================================== --- test-suite/trunk/TEST.nightly.report (original) +++ test-suite/trunk/TEST.nightly.report Mon May 5 19:04:32 2008 @@ -56,17 +56,6 @@ return "-"; } -sub OPTOPT_BETARatio { # OPT/OPT-BETA - my ($Cols, $Col) = @_; - my $LLC = $Cols->[$Col-9]; - my $OPT_BETA = $Cols->[$Col-7]; - return "n/allc" if ($LLC eq "*"); - return "n/aopt" if ($OPT_BETA eq "*"); - return "n/a" if ($LLC eq "*" or $OPT_BETA eq "*"); - return sprintf("%3.2f", $LLC/$OPT_BETA) if ($LLC >= 0.1 and $OPT_BETA >= 0.1); - return "-"; -} - # highlight the RATIO columns with green/red. $HilightColumns{14} = 1; $HilightColumns{15} = 1; @@ -85,19 +74,16 @@ ["Bytecode" , 'TEST-RESULT-compile: *([0-9]+)'], ["LLC compile" , "TEST-RESULT-llc: .*$WallTimeRE"], ["LLC-BETA compile" , "TEST-RESULT-llc-beta: .*$WallTimeRE"], - ["OPT-BETA compile" , "TEST-RESULT-opt-beta: .*$WallTimeRE"], ["JIT codegen" , "TEST-RESULT-jit-comptime: .*$WallTimeRE"], [], ["GCC" , 'TEST-RESULT-nat-time: program\s*([.0-9m:]+)', \&FormatTime], ["CBE" , 'TEST-RESULT-cbe-time: program\s*([.0-9m:]+)', \&FormatTime], ["LLC" , 'TEST-RESULT-llc-time: program\s*([.0-9m:]+)', \&FormatTime], ["LLC-BETA" , 'TEST-RESULT-llc-beta-time: program\s*([.0-9m:]+)',\&FormatTime], - ["OPT-BETA" , 'TEST-RESULT-opt-beta-time: program\s*([.0-9m:]+)',\&FormatTime], ["JIT" , 'TEST-RESULT-jit-time: program\s*([.0-9m:]+)', \&FormatTime], [], ["GCC/CBE" , \&GCCCBERatio], ["GCC/LLC" , \&GCCLLCRatio], ["GCC/LLC-BETA" , \&GCCLLC_BETARatio], - ["LLC/LLC-BETA" , \&LLCLLC_BETARatio], - ["OPT/OPT-BETA" , \&OPTOPT_BETARatio] + ["LLC/LLC-BETA" , \&LLCLLC_BETARatio] ); From resistor at mac.com Mon May 5 19:07:44 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 06 May 2008 00:07:44 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50686 - /llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Message-ID: <200805060007.m4607iFr012098@zion.cs.uiuc.edu> Author: resistor Date: Mon May 5 19:07:44 2008 New Revision: 50686 URL: http://llvm.org/viewvc/llvm-project?rev=50686&view=rev Log: Add loop deletion here too. Modified: llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp?rev=50686&r1=50685&r2=50686&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Mon May 5 19:07:44 2008 @@ -85,6 +85,8 @@ llvm::createStripDeadPrototypesPass(); llvm::createMemCpyOptPass(); llvm::createDeadTypeEliminationPass(); + llvm::createLoopDeletionPass(); + } /* LLVM LOCAL end (ENTIRE FILE!) */ From clattner at apple.com Mon May 5 19:09:52 2008 From: clattner at apple.com (Chris Lattner) Date: Mon, 5 May 2008 17:09:52 -0700 Subject: [llvm-commits] [test-suite] r50678 - in /test-suite/trunk: Makefile.programs TEST.nightly.Makefile TEST.nightly.report In-Reply-To: <200805052305.m45N5xou009853@zion.cs.uiuc.edu> References: <200805052305.m45N5xou009853@zion.cs.uiuc.edu> Message-ID: On May 5, 2008, at 4:05 PM, Devang Patel wrote: > Author: dpatel > Date: Mon May 5 18:05:59 2008 > New Revision: 50678 > > URL: http://llvm.org/viewvc/llvm-project?rev=50678&view=rev > Log: > Add OPT_BETA support. more details: > = > = > = > = > = > = > = > = > ====================================================================== > --- test-suite/trunk/TEST.nightly.report (original) > +++ test-suite/trunk/TEST.nightly.report Mon May 5 18:05:59 2008 > @@ -56,6 +56,17 @@ > return "-"; > } > > +sub OPTOPT_BETARatio { # OPT/OPT-BETA > + my ($Cols, $Col) = @_; > + my $LLC = $Cols->[$Col-9]; > + my $OPT_BETA = $Cols->[$Col-7]; > + return "n/allc" if ($LLC eq "*"); > + return "n/aopt" if ($OPT_BETA eq "*"); > + return "n/a" if ($LLC eq "*" or $OPT_BETA eq "*"); > + return sprintf("%3.2f", $LLC/$OPT_BETA) if ($LLC >= 0.1 and > $OPT_BETA >= 0.1); > + return "-"; > +} > + > # highlight the RATIO columns with green/red. > $HilightColumns{14} = 1; > $HilightColumns{15} = 1; > @@ -74,16 +85,19 @@ > ["Bytecode" , 'TEST-RESULT-compile: *([0-9]+)'], > ["LLC compile" , "TEST-RESULT-llc: .*$WallTimeRE"], > ["LLC-BETA compile" , "TEST-RESULT-llc-beta: .*$WallTimeRE"], > + ["OPT-BETA compile" , "TEST-RESULT-opt-beta: .*$WallTimeRE"], > ["JIT codegen" , "TEST-RESULT-jit-comptime: .*$WallTimeRE"], > [], > ["GCC" , 'TEST-RESULT-nat-time: program\s*([.0-9m:]+)', > \&FormatTime], > ["CBE" , 'TEST-RESULT-cbe-time: program\s*([.0-9m:]+)', > \&FormatTime], > ["LLC" , 'TEST-RESULT-llc-time: program\s*([.0-9m:]+)', > \&FormatTime], > ["LLC-BETA" , 'TEST-RESULT-llc-beta-time: program\s*([.0-9m:]+)', > \&FormatTime], > + ["OPT-BETA" , 'TEST-RESULT-opt-beta-time: program\s*([.0-9m:]+)', > \&FormatTime], > ["JIT" , 'TEST-RESULT-jit-time: program\s*([.0-9m:]+)', > \&FormatTime], > [], > ["GCC/CBE" , \&GCCCBERatio], > ["GCC/LLC" , \&GCCLLCRatio], > ["GCC/LLC-BETA" , \&GCCLLC_BETARatio], > - ["LLC/LLC-BETA" , \&LLCLLC_BETARatio] > + ["LLC/LLC-BETA" , \&LLCLLC_BETARatio], > + ["OPT/OPT-BETA" , \&OPTOPT_BETARatio] > ); This apparently broke all the ratios. Note that things like GCCLLCRatio are column dependent. > +$(PROGRAMS_TO_TEST:%=Output/%.llvm.optbeta.bc): \ > +Output/%.llvm.optbeta.bc: Output/%.linked.optbeta.bc $(LLVMLDPROG) > + -$(LLVMLD) $(STATS) $< $(EXTRA_LINKTIME_OPT_FLAGS) $ > (LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.llvm.optbeta > + > +$(PROGRAMS_TO_TEST:%=Output/%.llvm.optbeta): \ > +Output/%.llvm.optbeta: Output/%.linked.optbeta.bc $(LLVMLDPROG) > + -$(LLVMLD) $(STATS) $< $(LLVMLD_FLAGS) -lc $(LIBS) -o Output/ > $*.llvm.optbeta This should be the same invocation as the previous rule, specifically you need to pass EXTRA_LINKTIME_OPT_FLAGS right? > +$(PROGRAMS_TO_TEST:%=Output/%.bugpoint-opt-beta): \ > +Output/%.bugpoint-opt-beta: Output/%.llvm.optbeta.bc $(LBUGPOINT) > Output/%.out-nat > + $(LBUGPOINT) $< -run-llc $(BUGPOINT_OPTIONS) $(LLCBETAOPTION) $ > (BUGPOINT_ARGS) This seems wrong, you're passing in optbeta.bc which is already optimized. -Chris From dpatel at apple.com Mon May 5 19:17:50 2008 From: dpatel at apple.com (Devang Patel) Date: Mon, 5 May 2008 17:17:50 -0700 Subject: [llvm-commits] [test-suite] r50678 - in /test-suite/trunk: Makefile.programs TEST.nightly.Makefile TEST.nightly.report In-Reply-To: References: <200805052305.m45N5xou009853@zion.cs.uiuc.edu> Message-ID: <9E3DC020-1660-4BFD-ABD3-1AEADDEE0625@apple.com> On May 5, 2008, at 5:09 PM, Chris Lattner wrote: > > This apparently broke all the ratios. Note that things like > GCCLLCRatio are column dependent. I'll fix it. For now, I disabled this part. >> +$(PROGRAMS_TO_TEST:%=Output/%.llvm.optbeta.bc): \ >> +Output/%.llvm.optbeta.bc: Output/%.linked.optbeta.bc $(LLVMLDPROG) >> + -$(LLVMLD) $(STATS) $< $(EXTRA_LINKTIME_OPT_FLAGS) $ >> (LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.llvm.optbeta >> + >> +$(PROGRAMS_TO_TEST:%=Output/%.llvm.optbeta): \ >> +Output/%.llvm.optbeta: Output/%.linked.optbeta.bc $(LLVMLDPROG) >> + -$(LLVMLD) $(STATS) $< $(LLVMLD_FLAGS) -lc $(LIBS) -o Output/ >> $*.llvm.optbeta > > This should be the same invocation as the previous rule, specifically > you need to pass EXTRA_LINKTIME_OPT_FLAGS right? I copied Output/%.llvm.bc and Output/%.llvm respectively. >> +$(PROGRAMS_TO_TEST:%=Output/%.bugpoint-opt-beta): \ >> +Output/%.bugpoint-opt-beta: Output/%.llvm.optbeta.bc $(LBUGPOINT) >> Output/%.out-nat >> + $(LBUGPOINT) $< -run-llc $(BUGPOINT_OPTIONS) $(LLCBETAOPTION) $ >> (BUGPOINT_ARGS) > > This seems wrong, you're passing in optbeta.bc which is already > optimized. Aha.. I'll fix this. - Devang From gohman at apple.com Mon May 5 19:20:10 2008 From: gohman at apple.com (Dan Gohman) Date: Tue, 06 May 2008 00:20:10 -0000 Subject: [llvm-commits] [llvm] r50687 - in /llvm/trunk: include/llvm/CodeGen/MachineInstr.h lib/CodeGen/MachineInstr.cpp Message-ID: <200805060020.m460KBVT012707@zion.cs.uiuc.edu> Author: djg Date: Mon May 5 19:20:10 2008 New Revision: 50687 URL: http://llvm.org/viewvc/llvm-project?rev=50687&view=rev Log: Fix a broken doxygen comment, and reword it for clarity. Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h llvm/trunk/lib/CodeGen/MachineInstr.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstr.h?rev=50687&r1=50686&r2=50687&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineInstr.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineInstr.h Mon May 5 19:20:10 2008 @@ -184,10 +184,9 @@ } /// findRegisterDefOperandIdx() - Returns the operand index that is a def of - /// the specific register or -1 if it is not found. It further tightening - /// the search criteria to a def that is dead the register if isDead is true. - /// If TargetRegisterInfo is passed, then it also checks if there is a def of - /// a super-register. + /// the specified register or -1 if it is not found. If isDead is true, defs + /// that are not dead are skipped. If TargetRegisterInfo is non-null, then it + /// also checks if there is a def of a super-register. int findRegisterDefOperandIdx(unsigned Reg, bool isDead = false, const TargetRegisterInfo *TRI = NULL) const; Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=50687&r1=50686&r2=50687&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Mon May 5 19:20:10 2008 @@ -553,8 +553,9 @@ } /// findRegisterDefOperandIdx() - Returns the operand index that is a def of -/// the specific register or -1 if it is not found. It further tightening - /// the search criteria to a def that is dead the register if isDead is true. +/// the specified register or -1 if it is not found. If isDead is true, defs +/// that are not dead are skipped. If TargetRegisterInfo is non-null, then it +/// also checks if there is a def of a super-register. int MachineInstr::findRegisterDefOperandIdx(unsigned Reg, bool isDead, const TargetRegisterInfo *TRI) const { for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { From clattner at apple.com Mon May 5 19:38:28 2008 From: clattner at apple.com (Chris Lattner) Date: Mon, 5 May 2008 17:38:28 -0700 Subject: [llvm-commits] [test-suite] r50678 - in /test-suite/trunk: Makefile.programs TEST.nightly.Makefile TEST.nightly.report In-Reply-To: <9E3DC020-1660-4BFD-ABD3-1AEADDEE0625@apple.com> References: <200805052305.m45N5xou009853@zion.cs.uiuc.edu> <9E3DC020-1660-4BFD-ABD3-1AEADDEE0625@apple.com> Message-ID: On May 5, 2008, at 5:17 PM, Devang Patel wrote: >>> +$(PROGRAMS_TO_TEST:%=Output/%.llvm.optbeta.bc): \ >>> +Output/%.llvm.optbeta.bc: Output/%.linked.optbeta.bc $(LLVMLDPROG) >>> + -$(LLVMLD) $(STATS) $< $(EXTRA_LINKTIME_OPT_FLAGS) $ >>> (LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.llvm.optbeta >>> + >>> +$(PROGRAMS_TO_TEST:%=Output/%.llvm.optbeta): \ >>> +Output/%.llvm.optbeta: Output/%.linked.optbeta.bc $(LLVMLDPROG) >>> + -$(LLVMLD) $(STATS) $< $(LLVMLD_FLAGS) -lc $(LIBS) -o Output/ >>> $*.llvm.optbeta >> >> This should be the same invocation as the previous rule, specifically >> you need to pass EXTRA_LINKTIME_OPT_FLAGS right? > > I copied Output/%.llvm.bc and Output/%.llvm respectively. Ok, please update them too :) >> This seems wrong, you're passing in optbeta.bc which is already >> optimized. > > Aha.. I'll fix this. Thanks, -Chris From gohman at apple.com Mon May 5 19:51:49 2008 From: gohman at apple.com (Dan Gohman) Date: Tue, 06 May 2008 00:51:49 -0000 Subject: [llvm-commits] [llvm] r50692 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/srem-simplify-bug.ll Message-ID: <200805060051.m460poBI014200@zion.cs.uiuc.edu> Author: djg Date: Mon May 5 19:51:48 2008 New Revision: 50692 URL: http://llvm.org/viewvc/llvm-project?rev=50692&view=rev Log: Correct the value of LowBits in srem and urem handling in ComputeMaskedBits. Added: llvm/trunk/test/Transforms/InstCombine/srem-simplify-bug.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=50692&r1=50691&r2=50692&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon May 5 19:51:48 2008 @@ -1560,7 +1560,7 @@ if (ConstantSDNode *Rem = dyn_cast(Op.getOperand(1))) { APInt RA = Rem->getAPIntValue(); if (RA.isPowerOf2() || (-RA).isPowerOf2()) { - APInt LowBits = RA.isStrictlyPositive() ? ((RA - 1) | RA) : ~RA; + APInt LowBits = RA.isStrictlyPositive() ? (RA - 1) : ~RA; APInt Mask2 = LowBits | APInt::getSignBit(BitWidth); ComputeMaskedBits(Op.getOperand(0), Mask2,KnownZero2,KnownOne2,Depth+1); @@ -1581,8 +1581,8 @@ case ISD::UREM: { if (ConstantSDNode *Rem = dyn_cast(Op.getOperand(1))) { APInt RA = Rem->getAPIntValue(); - if (RA.isStrictlyPositive() && RA.isPowerOf2()) { - APInt LowBits = (RA - 1) | RA; + if (RA.isPowerOf2()) { + APInt LowBits = (RA - 1); APInt Mask2 = LowBits & Mask; KnownZero |= ~LowBits & Mask; ComputeMaskedBits(Op.getOperand(0), Mask2, KnownZero, KnownOne,Depth+1); Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=50692&r1=50691&r2=50692&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon May 5 19:51:48 2008 @@ -965,7 +965,7 @@ if (ConstantInt *Rem = dyn_cast(I->getOperand(1))) { APInt RA = Rem->getValue(); if (RA.isPowerOf2() || (-RA).isPowerOf2()) { - APInt LowBits = RA.isStrictlyPositive() ? ((RA - 1) | RA) : ~RA; + APInt LowBits = RA.isStrictlyPositive() ? (RA - 1) : ~RA; APInt Mask2 = LowBits | APInt::getSignBit(BitWidth); ComputeMaskedBits(I->getOperand(0), Mask2,KnownZero2,KnownOne2,Depth+1); @@ -986,8 +986,8 @@ case Instruction::URem: { if (ConstantInt *Rem = dyn_cast(I->getOperand(1))) { APInt RA = Rem->getValue(); - if (RA.isStrictlyPositive() && RA.isPowerOf2()) { - APInt LowBits = (RA - 1) | RA; + if (RA.isPowerOf2()) { + APInt LowBits = (RA - 1); APInt Mask2 = LowBits & Mask; KnownZero |= ~LowBits & Mask; ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero, KnownOne,Depth+1); @@ -1728,7 +1728,7 @@ if (ConstantInt *Rem = dyn_cast(I->getOperand(1))) { APInt RA = Rem->getValue(); if (RA.isPowerOf2() || (-RA).isPowerOf2()) { - APInt LowBits = RA.isStrictlyPositive() ? (RA - 1) | RA : ~RA; + APInt LowBits = RA.isStrictlyPositive() ? (RA - 1) : ~RA; APInt Mask2 = LowBits | APInt::getSignBit(BitWidth); if (SimplifyDemandedBits(I->getOperand(0), Mask2, LHSKnownZero, LHSKnownOne, Depth+1)) @@ -1749,8 +1749,8 @@ case Instruction::URem: { if (ConstantInt *Rem = dyn_cast(I->getOperand(1))) { APInt RA = Rem->getValue(); - if (RA.isStrictlyPositive() && RA.isPowerOf2()) { - APInt LowBits = (RA - 1) | RA; + if (RA.isPowerOf2()) { + APInt LowBits = (RA - 1); APInt Mask2 = LowBits & DemandedMask; KnownZero |= ~LowBits & DemandedMask; if (SimplifyDemandedBits(I->getOperand(0), Mask2, Added: llvm/trunk/test/Transforms/InstCombine/srem-simplify-bug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/srem-simplify-bug.ll?rev=50692&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/srem-simplify-bug.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/srem-simplify-bug.ll Mon May 5 19:51:48 2008 @@ -0,0 +1,9 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {ret i1 false} +; PR2276 + +define i1 @f(i32 %x) { + %A = or i32 %x, 1 + %B = srem i32 %A, 1 + %C = icmp ne i32 %B, 0 + ret i1 %C +} From gohman at apple.com Mon May 5 19:53:29 2008 From: gohman at apple.com (Dan Gohman) Date: Tue, 06 May 2008 00:53:29 -0000 Subject: [llvm-commits] [llvm] r50693 - /llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Message-ID: <200805060053.m460rTqe014267@zion.cs.uiuc.edu> Author: djg Date: Mon May 5 19:53:29 2008 New Revision: 50693 URL: http://llvm.org/viewvc/llvm-project?rev=50693&view=rev Log: Instead of enumerating each opcode that isn't handled that ComputeMaskedBits handles, just use a 'default:'. This avoids TargetLowering's list getting out of date with SelectionDAG's. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=50693&r1=50692&r2=50693&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Mon May 5 19:53:29 2008 @@ -979,17 +979,7 @@ } #endif break; - case ISD::ADD: - case ISD::SUB: - case ISD::INTRINSIC_WO_CHAIN: - case ISD::INTRINSIC_W_CHAIN: - case ISD::INTRINSIC_VOID: - case ISD::CTTZ: - case ISD::CTLZ: - case ISD::CTPOP: - case ISD::LOAD: - case ISD::SETCC: - case ISD::FGETSIGN: + default: // Just use ComputeMaskedBits to compute output bits. TLO.DAG.ComputeMaskedBits(Op, NewMask, KnownZero, KnownOne, Depth); break; From gohman at apple.com Mon May 5 20:32:55 2008 From: gohman at apple.com (Dan Gohman) Date: Tue, 06 May 2008 01:32:55 -0000 Subject: [llvm-commits] [llvm] r50695 - in /llvm/trunk: include/llvm/ include/llvm/Analysis/ include/llvm/CodeGen/ include/llvm/Support/ include/llvm/System/ include/llvm/Transforms/Utils/ lib/Analysis/ lib/Analysis/IPA/ lib/CodeGen/ lib/Support/ lib/System/ lib/Transforms/Utils/ lib/VMCore/ Message-ID: <200805060132.m461Wuns015814@zion.cs.uiuc.edu> Author: djg Date: Mon May 5 20:32:53 2008 New Revision: 50695 URL: http://llvm.org/viewvc/llvm-project?rev=50695&view=rev Log: Remove uses of llvm/System/IncludeFile.h that are no longer needed. Modified: llvm/trunk/include/llvm/Analysis/CallGraph.h llvm/trunk/include/llvm/Analysis/FindUsedTypes.h llvm/trunk/include/llvm/Analysis/LoopInfo.h llvm/trunk/include/llvm/Analysis/PostDominators.h llvm/trunk/include/llvm/Analysis/ValueNumbering.h llvm/trunk/include/llvm/CodeGen/MachineLoopInfo.h llvm/trunk/include/llvm/IntrinsicInst.h llvm/trunk/include/llvm/PassSupport.h llvm/trunk/include/llvm/Support/Dwarf.h llvm/trunk/include/llvm/Support/Mangler.h llvm/trunk/include/llvm/System/Alarm.h llvm/trunk/include/llvm/System/DynamicLibrary.h llvm/trunk/include/llvm/System/Memory.h llvm/trunk/include/llvm/System/Process.h llvm/trunk/include/llvm/System/Program.h llvm/trunk/include/llvm/System/Signals.h llvm/trunk/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp llvm/trunk/lib/Analysis/LoopInfo.cpp llvm/trunk/lib/Analysis/PostDominators.cpp llvm/trunk/lib/CodeGen/MachineLoopInfo.cpp llvm/trunk/lib/Support/Dwarf.cpp llvm/trunk/lib/System/Alarm.cpp llvm/trunk/lib/System/DynamicLibrary.cpp llvm/trunk/lib/System/Memory.cpp llvm/trunk/lib/System/Mutex.cpp llvm/trunk/lib/System/Process.cpp llvm/trunk/lib/System/Program.cpp llvm/trunk/lib/System/Signals.cpp llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp llvm/trunk/lib/VMCore/IntrinsicInst.cpp llvm/trunk/lib/VMCore/Mangler.cpp Modified: llvm/trunk/include/llvm/Analysis/CallGraph.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CallGraph.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/CallGraph.h (original) +++ llvm/trunk/include/llvm/Analysis/CallGraph.h Mon May 5 20:32:53 2008 @@ -55,6 +55,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Pass.h" #include "llvm/Support/CallSite.h" +#include "llvm/System/IncludeFile.h" #include namespace llvm { @@ -158,10 +159,7 @@ void print(std::ostream *o, const Module *M) const { if (o) print(*o, M); } void dump() const; - // stub - dummy function, just ignore it - static int stub; protected: - // destroy - Release memory for the call graph virtual void destroy(); }; Modified: llvm/trunk/include/llvm/Analysis/FindUsedTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/FindUsedTypes.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/FindUsedTypes.h (original) +++ llvm/trunk/include/llvm/Analysis/FindUsedTypes.h Mon May 5 20:32:53 2008 @@ -61,7 +61,4 @@ } // End llvm namespace -// Make sure that any clients of this file link in PostDominators.cpp -FORCE_DEFINING_FILE_TO_BE_LINKED(FindUsedTypes) - #endif Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfo.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Mon May 5 20:32:53 2008 @@ -1013,7 +1013,4 @@ } // End llvm namespace -// Make sure that any clients of this file link in LoopInfo.cpp -FORCE_DEFINING_FILE_TO_BE_LINKED(LoopInfo) - #endif Modified: llvm/trunk/include/llvm/Analysis/PostDominators.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/PostDominators.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/PostDominators.h (original) +++ llvm/trunk/include/llvm/Analysis/PostDominators.h Mon May 5 20:32:53 2008 @@ -92,7 +92,4 @@ } // End llvm namespace -// Make sure that any clients of this file link in PostDominators.cpp -FORCE_DEFINING_FILE_TO_BE_LINKED(PostDominanceFrontier) - #endif Modified: llvm/trunk/include/llvm/Analysis/ValueNumbering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ValueNumbering.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ValueNumbering.h (original) +++ llvm/trunk/include/llvm/Analysis/ValueNumbering.h Mon May 5 20:32:53 2008 @@ -22,6 +22,7 @@ #include #include "llvm/Pass.h" +#include "llvm/System/IncludeFile.h" namespace llvm { Modified: llvm/trunk/include/llvm/CodeGen/MachineLoopInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineLoopInfo.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineLoopInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineLoopInfo.h Mon May 5 20:32:53 2008 @@ -187,7 +187,4 @@ } // End llvm namespace -// Make sure that any clients of this file link in LoopInfo.cpp -FORCE_DEFINING_FILE_TO_BE_LINKED(MachineLoopInfo) - #endif Modified: llvm/trunk/include/llvm/IntrinsicInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicInst.h (original) +++ llvm/trunk/include/llvm/IntrinsicInst.h Mon May 5 20:32:53 2008 @@ -28,7 +28,6 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Intrinsics.h" -#include "llvm/System/IncludeFile.h" namespace llvm { /// IntrinsicInst - A useful wrapper class for inspecting calls to intrinsic @@ -316,8 +315,4 @@ } -// Ensure that the IntrinsicInst.cpp file gets added as a dependency of any -// file that includes this header -FORCE_DEFINING_FILE_TO_BE_LINKED(IntrinsicInst) - #endif Modified: llvm/trunk/include/llvm/PassSupport.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassSupport.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/PassSupport.h (original) +++ llvm/trunk/include/llvm/PassSupport.h Mon May 5 20:32:53 2008 @@ -21,7 +21,6 @@ #ifndef LLVM_PASS_SUPPORT_H #define LLVM_PASS_SUPPORT_H -#include "llvm/System/IncludeFile.h" // No need to include Pass.h, we are being included by it! namespace llvm { Modified: llvm/trunk/include/llvm/Support/Dwarf.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Dwarf.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Dwarf.h (original) +++ llvm/trunk/include/llvm/Support/Dwarf.h Mon May 5 20:32:53 2008 @@ -16,8 +16,6 @@ #ifndef LLVM_SUPPORT_DWARF_H #define LLVM_SUPPORT_DWARF_H -#include "llvm/System/IncludeFile.h" - namespace llvm { namespace dwarf { @@ -567,6 +565,4 @@ } // End of namespace llvm -FORCE_DEFINING_FILE_TO_BE_LINKED(SupportDwarf) - #endif Modified: llvm/trunk/include/llvm/Support/Mangler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Mangler.h (original) +++ llvm/trunk/include/llvm/Support/Mangler.h Mon May 5 20:32:53 2008 @@ -14,7 +14,6 @@ #ifndef LLVM_SUPPORT_MANGLER_H #define LLVM_SUPPORT_MANGLER_H -#include "llvm/System/IncludeFile.h" #include #include #include @@ -112,7 +111,4 @@ } // End llvm namespace -// Force the Mangler.cpp file to be linked when this header is #included -FORCE_DEFINING_FILE_TO_BE_LINKED(Mangler) - #endif // LLVM_SUPPORT_MANGLER_H Modified: llvm/trunk/include/llvm/System/Alarm.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Alarm.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Alarm.h (original) +++ llvm/trunk/include/llvm/System/Alarm.h Mon May 5 20:32:53 2008 @@ -17,8 +17,6 @@ #ifndef LLVM_SYSTEM_ALARM_H #define LLVM_SYSTEM_ALARM_H -#include "llvm/System/IncludeFile.h" - namespace llvm { namespace sys { @@ -44,6 +42,4 @@ } // End sys namespace } // End llvm namespace -FORCE_DEFINING_FILE_TO_BE_LINKED(SystemAlarm) - #endif Modified: llvm/trunk/include/llvm/System/DynamicLibrary.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/DynamicLibrary.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/DynamicLibrary.h (original) +++ llvm/trunk/include/llvm/System/DynamicLibrary.h Mon May 5 20:32:53 2008 @@ -15,7 +15,6 @@ #define LLVM_SYSTEM_DYNAMIC_LIBRARY_H #include "llvm/System/Path.h" -#include "llvm/System/IncludeFile.h" #include namespace llvm { @@ -96,6 +95,4 @@ } // End sys namespace } // End llvm namespace -FORCE_DEFINING_FILE_TO_BE_LINKED(SystemDynamicLibrary) - #endif // LLVM_SYSTEM_DYNAMIC_LIBRARY_H Modified: llvm/trunk/include/llvm/System/Memory.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Memory.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Memory.h (original) +++ llvm/trunk/include/llvm/System/Memory.h Mon May 5 20:32:53 2008 @@ -15,7 +15,6 @@ #define LLVM_SYSTEM_MEMORY_H #include -#include "llvm/System/IncludeFile.h" namespace llvm { namespace sys { @@ -71,6 +70,4 @@ } } -FORCE_DEFINING_FILE_TO_BE_LINKED(SystemMemory) - #endif Modified: llvm/trunk/include/llvm/System/Process.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Process.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Process.h (original) +++ llvm/trunk/include/llvm/System/Process.h Mon May 5 20:32:53 2008 @@ -15,7 +15,6 @@ #define LLVM_SYSTEM_PROCESS_H #include "llvm/System/TimeValue.h" -#include "llvm/System/IncludeFile.h" namespace llvm { namespace sys { @@ -100,6 +99,4 @@ } } -FORCE_DEFINING_FILE_TO_BE_LINKED(SystemProcess) - #endif Modified: llvm/trunk/include/llvm/System/Program.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Program.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Program.h (original) +++ llvm/trunk/include/llvm/System/Program.h Mon May 5 20:32:53 2008 @@ -15,7 +15,6 @@ #define LLVM_SYSTEM_PROGRAM_H #include "llvm/System/Path.h" -#include "llvm/System/IncludeFile.h" #include namespace llvm { @@ -90,6 +89,4 @@ } } -FORCE_DEFINING_FILE_TO_BE_LINKED(SystemProgram) - #endif Modified: llvm/trunk/include/llvm/System/Signals.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Signals.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Signals.h (original) +++ llvm/trunk/include/llvm/System/Signals.h Mon May 5 20:32:53 2008 @@ -16,7 +16,6 @@ #define LLVM_SYSTEM_SIGNALS_H #include "llvm/System/Path.h" -#include "llvm/System/IncludeFile.h" namespace llvm { namespace sys { @@ -50,6 +49,4 @@ } // End sys namespace } // End llvm namespace -FORCE_DEFINING_FILE_TO_BE_LINKED(SystemSignals) - #endif Modified: llvm/trunk/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h Mon May 5 20:32:53 2008 @@ -40,16 +40,10 @@ BasicBlock *getUnreachableBlock() const { return UnreachableBlock; } virtual bool runOnFunction(Function &F); - - // Force linking the impl of this class into anything that uses this header. - static int stub; }; Pass *createUnifyFunctionExitNodesPass(); -static IncludeFile -UNIFY_FUNCTION_EXIT_NODES_INCLUDE_FILE(&UnifyFunctionExitNodes::stub); - } // End llvm namespace #endif Modified: llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp Mon May 5 20:32:53 2008 @@ -96,6 +96,3 @@ E = UsedTypes.end(); I != E; ++I) WriteTypeSymbolic(o << " ", *I, M) << "\n"; } - -// Ensure that this file gets linked in when FindUsedTypes.h is used. -DEFINING_FILE_FOR(FindUsedTypes) Modified: llvm/trunk/lib/Analysis/LoopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopInfo.cpp?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LoopInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LoopInfo.cpp Mon May 5 20:32:53 2008 @@ -51,6 +51,3 @@ AU.setPreservesAll(); AU.addRequired(); } - -// Ensure this file gets linked when LoopInfo.h is used. -DEFINING_FILE_FOR(LoopInfo) Modified: llvm/trunk/lib/Analysis/PostDominators.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/PostDominators.cpp?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/PostDominators.cpp (original) +++ llvm/trunk/lib/Analysis/PostDominators.cpp Mon May 5 20:32:53 2008 @@ -84,6 +84,3 @@ return S; } - -// Ensure that this .cpp file gets linked when PostDominators.h is used. -DEFINING_FILE_FOR(PostDominanceFrontier) Modified: llvm/trunk/lib/CodeGen/MachineLoopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineLoopInfo.cpp?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineLoopInfo.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineLoopInfo.cpp Mon May 5 20:32:53 2008 @@ -40,6 +40,3 @@ AU.setPreservesAll(); AU.addRequired(); } - -// Ensure this file gets linked when MachineLoopInfo.h is used. -DEFINING_FILE_FOR(MachineLoopInfo) Modified: llvm/trunk/lib/Support/Dwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Dwarf.cpp?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/lib/Support/Dwarf.cpp (original) +++ llvm/trunk/lib/Support/Dwarf.cpp Mon May 5 20:32:53 2008 @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/Dwarf.h" -#include "llvm/System/IncludeFile.h" #include @@ -582,5 +581,3 @@ } // End of namespace dwarf. } // End of namespace llvm. - -DEFINING_FILE_FOR(SupportDwarf) Modified: llvm/trunk/lib/System/Alarm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Alarm.cpp?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/lib/System/Alarm.cpp (original) +++ llvm/trunk/lib/System/Alarm.cpp Mon May 5 20:32:53 2008 @@ -31,5 +31,3 @@ #ifdef LLVM_ON_WIN32 #include "Win32/Alarm.inc" #endif - -DEFINING_FILE_FOR(SystemAlarm) Modified: llvm/trunk/lib/System/DynamicLibrary.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/DynamicLibrary.cpp?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/lib/System/DynamicLibrary.cpp (original) +++ llvm/trunk/lib/System/DynamicLibrary.cpp Mon May 5 20:32:53 2008 @@ -159,5 +159,3 @@ } #endif // LLVM_ON_WIN32 - -DEFINING_FILE_FOR(SystemDynamicLibrary) Modified: llvm/trunk/lib/System/Memory.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Memory.cpp?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/lib/System/Memory.cpp (original) +++ llvm/trunk/lib/System/Memory.cpp Mon May 5 20:32:53 2008 @@ -14,7 +14,6 @@ #include "llvm/System/Memory.h" #include "llvm/Config/config.h" -#include "llvm/System/IncludeFile.h" namespace llvm { using namespace sys; @@ -33,5 +32,3 @@ #ifdef LLVM_ON_WIN32 #include "Win32/Memory.inc" #endif - -DEFINING_FILE_FOR(SystemMemory) Modified: llvm/trunk/lib/System/Mutex.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Mutex.cpp?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/lib/System/Mutex.cpp (original) +++ llvm/trunk/lib/System/Mutex.cpp Mon May 5 20:32:53 2008 @@ -13,7 +13,6 @@ #include "llvm/Config/config.h" #include "llvm/System/Mutex.h" -#include "llvm/System/IncludeFile.h" //===----------------------------------------------------------------------===// //=== WARNING: Implementation here must contain only TRULY operating system Modified: llvm/trunk/lib/System/Process.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Process.cpp?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/lib/System/Process.cpp (original) +++ llvm/trunk/lib/System/Process.cpp Mon May 5 20:32:53 2008 @@ -31,5 +31,3 @@ #ifdef LLVM_ON_WIN32 #include "Win32/Process.inc" #endif - -DEFINING_FILE_FOR(SystemProcess) Modified: llvm/trunk/lib/System/Program.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Program.cpp?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/lib/System/Program.cpp (original) +++ llvm/trunk/lib/System/Program.cpp Mon May 5 20:32:53 2008 @@ -31,5 +31,3 @@ #ifdef LLVM_ON_WIN32 #include "Win32/Program.inc" #endif - -DEFINING_FILE_FOR(SystemProgram) Modified: llvm/trunk/lib/System/Signals.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Signals.cpp?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/lib/System/Signals.cpp (original) +++ llvm/trunk/lib/System/Signals.cpp Mon May 5 20:32:53 2008 @@ -32,5 +32,3 @@ #ifdef LLVM_ON_WIN32 #include "Win32/Signals.inc" #endif - -DEFINING_FILE_FOR(SystemSignals) Modified: llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Mon May 5 20:32:53 2008 @@ -28,8 +28,6 @@ static RegisterPass X("mergereturn", "Unify function exit nodes"); -int UnifyFunctionExitNodes::stub; - Pass *llvm::createUnifyFunctionExitNodesPass() { return new UnifyFunctionExitNodes(); } Modified: llvm/trunk/lib/VMCore/IntrinsicInst.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/IntrinsicInst.cpp?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/IntrinsicInst.cpp (original) +++ llvm/trunk/lib/VMCore/IntrinsicInst.cpp Mon May 5 20:32:53 2008 @@ -74,7 +74,3 @@ ConstantStruct *CS = cast(GV->getInitializer()); return CS->getOperand(4)->getStringValue(); } - -//===----------------------------------------------------------------------===// -/// Ensure that users of IntrinsicInst.h will link with this module. -DEFINING_FILE_FOR(IntrinsicInst) Modified: llvm/trunk/lib/VMCore/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=50695&r1=50694&r2=50695&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Mangler.cpp (original) +++ llvm/trunk/lib/VMCore/Mangler.cpp Mon May 5 20:32:53 2008 @@ -211,6 +211,3 @@ for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) InsertName(I, Names); } - -// Cause this file to be linked in when Support/Mangler.h is #included -DEFINING_FILE_FOR(Mangler) From gohman at apple.com Mon May 5 20:53:17 2008 From: gohman at apple.com (Dan Gohman) Date: Tue, 06 May 2008 01:53:17 -0000 Subject: [llvm-commits] [llvm] r50696 - in /llvm/trunk/lib: Analysis/ CodeGen/ CodeGen/SelectionDAG/ Target/ Transforms/IPO/ Transforms/Instrumentation/ Transforms/Scalar/ Transforms/Utils/ Message-ID: <200805060153.m461rHCP016412@zion.cs.uiuc.edu> Author: djg Date: Mon May 5 20:53:16 2008 New Revision: 50696 URL: http://llvm.org/viewvc/llvm-project?rev=50696&view=rev Log: Make several variable declarations static. Modified: llvm/trunk/lib/Analysis/AliasAnalysisCounter.cpp llvm/trunk/lib/Analysis/AliasAnalysisEvaluator.cpp llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp llvm/trunk/lib/CodeGen/BranchFolding.cpp llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/Passes.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/trunk/lib/Target/TargetMachine.cpp llvm/trunk/lib/Transforms/IPO/Inliner.cpp llvm/trunk/lib/Transforms/IPO/Internalize.cpp llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp llvm/trunk/lib/Transforms/Scalar/LICM.cpp llvm/trunk/lib/Transforms/Scalar/LoopUnroll.cpp llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp llvm/trunk/lib/Transforms/Utils/BasicInliner.cpp Modified: llvm/trunk/lib/Analysis/AliasAnalysisCounter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasAnalysisCounter.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/AliasAnalysisCounter.cpp (original) +++ llvm/trunk/lib/Analysis/AliasAnalysisCounter.cpp Mon May 5 20:53:16 2008 @@ -22,9 +22,9 @@ using namespace llvm; namespace { - cl::opt + static cl::opt PrintAll("count-aa-print-all-queries", cl::ReallyHidden); - cl::opt + static cl::opt PrintAllFailures("count-aa-print-all-failed-queries", cl::ReallyHidden); class VISIBILITY_HIDDEN AliasAnalysisCounter Modified: llvm/trunk/lib/Analysis/AliasAnalysisEvaluator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasAnalysisEvaluator.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/AliasAnalysisEvaluator.cpp (original) +++ llvm/trunk/lib/Analysis/AliasAnalysisEvaluator.cpp Mon May 5 20:53:16 2008 @@ -35,16 +35,17 @@ using namespace llvm; namespace { - cl::opt PrintAll("print-all-alias-modref-info", cl::ReallyHidden); + static cl::opt + PrintAll("print-all-alias-modref-info", cl::ReallyHidden); - cl::opt PrintNoAlias("print-no-aliases", cl::ReallyHidden); - cl::opt PrintMayAlias("print-may-aliases", cl::ReallyHidden); - cl::opt PrintMustAlias("print-must-aliases", cl::ReallyHidden); - - cl::opt PrintNoModRef("print-no-modref", cl::ReallyHidden); - cl::opt PrintMod("print-mod", cl::ReallyHidden); - cl::opt PrintRef("print-ref", cl::ReallyHidden); - cl::opt PrintModRef("print-modref", cl::ReallyHidden); + static cl::opt PrintNoAlias("print-no-aliases", cl::ReallyHidden); + static cl::opt PrintMayAlias("print-may-aliases", cl::ReallyHidden); + static cl::opt PrintMustAlias("print-must-aliases", cl::ReallyHidden); + + static cl::opt PrintNoModRef("print-no-modref", cl::ReallyHidden); + static cl::opt PrintMod("print-mod", cl::ReallyHidden); + static cl::opt PrintRef("print-ref", cl::ReallyHidden); + static cl::opt PrintModRef("print-modref", cl::ReallyHidden); class VISIBILITY_HIDDEN AAEval : public FunctionPass { unsigned NoAlias, MayAlias, MustAlias; @@ -75,7 +76,7 @@ }; char AAEval::ID = 0; - RegisterPass + static RegisterPass X("aa-eval", "Exhaustive Alias Analysis Precision Evaluator", false, true); } Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Mon May 5 20:53:16 2008 @@ -31,7 +31,7 @@ namespace { // Control the calculation of non-local dependencies by only examining the // predecessors if the basic block has less than X amount (50 by default). - cl::opt + static cl::opt PredLimit("nonlocaldep-threshold", cl::Hidden, cl::init(50), cl::desc("Control the calculation of non-local" "dependencies (default = 50)")); Modified: llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp (original) +++ llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp Mon May 5 20:53:16 2008 @@ -24,7 +24,7 @@ using namespace llvm; namespace { - cl::opt + static cl::opt ProfileInfoFilename("profile-info-file", cl::init("llvmprof.out"), cl::value_desc("filename"), cl::desc("Profile file loaded by -profile-loader")); Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Mon May 5 20:53:16 2008 @@ -40,7 +40,7 @@ cl::init(cl::BOU_UNSET), cl::Hidden); namespace { // Throttle for huge numbers of predecessors (compile speed problems) - cl::opt + static cl::opt TailMergeThreshold("tail-merge-threshold", cl::desc("Max number of predecessors to consider tail merging"), cl::init(100), cl::Hidden); Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon May 5 20:53:16 2008 @@ -38,13 +38,13 @@ namespace { // Hidden options for help debugging. - cl::opt DisableReMat("disable-rematerialization", - cl::init(false), cl::Hidden); + static cl::opt DisableReMat("disable-rematerialization", + cl::init(false), cl::Hidden); - cl::opt SplitAtBB("split-intervals-at-bb", - cl::init(true), cl::Hidden); - cl::opt SplitLimit("split-limit", - cl::init(-1), cl::Hidden); + static cl::opt SplitAtBB("split-intervals-at-bb", + cl::init(true), cl::Hidden); + static cl::opt SplitLimit("split-limit", + cl::init(-1), cl::Hidden); } STATISTIC(numIntervals, "Number of original intervals"); Modified: llvm/trunk/lib/CodeGen/Passes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Passes.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Passes.cpp (original) +++ llvm/trunk/lib/CodeGen/Passes.cpp Mon May 5 20:53:16 2008 @@ -31,6 +31,7 @@ /// //===---------------------------------------------------------------------===// namespace { + static cl::opt > RegAlloc("regalloc", Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon May 5 20:53:16 2008 @@ -75,8 +75,8 @@ /// //===---------------------------------------------------------------------===// namespace { - cl::opt > + static cl::opt > ISHeuristic("pre-RA-sched", cl::init(&createDefaultScheduler), cl::desc("Instruction schedulers available (before register" Modified: llvm/trunk/lib/Target/TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/TargetMachine.cpp Mon May 5 20:53:16 2008 @@ -138,13 +138,13 @@ cl::location(OptimizeForSize), cl::init(false)); - cl::opt + static cl::opt EnableRealignStack("realign-stack", cl::desc("Realign stack if needed"), cl::location(RealignStack), cl::init(true)); - cl::opt + static cl::opt OverrideStackAlignment("stack-alignment", cl::desc("Override default stack alignment"), cl::location(StackAlignment), Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Mon May 5 20:53:16 2008 @@ -31,7 +31,7 @@ STATISTIC(NumDeleted, "Number of functions deleted because all callers found"); namespace { - cl::opt + static cl::opt InlineLimit("inline-threshold", cl::Hidden, cl::init(200), cl::desc("Control the amount of inlining to perform (default = 200)")); } Modified: llvm/trunk/lib/Transforms/IPO/Internalize.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Internalize.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/Internalize.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/Internalize.cpp Mon May 5 20:53:16 2008 @@ -32,12 +32,12 @@ // APIFile - A file which contains a list of symbols that should not be marked // external. - cl::opt + static cl::opt APIFile("internalize-public-api-file", cl::value_desc("filename"), cl::desc("A file containing list of symbol names to preserve")); // APIList - A list of symbols that should not be marked internal. - cl::list + static cl::list APIList("internalize-public-api-list", cl::value_desc("list"), cl::desc("A list of symbol names to preserve"), cl::CommaSeparated); Modified: llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp Mon May 5 20:53:16 2008 @@ -149,7 +149,7 @@ namespace { // BlockFile - A file which contains a list of blocks that should not be // extracted. - cl::opt + static cl::opt BlockFile("extract-blocks-file", cl::value_desc("filename"), cl::desc("A file containing list of basic blocks to not extract"), cl::Hidden); Modified: llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp Mon May 5 20:53:16 2008 @@ -56,7 +56,7 @@ GBV, GBVO, HOSTCC }; - cl::opt RandomMethod("profile-randomness", + static cl::opt RandomMethod("profile-randomness", cl::desc("How to randomly choose to profile:"), cl::values( clEnumValN(GBV, "global", "global counter"), Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Mon May 5 20:53:16 2008 @@ -59,7 +59,7 @@ STATISTIC(NumPromoted , "Number of memory locations promoted to registers"); namespace { - cl::opt + static cl::opt DisablePromotion("disable-licm-promotion", cl::Hidden, cl::desc("Disable memory promotion in LICM pass")); Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnroll.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnroll.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopUnroll.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopUnroll.cpp Mon May 5 20:53:16 2008 @@ -45,12 +45,12 @@ STATISTIC(NumUnrolled, "Number of loops unrolled (completely or otherwise)"); namespace { - cl::opt + static cl::opt UnrollThreshold ("unroll-threshold", cl::init(100), cl::Hidden, cl::desc("The cut-off point for automatic loop unrolling")); - cl::opt + static cl::opt UnrollCount ("unroll-count", cl::init(0), cl::Hidden, cl::desc("Use this unroll count for all loops, for testing purposes")); Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Mon May 5 20:53:16 2008 @@ -55,7 +55,7 @@ STATISTIC(NumSimplify, "Number of simplifications of unswitched code"); namespace { - cl::opt + static cl::opt Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"), cl::init(10), cl::Hidden); Modified: llvm/trunk/lib/Transforms/Utils/BasicInliner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BasicInliner.cpp?rev=50696&r1=50695&r2=50696&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/BasicInliner.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/BasicInliner.cpp Mon May 5 20:53:16 2008 @@ -27,7 +27,7 @@ using namespace llvm; namespace { - cl::opt + static cl::opt BasicInlineThreshold("inline-threshold", cl::Hidden, cl::init(200), cl::desc("Control the amount of basic inlining to perform (default = 200)")); } From baldrick at free.fr Mon May 5 20:55:30 2008 From: baldrick at free.fr (Duncan Sands) Date: Tue, 6 May 2008 03:55:30 +0200 Subject: [llvm-commits] [llvm] r50667 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/2008-05-05-MRV-Crash.ll In-Reply-To: <200805052021.m45KLMMe003716@zion.cs.uiuc.edu> References: <200805052021.m45KLMMe003716@zion.cs.uiuc.edu> Message-ID: <200805060355.31499.baldrick@free.fr> Hi Chris, thanks for fixing this. > + // We can't use 'DemoteRegToStack' because the at will create loads and the at -> that Ciao, Duncan. From sabre at nondot.org Mon May 5 21:29:29 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 06 May 2008 02:29:29 -0000 Subject: [llvm-commits] [llvm] r50698 - /llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Message-ID: <200805060229.m462TTkE017722@zion.cs.uiuc.edu> Author: lattner Date: Mon May 5 21:29:28 2008 New Revision: 50698 URL: http://llvm.org/viewvc/llvm-project?rev=50698&view=rev Log: Match things like 'armv5tejl-unknown-linux-gnu' for PR2290 Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=50698&r1=50697&r2=50698&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Mon May 5 21:29:28 2008 @@ -94,7 +94,8 @@ unsigned ARMTargetMachine::getModuleMatchQuality(const Module &M) { std::string TT = M.getTargetTriple(); - if (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "arm-") + if (TT.size() >= 4 && // Match arm-foo-bar, as well as things like armv5blah-* + (TT.substr(0, 4) == "arm-" || TT.substr(0, 4) == "armv")) return 20; // If the target triple is something non-arm, we don't match. if (!TT.empty()) return 0; From sabre at nondot.org Mon May 5 21:31:18 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 06 May 2008 02:31:18 -0000 Subject: [llvm-commits] [llvm] r50699 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200805060231.m462VIek017826@zion.cs.uiuc.edu> Author: lattner Date: Mon May 5 21:31:18 2008 New Revision: 50699 URL: http://llvm.org/viewvc/llvm-project?rev=50699&view=rev Log: fix typo Duncan noticed Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=50699&r1=50698&r2=50699&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon May 5 21:31:18 2008 @@ -445,7 +445,7 @@ } // Alternatively, I must be a call or invoke that returns multiple retvals. - // We can't use 'DemoteRegToStack' because the at will create loads and + // We can't use 'DemoteRegToStack' because that will create loads and // stores of aggregates which is not valid yet. If I is a call, we can just // pull all the getresult instructions up to this block. If I is an invoke, // we are out of luck. From nicholas at mxc.ca Mon May 5 22:42:21 2008 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 06 May 2008 03:42:21 -0000 Subject: [llvm-commits] [llvm] r50702 - /llvm/trunk/lib/System/Win32/Path.inc Message-ID: <200805060342.m463gLkw020272@zion.cs.uiuc.edu> Author: nicholas Date: Mon May 5 22:42:21 2008 New Revision: 50702 URL: http://llvm.org/viewvc/llvm-project?rev=50702&view=rev Log: Fix renamePathOnDisk on Win32, patch from David Leon. This fixes problems with llvm-ar being unable to rename files. Modified: llvm/trunk/lib/System/Win32/Path.inc Modified: llvm/trunk/lib/System/Win32/Path.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Path.inc?rev=50702&r1=50701&r2=50702&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/Path.inc (original) +++ llvm/trunk/lib/System/Win32/Path.inc Mon May 5 22:42:21 2008 @@ -672,7 +672,7 @@ if (!MoveFileEx(path.c_str(), newName.c_str(), MOVEFILE_REPLACE_EXISTING)) return MakeErrMsg(ErrMsg, "Can't move '" + path + "' to '" + newName.path + "': "); - return true; + return false; } bool From nicholas at mxc.ca Mon May 5 22:57:57 2008 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 06 May 2008 03:57:57 -0000 Subject: [llvm-commits] [llvm] r50703 - in /llvm/branches/non-call-eh: include/llvm/BasicBlock.h include/llvm/Bitcode/LLVMBitCodes.h lib/AsmParser/llvmAsmParser.y lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Writer/BitcodeWriter.cpp lib/VMCore/AsmWriter.cpp lib/VMCore/BasicBlock.cpp test/Feature/unwindto.ll Message-ID: <200805060357.m463vwwg020789@zion.cs.uiuc.edu> Author: nicholas Date: Mon May 5 22:57:57 2008 New Revision: 50703 URL: http://llvm.org/viewvc/llvm-project?rev=50703&view=rev Log: Add an optional 'nounwind' marker to basic blocks. Modified: llvm/branches/non-call-eh/include/llvm/BasicBlock.h llvm/branches/non-call-eh/include/llvm/Bitcode/LLVMBitCodes.h llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.y llvm/branches/non-call-eh/lib/Bitcode/Reader/BitcodeReader.cpp llvm/branches/non-call-eh/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/branches/non-call-eh/lib/VMCore/AsmWriter.cpp llvm/branches/non-call-eh/lib/VMCore/BasicBlock.cpp llvm/branches/non-call-eh/test/Feature/unwindto.ll Modified: llvm/branches/non-call-eh/include/llvm/BasicBlock.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/BasicBlock.h?rev=50703&r1=50702&r2=50703&view=diff ============================================================================== --- llvm/branches/non-call-eh/include/llvm/BasicBlock.h (original) +++ llvm/branches/non-call-eh/include/llvm/BasicBlock.h Mon May 5 22:57:57 2008 @@ -86,15 +86,26 @@ /// getUnwindDest - Returns the BasicBlock that flow will enter if an unwind /// instruction occurs in this block. May be null, in which case unwinding - /// is undefined in this block. + /// exits the function. + /// const BasicBlock *getUnwindDest() const; BasicBlock *getUnwindDest(); /// setUnwindDest - Set which BasicBlock flow will enter if an unwind is - /// executed within this block. It may be set to null if unwinding is not - /// permitted in this block. + /// executed within this block. It may be set to null to indicate that + /// unwinding will exit the function. + /// void setUnwindDest(BasicBlock *unwindDest); + /// doesNotThrow - Determine whether the block may not unwind. + /// + bool doesNotThrow() const; + + /// setDoesNotThrow - Set whether unwinding is permissible in this + /// BasicBlock. Setting it to true will also clear the unwind dest. + /// + void setDoesNotThrow(bool doesNotThrow = true); + /// getParent - Return the enclosing method, or null if none /// const Function *getParent() const { return Parent; } Modified: llvm/branches/non-call-eh/include/llvm/Bitcode/LLVMBitCodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Bitcode/LLVMBitCodes.h?rev=50703&r1=50702&r2=50703&view=diff ============================================================================== --- llvm/branches/non-call-eh/include/llvm/Bitcode/LLVMBitCodes.h (original) +++ llvm/branches/non-call-eh/include/llvm/Bitcode/LLVMBitCodes.h Mon May 5 22:57:57 2008 @@ -204,7 +204,8 @@ FUNC_CODE_INST_STORE2 = 24, // STORE: [ptrty,ptr,val, align, vol] FUNC_CODE_INST_GETRESULT = 25, // GETRESULT: [ty, opval, n] - FUNC_CODE_INST_BB_UNWINDDEST = 26 // BB_UNWINDDEST: [bb#] + FUNC_CODE_INST_BB_UNWINDDEST = 26, // BB_UNWINDDEST: [bb#] + FUNC_CODE_INST_BB_NOUNWIND = 27 // BB_NOUNWIND }; } // End bitc namespace } // End llvm namespace Modified: llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.y URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.y?rev=50703&r1=50702&r2=50703&view=diff ============================================================================== --- llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.y (original) +++ llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.y Mon May 5 22:57:57 2008 @@ -2561,10 +2561,21 @@ $$ = defineBBVal(ValID::createLocalID(CurFun.NextValNum), 0); CHECK_FOR_ERROR } - | UNWINDS TO ValueRef { // Only the unwind to block + | UNWINDS TO ValueRef { // Only the unwind to block $$ = defineBBVal(ValID::createLocalID(CurFun.NextValNum), getBBVal($3)); CHECK_FOR_ERROR } + | NOUNWIND { // Only the nounwind label + $$ = defineBBVal(ValID::createLocalID(CurFun.NextValNum), 0); + $$->setDoesNotThrow(); + CHECK_FOR_ERROR + } + | NOUNWIND UNWINDS TO ValueRef { // Only the nounwind and unwind to block + $$ = defineBBVal(ValID::createLocalID(CurFun.NextValNum), getBBVal($4)); + $$->setDoesNotThrow(); + CHECK_FOR_ERROR + } + | LABELSTR { // Labelled (named) basic block $$ = defineBBVal(ValID::createLocalName(*$1), 0); delete $1; @@ -2575,6 +2586,18 @@ delete $1; CHECK_FOR_ERROR }; + | LABELSTR NOUNWIND { + $$ = defineBBVal(ValID::createLocalName(*$1), 0); + $$->setDoesNotThrow(); + delete $1; + CHECK_FOR_ERROR + }; + | LABELSTR NOUNWIND UNWINDS TO ValueRef { + $$ = defineBBVal(ValID::createLocalName(*$1), getBBVal($5)); + $$->setDoesNotThrow(); + delete $1; + CHECK_FOR_ERROR + }; BBTerminatorInst : RET ReturnedVal { // Return with a result... Modified: llvm/branches/non-call-eh/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Bitcode/Reader/BitcodeReader.cpp?rev=50703&r1=50702&r2=50703&view=diff ============================================================================== --- llvm/branches/non-call-eh/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/branches/non-call-eh/lib/Bitcode/Reader/BitcodeReader.cpp Mon May 5 22:57:57 2008 @@ -1233,6 +1233,10 @@ CurBB->setUnwindDest(getBasicBlock(Record[0])); continue; + case bitc::FUNC_CODE_INST_BB_NOUNWIND: // BB_NOUNWIND + CurBB->setDoesNotThrow(); + continue; + case bitc::FUNC_CODE_INST_BINOP: { // BINOP: [opval, ty, opval, opcode] unsigned OpNum = 0; Value *LHS, *RHS; Modified: llvm/branches/non-call-eh/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=50703&r1=50702&r2=50703&view=diff ============================================================================== --- llvm/branches/non-call-eh/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/branches/non-call-eh/lib/Bitcode/Writer/BitcodeWriter.cpp Mon May 5 22:57:57 2008 @@ -975,7 +975,11 @@ Vals.push_back(VE.getValueID(unwindDest)); Stream.EmitRecord(bitc::FUNC_CODE_INST_BB_UNWINDDEST, Vals); Vals.clear(); - } + } + if (BB->doesNotThrow()) { + Stream.EmitRecord(bitc::FUNC_CODE_INST_BB_NOUNWIND, Vals); + Vals.clear(); + } for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I) { Modified: llvm/branches/non-call-eh/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/VMCore/AsmWriter.cpp?rev=50703&r1=50702&r2=50703&view=diff ============================================================================== --- llvm/branches/non-call-eh/lib/VMCore/AsmWriter.cpp (original) +++ llvm/branches/non-call-eh/lib/VMCore/AsmWriter.cpp Mon May 5 22:57:57 2008 @@ -1164,15 +1164,15 @@ /// void AssemblyWriter::printBasicBlock(const BasicBlock *BB) { if (BB->hasName()) // Print out the label if it exists... - Out << getLLVMName(BB->getName(), LabelPrefix) << ':'; + Out << getLLVMName(BB->getName(), LabelPrefix) << ": "; - if (const BasicBlock* unwindDest = BB->getUnwindDest()) { - if (BB->hasName()) - Out << ' '; + if (BB->doesNotThrow()) + Out << "nounwind "; + if (const BasicBlock* unwindDest = BB->getUnwindDest()) { Out << "unwinds to"; writeOperand(unwindDest, false); - } + } if (!BB->hasName() && !BB->use_empty()) { // Don't print block # of no uses... Out << ";
  • + + +
    +

    + This file implements the Dead Loop Deletion Pass. This pass is responsible + for eliminating loops with non-infinite computable trip counts that have no + side effects or volatile instructions, and do not contribute to the + computation of the function's return value. +

    +
    @@ -1390,17 +1418,6 @@ -
    -

    - Lowers operations on vector datatypes into operations on more primitive vector - datatypes, and finally to scalar operations. -

    -
    - - -
    @@ -1417,29 +1434,6 @@ -
    -

    - This file implements lowering for the llvm.gc* intrinsics for targets - that do not natively support them (which includes the C backend). Note that - the code generated is not as efficient as it would be for targets that - natively support the GC intrinsics, but it is useful for getting new targets - up-and-running quickly. -

    - -

    - This pass implements the code transformation described in this paper: -

    - -

    - "Accurate Garbage Collection in an Uncooperative Environment" - Fergus Henderson, ISMM, 2002 -

    -
    - - -
    @@ -1481,25 +1475,6 @@ -
    -

    - Lowers select instructions into conditional branches for targets that do not - have conditional moves or that have not implemented the select instruction - yet. -

    - -

    - Note that this pass could be improved. In particular it turns every select - instruction into a new conditional branch, even though some common cases have - select instructions on the same predicate next to each other. It would be - better to use the same branch for the whole group of selects. -

    -
    - - -
    @@ -1557,6 +1532,17 @@ +
    +

    + This pass performs various transformations related to eliminating memcpy + calls, or transforming sets of stores into memset's. +

    +
    + + +
    @@ -1753,6 +1739,42 @@ +
    +

    + This pass loops over all of the functions in the input module, looking for + dead declarations and removes them. Dead declarations are declarations of + functions for which no implementation is available (i.e., declarations for + unused library functions). +

    +
    + + + +
    +

    + This pass finds functions that return a struct (using a pointer to the struct + as the first argument of the function, marked with the 'sret' attribute) and + replaces them with a new function that simply returns each of the elements of + that struct (using multiple return values). +

    + +

    + This pass works under a number of conditions: +

    + +
      +
    • The returned struct must not contain other structs
    • +
    • The returned struct must only be used to load values from
    • +
    • The placeholder struct passed in is the result of an alloca
    • +
    +
    + + +
    Modified: llvm/trunk/lib/Transforms/IPO/StripDeadPrototypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/StripDeadPrototypes.cpp?rev=50861&r1=50860&r2=50861&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/StripDeadPrototypes.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/StripDeadPrototypes.cpp Thu May 8 12:46:35 2008 @@ -1,4 +1,4 @@ -//===-- StripDeadPrototypes.cpp - Removed unused function declarations ----===// +//===-- StripDeadPrototypes.cpp - Remove unused function declarations ----===// // // The LLVM Compiler Infrastructure // @@ -8,7 +8,9 @@ //===----------------------------------------------------------------------===// // // This pass loops over all of the functions in the input module, looking for -// dead declarations and removes them. +// dead declarations and removes them. Dead declarations are declarations of +// functions for which no implementation is available (i.e., declarations for +// unused library functions). // //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp?rev=50861&r1=50860&r2=50861&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp Thu May 8 12:46:35 2008 @@ -1,4 +1,4 @@ -//===-- StructRetPromotion.cpp - Promote sret arguments -000000------------===// +//===-- StructRetPromotion.cpp - Promote sret arguments ------------------===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,16 @@ // //===----------------------------------------------------------------------===// // -// TODO : Describe this pass. +// This pass finds functions that return a struct (using a pointer to the struct +// as the first argument of the function, marked with the 'sret' attribute) and +// replaces them with a new function that simply returns each of the elements of +// that struct (using multiple return values). +// +// This pass works under a number of conditions: +// 1. The returned struct must not contain other structs +// 2. The returned struct must only be used to load values from +// 3. The placeholder struct passed in is the result of an alloca +// //===----------------------------------------------------------------------===// #define DEBUG_TYPE "sretpromotion" Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=50861&r1=50860&r2=50861&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Thu May 8 12:46:35 2008 @@ -8,8 +8,8 @@ //===----------------------------------------------------------------------===// // // This pass munges the code in the input function to better prepare it for -// SelectionDAG-based code generation. This works around limitations in it's -// basic-block-at-a-time approach. It should eventually be removed. +// SelectionDAG-based code generation. This works around limitations in it's +// basic-block-at-a-time approach. It should eventually be removed. // //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=50861&r1=50860&r2=50861&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Thu May 8 12:46:35 2008 @@ -9,6 +9,23 @@ // // This file implements the Jump Threading pass. // +// Jump threading tries to find distinct threads of control flow running through +// a basic block. This pass looks at blocks that have multiple predecessors and +// multiple successors. If one or more of the predecessors of the block can be +// proven to always cause a jump to one of the successors, we forward the edge +// from the predecessor to the successor by duplicating the contents of this +// block. +// +// An example of when this can occur is code like this: +// +// if () { ... +// X = 4; +// } +// if (X < 3) { +// +// In this case, the unconditional branch at the end of the first if can be +// revectored to the false side of the second if. +// //===----------------------------------------------------------------------===// #define DEBUG_TYPE "jump-threading" @@ -33,22 +50,6 @@ cl::init(6), cl::Hidden); namespace { - /// This pass performs 'jump threading', which looks at blocks that have - /// multiple predecessors and multiple successors. If one or more of the - /// predecessors of the block can be proven to always jump to one of the - /// successors, we forward the edge from the predecessor to the successor by - /// duplicating the contents of this block. - /// - /// An example of when this can occur is code like this: - /// - /// if () { ... - /// X = 4; - /// } - /// if (X < 3) { - /// - /// In this case, the unconditional branch at the end of the first if can be - /// revectored to the false side of the second if. - /// class VISIBILITY_HIDDEN JumpThreading : public FunctionPass { public: static char ID; // Pass identification Modified: llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp?rev=50861&r1=50860&r2=50861&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Thu May 8 12:46:35 2008 @@ -7,10 +7,10 @@ // //===----------------------------------------------------------------------===// // -// This file implements the Dead Loop Elimination Pass. This pass is -// responsible for eliminating loops with non-infinite computable trip counts -// that have no side effects or volatile instructions, and do not contribute -// to the computation of the function's return value. +// This file implements the Dead Loop Deletion Pass. This pass is responsible +// for eliminating loops with non-infinite computable trip counts that have no +// side effects or volatile instructions, and do not contribute to the +// computation of the function's return value. // //===----------------------------------------------------------------------===// From isanbard at gmail.com Thu May 8 12:57:12 2008 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 8 May 2008 10:57:12 -0700 Subject: [llvm-commits] [llvm] r50840 - /llvm/trunk/lib/Analysis/ConstantFolding.cpp In-Reply-To: <200805080454.m484sh4D026435@zion.cs.uiuc.edu> References: <200805080454.m484sh4D026435@zion.cs.uiuc.edu> Message-ID: <7E80FAB1-9B04-4E81-AE23-0FE7B8C34C1F@gmail.com> Hey Chris, > --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) > +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Wed May 7 23:54:43 > 2008 > @@ -122,25 +122,32 @@ > const Type *ResultTy, > const TargetData *TD) { > Constant *Ptr = Ops[0]; > - if (!cast(Ptr->getType())->getElementType()- > >isSized()) > + if (!TD || !cast(Ptr->getType())->getElementType()- > >isSized()) > return 0; > > - if (TD && Ptr->isNullValue()) { > - // If this is a constant expr gep that is effectively computing > an > - // "offsetof", fold it into 'cast int Size to T*' instead of > 'gep 0, 0, 12' > - bool isFoldableGEP = true; > - for (unsigned i = 1; i != NumOps; ++i) > - if (!isa(Ops[i])) { > - isFoldableGEP = false; > - break; > - } > - if (isFoldableGEP) { > - uint64_t Offset = TD->getIndexedOffset(Ptr->getType(), > - (Value**)Ops+1, > NumOps-1); > - Constant *C = ConstantInt::get(TD->getIntPtrType(), Offset); > - return ConstantExpr::getIntToPtr(C, ResultTy); > - } > + uint64_t BasePtr = 0; > + if (!Ptr->isNullValue()) { > + // If this is a inttoptr from a constant int, we can fold this > as the base, > + // otherwise we can't. > + if (ConstantExpr *CE = dyn_cast(Ptr)) > + if (CE->getOpcode() == Instruction::IntToPtr) > + if (ConstantInt *Base = dyn_cast(CE- > >getOperand(0))) > + BasePtr = Base->getZExtValue(); > + > + if (BasePtr == 0) > + return 0; > } > + > + // If this is a constant expr gep that is effectively computing an > + // "offsetof", fold it into 'cast int Size to T*' instead of 'gep > 0, 0, 12' > + for (unsigned i = 1; i != NumOps; ++i) > + if (!isa(Ops[i])) > + return false; > + > + uint64_t Offset = TD->getIndexedOffset(Ptr->getType(), > + (Value**)Ops+1, NumOps-1); > + Constant *C = ConstantInt::get(TD->getIntPtrType(), Offset > +BasePtr); > + return ConstantExpr::getIntToPtr(C, ResultTy); > > return 0; This last return statement is now dead. -bw > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From lattner at apple.com Thu May 8 13:11:45 2008 From: lattner at apple.com (Tanya Lattner) Date: Thu, 8 May 2008 11:11:45 -0700 Subject: [llvm-commits] [llvm] r50861 - in /llvm/trunk: docs/Passes.html lib/Transforms/IPO/StripDeadPrototypes.cpp lib/Transforms/IPO/StructRetPromotion.cpp lib/Transforms/Scalar/CodeGenPrepare.cpp lib/Transforms/Scalar/JumpThreading.cpp lib/Transforms/Scalar/LoopDeletion.cpp In-Reply-To: <200805081746.m48HkZLA002042@zion.cs.uiuc.edu> References: <200805081746.m48HkZLA002042@zion.cs.uiuc.edu> Message-ID: <4DCA2C8A-919E-42D9-939D-18D2667A08B6@apple.com> For the changes to the JumpThreading Class, I don't think doxygen will pick up the comments at the top of the file (but correct me if I am wrong). I think its better to leave them at the top of the class (in doxygen style) so it shows up in doxygen. -Tanya On May 8, 2008, at 10:46 AM, Gordon Henriksen wrote: > Author: gordon > Date: Thu May 8 12:46:35 2008 > New Revision: 50861 > > URL: http://llvm.org/viewvc/llvm-project?rev=50861&view=rev > Log: > Improve pass documentation and comments. > > Patch by Matthijs Kooijman! > > Modified: > llvm/trunk/docs/Passes.html > llvm/trunk/lib/Transforms/IPO/StripDeadPrototypes.cpp > llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp > llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp > llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp > llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp > > Modified: llvm/trunk/docs/Passes.html > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ > Passes.html?rev=50861&r1=50860&r2=50861&view=diff > > ====================================================================== > ======== > --- llvm/trunk/docs/Passes.html (original) > +++ llvm/trunk/docs/Passes.html Thu May 8 12:46:35 2008 > @@ -116,7 +116,7 @@ > -argpromotionPromote > 'by reference' arguments to scalars > -block-placement td>Profile Guided Basic Block Placement > -break-crit-edges td>Break critical edges in CFG > --ceeCorrelated Expression > Elimination > +-codegenprepare td>Prepare a function for code generation > -condpropConditional > Propagation > -constmergeMerge > Duplicate Global Constants > -constpropSimple > constant propagation > @@ -142,8 +142,10 @@ > -internalize td>Internalize Global Symbols > -ipconstprop td>Interprocedural constant propagation > -ipsccpInterprocedural > Sparse Conditional Constant Propagation > +-jump-threading td>Thread control through conditional blocks > -lcssaLoop-Closed SSA Form > Pass > -licmLoop Invariant Code > Motion > +-loop-deletionDead > Loop Deletion Pass > -loop-extractExtract > loops into new functions > -loop-extract-single td>Extract at most one loop into a new function > -loop-index-split td>Index Split Loops > @@ -152,14 +154,12 @@ > -loop-unrollUnroll > loops > -loop-unswitch td>Unswitch loops > -loopsimplify td>Canonicalize natural loops > --lower-packedlowers > packed operations to operations on smaller packed datatypes > -lowerallocsLower > allocations from instructions to calls > --lowergcLower GC > intrinsics, for GCless code generators > -lowerinvokeLower > invoke and unwind, for unwindless code generators > --lowerselectLower > select instructions to branches > -lowersetjmpLower Set > Jump > -lowerswitchLower > SwitchInst's to branches > -mem2regPromote Memory to > Register > +-memcpyoptOptimize use > of memcpy and friends > -mergereturnUnify > function exit nodes > -predsimplify td>Predicate Simplifier > -prune-ehRemove unused > exception handling info > @@ -171,6 +171,8 @@ > -simplify-libcalls td>Simplify well-known library calls > -simplifycfgSimplify > the CFG > -stripStrip all symbols from > a module > +-strip-dead-prototypes a>Remove unused function declarations > +-sretpromotion td>Promote sret arguments > -tailcallelimTail > Call Elimination > -tailduplicateTail > Duplication > > @@ -739,27 +741,12 @@ > > > > >
    > -

    Correlated Expression Elimination propagates information from > conditional > - branches to blocks dominated by destinations of the branch. It > propagates > - information from the condition check itself into the body of the > branch, > - allowing transformations like these for example:

    > - > -
    > -if (i == 7)
    > -  ... 4*i;  // constant propagation
    > -
    > -M = i+1; N = j+1;
    > -if (i == j)
    > -  X = M-N;  // = M-M == 0;
    > -
    > - > -

    This is called Correlated Expression Elimination because we > eliminate or > - simplify expressions that are correlated with the direction of > a branch. In > - this way we use static information to give us some information > about the > - dynamic value of a variable.

    > + This pass munges the code in the input function to better > prepare it for > + SelectionDAG-based code generation. This works around > limitations in it's > + basic-block-at-a-time approach. It should eventually be removed. >
    > > > > @@ -1183,6 +1170,35 @@ > > > > > +
    > +

    > + Jump threading tries to find distinct threads of control flow > running through > + a basic block. This pass looks at blocks that have multiple > predecessors and > + multiple successors. If one or more of the predecessors of the > block can be > + proven to always cause a jump to one of the successors, we > forward the edge > + from the predecessor to the successor by duplicating the > contents of this > + block. > +

    > +

    > + An example of when this can occur is code like this: > +

    > + > +
     +>if () { ...
    > +  X = 4;
    > +}
    > +if (X < 3) {
    > + > +

    > + In this case, the unconditional branch at the end of the first > if can be > + revectored to the false side of the second if. > +

    > +
    > + > + > + >
    > @@ -1246,6 +1262,18 @@ > variable. > >
    > + > + > +
    > +

    > + This file implements the Dead Loop Deletion Pass. This pass is > responsible > + for eliminating loops with non-infinite computable trip counts > that have no > + side effects or volatile instructions, and do not contribute to the > + computation of the function's return value. > +

    > +
    > > > >
    > @@ -1390,17 +1418,6 @@ > > > > > -
    > -

    > - Lowers operations on vector datatypes into operations on more > primitive vector > - datatypes, and finally to scalar operations. > -

    > -
    > - > - > > - >
    > @@ -1417,29 +1434,6 @@ > > > > > -
    > -

    > - This file implements lowering for the llvm.gc* > intrinsics for targets > - that do not natively support them (which includes the C > backend). Note that > - the code generated is not as efficient as it would be for > targets that > - natively support the GC intrinsics, but it is useful for getting > new targets > - up-and-running quickly. > -

    > - > -

    > - This pass implements the code transformation described in this > paper: > -

    > - > -

    > - "Accurate Garbage Collection in an Uncooperative Environment" > - Fergus Henderson, ISMM, 2002 > -

    > -
    > - > - > > - >
    > @@ -1481,25 +1475,6 @@ > > > > > -
    > -

    > - Lowers select instructions into conditional branches for targets > that do not > - have conditional moves or that have not implemented the select > instruction > - yet. > -

    > - > -

    > - Note that this pass could be improved. In particular it turns > every select > - instruction into a new conditional branch, even though some > common cases have > - select instructions on the same predicate next to each other. > It would be > - better to use the same branch for the whole group of selects. > -

    > -
    > - > - > > - >
    > @@ -1557,6 +1532,17 @@ > > > > > +
    > +

    > + This pass performs various transformations related to > eliminating memcpy > + calls, or transforming sets of stores into memset's. > +

    > +
    > + > + > + >
    > @@ -1753,6 +1739,42 @@ > > > > > +
    > +

    > + This pass loops over all of the functions in the input module, > looking for > + dead declarations and removes them. Dead declarations are > declarations of > + functions for which no implementation is available (i.e., > declarations for > + unused library functions). > +

    > +
    > + > + > + > +
    > +

    > + This pass finds functions that return a struct (using a pointer > to the struct > + as the first argument of the function, marked with the > 'sret' attribute) and > + replaces them with a new function that simply returns each of > the elements of > + that struct (using multiple return values). > +

    > + > +

    > + This pass works under a number of conditions: > +

    > + > +
      > +
    • The returned struct must not contain other structs
    • > +
    • The returned struct must only be used to load values from
    • > +
    • The placeholder struct passed in is the result of an > alloca
    • > +
    > +
    > + > + > + >
    > > Modified: llvm/trunk/lib/Transforms/IPO/StripDeadPrototypes.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ > IPO/StripDeadPrototypes.cpp?rev=50861&r1=50860&r2=50861&view=diff > > ====================================================================== > ======== > --- llvm/trunk/lib/Transforms/IPO/StripDeadPrototypes.cpp (original) > +++ llvm/trunk/lib/Transforms/IPO/StripDeadPrototypes.cpp Thu May > 8 12:46:35 2008 > @@ -1,4 +1,4 @@ > -//===-- StripDeadPrototypes.cpp - Removed unused function > declarations ----===// > +//===-- StripDeadPrototypes.cpp - Remove unused function > declarations ----===// > // > // The LLVM Compiler Infrastructure > // > @@ -8,7 +8,9 @@ > // > ===------------------------------------------------------------------- > ---===// > // > // This pass loops over all of the functions in the input module, > looking for > -// dead declarations and removes them. > +// dead declarations and removes them. Dead declarations are > declarations of > +// functions for which no implementation is available (i.e., > declarations for > +// unused library functions). > // > // > ===------------------------------------------------------------------- > ---===// > > > Modified: llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ > IPO/StructRetPromotion.cpp?rev=50861&r1=50860&r2=50861&view=diff > > ====================================================================== > ======== > --- llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp (original) > +++ llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp Thu May 8 > 12:46:35 2008 > @@ -1,4 +1,4 @@ > -//===-- StructRetPromotion.cpp - Promote sret arguments > -000000------------===// > +//===-- StructRetPromotion.cpp - Promote sret arguments > ------------------===// > // > // The LLVM Compiler Infrastructure > // > @@ -7,7 +7,16 @@ > // > // > ===------------------------------------------------------------------- > ---===// > // > -// TODO : Describe this pass. > +// This pass finds functions that return a struct (using a pointer > to the struct > +// as the first argument of the function, marked with the 'sret' > attribute) and > +// replaces them with a new function that simply returns each of > the elements of > +// that struct (using multiple return values). > +// > +// This pass works under a number of conditions: > +// 1. The returned struct must not contain other structs > +// 2. The returned struct must only be used to load values from > +// 3. The placeholder struct passed in is the result of an alloca > +// > // > ===------------------------------------------------------------------- > ---===// > > #define DEBUG_TYPE "sretpromotion" > > Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ > Scalar/CodeGenPrepare.cpp?rev=50861&r1=50860&r2=50861&view=diff > > ====================================================================== > ======== > --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Thu May 8 > 12:46:35 2008 > @@ -8,8 +8,8 @@ > // > ===------------------------------------------------------------------- > ---===// > // > // This pass munges the code in the input function to better > prepare it for > -// SelectionDAG-based code generation. This works around > limitations in it's > -// basic-block-at-a-time approach. It should eventually be removed. > +// SelectionDAG-based code generation. This works around > limitations in it's > +// basic-block-at-a-time approach. It should eventually be removed. > // > // > ===------------------------------------------------------------------- > ---===// > > > Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ > Scalar/JumpThreading.cpp?rev=50861&r1=50860&r2=50861&view=diff > > ====================================================================== > ======== > --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Thu May 8 > 12:46:35 2008 > @@ -9,6 +9,23 @@ > // > // This file implements the Jump Threading pass. > // > +// Jump threading tries to find distinct threads of control flow > running through > +// a basic block. This pass looks at blocks that have multiple > predecessors and > +// multiple successors. If one or more of the predecessors of the > block can be > +// proven to always cause a jump to one of the successors, we > forward the edge > +// from the predecessor to the successor by duplicating the > contents of this > +// block. > +// > +// An example of when this can occur is code like this: > +// > +// if () { ... > +// X = 4; > +// } > +// if (X < 3) { > +// > +// In this case, the unconditional branch at the end of the first > if can be > +// revectored to the false side of the second if. > +// > // > ===------------------------------------------------------------------- > ---===// > > #define DEBUG_TYPE "jump-threading" > @@ -33,22 +50,6 @@ > cl::init(6), cl::Hidden); > > namespace { > - /// This pass performs 'jump threading', which looks at blocks > that have > - /// multiple predecessors and multiple successors. If one or > more of the > - /// predecessors of the block can be proven to always jump to > one of the > - /// successors, we forward the edge from the predecessor to the > successor by > - /// duplicating the contents of this block. > - /// > - /// An example of when this can occur is code like this: > - /// > - /// if () { ... > - /// X = 4; > - /// } > - /// if (X < 3) { > - /// > - /// In this case, the unconditional branch at the end of the > first if can be > - /// revectored to the false side of the second if. > - /// > class VISIBILITY_HIDDEN JumpThreading : public FunctionPass { > public: > static char ID; // Pass identification > > Modified: llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ > Scalar/LoopDeletion.cpp?rev=50861&r1=50860&r2=50861&view=diff > > ====================================================================== > ======== > --- llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Thu May 8 > 12:46:35 2008 > @@ -7,10 +7,10 @@ > // > // > ===------------------------------------------------------------------- > ---===// > // > -// This file implements the Dead Loop Elimination Pass. This pass is > -// responsible for eliminating loops with non-infinite computable > trip counts > -// that have no side effects or volatile instructions, and do not > contribute > -// to the computation of the function's return value. > +// This file implements the Dead Loop Deletion Pass. This pass is > responsible > +// for eliminating loops with non-infinite computable trip counts > that have no > +// side effects or volatile instructions, and do not contribute to > the > +// computation of the function's return value. > // > // > ===------------------------------------------------------------------- > ---===// > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Thu May 8 13:26:57 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 08 May 2008 18:26:57 -0000 Subject: [llvm-commits] [llvm] r50863 - /llvm/trunk/lib/Analysis/ConstantFolding.cpp Message-ID: <200805081826.m48IQvEe003297@zion.cs.uiuc.edu> Author: lattner Date: Thu May 8 13:26:56 2008 New Revision: 50863 URL: http://llvm.org/viewvc/llvm-project?rev=50863&view=rev Log: Remove dead return. Thanks to Bill for the review! Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=50863&r1=50862&r2=50863&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Thu May 8 13:26:56 2008 @@ -148,8 +148,6 @@ (Value**)Ops+1, NumOps-1); Constant *C = ConstantInt::get(TD->getIntPtrType(), Offset+BasePtr); return ConstantExpr::getIntToPtr(C, ResultTy); - - return 0; } /// FoldBitCast - Constant fold bitcast, symbolically evaluating it with From dag at cray.com Thu May 8 13:47:45 2008 From: dag at cray.com (David Greene) Date: Thu, 8 May 2008 13:47:45 -0500 Subject: [llvm-commits] Speeding up RegAllocLinearScan on big test-cases In-Reply-To: <4933F9BB-8DED-43F1-BDAE-4F59D23E9CA3@apple.com> References: <4933F9BB-8DED-43F1-BDAE-4F59D23E9CA3@apple.com> Message-ID: <200805081347.46039.dag@cray.com> On Wednesday 07 May 2008 11:54, Evan Cheng wrote: > Can we hook up the llvm pool allocator to std::set and use it for the > register allocator? It's simple and it made a huge difference on Mac > OS X when we switched all LiveInterval VNInfo allocations to it. Though I have not used it before, Boost pool_alloc is another option. -Dave From matthijs at stdin.nl Thu May 8 13:48:22 2008 From: matthijs at stdin.nl (Matthijs Kooijman) Date: Thu, 8 May 2008 20:48:22 +0200 Subject: [llvm-commits] [llvm] r50861 - in /llvm/trunk: docs/Passes.html lib/Transforms/IPO/StripDeadPrototypes.cpp lib/Transforms/IPO/StructRetPromotion.cpp lib/Transforms/Scalar/CodeGenPrepare.cpp lib/Transforms/Scalar/JumpThreading.cpp lib/Transforms/Scalar/LoopDeletion.cpp In-Reply-To: <4DCA2C8A-919E-42D9-939D-18D2667A08B6@apple.com> References: <200805081746.m48HkZLA002042@zion.cs.uiuc.edu> <4DCA2C8A-919E-42D9-939D-18D2667A08B6@apple.com> Message-ID: <20080508184822.GE27072@katherina.student.utwente.nl> Hi, > For the changes to the JumpThreading Class, I don't think doxygen > will pick up the comments at the top of the file (but correct me if I > am wrong). From what I've seen, none of the other passes have duplicate documentation like this? I agree that having comments in the API docs is quite desirable, but wouldn't it be better to make the per-file comments doxygen style as well then (and perhaps add a reference)? Gr. Matthijs -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080508/69a02c56/attachment.bin From nicolas.geoffray at lip6.fr Thu May 8 14:26:31 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 08 May 2008 19:26:31 -0000 Subject: [llvm-commits] [vmkit] r50865 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaInitialise.cpp JavaJITOpcodes.cpp JavaTypes.cpp JavaTypes.h Message-ID: <200805081926.m48JQVUk005410@zion.cs.uiuc.edu> Author: geoffray Date: Thu May 8 14:26:31 2008 New Revision: 50865 URL: http://llvm.org/viewvc/llvm-project?rev=50865&view=rev Log: Inline NEWARRAY as well. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=50865&r1=50864&r2=50865&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp Thu May 8 14:26:31 2008 @@ -111,7 +111,6 @@ CommonClass::jnjvmClassLoader); ((UTF8*)utf8OfChar)->classOf = JavaArray::ofChar; - AssessorDesc::initialise(vm); @@ -159,6 +158,8 @@ CommonClass::jnjvmClassLoader); // End array initialization + + AssessorDesc::initialise(vm); Attribut::codeAttribut = vm->asciizConstructUTF8("Code"); Attribut::exceptionsAttribut = vm->asciizConstructUTF8("Exceptions"); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=50865&r1=50864&r2=50865&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Thu May 8 14:26:31 2008 @@ -99,7 +99,8 @@ } } -void convertValue(Value*& val, const Type* t1, BasicBlock* currentBlock, bool usign) { +void convertValue(Value*& val, const Type* t1, BasicBlock* currentBlock, + bool usign) { const Type* t2 = val->getType(); if (t1 != t2) { if (t1->isInteger() && t2->isInteger()) { @@ -143,18 +144,22 @@ setCurrentBlock(opinfo->newBlock); } currentExceptionBlock = opinfo->exceptionBlock; - if (currentBlock->getTerminator() != 0) { // To prevent a gcj bug with useless goto + + // To prevent a gcj bug with useless goto + if (currentBlock->getTerminator() != 0) { currentBlock = createBasicBlock("gcj bug"); } #if JNJVM_EXECUTE > 1 { std::vector args; - mvm::jit::protectConstants();//->lock(); - args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)OpcodeNames[bytecodes[i]])); + mvm::jit::protectConstants(); + args.push_back(ConstantInt::get(Type::Int32Ty, + (int64_t)OpcodeNames[bytecodes[i]])); args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)i)); args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod)); - mvm::jit::unprotectConstants();//->unlock(); - CallInst::Create(printExecutionLLVM, args.begin(), args.end(), "", currentBlock); + mvm::jit::unprotectConstants(); + CallInst::Create(printExecutionLLVM, args.begin(), args.end(), "", + currentBlock); } #endif @@ -301,75 +306,91 @@ break; case LLOAD_0 : - push(new LoadInst(longLocals[0], "", currentBlock), AssessorDesc::dLong); + push(new LoadInst(longLocals[0], "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; case LLOAD_1 : - push(new LoadInst(longLocals[1], "", currentBlock), AssessorDesc::dLong); + push(new LoadInst(longLocals[1], "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; case LLOAD_2 : - push(new LoadInst(longLocals[2], "", currentBlock), AssessorDesc::dLong); + push(new LoadInst(longLocals[2], "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; case LLOAD_3 : - push(new LoadInst(longLocals[3], "", currentBlock), AssessorDesc::dLong); + push(new LoadInst(longLocals[3], "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; case FLOAD_0 : - push(new LoadInst(floatLocals[0], "", currentBlock), AssessorDesc::dFloat); + push(new LoadInst(floatLocals[0], "", currentBlock), + AssessorDesc::dFloat); break; case FLOAD_1 : - push(new LoadInst(floatLocals[1], "", currentBlock), AssessorDesc::dFloat); + push(new LoadInst(floatLocals[1], "", currentBlock), + AssessorDesc::dFloat); break; case FLOAD_2 : - push(new LoadInst(floatLocals[2], "", currentBlock), AssessorDesc::dFloat); + push(new LoadInst(floatLocals[2], "", currentBlock), + AssessorDesc::dFloat); break; case FLOAD_3 : - push(new LoadInst(floatLocals[3], "", currentBlock), AssessorDesc::dFloat); + push(new LoadInst(floatLocals[3], "", currentBlock), + AssessorDesc::dFloat); break; case DLOAD_0 : - push(new LoadInst(doubleLocals[0], "", currentBlock), AssessorDesc::dDouble); + push(new LoadInst(doubleLocals[0], "", currentBlock), + AssessorDesc::dDouble); push(mvm::jit::constantZero, AssessorDesc::dInt); break; case DLOAD_1 : - push(new LoadInst(doubleLocals[1], "", currentBlock), AssessorDesc::dDouble); + push(new LoadInst(doubleLocals[1], "", currentBlock), + AssessorDesc::dDouble); push(mvm::jit::constantZero, AssessorDesc::dInt); break; case DLOAD_2 : - push(new LoadInst(doubleLocals[2], "", currentBlock), AssessorDesc::dDouble); + push(new LoadInst(doubleLocals[2], "", currentBlock), + AssessorDesc::dDouble); push(mvm::jit::constantZero, AssessorDesc::dInt); break; case DLOAD_3 : - push(new LoadInst(doubleLocals[3], "", currentBlock), AssessorDesc::dDouble); + push(new LoadInst(doubleLocals[3], "", currentBlock), + AssessorDesc::dDouble); push(mvm::jit::constantZero, AssessorDesc::dInt); break; case ALOAD_0 : - push(new LoadInst(objectLocals[0], "", currentBlock), AssessorDesc::dRef); + push(new LoadInst(objectLocals[0], "", currentBlock), + AssessorDesc::dRef); break; case ALOAD_1 : - push(new LoadInst(objectLocals[1], "", currentBlock), AssessorDesc::dRef); + push(new LoadInst(objectLocals[1], "", currentBlock), + AssessorDesc::dRef); break; case ALOAD_2 : - push(new LoadInst(objectLocals[2], "", currentBlock), AssessorDesc::dRef); + push(new LoadInst(objectLocals[2], "", currentBlock), + AssessorDesc::dRef); break; case ALOAD_3 : - push(new LoadInst(objectLocals[3], "", currentBlock), AssessorDesc::dRef); + push(new LoadInst(objectLocals[3], "", currentBlock), + AssessorDesc::dRef); break; case IALOAD : { @@ -419,7 +440,8 @@ Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, ArraySInt8::llvmType); Value* val = new LoadInst(ptr, "", currentBlock); - push(new SExtInst(val, Type::Int32Ty, "", currentBlock), AssessorDesc::dInt); + push(new SExtInst(val, Type::Int32Ty, "", currentBlock), + AssessorDesc::dInt); break; } @@ -428,7 +450,8 @@ Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, ArrayUInt16::llvmType); Value* val = new LoadInst(ptr, "", currentBlock); - push(new ZExtInst(val, Type::Int32Ty, "", currentBlock), AssessorDesc::dInt); + push(new ZExtInst(val, Type::Int32Ty, "", currentBlock), + AssessorDesc::dInt); break; } @@ -437,7 +460,8 @@ Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, ArraySInt16::llvmType); Value* val = new LoadInst(ptr, "", currentBlock); - push(new SExtInst(val, Type::Int32Ty, "", currentBlock), AssessorDesc::dInt); + push(new SExtInst(val, Type::Int32Ty, "", currentBlock), + AssessorDesc::dInt); break; } @@ -743,7 +767,8 @@ case IADD : { Value* val2 = popAsInt(); Value* val1 = popAsInt(); - push(BinaryOperator::createAdd(val1, val2, "", currentBlock), AssessorDesc::dInt); + push(BinaryOperator::createAdd(val1, val2, "", currentBlock), + AssessorDesc::dInt); break; } @@ -752,7 +777,8 @@ llvm::Value* val2 = pop(); pop(); llvm::Value* val1 = pop(); - push(BinaryOperator::createAdd(val1, val2, "", currentBlock), AssessorDesc::dLong); + push(BinaryOperator::createAdd(val1, val2, "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -760,7 +786,8 @@ case FADD : { Value* val2 = pop(); Value* val1 = pop(); - push(BinaryOperator::createAdd(val1, val2, "", currentBlock), AssessorDesc::dFloat); + push(BinaryOperator::createAdd(val1, val2, "", currentBlock), + AssessorDesc::dFloat); break; } @@ -769,7 +796,8 @@ llvm::Value* val2 = pop(); pop(); llvm::Value* val1 = pop(); - push(BinaryOperator::createAdd(val1, val2, "", currentBlock), AssessorDesc::dDouble); + push(BinaryOperator::createAdd(val1, val2, "", currentBlock), + AssessorDesc::dDouble); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -777,7 +805,8 @@ case ISUB : { Value* val2 = popAsInt(); Value* val1 = popAsInt(); - push(BinaryOperator::createSub(val1, val2, "", currentBlock), AssessorDesc::dInt); + push(BinaryOperator::createSub(val1, val2, "", currentBlock), + AssessorDesc::dInt); break; } case LSUB : { @@ -785,7 +814,8 @@ llvm::Value* val2 = pop(); pop(); llvm::Value* val1 = pop(); - push(BinaryOperator::createSub(val1, val2, "", currentBlock), AssessorDesc::dLong); + push(BinaryOperator::createSub(val1, val2, "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -793,7 +823,8 @@ case FSUB : { Value* val2 = pop(); Value* val1 = pop(); - push(BinaryOperator::createSub(val1, val2, "", currentBlock), AssessorDesc::dFloat); + push(BinaryOperator::createSub(val1, val2, "", currentBlock), + AssessorDesc::dFloat); break; } @@ -802,7 +833,8 @@ llvm::Value* val2 = pop(); pop(); llvm::Value* val1 = pop(); - push(BinaryOperator::createSub(val1, val2, "", currentBlock), AssessorDesc::dDouble); + push(BinaryOperator::createSub(val1, val2, "", currentBlock), + AssessorDesc::dDouble); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -810,7 +842,8 @@ case IMUL : { Value* val2 = popAsInt(); Value* val1 = popAsInt(); - push(BinaryOperator::createMul(val1, val2, "", currentBlock), AssessorDesc::dInt); + push(BinaryOperator::createMul(val1, val2, "", currentBlock), + AssessorDesc::dInt); break; } @@ -819,7 +852,8 @@ llvm::Value* val2 = pop(); pop(); llvm::Value* val1 = pop(); - push(BinaryOperator::createMul(val1, val2, "", currentBlock), AssessorDesc::dLong); + push(BinaryOperator::createMul(val1, val2, "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -827,7 +861,8 @@ case FMUL : { Value* val2 = pop(); Value* val1 = pop(); - push(BinaryOperator::createMul(val1, val2, "", currentBlock), AssessorDesc::dFloat); + push(BinaryOperator::createMul(val1, val2, "", currentBlock), + AssessorDesc::dFloat); break; } @@ -836,7 +871,8 @@ llvm::Value* val2 = pop(); pop(); llvm::Value* val1 = pop(); - push(BinaryOperator::createMul(val1, val2, "", currentBlock), AssessorDesc::dDouble); + push(BinaryOperator::createMul(val1, val2, "", currentBlock), + AssessorDesc::dDouble); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -844,7 +880,8 @@ case IDIV : { Value* val2 = popAsInt(); Value* val1 = popAsInt(); - push(BinaryOperator::createSDiv(val1, val2, "", currentBlock), AssessorDesc::dInt); + push(BinaryOperator::createSDiv(val1, val2, "", currentBlock), + AssessorDesc::dInt); break; } @@ -853,7 +890,8 @@ llvm::Value* val2 = pop(); pop(); llvm::Value* val1 = pop(); - push(BinaryOperator::createSDiv(val1, val2, "", currentBlock), AssessorDesc::dLong); + push(BinaryOperator::createSDiv(val1, val2, "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -861,7 +899,8 @@ case FDIV : { Value* val2 = pop(); Value* val1 = pop(); - push(BinaryOperator::createFDiv(val1, val2, "", currentBlock), AssessorDesc::dFloat); + push(BinaryOperator::createFDiv(val1, val2, "", currentBlock), + AssessorDesc::dFloat); break; } @@ -870,7 +909,8 @@ llvm::Value* val2 = pop(); pop(); llvm::Value* val1 = pop(); - push(BinaryOperator::createFDiv(val1, val2, "", currentBlock), AssessorDesc::dDouble); + push(BinaryOperator::createFDiv(val1, val2, "", currentBlock), + AssessorDesc::dDouble); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -878,7 +918,8 @@ case IREM : { Value* val2 = popAsInt(); Value* val1 = popAsInt(); - push(BinaryOperator::createSRem(val1, val2, "", currentBlock), AssessorDesc::dInt); + push(BinaryOperator::createSRem(val1, val2, "", currentBlock), + AssessorDesc::dInt); break; } @@ -887,7 +928,8 @@ llvm::Value* val2 = pop(); pop(); llvm::Value* val1 = pop(); - push(BinaryOperator::createSRem(val1, val2, "", currentBlock), AssessorDesc::dLong); + push(BinaryOperator::createSRem(val1, val2, "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -895,7 +937,8 @@ case FREM : { Value* val2 = pop(); Value* val1 = pop(); - push(BinaryOperator::createFRem(val1, val2, "", currentBlock), AssessorDesc::dFloat); + push(BinaryOperator::createFRem(val1, val2, "", currentBlock), + AssessorDesc::dFloat); break; } @@ -904,7 +947,8 @@ llvm::Value* val2 = pop(); pop(); llvm::Value* val1 = pop(); - push(BinaryOperator::createFRem(val1, val2, "", currentBlock), AssessorDesc::dDouble); + push(BinaryOperator::createFRem(val1, val2, "", currentBlock), + AssessorDesc::dDouble); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -912,7 +956,8 @@ case INEG : push(BinaryOperator::createSub( mvm::jit::constantZero, - popAsInt(), "", currentBlock), AssessorDesc::dInt); + popAsInt(), "", currentBlock), + AssessorDesc::dInt); break; case LNEG : { @@ -942,7 +987,8 @@ case ISHL : { Value* val2 = popAsInt(); Value* val1 = popAsInt(); - push(BinaryOperator::createShl(val1, val2, "", currentBlock), AssessorDesc::dInt); + push(BinaryOperator::createShl(val1, val2, "", currentBlock), + AssessorDesc::dInt); break; } @@ -950,7 +996,8 @@ Value* val2 = new ZExtInst(pop(), Type::Int64Ty, "", currentBlock); pop(); // remove the 0 on the stack Value* val1 = pop(); - push(BinaryOperator::createShl(val1, val2, "", currentBlock), AssessorDesc::dLong); + push(BinaryOperator::createShl(val1, val2, "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -958,7 +1005,8 @@ case ISHR : { Value* val2 = popAsInt(); Value* val1 = popAsInt(); - push(BinaryOperator::createAShr(val1, val2, "", currentBlock), AssessorDesc::dInt); + push(BinaryOperator::createAShr(val1, val2, "", currentBlock), + AssessorDesc::dInt); break; } @@ -966,7 +1014,8 @@ Value* val2 = new ZExtInst(pop(), Type::Int64Ty, "", currentBlock); pop(); // remove the 0 on the stack Value* val1 = pop(); - push(BinaryOperator::createAShr(val1, val2, "", currentBlock), AssessorDesc::dLong); + push(BinaryOperator::createAShr(val1, val2, "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -974,7 +1023,8 @@ case IUSHR : { Value* val2 = popAsInt(); Value* val1 = popAsInt(); - push(BinaryOperator::createLShr(val1, val2, "", currentBlock), AssessorDesc::dInt); + push(BinaryOperator::createLShr(val1, val2, "", currentBlock), + AssessorDesc::dInt); break; } @@ -982,7 +1032,8 @@ Value* val2 = new ZExtInst(pop(), Type::Int64Ty, "", currentBlock); pop(); // remove the 0 on the stack Value* val1 = pop(); - push(BinaryOperator::createLShr(val1, val2, "", currentBlock), AssessorDesc::dLong); + push(BinaryOperator::createLShr(val1, val2, "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -990,7 +1041,8 @@ case IAND : { Value* val2 = popAsInt(); Value* val1 = popAsInt(); - push(BinaryOperator::createAnd(val1, val2, "", currentBlock), AssessorDesc::dInt); + push(BinaryOperator::createAnd(val1, val2, "", currentBlock), + AssessorDesc::dInt); break; } @@ -999,7 +1051,8 @@ Value* val2 = pop(); pop(); // remove the 0 on the stack Value* val1 = pop(); - push(BinaryOperator::createAnd(val1, val2, "", currentBlock), AssessorDesc::dLong); + push(BinaryOperator::createAnd(val1, val2, "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -1007,7 +1060,8 @@ case IOR : { Value* val2 = popAsInt(); Value* val1 = popAsInt(); - push(BinaryOperator::createOr(val1, val2, "", currentBlock), AssessorDesc::dInt); + push(BinaryOperator::createOr(val1, val2, "", currentBlock), + AssessorDesc::dInt); break; } @@ -1016,7 +1070,8 @@ Value* val2 = pop(); pop(); // remove the 0 on the stack Value* val1 = pop(); - push(BinaryOperator::createOr(val1, val2, "", currentBlock), AssessorDesc::dLong); + push(BinaryOperator::createOr(val1, val2, "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -1024,7 +1079,8 @@ case IXOR : { Value* val2 = popAsInt(); Value* val1 = popAsInt(); - push(BinaryOperator::createXor(val1, val2, "", currentBlock), AssessorDesc::dInt); + push(BinaryOperator::createXor(val1, val2, "", currentBlock), + AssessorDesc::dInt); break; } @@ -1033,7 +1089,8 @@ Value* val2 = pop(); pop(); // remove the 0 on the stack Value* val1 = pop(); - push(BinaryOperator::createXor(val1, val2, "", currentBlock), AssessorDesc::dLong); + push(BinaryOperator::createXor(val1, val2, "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; } @@ -1041,43 +1098,49 @@ case IINC : { uint16 idx = WREAD_U1(bytecodes, true, i); sint16 val = WREAD_S1(bytecodes, false, i); - mvm::jit::protectConstants();//->lock(); + mvm::jit::protectConstants(); llvm::Value* add = BinaryOperator::createAdd( new LoadInst(intLocals[idx], "", currentBlock), ConstantInt::get(Type::Int32Ty, val), "", currentBlock); - mvm::jit::unprotectConstants();//->unlock(); + mvm::jit::unprotectConstants(); new StoreInst(add, intLocals[idx], false, currentBlock); break; } case I2L : - push(new SExtInst(pop(), llvm::Type::Int64Ty, "", currentBlock), AssessorDesc::dLong); + push(new SExtInst(pop(), llvm::Type::Int64Ty, "", currentBlock), + AssessorDesc::dLong); push(mvm::jit::constantZero, AssessorDesc::dInt); break; case I2F : - push(new SIToFPInst(pop(), llvm::Type::FloatTy, "", currentBlock), AssessorDesc::dFloat); + push(new SIToFPInst(pop(), llvm::Type::FloatTy, "", currentBlock), + AssessorDesc::dFloat); break; case I2D : - push(new SIToFPInst(pop(), llvm::Type::DoubleTy, "", currentBlock), AssessorDesc::dDouble); + push(new SIToFPInst(pop(), llvm::Type::DoubleTy, "", currentBlock), + AssessorDesc::dDouble); push(mvm::jit::constantZero, AssessorDesc::dInt); break; case L2I : pop(); - push(new TruncInst(pop(), llvm::Type::Int32Ty, "", currentBlock), AssessorDesc::dInt); + push(new TruncInst(pop(), llvm::Type::Int32Ty, "", currentBlock), + AssessorDesc::dInt); break; case L2F : pop(); - push(new SIToFPInst(pop(), llvm::Type::FloatTy, "", currentBlock), AssessorDesc::dFloat); + push(new SIToFPInst(pop(), llvm::Type::FloatTy, "", currentBlock), + AssessorDesc::dFloat); break; case L2D : pop(); - push(new SIToFPInst(pop(), llvm::Type::DoubleTy, "", currentBlock), AssessorDesc::dDouble); + push(new SIToFPInst(pop(), llvm::Type::DoubleTy, "", currentBlock), + AssessorDesc::dDouble); push(mvm::jit::constantZero, AssessorDesc::dInt); break; @@ -1177,7 +1240,8 @@ } case F2D : - push(new FPExtInst(pop(), llvm::Type::DoubleTy, "", currentBlock), AssessorDesc::dDouble); + push(new FPExtInst(pop(), llvm::Type::DoubleTy, "", currentBlock), + AssessorDesc::dDouble); push(mvm::jit::constantZero, AssessorDesc::dInt); break; @@ -1196,7 +1260,8 @@ currentBlock = cont; - test = new FCmpInst(FCmpInst::FCMP_OGE, val, mvm::jit::constantMaxIntDouble, + test = new FCmpInst(FCmpInst::FCMP_OGE, val, + mvm::jit::constantMaxIntDouble, "", currentBlock); cont = createBasicBlock("D2I"); @@ -1206,7 +1271,8 @@ currentBlock = cont; - test = new FCmpInst(FCmpInst::FCMP_OLE, val, mvm::jit::constantMinIntDouble, + test = new FCmpInst(FCmpInst::FCMP_OLE, val, + mvm::jit::constantMinIntDouble, "", currentBlock); cont = createBasicBlock("D2I"); @@ -1243,7 +1309,8 @@ currentBlock = cont; - test = new FCmpInst(FCmpInst::FCMP_OGE, val, mvm::jit::constantMaxLongDouble, + test = new FCmpInst(FCmpInst::FCMP_OGE, val, + mvm::jit::constantMaxLongDouble, "", currentBlock); cont = createBasicBlock("D2L"); @@ -1278,7 +1345,8 @@ case D2F : pop(); // remove the 0 on the stack - push(new FPTruncInst(pop(), llvm::Type::FloatTy, "", currentBlock), AssessorDesc::dFloat); + push(new FPTruncInst(pop(), llvm::Type::FloatTy, "", currentBlock), + AssessorDesc::dFloat); break; case I2B : { @@ -1286,7 +1354,8 @@ if (val->getType() == Type::Int32Ty) { val = new TruncInst(val, llvm::Type::Int8Ty, "", currentBlock); } - push(new SExtInst(val, llvm::Type::Int32Ty, "", currentBlock), AssessorDesc::dInt); + push(new SExtInst(val, llvm::Type::Int32Ty, "", currentBlock), + AssessorDesc::dInt); break; } @@ -1295,7 +1364,8 @@ if (val->getType() == Type::Int32Ty) { val = new TruncInst(val, llvm::Type::Int16Ty, "", currentBlock); } - push(new ZExtInst(val, llvm::Type::Int32Ty, "", currentBlock), AssessorDesc::dInt); + push(new ZExtInst(val, llvm::Type::Int32Ty, "", currentBlock), + AssessorDesc::dInt); break; } @@ -1304,7 +1374,8 @@ if (val->getType() == Type::Int32Ty) { val = new TruncInst(val, llvm::Type::Int16Ty, "", currentBlock); } - push(new SExtInst(val, llvm::Type::Int32Ty, "", currentBlock), AssessorDesc::dInt); + push(new SExtInst(val, llvm::Type::Int32Ty, "", currentBlock), + AssessorDesc::dInt); break; } @@ -1570,12 +1641,12 @@ case JSR : { uint32 tmp = i; - mvm::jit::protectConstants();//->lock(); + mvm::jit::protectConstants(); Value* expr = ConstantExpr::getIntToPtr( ConstantInt::get(Type::Int64Ty, uint64_t (jsrIndex++)), JavaObject::llvmType); - mvm::jit::unprotectConstants();//->unlock(); + mvm::jit::unprotectConstants(); new StoreInst(expr, supplLocal, false, currentBlock); BranchInst::Create(opcodeInfos[tmp + readS2(bytecodes, i)].newBlock, @@ -1591,12 +1662,12 @@ currentBlock); uint32 index = 0; - mvm::jit::protectConstants();//->lock(); + mvm::jit::protectConstants(); for (std::vector::iterator i = jsrs.begin(), e = jsrs.end(); i!= e; ++i, ++index) { inst->addCase(ConstantInt::get(Type::Int32Ty, index), *i); } - mvm::jit::unprotectConstants();//->unlock(); + mvm::jit::unprotectConstants(); break; } @@ -1614,21 +1685,19 @@ Value* index = pop(); const llvm::Type* type = index->getType(); - mvm::jit::protectConstants();//->lock(); + mvm::jit::protectConstants(); for (uint32 cur = low; cur < high; ++cur) { Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, ConstantInt::get(type, cur), index, "", currentBlock); BasicBlock* falseBlock = createBasicBlock("continue tableswitch"); - branch(cmp, opcodeInfos[tmp + readU4(bytecodes, i)].newBlock, falseBlock, currentBlock); + branch(cmp, opcodeInfos[tmp + readU4(bytecodes, i)].newBlock, + falseBlock, currentBlock); currentBlock = falseBlock; } - mvm::jit::unprotectConstants();//->unlock(); + mvm::jit::unprotectConstants(); - //Value* cmp = new ICmpInst(ICmpInst::ICMP_SLT, index, - // ConstantInt::get(Type::Int32Ty, low), "", - // currentBlock); branch(def, currentBlock); i = tmp + 12 + filled + ((high - low) << 2); @@ -1654,7 +1723,8 @@ Value* val = ConstantInt::get(Type::Int32Ty, readU4(bytecodes, i)); Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, val, key, "", currentBlock); BasicBlock* falseBlock = createBasicBlock("continue lookupswitch"); - branch(cmp, opcodeInfos[tmp + readU4(bytecodes, i)].newBlock, falseBlock, currentBlock); + branch(cmp, opcodeInfos[tmp + readU4(bytecodes, i)].newBlock, + falseBlock, currentBlock); currentBlock = falseBlock; } mvm::jit::unprotectConstants();//->unlock(); @@ -1753,48 +1823,39 @@ break; } - case NEWARRAY : { - - Jnjvm* vm = compilingClass->isolate; - uint8 id = bytecodes[++i]; - ClassArray* cl = 0; - AssessorDesc* ass = 0; - Function* ctr = 0; - AssessorDesc::arrayType(vm, compilingClass->classLoader, id, cl, ass, - ctr); - - llvm::Value* valCl = new LoadInst(cl->llvmVar(vm->module), "", currentBlock); - llvm::Value* arg1 = popAsInt(); -#ifdef MULTIPLE_VM - std::vector args; - args.push_back(arg1); - args.push_back(valCl); - args.push_back(isolateLocal); - push(invoke(ctr, args, "", currentBlock), AssessorDesc::dRef); -#else - push(invoke(ctr, arg1, valCl, "", currentBlock), AssessorDesc::dRef); -#endif - break; - } - + case NEWARRAY : case ANEWARRAY : { + ClassArray* dcl = 0; + ConstantInt* sizeElement = 0; + GlobalVariable* TheVT = 0; Jnjvm* vm = compilingClass->isolate; - uint16 index = readU2(bytecodes, i); - const UTF8* className = - compilingClass->ctpInfo->resolveClassName(index); + + if (bytecodes[i] == NEWARRAY) { + uint8 id = bytecodes[++i]; + AssessorDesc* ass = AssessorDesc::arrayType(id); + dcl = ass->arrayClass; + TheVT = JavaObjectVT; + sizeElement = ass->sizeInBytesConstant; + } else { + uint16 index = readU2(bytecodes, i); + const UTF8* className = + compilingClass->ctpInfo->resolveClassName(index); - const UTF8* arrayName = - AssessorDesc::constructArrayName(vm, 0, 1, className); + const UTF8* arrayName = + AssessorDesc::constructArrayName(vm, 0, 1, className); - ClassArray* dcl = - vm->constructArray(arrayName, compilingClass->classLoader); - + dcl = vm->constructArray(arrayName, compilingClass->classLoader); + TheVT = ArrayObjectVT; + sizeElement = mvm::jit::constantPtrSize; + } - llvm::Value* valCl = new LoadInst(dcl->llvmVar(vm->module), "", currentBlock); + llvm::Value* valCl = new LoadInst(dcl->llvmVar(vm->module), "", + currentBlock); llvm::Value* arg1 = popAsInt(); - Value* cmp = new ICmpInst(ICmpInst::ICMP_SLT, arg1, mvm::jit::constantZero, "", currentBlock); + Value* cmp = new ICmpInst(ICmpInst::ICMP_SLT, arg1, + mvm::jit::constantZero, "", currentBlock); BasicBlock* BB1 = createBasicBlock(""); BasicBlock* BB2 = createBasicBlock(""); @@ -1804,14 +1865,18 @@ std::vector exArgs; exArgs.push_back(arg1); if (currentExceptionBlock != endExceptionBlock) { - InvokeInst::Create(negativeArraySizeExceptionLLVM, unifiedUnreachable, currentExceptionBlock, exArgs.begin(), exArgs.end(), "", currentBlock); + InvokeInst::Create(negativeArraySizeExceptionLLVM, unifiedUnreachable, + currentExceptionBlock, exArgs.begin(), + exArgs.end(), "", currentBlock); } else { - CallInst::Create(negativeArraySizeExceptionLLVM, exArgs.begin(), exArgs.end(), "", currentBlock); + CallInst::Create(negativeArraySizeExceptionLLVM, exArgs.begin(), + exArgs.end(), "", currentBlock); new UnreachableInst(currentBlock); } currentBlock = BB2; - cmp = new ICmpInst(ICmpInst::ICMP_SGT, arg1, constantMaxArraySize, "", currentBlock); + cmp = new ICmpInst(ICmpInst::ICMP_SGT, arg1, constantMaxArraySize, + "", currentBlock); BB1 = createBasicBlock(""); BB2 = createBasicBlock(""); @@ -1819,62 +1884,47 @@ BranchInst::Create(BB1, BB2, cmp, currentBlock); currentBlock = BB1; if (currentExceptionBlock != endExceptionBlock) { - InvokeInst::Create(outOfMemoryErrorLLVM, unifiedUnreachable, currentExceptionBlock, exArgs.begin(), exArgs.end(), "", currentBlock); + InvokeInst::Create(outOfMemoryErrorLLVM, unifiedUnreachable, + currentExceptionBlock, exArgs.begin(), + exArgs.end(), "", currentBlock); } else { - CallInst::Create(outOfMemoryErrorLLVM, exArgs.begin(), exArgs.end(), "", currentBlock); + CallInst::Create(outOfMemoryErrorLLVM, exArgs.begin(), exArgs.end(), + "", currentBlock); new UnreachableInst(currentBlock); } currentBlock = BB2; - Value* mult = BinaryOperator::createMul(arg1, mvm::jit::constantPtrSize, "", currentBlock); - Value* size = BinaryOperator::createAdd(constantJavaObjectSize, mult, "", currentBlock); + Value* mult = BinaryOperator::createMul(arg1, sizeElement, "", + currentBlock); + Value* size = BinaryOperator::createAdd(constantJavaObjectSize, mult, + "", currentBlock); std::vector args; args.push_back(size); - args.push_back(new LoadInst(ArrayObjectVT, "", currentBlock)); + args.push_back(new LoadInst(TheVT, "", currentBlock)); #ifdef MULTIPLE_GC - args.push_back(CallInst::Create(getCollector, isolateLocal, "", currentBlock)); + args.push_back(CallInst::Create(getCollector, isolateLocal, "", + currentBlock)); #endif Value* res = invoke(javaObjectAllocateLLVM, args, "", currentBlock); - Value* cast = new BitCastInst(res, ArrayObject::llvmType, "", currentBlock); + Value* cast = new BitCastInst(res, JavaArray::llvmType, "", + currentBlock); // Set the size std::vector gep4; gep4.push_back(mvm::jit::constantZero); gep4.push_back(JavaArray::sizeOffset()); - new StoreInst(arg1, GetElementPtrInst::Create(cast, gep4.begin(), gep4.end(), "", currentBlock), currentBlock); + Value* GEP = GetElementPtrInst::Create(cast, gep4.begin(), gep4.end(), + "", currentBlock); + new StoreInst(arg1, GEP, currentBlock); - /* - // Memset 0 to everyone - std::vector gep5; - gep5.push_back(mvm::jit::constantZero); - gep5.push_back(JavaArray::elementsOffset()); - Value* elements = GetElementPtrInst::Create(cast, gep5.begin(), gep5.end(), "", currentBlock); - - std::vector argsM; - argsM.push_back(new BitCastInst(elements, mvm::jit::ptrType, "", currentBlock)); - argsM.push_back(mvm::jit::constantInt8Zero); - argsM.push_back(mult); - argsM.push_back(mvm::jit::constantFour); - CallInst::Create(mvm::jit::llvm_memset_i32, argsM.begin(), argsM.end(), "", currentBlock); - */ // Set the class std::vector gep; gep.push_back(mvm::jit::constantZero); gep.push_back(JavaObject::classOffset()); - new StoreInst(valCl, GetElementPtrInst::Create(res, gep.begin(), gep.end(), "", currentBlock), currentBlock); - /* - // Set the lock to zero - std::vector gep2; - gep2.push_back(mvm::jit::constantZero); - gep2.push_back(JavaObject::lockOffset()); - new StoreInst(mvm::jit::constantPtrNull, GetElementPtrInst::Create(res, gep2.begin(), gep2.end(), "", currentBlock), currentBlock); - - // Set the real VT - std::vector gep3; - gep3.push_back(mvm::jit::constantZero); - gep3.push_back(mvm::jit::constantZero); - new StoreInst(new LoadInst(ArrayObjectVT, "", currentBlock), GetElementPtrInst::Create(res, gep3.begin(), gep3.end(), "", currentBlock), currentBlock); - */ + GEP = GetElementPtrInst::Create(res, gep.begin(), gep.end(), "", + currentBlock); + new StoreInst(valCl, GEP, currentBlock); + push(res, AssessorDesc::dRef); break; @@ -1892,9 +1942,12 @@ std::vector args; args.push_back(arg); if (currentExceptionBlock != endExceptionBlock) { - InvokeInst::Create(throwExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", currentBlock); + InvokeInst::Create(throwExceptionLLVM, unifiedUnreachable, + currentExceptionBlock, args.begin(), args.end(), + "", currentBlock); } else { - CallInst::Create(throwExceptionLLVM, args.begin(), args.end(), "", currentBlock); + CallInst::Create(throwExceptionLLVM, args.begin(), args.end(), "", + currentBlock); new UnreachableInst(currentBlock); } break; @@ -1918,7 +1971,8 @@ currentBlock = ifFalse; Value* clVar = 0; if (dcl) { - clVar = new LoadInst(dcl->llvmVar(compilingClass->isolate->module), "", ifFalse); + clVar = new LoadInst(dcl->llvmVar(compilingClass->isolate->module), + "", ifFalse); } else { clVar = getResolvedClass(index, false); } @@ -1926,7 +1980,7 @@ args.push_back(obj); args.push_back(clVar); Value* call = CallInst::Create(instanceOfLLVM, args.begin(), args.end(), - "", currentBlock); + "", currentBlock); cmp = new ICmpInst(ICmpInst::ICMP_EQ, call, mvm::jit::constantZero, "", currentBlock); @@ -1938,9 +1992,12 @@ exArgs.push_back(obj); exArgs.push_back(clVar); if (currentExceptionBlock != endExceptionBlock) { - InvokeInst::Create(classCastExceptionLLVM, unifiedUnreachable, currentExceptionBlock, exArgs.begin(), exArgs.end(), "", ex); + InvokeInst::Create(classCastExceptionLLVM, unifiedUnreachable, + currentExceptionBlock, exArgs.begin(), + exArgs.end(), "", ex); } else { - CallInst::Create(classCastExceptionLLVM, exArgs.begin(), exArgs.end(), "", ex); + CallInst::Create(classCastExceptionLLVM, exArgs.begin(), + exArgs.end(), "", ex); new UnreachableInst(ex); } @@ -1955,14 +2012,17 @@ Value* clVar = 0; if (dcl) { - clVar = new LoadInst(dcl->llvmVar(compilingClass->isolate->module), "", currentBlock); + clVar = new LoadInst(dcl->llvmVar(compilingClass->isolate->module), + "", currentBlock); } else { clVar = getResolvedClass(index, false); } std::vector args; args.push_back(pop()); args.push_back(clVar); - push(CallInst::Create(instanceOfLLVM, args.begin(), args.end(), "", currentBlock), AssessorDesc::dInt); + push(CallInst::Create(instanceOfLLVM, args.begin(), args.end(), "", + currentBlock), + AssessorDesc::dInt); break; } @@ -2018,7 +2078,8 @@ #ifdef MULTIPLE_VM Args.push_back(isolateLocal); #endif - push(invoke(multiCallNewLLVM, Args, "", currentBlock), AssessorDesc::dRef); + push(invoke(multiCallNewLLVM, Args, "", currentBlock), + AssessorDesc::dRef); break; } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp?rev=50865&r1=50864&r2=50865&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp Thu May 8 14:26:31 2008 @@ -59,7 +59,8 @@ AssessorDesc* AssessorDesc::allocate(bool dt, char bid, uint32 nb, uint32 nw, const char* name, const char* className, Jnjvm* vm, const llvm::Type* t, - const char* assocName, arrayCtor_t ctor) { + const char* assocName, ClassArray* cl, + llvm::ConstantInt* CI, arrayCtor_t ctor) { AssessorDesc* res = vm_new(vm, AssessorDesc)(); res->doTrace = dt; res->byteId = bid; @@ -68,11 +69,13 @@ res->asciizName = name; res->UTF8Name = vm->asciizConstructUTF8(name); res->llvmType = t; + res->sizeInBytesConstant = CI; + res->arrayCtor = ctor; if (t && t != llvm::Type::VoidTy) { res->llvmTypePtr = llvm::PointerType::getUnqual(t); res->llvmNullConstant = llvm::Constant::getNullValue(t); } - res->arrayCtor = ctor; + res->arrayClass = cl; if (assocName) res->assocClassName = vm->asciizConstructUTF8(assocName); else @@ -91,43 +94,56 @@ void AssessorDesc::initialise(Jnjvm* vm) { - dParg = AssessorDesc::allocate(false, I_PARG, 0, 0, "(", "(", vm, 0, 0, 0); - dPard = AssessorDesc::allocate(false, I_PARD, 0, 0, ")", ")", vm, 0, 0, 0); + dParg = AssessorDesc::allocate(false, I_PARG, 0, 0, "(", "(", vm, 0, 0, 0, + 0, 0); + dPard = AssessorDesc::allocate(false, I_PARD, 0, 0, ")", ")", vm, 0, 0, 0, + 0, 0); dVoid = AssessorDesc::allocate(false, I_VOID, 0, 0, "void", "*** void ***", - vm, llvm::Type::VoidTy, "java/lang/Void", 0); + vm, llvm::Type::VoidTy, "java/lang/Void", + 0, 0, 0); dBool = AssessorDesc::allocate(false, I_BOOL, 1, 1, "boolean", "*** boolean ***", vm, llvm::Type::Int8Ty, "java/lang/Boolean", + JavaArray::ofBool, mvm::jit::constantOne, (arrayCtor_t)ArrayUInt8::acons); dByte = AssessorDesc::allocate(false, I_BYTE, 1, 1, "byte", "*** byte ***", vm, llvm::Type::Int8Ty, "java/lang/Byte", + JavaArray::ofByte, mvm::jit::constantOne, (arrayCtor_t)ArraySInt8::acons); dChar = AssessorDesc::allocate(false, I_CHAR, 2, 1, "char", "*** char ***", vm, llvm::Type::Int16Ty, "java/lang/Character", + JavaArray::ofChar, mvm::jit::constantTwo, (arrayCtor_t)ArrayUInt16::acons); dShort = AssessorDesc::allocate(false, I_SHORT, 2, 1, "short", "*** short ***", vm, llvm::Type::Int16Ty, "java/lang/Short", + JavaArray::ofShort, mvm::jit::constantTwo, (arrayCtor_t)ArraySInt16::acons); dInt = AssessorDesc::allocate(false, I_INT, 4, 1, "int", "*** int ***", vm, llvm::Type::Int32Ty, "java/lang/Integer", + JavaArray::ofInt, mvm::jit::constantFour, (arrayCtor_t)ArraySInt32::acons); dFloat = AssessorDesc::allocate(false, I_FLOAT, 4, 1, "float", "*** float ***", vm, llvm::Type::FloatTy, "java/lang/Float", + JavaArray::ofFloat, mvm::jit::constantFour, (arrayCtor_t)ArrayFloat::acons); dLong = AssessorDesc::allocate(false, I_LONG, 8, 2, "long", "*** long ***", vm, llvm::Type::Int64Ty, "java/lang/Long", - (arrayCtor_t)ArrayLong::acons); + JavaArray::ofLong, mvm::jit::constantEight, + (arrayCtor_t)ArrayLong::acons); dDouble = AssessorDesc::allocate(false, I_DOUBLE, 8, 2, "double", "*** double ***", vm, llvm::Type::DoubleTy, "java/lang/Double", + JavaArray::ofDouble, mvm::jit::constantEight, (arrayCtor_t)ArrayDouble::acons); - dTab = AssessorDesc::allocate(true, I_TAB, 4, 1, "array", "array", vm, - JavaObject::llvmType, 0, + dTab = AssessorDesc::allocate(true, I_TAB, sizeof(void*), 1, "array", "array", + vm, JavaObject::llvmType, 0, 0, + mvm::jit::constantPtrSize, (arrayCtor_t)ArrayObject::acons); - dRef = AssessorDesc::allocate(true, I_REF, 4, 1, "reference", "reference", vm, - JavaObject::llvmType, 0, + dRef = AssessorDesc::allocate(true, I_REF, sizeof(void*), 1, "reference", + "reference", vm, JavaObject::llvmType, 0, 0, + mvm::jit::constantPtrSize, (arrayCtor_t)ArrayObject::acons); mvm::Object::pushRoot((mvm::Object*)dParg); @@ -313,45 +329,29 @@ } } -static void _arrayType(Jnjvm *vm, unsigned int t, AssessorDesc*& funcs, - llvm::Function*& ctor) { +AssessorDesc* AssessorDesc::arrayType(unsigned int t) { if (t == JavaArray::T_CHAR) { - funcs = AssessorDesc::dChar; - ctor = JavaJIT::UTF8AconsLLVM; + return AssessorDesc::dChar; } else if (t == JavaArray::T_BOOLEAN) { - funcs = AssessorDesc::dBool; - ctor = JavaJIT::Int8AconsLLVM; + return AssessorDesc::dBool; } else if (t == JavaArray::T_INT) { - funcs = AssessorDesc::dInt; - ctor = JavaJIT::Int32AconsLLVM; + return AssessorDesc::dInt; } else if (t == JavaArray::T_SHORT) { - funcs = AssessorDesc::dShort; - ctor = JavaJIT::Int16AconsLLVM; + return AssessorDesc::dShort; } else if (t == JavaArray::T_BYTE) { - funcs = AssessorDesc::dByte; - ctor = JavaJIT::Int8AconsLLVM; + return AssessorDesc::dByte; } else if (t == JavaArray::T_FLOAT) { - funcs = AssessorDesc::dFloat; - ctor = JavaJIT::FloatAconsLLVM; + return AssessorDesc::dFloat; } else if (t == JavaArray::T_LONG) { - funcs = AssessorDesc::dLong; - ctor = JavaJIT::LongAconsLLVM; + return AssessorDesc::dLong; } else if (t == JavaArray::T_DOUBLE) { - funcs = AssessorDesc::dDouble; - ctor = JavaJIT::DoubleAconsLLVM; + return AssessorDesc::dDouble; } else { - vm->unknownError("unknown array type %d\n", t); + JavaThread::get()->isolate->unknownError("unknown array type %d\n", t); + return 0; } } -void AssessorDesc::arrayType(Jnjvm *vm, JavaObject* loader, unsigned int t, - ClassArray*& cl, AssessorDesc*& ass, - llvm::Function*& ctr) { - _arrayType(vm, t, ass, ctr); - cl = vm->constructArray(constructArrayName(vm, ass, 1, 0), loader); - assert(cl); -} - void Typedef::tPrintBuf(mvm::PrintBuffer* buf) const { if (pseudoAssocClassName == 0) buf->write(funcs->asciizName); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h?rev=50865&r1=50864&r2=50865&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h Thu May 8 14:26:31 2008 @@ -56,8 +56,10 @@ const llvm::Type* llvmType; const llvm::Type* llvmTypePtr; llvm::Constant* llvmNullConstant; + llvm::ConstantInt* sizeInBytesConstant; const UTF8* assocClassName; const UTF8* UTF8Name; + ClassArray* arrayClass; arrayCtor_t arrayCtor; static AssessorDesc* dParg; @@ -77,7 +79,8 @@ static AssessorDesc* allocate(bool dt, char bid, uint32 nb, uint32 nw, const char* name, const char* className, Jnjvm* vm, const llvm::Type* type, - const char* assocName, arrayCtor_t ctor); + const char* assocName, ClassArray* cl, + llvm::ConstantInt* CI, arrayCtor_t ctor); static void initialise(Jnjvm* vm); @@ -99,9 +102,7 @@ uint32 start, AssessorDesc*& ass, CommonClass*& res); - static void arrayType(Jnjvm *vm, JavaObject* loader, unsigned int t, - ClassArray*& cl, AssessorDesc*& ass, - llvm::Function*& ctr); + static AssessorDesc* arrayType(unsigned int t); static AssessorDesc* byteIdToPrimitive(const char id); static AssessorDesc* classToPrimitive(CommonClass* cl); From foldr at codedgers.com Thu May 8 15:02:04 2008 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Thu, 08 May 2008 20:02:04 -0000 Subject: [llvm-commits] [llvm] r50867 - in /llvm/trunk: tools/llvmc2/Common.td utils/TableGen/LLVMCConfigurationEmitter.cpp Message-ID: <200805082002.m48K24tT006657@zion.cs.uiuc.edu> Author: foldr Date: Thu May 8 15:02:03 2008 New Revision: 50867 URL: http://llvm.org/viewvc/llvm-project?rev=50867&view=rev Log: A small refactoring (extract method) + some comment fixes. Modified: llvm/trunk/tools/llvmc2/Common.td llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Modified: llvm/trunk/tools/llvmc2/Common.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Common.td?rev=50867&r1=50866&r2=50867&view=diff ============================================================================== --- llvm/trunk/tools/llvmc2/Common.td (original) +++ llvm/trunk/tools/llvmc2/Common.td Thu May 8 15:02:03 2008 @@ -15,7 +15,7 @@ list properties = l; } -// Special Tool instance - graph root. +// Special Tool instance - the root node of the compilation graph. def root : Tool<[]>; @@ -47,6 +47,7 @@ // Possible edge properties +// 'Atomic' properties. def switch_on; def parameter_equals; def element_in_list; Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=50867&r1=50866&r2=50867&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Thu May 8 15:02:03 2008 @@ -163,8 +163,8 @@ std::string Help; unsigned Flags; - // We need t provide a default constructor since - // StringMap can only store DefaultConstructible objects + // We need to provide a default constructor because + // StringMap can only store DefaultConstructible objects. GlobalOptionDescription() : OptionDescription(), Flags(0) {} @@ -222,9 +222,9 @@ }; -// Tool-local option description +// Tool-local option description. -// Properties without arguments are implemented as flags +// Properties without arguments are implemented as flags. namespace ToolOptionDescriptionFlags { enum ToolOptionDescriptionFlags { StopCompilation = 0x1, Forward = 0x2, UnpackValues = 0x4}; @@ -314,7 +314,7 @@ /// CollectProperties - Function object for iterating over a list of -/// tool property records +/// tool property records. class CollectProperties { private: @@ -569,7 +569,8 @@ /// CollectToolProperties - Gather information from the parsed -/// TableGen data (basically a wrapper for CollectProperties). +/// TableGen data (basically a wrapper for the CollectProperties +/// function object). void CollectToolProperties (RecordVector::const_iterator B, RecordVector::const_iterator E, ToolPropertiesList& TPList, @@ -589,12 +590,50 @@ } } -/// EmitOptionPropertyHandlingCode - Used by EmitGenerateActionMethod. +/// EmitForwardOptionPropertyHandlingCode - Helper function used to +/// implement EmitOptionPropertyHandlingCode(). Emits code for +/// handling the (forward) option property. +void EmitForwardOptionPropertyHandlingCode (const ToolOptionDescription& D, + std::ostream& O) { + switch (D.Type) { + case OptionType::Switch: + O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n"; + break; + case OptionType::Parameter: + O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n"; + O << Indent3 << "vec.push_back(" << D.GenVariableName() << ");\n"; + break; + case OptionType::Prefix: + O << Indent3 << "vec.push_back(\"-" << D.Name << "\" + " + << D.GenVariableName() << ");\n"; + break; + case OptionType::PrefixList: + O << Indent3 << "for (" << D.GenTypeDeclaration() + << "::iterator B = " << D.GenVariableName() << ".begin(),\n" + << Indent3 << "E = " << D.GenVariableName() << ".end(); B != E; ++B)\n" + << Indent4 << "vec.push_back(\"-" << D.Name << "\" + " + << "*B);\n"; + break; + case OptionType::ParameterList: + O << Indent3 << "for (" << D.GenTypeDeclaration() + << "::iterator B = " << D.GenVariableName() << ".begin(),\n" + << Indent3 << "E = " << D.GenVariableName() + << ".end() ; B != E; ++B) {\n" + << Indent4 << "vec.push_back(\"-" << D.Name << "\");\n" + << Indent4 << "vec.push_back(*B);\n" + << Indent3 << "}\n"; + break; + } +} + +/// EmitOptionPropertyHandlingCode - Helper function used by +/// EmitGenerateActionMethod(). Emits code that handles option +/// properties. void EmitOptionPropertyHandlingCode (const ToolProperties& P, const ToolOptionDescription& D, std::ostream& O) { - // if clause + // Start of the if-clause. O << Indent2 << "if ("; if (D.Type == OptionType::Switch) O << D.GenVariableName(); @@ -603,7 +642,7 @@ O <<") {\n"; - // Handle option properties that take an argument + // Handle option properties that take an argument. for (OptionPropertyList::const_iterator B = D.Props.begin(), E = D.Props.end(); B!=E; ++B) { const OptionProperty& val = *B; @@ -622,37 +661,8 @@ // Handle flags // (forward) property - if (D.isForward()) { - switch (D.Type) { - case OptionType::Switch: - O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n"; - break; - case OptionType::Parameter: - O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n"; - O << Indent3 << "vec.push_back(" << D.GenVariableName() << ");\n"; - break; - case OptionType::Prefix: - O << Indent3 << "vec.push_back(\"-" << D.Name << "\" + " - << D.GenVariableName() << ");\n"; - break; - case OptionType::PrefixList: - O << Indent3 << "for (" << D.GenTypeDeclaration() - << "::iterator B = " << D.GenVariableName() << ".begin(),\n" - << Indent3 << "E = " << D.GenVariableName() << ".end(); B != E; ++B)\n" - << Indent4 << "vec.push_back(\"-" << D.Name << "\" + " - << "*B);\n"; - break; - case OptionType::ParameterList: - O << Indent3 << "for (" << D.GenTypeDeclaration() - << "::iterator B = " << D.GenVariableName() << ".begin(),\n" - << Indent3 << "E = " << D.GenVariableName() - << ".end() ; B != E; ++B) {\n" - << Indent4 << "vec.push_back(\"-" << D.Name << "\");\n" - << Indent4 << "vec.push_back(*B);\n" - << Indent3 << "}\n"; - break; - } - } + if (D.isForward()) + HandleForwardPropertyy(O); // (unpack_values) property if (D.isUnpackValues()) { @@ -673,16 +683,15 @@ } } - // close if clause + // End of the if-clause. O << Indent2 << "}\n"; } -// EmitGenerateActionMethod - Emit one of two versions of -// GenerateAction method. -void EmitGenerateActionMethod (const ToolProperties& P, int V, std::ostream& O) +// EmitGenerateActionMethod - Emit one of two versions of the +// Tool::GenerateAction() method. +void EmitGenerateActionMethod (const ToolProperties& P, bool V, std::ostream& O) { - assert(V==1 || V==2); - if (V==1) + if (V) O << Indent1 << "Action GenerateAction(const PathVector& inFiles,\n"; else O << Indent1 << "Action GenerateAction(const sys::Path& inFile,\n"; @@ -701,7 +710,7 @@ const std::string& cmd = *I; O << Indent2; if (cmd == "$INFILE") { - if (V==1) + if (V) O << "for (PathVector::const_iterator B = inFiles.begin()" << ", E = inFiles.end();\n" << Indent2 << "B != E; ++B)\n" @@ -717,14 +726,14 @@ } } - // For every understood option, emit handling code + // For every understood option, emit handling code. for (ToolOptionDescriptions::const_iterator B = P.OptDescs.begin(), E = P.OptDescs.end(); B != E; ++B) { const ToolOptionDescription& val = B->second; EmitOptionPropertyHandlingCode(P, val, O); } - // Handle Sink property + // Handle the Sink property. if (P.isSink()) { O << Indent2 << "if (!" << SinkOptionName << ".empty()) {\n" << Indent3 << "vec.insert(vec.end(), " @@ -736,8 +745,8 @@ << Indent1 << "}\n\n"; } -/// EmitGenerateActionMethods - Emit two GenerateAction methods for a given -/// Tool class. +/// EmitGenerateActionMethods - Emit two GenerateAction() methods for +/// a given Tool class. void EmitGenerateActionMethods (const ToolProperties& P, std::ostream& O) { if (!P.isJoin()) @@ -753,7 +762,8 @@ EmitGenerateActionMethod(P, 2, O); } -/// EmitIsLastMethod - Emit IsLast() method for a given Tool class +/// EmitIsLastMethod - Emit the IsLast() method for a given Tool +/// class. void EmitIsLastMethod (const ToolProperties& P, std::ostream& O) { O << Indent1 << "bool IsLast() const {\n" << Indent2 << "bool last = false;\n"; From foldr at codedgers.com Thu May 8 15:02:36 2008 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Thu, 08 May 2008 20:02:36 -0000 Subject: [llvm-commits] [llvm] r50868 - /llvm/trunk/tools/llvmc2/Tools.td Message-ID: <200805082002.m48K2a3o006679@zion.cs.uiuc.edu> Author: foldr Date: Thu May 8 15:02:36 2008 New Revision: 50868 URL: http://llvm.org/viewvc/llvm-project?rev=50868&view=rev Log: Add -E and -S options Modified: llvm/trunk/tools/llvmc2/Tools.td Modified: llvm/trunk/tools/llvmc2/Tools.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Tools.td?rev=50868&r1=50867&r2=50868&view=diff ============================================================================== --- llvm/trunk/tools/llvmc2/Tools.td (original) +++ llvm/trunk/tools/llvmc2/Tools.td Thu May 8 15:02:36 2008 @@ -26,6 +26,8 @@ (out_language "llvm-bitcode"), (output_suffix "bc"), (cmd_line "llvm-gcc -c -x c $INFILE -o $OUTFILE -emit-llvm"), + (switch_option "E", (stop_compilation), + (help "Stop after the preprocessing stage, do not run the compiler")), (sink) ]>; @@ -34,6 +36,7 @@ (out_language "llvm-bitcode"), (output_suffix "bc"), (cmd_line "llvm-g++ -c -x c++ $INFILE -o $OUTFILE -emit-llvm"), + (switch_option "E", (stop_compilation)), (sink) ]>; @@ -56,6 +59,8 @@ [(in_language "llvm-bitcode"), (out_language "assembler"), (output_suffix "s"), + (switch_option "S", (stop_compilation), + (help "Stop after compilation, do not assemble")), (cmd_line "llc -f $INFILE -o $OUTFILE") ]>; From edwintorok at gmail.com Thu May 8 15:38:16 2008 From: edwintorok at gmail.com (=?UTF-8?B?VMO2csO2ayBFZHdpbg==?=) Date: Thu, 08 May 2008 23:38:16 +0300 Subject: [llvm-commits] [llvm] r50867 - in /llvm/trunk: tools/llvmc2/Common.td utils/TableGen/LLVMCConfigurationEmitter.cpp In-Reply-To: <200805082002.m48K24tT006657@zion.cs.uiuc.edu> References: <200805082002.m48K24tT006657@zion.cs.uiuc.edu> Message-ID: <482364B8.8070503@gmail.com> Mikhail Glushenkov wrote: > Author: foldr > Date: Thu May 8 15:02:03 2008 > New Revision: 50867 > > + if (D.isForward()) > + HandleForwardPropertyy(O); Where is HandleForwardPropertyy? My build fails: llvm[2]: Compiling LLVMCConfigurationEmitter.cpp for Debug build LLVMCConfigurationEmitter.cpp: In function ?void::EmitOptionPropertyHandlingCode(const::ToolProperties&, const::ToolOptionDescription&, std::ostream&)?: LLVMCConfigurationEmitter.cpp:665: error: ?HandleForwardProperty? was not declared in this scope make[2]: *** [/home/edwin/llvm-svn/llvm/utils/TableGen/Debug/LLVMCConfigurationEmitter.o] Error 1 make[2]: Leaving directory `/home/edwin/llvm-svn/llvm/utils/TableGen' --Edwin From lattner at apple.com Thu May 8 16:02:12 2008 From: lattner at apple.com (Tanya Lattner) Date: Thu, 8 May 2008 14:02:12 -0700 Subject: [llvm-commits] [llvm] r50861 - in /llvm/trunk: docs/Passes.html lib/Transforms/IPO/StripDeadPrototypes.cpp lib/Transforms/IPO/StructRetPromotion.cpp lib/Transforms/Scalar/CodeGenPrepare.cpp lib/Transforms/Scalar/JumpThreading.cpp lib/Transforms/Scalar/LoopDeletion.cpp In-Reply-To: <20080508184822.GE27072@katherina.student.utwente.nl> References: <200805081746.m48HkZLA002042@zion.cs.uiuc.edu> <4DCA2C8A-919E-42D9-939D-18D2667A08B6@apple.com> <20080508184822.GE27072@katherina.student.utwente.nl> Message-ID: On May 8, 2008, at 11:48 AM, Matthijs Kooijman wrote: > Hi, > >> For the changes to the JumpThreading Class, I don't think doxygen >> will pick up the comments at the top of the file (but correct me if I >> am wrong). > From what I've seen, none of the other passes have duplicate > documentation > like this? I agree that having comments in the API docs is quite > desirable, > but wouldn't it be better to make the per-file comments doxygen > style as well > then (and perhaps add a reference)? > I'm not suggestion duplicate documentation. I'm just saying that if this means that less documentation shows up in doxygen, then thats bad. I would much prefer that the file description be simple/generic and the comments for function/class be more detailed so it shows up in doxygen. This is just my personal opinion, so others can weigh in. -Tanya > Gr. > > Matthijs > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From edwintorok at gmail.com Thu May 8 16:05:30 2008 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Fri, 09 May 2008 00:05:30 +0300 Subject: [llvm-commits] LibCallAliasAnalysis should be in anonymous namespace Message-ID: <48236B1A.3030309@gmail.com> Hi, I got a linker failure because of multiple definition of llvm::X in LibCallAliasAnalysis. The second definition was in a pass I am writing, and I haven't noticed I have the same bug until now. I think the namespace should be anonymous, like for other analysis. Ok to commit? Index: lib/Analysis/LibCallAliasAnalysis.cpp =================================================================== --- lib/Analysis/LibCallAliasAnalysis.cpp (revision 50866) +++ lib/Analysis/LibCallAliasAnalysis.cpp (working copy) @@ -18,7 +18,7 @@ #include "llvm/Target/TargetData.h" using namespace llvm; -namespace llvm { +namespace { /// LibCallAliasAnalysis - Alias analysis driven from LibCallInfo. struct LibCallAliasAnalysis : public FunctionPass, AliasAnalysis { static char ID; // Class identification From matthijs at stdin.nl Thu May 8 16:39:46 2008 From: matthijs at stdin.nl (Matthijs Kooijman) Date: Thu, 8 May 2008 23:39:46 +0200 Subject: [llvm-commits] [llvm] r50861 - in /llvm/trunk: docs/Passes.html lib/Transforms/IPO/StripDeadPrototypes.cpp lib/Transforms/IPO/StructRetPromotion.cpp lib/Transforms/Scalar/CodeGenPrepare.cpp lib/Transforms/Scalar/JumpThreading.cpp lib/Transforms/Scalar/LoopDeletion.cpp In-Reply-To: References: <200805081746.m48HkZLA002042@zion.cs.uiuc.edu> <4DCA2C8A-919E-42D9-939D-18D2667A08B6@apple.com> <20080508184822.GE27072@katherina.student.utwente.nl> Message-ID: <20080508213946.GI27072@katherina.student.utwente.nl> Hi Tanya, > I'm not suggestion duplicate documentation. > I'm just saying that if this means that less documentation shows up in > doxygen, then thats bad. Agreed. This point could also be made for the other passes, most of which are not doxygen'd. > I would much prefer that the file description be simple/generic > and the comments for function/class be more detailed so it shows up > in doxygen. I do think the more elaborate description should show up in the passes document. I was, howerver, under the assumption that the file header should be identical to what shows up in the passes document, which is probably not so true. In that case, reverting the changes to the JumpThreading.cpp file but keeping the changes to Passes.html would probably be sufficient. Besides this particular case, is there any reason the file headers are not doxygen comments? And couldn't the passes document be generated using doxygen? Gr. Matthijs -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080508/c5071572/attachment.bin From matthijs at stdin.nl Thu May 8 16:41:06 2008 From: matthijs at stdin.nl (Matthijs Kooijman) Date: Thu, 8 May 2008 23:41:06 +0200 Subject: [llvm-commits] LibCallAliasAnalysis should be in anonymous namespace In-Reply-To: <48236B1A.3030309@gmail.com> References: <48236B1A.3030309@gmail.com> Message-ID: <20080508214106.GJ27072@katherina.student.utwente.nl> Hi, > -namespace llvm { > +namespace { > /// LibCallAliasAnalysis - Alias analysis driven from LibCallInfo. > struct LibCallAliasAnalysis : public FunctionPass, AliasAnalysis { > static char ID; // Class identification Following other examples, shouldn't there also be a VISIBILITY_HIDDEN put in there somewhere? Gr. Matthijs -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080508/5de5f6fb/attachment.bin From gohman at apple.com Thu May 8 16:45:12 2008 From: gohman at apple.com (Dan Gohman) Date: Thu, 8 May 2008 14:45:12 -0700 Subject: [llvm-commits] [llvm] r50838 - in /llvm/trunk: lib/Target/X86/X86ISelDAGToDAG.cpp lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h lib/Target/X86/X86InstrMMX.td lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/vec_set-5.ll test/CodeGen/X86/vec_set-6.ll test/CodeGen/X86/vec_set-C.ll test/CodeGen/X86/vec_set-D.ll In-Reply-To: <200805080057.m480vJW2019730@zion.cs.uiuc.edu> References: <200805080057.m480vJW2019730@zion.cs.uiuc.edu> Message-ID: <1E30D774-ABD3-4892-977A-A39060506179@apple.com> Hi Evan, This is causing regressions on x86 in UnitTests/Vector/build UnitTests/Vector/simple . llc is aborting with this message: $ llc -f Output/build.llvm.bc -o Output/build.llc.s Cannot yet select: 0x14081f0: v2f64 = X86ISD::ZEXT_VMOVL 0x1407fd0 Can you investigate? Thanks, Dan On May 7, 2008, at 5:57 PM, Evan Cheng wrote: > Author: evancheng > Date: Wed May 7 19:57:18 2008 > New Revision: 50838 > > URL: http://llvm.org/viewvc/llvm-project?rev=50838&view=rev > Log: > Handle vector move / load which zero the destination register top > bits (i.e. movd, movq, movss (addr), movsd (addr)) with X86 specific > dag combine. > > Added: > llvm/trunk/test/CodeGen/X86/vec_set-C.ll > llvm/trunk/test/CodeGen/X86/vec_set-D.ll > Modified: > llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp > llvm/trunk/lib/Target/X86/X86ISelLowering.cpp > llvm/trunk/lib/Target/X86/X86ISelLowering.h > llvm/trunk/lib/Target/X86/X86InstrMMX.td > llvm/trunk/lib/Target/X86/X86InstrSSE.td > llvm/trunk/test/CodeGen/X86/vec_set-5.ll > llvm/trunk/test/CodeGen/X86/vec_set-6.ll > > Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=50838&r1=50837&r2=50838&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Wed May 7 > 19:57:18 2008 > @@ -975,38 +975,19 @@ > > // Also handle the case where we explicitly require zeros in the top > // elements. This is a vector shuffle from the zero vector. > - if (N.getOpcode() == ISD::VECTOR_SHUFFLE && N.Val->hasOneUse() && > + if (N.getOpcode() == X86ISD::ZEXT_VMOVL && N.Val->hasOneUse() && > // Check to see if the top elements are all zeros (or bitcast > of zeros). > - ISD::isBuildVectorAllZeros(N.getOperand(0).Val) && > - N.getOperand(1).getOpcode() == ISD::SCALAR_TO_VECTOR && > - N.getOperand(1).Val->hasOneUse() && > - ISD::isNON_EXTLoad(N.getOperand(1).getOperand(0).Val) && > - N.getOperand(1).getOperand(0).hasOneUse()) { > - // Check to see if the shuffle mask is 4/L/L/L or 2/L, where L > is something > - // from the LHS. > - unsigned > VecWidth=MVT::getVectorNumElements(N.getOperand(0).getValueType()); > - SDOperand ShufMask = N.getOperand(2); > - assert(ShufMask.getOpcode() == ISD::BUILD_VECTOR && "Invalid > shuf mask!"); > - if (ConstantSDNode *C = > dyn_cast(ShufMask.getOperand(0))) { > - if (C->getValue() == VecWidth) { > - for (unsigned i = 1; i != VecWidth; ++i) { > - if (ShufMask.getOperand(i).getOpcode() == ISD::UNDEF) { > - // ok. > - } else { > - ConstantSDNode *C = > cast(ShufMask.getOperand(i)); > - if (C->getValue() >= VecWidth) return false; > - } > - } > - } > - > - // Okay, this is a zero extending load. Fold it. > - LoadSDNode *LD = > cast(N.getOperand(1).getOperand(0)); > - if (!SelectAddr(Op, LD->getBasePtr(), Base, Scale, Index, > Disp)) > - return false; > - OutChain = LD->getChain(); > - InChain = SDOperand(LD, 1); > - return true; > - } > + N.getOperand(0).getOpcode() == ISD::SCALAR_TO_VECTOR && > + N.getOperand(0).Val->hasOneUse() && > + ISD::isNON_EXTLoad(N.getOperand(0).getOperand(0).Val) && > + N.getOperand(0).getOperand(0).hasOneUse()) { > + // Okay, this is a zero extending load. Fold it. > + LoadSDNode *LD = cast(N.getOperand(0).getOperand(0)); > + if (!SelectAddr(Op, LD->getBasePtr(), Base, Scale, Index, Disp)) > + return false; > + OutChain = LD->getChain(); > + InChain = SDOperand(LD, 1); > + return true; > } > return false; > } > > Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=50838&r1=50837&r2=50838&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed May 7 > 19:57:18 2008 > @@ -2605,11 +2605,16 @@ > } > > /// isScalarLoadToVector - Returns true if the node is a scalar load > that > -/// is promoted to a vector. > -static inline bool isScalarLoadToVector(SDNode *N) { > +/// is promoted to a vector. It also returns the LoadSDNode by > reference if > +/// required. > +static bool isScalarLoadToVector(SDNode *N, LoadSDNode **LD = NULL) { > if (N->getOpcode() == ISD::SCALAR_TO_VECTOR) { > N = N->getOperand(0).Val; > - return ISD::isNON_EXTLoad(N); > + if (ISD::isNON_EXTLoad(N)) { > + if (LD) > + *LD = cast(N); > + return true; > + } > } > return false; > } > @@ -3082,8 +3087,16 @@ > return SDOperand(); > > // Let legalizer expand 2-wide build_vectors. > - if (EVTBits == 64) > + if (EVTBits == 64) { > + if (NumNonZero == 1) { > + // One half is zero or undef. > + unsigned Idx = CountTrailingZeros_32(NonZeros); > + SDOperand V2 = DAG.getNode(ISD::SCALAR_TO_VECTOR, VT, > + Op.getOperand(Idx)); > + return getShuffleVectorZeroOrUndef(V2, Idx, true, DAG); > + } > return SDOperand(); > + } > > // If element VT is < 32 bits, convert it to inserts into a zero > vector. > if (EVTBits == 8 && NumElems == 16) { > @@ -3131,13 +3144,6 @@ > } > } > > - // Take advantage of the fact GR32 to VR128 scalar_to_vector > (i.e. movd) > - // clears the upper bits. > - // FIXME: we can do the same for v4f32 case when we know both > parts of > - // the lower half come from scalar_to_vector (loadf32). We > should do > - // that in post legalizer dag combiner with target specific > hooks. > - if (MVT::isInteger(EVT) && (NonZeros & (0x3 << 2)) == 0) > - return V[0]; > MVT::ValueType MaskVT = > MVT::getIntVectorWithNumElements(NumElems); > MVT::ValueType EVT = MVT::getVectorElementType(MaskVT); > SmallVector MaskVec; > @@ -3475,6 +3481,38 @@ > &MaskVec[0], MaskVec.size())); > } > > +/// getZextVMoveL - Return a zero-extending vector move low node. > +/// > +static SDOperand getZextVMoveL(MVT::ValueType VT, MVT::ValueType > OpVT, > + SDOperand SrcOp, SelectionDAG &DAG, > + const X86Subtarget *Subtarget) { > + if (VT == MVT::v2f64 || VT == MVT::v4f32) { > + LoadSDNode *LD = NULL; > + if (!isScalarLoadToVector(SrcOp.Val, &LD)) > + LD = dyn_cast(SrcOp); > + if (!LD) { > + // movssrr and movsdrr do not clear top bits. Try to use > movd, movq > + // instead. > + MVT::ValueType EVT = (OpVT == MVT::v2f64) ? MVT::i64 : > MVT::i32; > + if ((EVT != MVT::i64 || Subtarget->is64Bit()) && > + SrcOp.getOpcode() == ISD::SCALAR_TO_VECTOR && > + SrcOp.getOperand(0).getOpcode() == ISD::BIT_CONVERT && > + SrcOp.getOperand(0).getOperand(0).getValueType() == EVT) { > + // PR2108 > + OpVT = (OpVT == MVT::v2f64) ? MVT::v2i64 : MVT::v4i32; > + return DAG.getNode(ISD::BIT_CONVERT, VT, > + DAG.getNode(X86ISD::ZEXT_VMOVL, OpVT, > + > DAG.getNode(ISD::SCALAR_TO_VECTOR, OpVT, > + > SrcOp.getOperand(0).getOperand(0)))); > + } > + } > + } > + > + return DAG.getNode(ISD::BIT_CONVERT, VT, > + DAG.getNode(X86ISD::ZEXT_VMOVL, OpVT, > + DAG.getNode(ISD::BIT_CONVERT, > OpVT, SrcOp))); > +} > + > SDOperand > X86TargetLowering::LowerVECTOR_SHUFFLE(SDOperand Op, SelectionDAG > &DAG) { > SDOperand V1 = Op.getOperand(0); > @@ -3515,27 +3553,33 @@ > // FIXME: Figure out a cleaner way to do this. > // Try to make use of movq to zero out the top part. > if (ISD::isBuildVectorAllZeros(V2.Val)) { > - SDOperand NewOp = RewriteAsNarrowerShuffle(V1, V2, VT, > PermMask, DAG, *this); > + SDOperand NewOp = RewriteAsNarrowerShuffle(V1, V2, VT, > PermMask, > + DAG, *this); > if (NewOp.Val) { > SDOperand NewV1 = NewOp.getOperand(0); > SDOperand NewV2 = NewOp.getOperand(1); > SDOperand NewMask = NewOp.getOperand(2); > if (isCommutedMOVL(NewMask.Val, true, false)) { > NewOp = CommuteVectorShuffle(NewOp, NewV1, NewV2, NewMask, > DAG); > - NewOp = DAG.getNode(ISD::VECTOR_SHUFFLE, > NewOp.getValueType(), > - NewV1, NewV2, getMOVLMask(2, DAG)); > - return DAG.getNode(ISD::BIT_CONVERT, VT, > LowerVECTOR_SHUFFLE(NewOp, DAG)); > + return getZextVMoveL(VT, NewOp.getValueType(), NewV2, > DAG, Subtarget); > } > } > } else if (ISD::isBuildVectorAllZeros(V1.Val)) { > - SDOperand NewOp= RewriteAsNarrowerShuffle(V1, V2, VT, > PermMask, DAG, *this); > + SDOperand NewOp= RewriteAsNarrowerShuffle(V1, V2, VT, PermMask, > + DAG, *this); > if (NewOp.Val && X86::isMOVLMask(NewOp.getOperand(2).Val)) > - return DAG.getNode(ISD::BIT_CONVERT, VT, > LowerVECTOR_SHUFFLE(NewOp, DAG)); > + return getZextVMoveL(VT, NewOp.getValueType(), > NewOp.getOperand(1), > + DAG, Subtarget); > } > } > > - if (X86::isMOVLMask(PermMask.Val)) > - return (V1IsUndef) ? V2 : Op; > + if (X86::isMOVLMask(PermMask.Val)) { > + if (V1IsUndef) > + return V2; > + if (ISD::isBuildVectorAllZeros(V1.Val)) > + return getZextVMoveL(VT, VT, V2, DAG, Subtarget); > + return Op; > + } > > if (X86::isMOVSHDUPMask(PermMask.Val) || > X86::isMOVSLDUPMask(PermMask.Val) || > @@ -5629,8 +5673,9 @@ > case X86ISD::EH_RETURN: return "X86ISD::EH_RETURN"; > case X86ISD::TC_RETURN: return "X86ISD::TC_RETURN"; > case X86ISD::FNSTCW16m: return "X86ISD::FNSTCW16m"; > - case X86ISD::LCMPXCHG_DAG: return "x86ISD::LCMPXCHG_DAG"; > - case X86ISD::LCMPXCHG8_DAG: return "x86ISD::LCMPXCHG8_DAG"; > + case X86ISD::LCMPXCHG_DAG: return "X86ISD::LCMPXCHG_DAG"; > + case X86ISD::LCMPXCHG8_DAG: return "X86ISD::LCMPXCHG8_DAG"; > + case X86ISD::ZEXT_VMOVL: return "X86ISD::ZEXT_VMOVL"; > } > } > > @@ -6192,16 +6237,46 @@ > return false; > } > > -static bool isBaseAlignment16(SDNode *Base, MachineFrameInfo *MFI, > - const X86Subtarget *Subtarget) { > +static bool isBaseAlignmentOfN(unsigned N, SDNode *Base, > MachineFrameInfo *MFI, > + const X86Subtarget *Subtarget) { > GlobalValue *GV; > int64_t Offset = 0; > if (isGAPlusOffset(Base, GV, Offset)) > - return (GV->getAlignment() >= 16 && (Offset % 16) == 0); > + return (GV->getAlignment() >= N && (Offset % N) == 0); > // DAG combine handles the stack object case. > return false; > } > > +static bool EltsFromConsecutiveLoads(SDNode *N, SDOperand PermMask, > + unsigned NumElems, > MVT::ValueType EVT, > + MachineFrameInfo *MFI, > + SelectionDAG &DAG, SDNode > *&Base) { > + Base = NULL; > + for (unsigned i = 0; i < NumElems; ++i) { > + SDOperand Idx = PermMask.getOperand(i); > + if (Idx.getOpcode() == ISD::UNDEF) { > + if (!Base) > + return false; > + continue; > + } > + > + unsigned Index = cast(Idx)->getValue(); > + SDOperand Elt = getShuffleScalarElt(N, Index, DAG); > + if (!Elt.Val || > + (Elt.getOpcode() != ISD::UNDEF && ! > ISD::isNON_EXTLoad(Elt.Val))) > + return false; > + if (!Base) { > + Base = Elt.Val; > + continue; > + } > + if (Elt.getOpcode() == ISD::UNDEF) > + continue; > + > + if (!isConsecutiveLoad(Elt.Val, Base, i, > MVT::getSizeInBits(EVT)/8,MFI)) > + return false; > + } > + return true; > +} > > /// PerformShuffleCombine - Combine a vector_shuffle that is equal to > /// build_vector load1, load2, load3, load4, <0, 1, 2, 3> into a 128- > bit load > @@ -6209,36 +6284,17 @@ > /// order. > static SDOperand PerformShuffleCombine(SDNode *N, SelectionDAG &DAG, > const X86Subtarget > *Subtarget) { > - MachineFunction &MF = DAG.getMachineFunction(); > - MachineFrameInfo *MFI = MF.getFrameInfo(); > + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); > MVT::ValueType VT = N->getValueType(0); > MVT::ValueType EVT = MVT::getVectorElementType(VT); > SDOperand PermMask = N->getOperand(2); > unsigned NumElems = PermMask.getNumOperands(); > SDNode *Base = NULL; > - for (unsigned i = 0; i < NumElems; ++i) { > - SDOperand Elt = PermMask.getOperand(i); > - if (Elt.getOpcode() == ISD::UNDEF) { > - if (!Base) > - return SDOperand(); > - continue; > - } > - > - unsigned Idx = cast(Elt)->getValue(); > - SDOperand Arg = getShuffleScalarElt(N, Idx, DAG); > - if (!Arg.Val || !ISD::isNON_EXTLoad(Arg.Val)) > - return SDOperand(); > - if (!Base) { > - Base = Arg.Val; > - continue; > - } > - > - if (!isConsecutiveLoad(Arg.Val, Base, i, > MVT::getSizeInBits(EVT)/8,MFI)) > - return SDOperand(); > - } > + if (!EltsFromConsecutiveLoads(N, PermMask, NumElems, EVT, MFI, > DAG, Base)) > + return SDOperand(); > > LoadSDNode *LD = cast(Base); > - if (isBaseAlignment16(Base->getOperand(1).Val, MFI, Subtarget)) > + if (isBaseAlignmentOfN(16, Base->getOperand(1).Val, MFI, > Subtarget)) > return DAG.getLoad(VT, LD->getChain(), LD->getBasePtr(), LD- > >getSrcValue(), > LD->getSrcValueOffset(), LD->isVolatile()); > return DAG.getLoad(VT, LD->getChain(), LD->getBasePtr(), LD- > >getSrcValue(), > @@ -6319,12 +6375,13 @@ > } > > /// PerformSTORECombine - Do target-specific dag combines on STORE > nodes. > -static SDOperand PerformSTORECombine(StoreSDNode *St, SelectionDAG > &DAG, > +static SDOperand PerformSTORECombine(SDNode *N, SelectionDAG &DAG, > const X86Subtarget *Subtarget) { > // Turn load->store of MMX types into GPR load/stores. This > avoids clobbering > // the FP state in cases where an emms may be missing. > // A preferable solution to the general problem is to figure out > the right > // places to insert EMMS. This qualifies as a quick hack. > + StoreSDNode *St = cast(N); > if (MVT::isVector(St->getValue().getValueType()) && > MVT::getSizeInBits(St->getValue().getValueType()) == 64 && > isa(St->getValue()) && > @@ -6442,8 +6499,7 @@ > default: break; > case ISD::VECTOR_SHUFFLE: return PerformShuffleCombine(N, DAG, > Subtarget); > case ISD::SELECT: return PerformSELECTCombine(N, DAG, > Subtarget); > - case ISD::STORE: > - return PerformSTORECombine(cast(N), DAG, > Subtarget); > + case ISD::STORE: return PerformSTORECombine(N, DAG, > Subtarget); > case X86ISD::FXOR: > case X86ISD::FOR: return PerformFORCombine(N, DAG); > case X86ISD::FAND: return PerformFANDCombine(N, DAG); > > Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=50838&r1=50837&r2=50838&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) > +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Wed May 7 19:57:18 > 2008 > @@ -181,10 +181,10 @@ > /// in order to obtain suitable precision. > FRSQRT, FRCP, > > - // Thread Local Storage > + // TLSADDR, THREAThread - Thread Local Storage. > TLSADDR, THREAD_POINTER, > > - // Exception Handling helpers > + // EH_RETURN - Exception Handling helpers. > EH_RETURN, > > /// TC_RETURN - Tail call return. > @@ -194,12 +194,15 @@ > /// operand #3 optional in flag > TC_RETURN, > > - // compare and swap > + // LCMPXCHG_DAG, LCMPXCHG8_DAG - Compare and swap. > LCMPXCHG_DAG, > LCMPXCHG8_DAG, > > - // Store FP control world into i16 memory > - FNSTCW16m > + // FNSTCW16m - Store FP control world into i16 memory. > + FNSTCW16m, > + > + // ZEXT_VMOVL - Vector move low and zero extend. > + ZEXT_VMOVL > }; > } > > > Modified: llvm/trunk/lib/Target/X86/X86InstrMMX.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrMMX.td?rev=50838&r1=50837&r2=50838&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/X86/X86InstrMMX.td (original) > +++ llvm/trunk/lib/Target/X86/X86InstrMMX.td Wed May 7 19:57:18 2008 > @@ -200,18 +200,14 @@ > // movd to MMX register zero-extends > def MMX_MOVZDI2PDIrr : MMXI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins > GR32:$src), > "movd\t{$src, $dst|$dst, $src}", > - [(set VR64:$dst, > - (v2i32 (vector_shuffle immAllZerosV, > - (v2i32 (scalar_to_vector > GR32:$src)), > - MMX_MOVL_shuffle_mask)))]>; > + [(set VR64:$dst, > + (v2i32 (X86zvmovl (v2i32 (scalar_to_vector > GR32:$src)))))]>; > let AddedComplexity = 20 in > def MMX_MOVZDI2PDIrm : MMXI<0x6E, MRMSrcMem, (outs VR64:$dst), (ins > i32mem:$src), > "movd\t{$src, $dst|$dst, $src}", > - [(set VR64:$dst, > - (v2i32 (vector_shuffle immAllZerosV, > - (v2i32 (scalar_to_vector > - (loadi32 addr:$src))), > - MMX_MOVL_shuffle_mask)))]>; > + [(set VR64:$dst, > + (v2i32 (X86zvmovl (v2i32 > + (scalar_to_vector (loadi32 addr: > $src))))))]>; > > // Arithmetic Instructions > > @@ -564,14 +560,10 @@ > // Move scalar to XMM zero-extended > // movd to XMM register zero-extends > let AddedComplexity = 15 in { > - def : Pat<(v8i8 (vector_shuffle immAllZerosV_bc, > - (bc_v8i8 (v2i32 (scalar_to_vector GR32:$src))), > - MMX_MOVL_shuffle_mask)), > - (MMX_MOVZDI2PDIrr GR32:$src)>; > - def : Pat<(v4i16 (vector_shuffle immAllZerosV_bc, > - (bc_v4i16 (v2i32 (scalar_to_vector GR32:$src))), > - MMX_MOVL_shuffle_mask)), > - (MMX_MOVZDI2PDIrr GR32:$src)>; > + def : Pat<(v8i8 (X86zvmovl (bc_v8i8 (v2i32 (scalar_to_vector > GR32:$src))))), > + (MMX_MOVZDI2PDIrr GR32:$src)>; > + def : Pat<(v4i16 (X86zvmovl (bc_v8i8 (v2i32 (scalar_to_vector > GR32:$src))))), > + (MMX_MOVZDI2PDIrr GR32:$src)>; > } > > // Scalar to v4i16 / v8i8. The source may be a GR32, but only the > lower > > Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=50838&r1=50837&r2=50838&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) > +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Wed May 7 19:57:18 2008 > @@ -47,6 +47,7 @@ > def X86insrtps : SDNode<"X86ISD::INSERTPS", > SDTypeProfile<1, 3, [SDTCisVT<0, v4f32>, > SDTCisSameAs<0,1>, > SDTCisVT<2, f32>, > SDTCisPtrTy<3>]>>; > +def X86zvmovl : SDNode<"X86ISD::ZEXT_VMOVL", SDTUnaryOp>; > > // > = > = > = > ----------------------------------------------------------------------= > ==// > // SSE Complex Patterns > @@ -1007,10 +1008,11 @@ > let AddedComplexity = 20 in > def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins > f32mem:$src), > "movss\t{$src, $dst|$dst, $src}", > - [(set VR128:$dst, (v4f32 (vector_shuffle > immAllZerosV_bc, > - (v4f32 (scalar_to_vector (loadf32 > addr:$src))), > - > MOVL_shuffle_mask)))]>; > + [(set VR128:$dst, (v4f32 (X86zvmovl (v4f32 > (scalar_to_vector > + (loadf32 addr: > $src))))))]>; > > +def : Pat<(v4f32 (X86zvmovl (memopv4f32 addr:$src))), > + (MOVZSS2PSrm addr:$src)>; > > // > = > = > = > ----------------------------------------------------------------------= > ==// > // SSE2 Instructions > @@ -2264,51 +2266,36 @@ > def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins > f64mem:$src), > "movsd\t{$src, $dst|$dst, $src}", > [(set VR128:$dst, > - (v2f64 (vector_shuffle immAllZerosV_bc, > - (v2f64 (scalar_to_vector > - (loadf64 addr:$src))), > - MOVL_shuffle_mask)))]>; > + (v2f64 (X86zvmovl (v2f64 (scalar_to_vector > + (loadf64 addr: > $src))))))]>; > + > +def : Pat<(v2f64 (X86zvmovl (memopv2f64 addr:$src))), > + (MOVZSD2PDrm addr:$src)>; > > // movd / movq to XMM register zero-extends > let AddedComplexity = 15 in { > def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins > GR32:$src), > "movd\t{$src, $dst|$dst, $src}", > - [(set VR128:$dst, > - (v4i32 (vector_shuffle immAllZerosV, > - (v4i32 (scalar_to_vector > GR32:$src)), > - MOVL_shuffle_mask)))]>; > + [(set VR128:$dst, (v4i32 (X86zvmovl > + (v4i32 (scalar_to_vector > GR32:$src)))))]>; > // This is X86-64 only. > def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins > GR64:$src), > "mov{d|q}\t{$src, $dst|$dst, $src}", > - [(set VR128:$dst, > - (v2i64 (vector_shuffle immAllZerosV_bc, > - (v2i64 (scalar_to_vector > GR64:$src)), > - MOVL_shuffle_mask)))]>; > + [(set VR128:$dst, (v2i64 (X86zvmovl > + (v2i64 (scalar_to_vector > GR64:$src)))))]>; > } > > -// Handle the v2f64 form of 'MOVZQI2PQIrr' for PR2108. FIXME: this > would be > -// better written as a dag combine xform. > -let AddedComplexity = 15 in > -def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc, > - (v2f64 (scalar_to_vector > - (f64 (bitconvert > GR64:$src)))), > - MOVL_shuffle_mask)), > - (MOVZQI2PQIrr GR64:$src)>, Requires<[HasSSE2]>; > - > - > let AddedComplexity = 20 in { > def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins > i32mem:$src), > "movd\t{$src, $dst|$dst, $src}", > [(set VR128:$dst, > - (v4i32 (vector_shuffle immAllZerosV, > - (v4i32 (scalar_to_vector (loadi32 > addr:$src))), > - MOVL_shuffle_mask)))]>; > + (v4i32 (X86zvmovl (v4i32 (scalar_to_vector > + (loadi32 addr: > $src))))))]>; > def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem: > $src), > "movq\t{$src, $dst|$dst, $src}", > [(set VR128:$dst, > - (v2i64 (vector_shuffle immAllZerosV_bc, > - (v2i64 (scalar_to_vector (loadi64 > addr:$src))), > - MOVL_shuffle_mask)))]>, XS, > + (v2i64 (X86zvmovl (v2i64 (scalar_to_vector > + (loadi64 addr: > $src))))))]>, XS, > Requires<[HasSSE2]>; > } > > @@ -2317,17 +2304,14 @@ > let AddedComplexity = 15 in > def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins > VR128:$src), > "movq\t{$src, $dst|$dst, $src}", > - [(set VR128:$dst, (v2i64 (vector_shuffle > immAllZerosV_bc, > - VR128:$src, > - MOVL_shuffle_mask)))]>, > + [(set VR128:$dst, (v2i64 (X86zvmovl (v2i64 > VR128:$src))))]>, > XS, Requires<[HasSSE2]>; > > let AddedComplexity = 20 in > def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins > i128mem:$src), > "movq\t{$src, $dst|$dst, $src}", > - [(set VR128:$dst, (v2i64 (vector_shuffle > immAllZerosV_bc, > - (memopv2i64 addr:$src), > - MOVL_shuffle_mask)))]>, > + [(set VR128:$dst, (v2i64 (X86zvmovl > + (memopv2i64 addr: > $src))))]>, > XS, Requires<[HasSSE2]>; > > // > = > = > = > ----------------------------------------------------------------------= > ==// > @@ -2774,11 +2758,9 @@ > // movd to XMM register zero-extends > let AddedComplexity = 15 in { > // Zeroing a VR128 then do a MOVS{S|D} to the lower bits. > -def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc, > - (v2f64 (scalar_to_vector FR64:$src)), > MOVL_shuffle_mask)), > +def : Pat<(v2f64 (X86zvmovl (v2f64 (scalar_to_vector FR64:$src)))), > (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>; > -def : Pat<(v4f32 (vector_shuffle immAllZerosV_bc, > - (v4f32 (scalar_to_vector FR32:$src)), > MOVL_shuffle_mask)), > +def : Pat<(v4f32 (X86zvmovl (v4f32 (scalar_to_vector FR32:$src)))), > (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE2]>; > } > > > Modified: llvm/trunk/test/CodeGen/X86/vec_set-5.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_set-5.ll?rev=50838&r1=50837&r2=50838&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/CodeGen/X86/vec_set-5.ll (original) > +++ llvm/trunk/test/CodeGen/X86/vec_set-5.ll Wed May 7 19:57:18 2008 > @@ -1,8 +1,7 @@ > ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -o %t -f > ; RUN: grep movlhps %t | count 1 > -; RUN: grep unpcklps %t | count 1 > -; RUN: grep punpckldq %t | count 1 > ; RUN: grep movq %t | count 1 > +; RUN: grep movsd %t | count 1 > > define <4 x float> @test1(float %a, float %b) nounwind { > %tmp = insertelement <4 x float> zeroinitializer, float %a, i32 > 0 ; <<4 x float>> [#uses=1] > > Modified: llvm/trunk/test/CodeGen/X86/vec_set-6.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_set-6.ll?rev=50838&r1=50837&r2=50838&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/CodeGen/X86/vec_set-6.ll (original) > +++ llvm/trunk/test/CodeGen/X86/vec_set-6.ll Wed May 7 19:57:18 2008 > @@ -1,5 +1,6 @@ > ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -o %t -f > -; RUN: grep unpcklps %t | count 1 > +; RUN: grep movss %t | count 1 > +; RUN: grep movups %t | count 1 > ; RUN: grep shufps %t | count 1 > > define <4 x float> @test(float %a, float %b, float %c) nounwind { > > Added: llvm/trunk/test/CodeGen/X86/vec_set-C.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_set-C.ll?rev=50838&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/CodeGen/X86/vec_set-C.ll (added) > +++ llvm/trunk/test/CodeGen/X86/vec_set-C.ll Wed May 7 19:57:18 2008 > @@ -0,0 +1,7 @@ > +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep movq > +; RUN: llvm-as < %s | llc -march=x86-64 -mattr=+sse2 | grep movd > + > +define <2 x i64> @t1(i64 %x) nounwind { > + %tmp8 = insertelement <2 x i64> zeroinitializer, i64 %x, i32 0 > + ret <2 x i64> %tmp8 > +} > > Added: llvm/trunk/test/CodeGen/X86/vec_set-D.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_set-D.ll?rev=50838&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/CodeGen/X86/vec_set-D.ll (added) > +++ llvm/trunk/test/CodeGen/X86/vec_set-D.ll Wed May 7 19:57:18 2008 > @@ -0,0 +1,7 @@ > +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep movq > + > +define <4 x i32> @t(i32 %x, i32 %y) nounwind { > + %tmp1 = insertelement <4 x i32> zeroinitializer, i32 %x, i32 0 > + %tmp2 = insertelement <4 x i32> %tmp1, i32 %y, i32 1 > + ret <4 x i32> %tmp2 > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Thu May 8 16:47:43 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 08 May 2008 21:47:43 -0000 Subject: [llvm-commits] [llvm] r50869 - /llvm/trunk/lib/VMCore/Instruction.cpp Message-ID: <200805082147.m48LlhTn011464@zion.cs.uiuc.edu> Author: lattner Date: Thu May 8 16:47:43 2008 New Revision: 50869 URL: http://llvm.org/viewvc/llvm-project?rev=50869&view=rev Log: store can't read from memory. Modified: llvm/trunk/lib/VMCore/Instruction.cpp Modified: llvm/trunk/lib/VMCore/Instruction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instruction.cpp?rev=50869&r1=50868&r2=50869&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instruction.cpp (original) +++ llvm/trunk/lib/VMCore/Instruction.cpp Thu May 8 16:47:43 2008 @@ -225,7 +225,6 @@ switch (getOpcode()) { default: return false; case Instruction::Free: - case Instruction::Store: case Instruction::VAArg: return true; case Instruction::Call: From tonic at nondot.org Thu May 8 16:54:20 2008 From: tonic at nondot.org (Tanya Lattner) Date: Thu, 08 May 2008 21:54:20 -0000 Subject: [llvm-commits] [llvm] r50871 - in /llvm/trunk: tools/llvmc2/Common.td utils/TableGen/LLVMCConfigurationEmitter.cpp Message-ID: <200805082154.m48LsLWo011693@zion.cs.uiuc.edu> Author: tbrethou Date: Thu May 8 16:54:20 2008 New Revision: 50871 URL: http://llvm.org/viewvc/llvm-project?rev=50871&view=rev Log: Revertin 50867 since it was breaking the build. Modified: llvm/trunk/tools/llvmc2/Common.td llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Modified: llvm/trunk/tools/llvmc2/Common.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Common.td?rev=50871&r1=50870&r2=50871&view=diff ============================================================================== --- llvm/trunk/tools/llvmc2/Common.td (original) +++ llvm/trunk/tools/llvmc2/Common.td Thu May 8 16:54:20 2008 @@ -15,7 +15,7 @@ list properties = l; } -// Special Tool instance - the root node of the compilation graph. +// Special Tool instance - graph root. def root : Tool<[]>; @@ -47,7 +47,6 @@ // Possible edge properties -// 'Atomic' properties. def switch_on; def parameter_equals; def element_in_list; Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=50871&r1=50870&r2=50871&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Thu May 8 16:54:20 2008 @@ -163,8 +163,8 @@ std::string Help; unsigned Flags; - // We need to provide a default constructor because - // StringMap can only store DefaultConstructible objects. + // We need t provide a default constructor since + // StringMap can only store DefaultConstructible objects GlobalOptionDescription() : OptionDescription(), Flags(0) {} @@ -222,9 +222,9 @@ }; -// Tool-local option description. +// Tool-local option description -// Properties without arguments are implemented as flags. +// Properties without arguments are implemented as flags namespace ToolOptionDescriptionFlags { enum ToolOptionDescriptionFlags { StopCompilation = 0x1, Forward = 0x2, UnpackValues = 0x4}; @@ -314,7 +314,7 @@ /// CollectProperties - Function object for iterating over a list of -/// tool property records. +/// tool property records class CollectProperties { private: @@ -569,8 +569,7 @@ /// CollectToolProperties - Gather information from the parsed -/// TableGen data (basically a wrapper for the CollectProperties -/// function object). +/// TableGen data (basically a wrapper for CollectProperties). void CollectToolProperties (RecordVector::const_iterator B, RecordVector::const_iterator E, ToolPropertiesList& TPList, @@ -590,50 +589,12 @@ } } -/// EmitForwardOptionPropertyHandlingCode - Helper function used to -/// implement EmitOptionPropertyHandlingCode(). Emits code for -/// handling the (forward) option property. -void EmitForwardOptionPropertyHandlingCode (const ToolOptionDescription& D, - std::ostream& O) { - switch (D.Type) { - case OptionType::Switch: - O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n"; - break; - case OptionType::Parameter: - O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n"; - O << Indent3 << "vec.push_back(" << D.GenVariableName() << ");\n"; - break; - case OptionType::Prefix: - O << Indent3 << "vec.push_back(\"-" << D.Name << "\" + " - << D.GenVariableName() << ");\n"; - break; - case OptionType::PrefixList: - O << Indent3 << "for (" << D.GenTypeDeclaration() - << "::iterator B = " << D.GenVariableName() << ".begin(),\n" - << Indent3 << "E = " << D.GenVariableName() << ".end(); B != E; ++B)\n" - << Indent4 << "vec.push_back(\"-" << D.Name << "\" + " - << "*B);\n"; - break; - case OptionType::ParameterList: - O << Indent3 << "for (" << D.GenTypeDeclaration() - << "::iterator B = " << D.GenVariableName() << ".begin(),\n" - << Indent3 << "E = " << D.GenVariableName() - << ".end() ; B != E; ++B) {\n" - << Indent4 << "vec.push_back(\"-" << D.Name << "\");\n" - << Indent4 << "vec.push_back(*B);\n" - << Indent3 << "}\n"; - break; - } -} - -/// EmitOptionPropertyHandlingCode - Helper function used by -/// EmitGenerateActionMethod(). Emits code that handles option -/// properties. +/// EmitOptionPropertyHandlingCode - Used by EmitGenerateActionMethod. void EmitOptionPropertyHandlingCode (const ToolProperties& P, const ToolOptionDescription& D, std::ostream& O) { - // Start of the if-clause. + // if clause O << Indent2 << "if ("; if (D.Type == OptionType::Switch) O << D.GenVariableName(); @@ -642,7 +603,7 @@ O <<") {\n"; - // Handle option properties that take an argument. + // Handle option properties that take an argument for (OptionPropertyList::const_iterator B = D.Props.begin(), E = D.Props.end(); B!=E; ++B) { const OptionProperty& val = *B; @@ -661,8 +622,37 @@ // Handle flags // (forward) property - if (D.isForward()) - HandleForwardPropertyy(O); + if (D.isForward()) { + switch (D.Type) { + case OptionType::Switch: + O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n"; + break; + case OptionType::Parameter: + O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n"; + O << Indent3 << "vec.push_back(" << D.GenVariableName() << ");\n"; + break; + case OptionType::Prefix: + O << Indent3 << "vec.push_back(\"-" << D.Name << "\" + " + << D.GenVariableName() << ");\n"; + break; + case OptionType::PrefixList: + O << Indent3 << "for (" << D.GenTypeDeclaration() + << "::iterator B = " << D.GenVariableName() << ".begin(),\n" + << Indent3 << "E = " << D.GenVariableName() << ".end(); B != E; ++B)\n" + << Indent4 << "vec.push_back(\"-" << D.Name << "\" + " + << "*B);\n"; + break; + case OptionType::ParameterList: + O << Indent3 << "for (" << D.GenTypeDeclaration() + << "::iterator B = " << D.GenVariableName() << ".begin(),\n" + << Indent3 << "E = " << D.GenVariableName() + << ".end() ; B != E; ++B) {\n" + << Indent4 << "vec.push_back(\"-" << D.Name << "\");\n" + << Indent4 << "vec.push_back(*B);\n" + << Indent3 << "}\n"; + break; + } + } // (unpack_values) property if (D.isUnpackValues()) { @@ -683,15 +673,16 @@ } } - // End of the if-clause. + // close if clause O << Indent2 << "}\n"; } -// EmitGenerateActionMethod - Emit one of two versions of the -// Tool::GenerateAction() method. -void EmitGenerateActionMethod (const ToolProperties& P, bool V, std::ostream& O) +// EmitGenerateActionMethod - Emit one of two versions of +// GenerateAction method. +void EmitGenerateActionMethod (const ToolProperties& P, int V, std::ostream& O) { - if (V) + assert(V==1 || V==2); + if (V==1) O << Indent1 << "Action GenerateAction(const PathVector& inFiles,\n"; else O << Indent1 << "Action GenerateAction(const sys::Path& inFile,\n"; @@ -710,7 +701,7 @@ const std::string& cmd = *I; O << Indent2; if (cmd == "$INFILE") { - if (V) + if (V==1) O << "for (PathVector::const_iterator B = inFiles.begin()" << ", E = inFiles.end();\n" << Indent2 << "B != E; ++B)\n" @@ -726,14 +717,14 @@ } } - // For every understood option, emit handling code. + // For every understood option, emit handling code for (ToolOptionDescriptions::const_iterator B = P.OptDescs.begin(), E = P.OptDescs.end(); B != E; ++B) { const ToolOptionDescription& val = B->second; EmitOptionPropertyHandlingCode(P, val, O); } - // Handle the Sink property. + // Handle Sink property if (P.isSink()) { O << Indent2 << "if (!" << SinkOptionName << ".empty()) {\n" << Indent3 << "vec.insert(vec.end(), " @@ -745,8 +736,8 @@ << Indent1 << "}\n\n"; } -/// EmitGenerateActionMethods - Emit two GenerateAction() methods for -/// a given Tool class. +/// EmitGenerateActionMethods - Emit two GenerateAction methods for a given +/// Tool class. void EmitGenerateActionMethods (const ToolProperties& P, std::ostream& O) { if (!P.isJoin()) @@ -762,8 +753,7 @@ EmitGenerateActionMethod(P, 2, O); } -/// EmitIsLastMethod - Emit the IsLast() method for a given Tool -/// class. +/// EmitIsLastMethod - Emit IsLast() method for a given Tool class void EmitIsLastMethod (const ToolProperties& P, std::ostream& O) { O << Indent1 << "bool IsLast() const {\n" << Indent2 << "bool last = false;\n"; From gohman at apple.com Thu May 8 16:54:31 2008 From: gohman at apple.com (Dan Gohman) Date: Thu, 8 May 2008 14:54:31 -0700 Subject: [llvm-commits] [llvm] r50869 - /llvm/trunk/lib/VMCore/Instruction.cpp In-Reply-To: <200805082147.m48LlhTn011464@zion.cs.uiuc.edu> References: <200805082147.m48LlhTn011464@zion.cs.uiuc.edu> Message-ID: Hi Chris, Should mayReadFromMemory consider that a volatile store reads memory, similar to how mayWriteToMemory considers that a volatile load may write to memory? Dan On May 8, 2008, at 2:47 PM, Chris Lattner wrote: > Author: lattner > Date: Thu May 8 16:47:43 2008 > New Revision: 50869 > > URL: http://llvm.org/viewvc/llvm-project?rev=50869&view=rev > Log: > store can't read from memory. > > Modified: > llvm/trunk/lib/VMCore/Instruction.cpp > > Modified: llvm/trunk/lib/VMCore/Instruction.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instruction.cpp?rev=50869&r1=50868&r2=50869&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/VMCore/Instruction.cpp (original) > +++ llvm/trunk/lib/VMCore/Instruction.cpp Thu May 8 16:47:43 2008 > @@ -225,7 +225,6 @@ > switch (getOpcode()) { > default: return false; > case Instruction::Free: > - case Instruction::Store: > case Instruction::VAArg: > return true; > case Instruction::Call: > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Thu May 8 16:57:55 2008 From: clattner at apple.com (Chris Lattner) Date: Thu, 8 May 2008 14:57:55 -0700 Subject: [llvm-commits] [llvm] r50869 - /llvm/trunk/lib/VMCore/Instruction.cpp In-Reply-To: References: <200805082147.m48LlhTn011464@zion.cs.uiuc.edu> Message-ID: <5DE23645-5349-47D4-83A5-31DB7626DE15@apple.com> On May 8, 2008, at 2:54 PM, Dan Gohman wrote: > Hi Chris, > Should mayReadFromMemory consider that a volatile store > reads memory, similar to how mayWriteToMemory considers > that a volatile load may write to memory? Sure, that is conservatively correct. I'll take care of it. -Chris From sabre at nondot.org Thu May 8 16:58:50 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 08 May 2008 21:58:50 -0000 Subject: [llvm-commits] [llvm] r50872 - /llvm/trunk/lib/VMCore/Instruction.cpp Message-ID: <200805082158.m48LwoAO011830@zion.cs.uiuc.edu> Author: lattner Date: Thu May 8 16:58:49 2008 New Revision: 50872 URL: http://llvm.org/viewvc/llvm-project?rev=50872&view=rev Log: conservatively say that volatile stores read memory. Modified: llvm/trunk/lib/VMCore/Instruction.cpp Modified: llvm/trunk/lib/VMCore/Instruction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instruction.cpp?rev=50872&r1=50871&r2=50872&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instruction.cpp (original) +++ llvm/trunk/lib/VMCore/Instruction.cpp Thu May 8 16:58:49 2008 @@ -226,13 +226,14 @@ default: return false; case Instruction::Free: case Instruction::VAArg: + case Instruction::Load: return true; case Instruction::Call: return !cast(this)->doesNotAccessMemory(); case Instruction::Invoke: return !cast(this)->doesNotAccessMemory(); - case Instruction::Load: - return true; + case Instruction::Store: + return cast(this)->isVolatile(); } } From clattner at apple.com Thu May 8 16:59:59 2008 From: clattner at apple.com (Chris Lattner) Date: Thu, 8 May 2008 14:59:59 -0700 Subject: [llvm-commits] LibCallAliasAnalysis should be in anonymous namespace In-Reply-To: <48236B1A.3030309@gmail.com> References: <48236B1A.3030309@gmail.com> Message-ID: <9373CAF7-F540-4347-BD6C-3B45E13FB04A@apple.com> On May 8, 2008, at 2:05 PM, T?r?k Edwin wrote: > Hi, > > I got a linker failure because of multiple definition of llvm::X in > LibCallAliasAnalysis. > The second definition was in a pass I am writing, and I haven't > noticed > I have the same bug until now. > I think the namespace should be anonymous, like for other analysis. Sounds good to me, go for it. Thanks! -Chris > > > Ok to commit? > > Index: lib/Analysis/LibCallAliasAnalysis.cpp > =================================================================== > --- lib/Analysis/LibCallAliasAnalysis.cpp (revision 50866) > +++ lib/Analysis/LibCallAliasAnalysis.cpp (working copy) > @@ -18,7 +18,7 @@ > #include "llvm/Target/TargetData.h" > using namespace llvm; > > -namespace llvm { > +namespace { > /// LibCallAliasAnalysis - Alias analysis driven from LibCallInfo. > struct LibCallAliasAnalysis : public FunctionPass, AliasAnalysis { > static char ID; // Class identification > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From lattner at apple.com Thu May 8 16:58:30 2008 From: lattner at apple.com (Tanya Lattner) Date: Thu, 8 May 2008 14:58:30 -0700 Subject: [llvm-commits] [llvm] r50867 - in /llvm/trunk: tools/llvmc2/Common.td utils/TableGen/LLVMCConfigurationEmitter.cpp In-Reply-To: <482364B8.8070503@gmail.com> References: <200805082002.m48K24tT006657@zion.cs.uiuc.edu> <482364B8.8070503@gmail.com> Message-ID: This has been reverted. -Tanya On May 8, 2008, at 1:38 PM, T?r?k Edwin wrote: > Mikhail Glushenkov wrote: >> Author: foldr >> Date: Thu May 8 15:02:03 2008 >> New Revision: 50867 >> >> + if (D.isForward()) >> + HandleForwardPropertyy(O); > > Where is HandleForwardPropertyy? > > My build fails: > > llvm[2]: Compiling LLVMCConfigurationEmitter.cpp for Debug build > LLVMCConfigurationEmitter.cpp: In function > ?void::EmitOptionPropertyHandlingCode > (const::ToolProperties&, > const::ToolOptionDescription&, std::ostream&)?: > LLVMCConfigurationEmitter.cpp:665: error: ?HandleForwardProperty? was > not declared in this scope > make[2]: *** > [/home/edwin/llvm-svn/llvm/utils/TableGen/Debug/ > LLVMCConfigurationEmitter.o] > Error 1 > make[2]: Leaving directory `/home/edwin/llvm-svn/llvm/utils/TableGen' > > > --Edwin > > > _______________________________________________ > 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 Thu May 8 17:35:02 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 08 May 2008 22:35:02 -0000 Subject: [llvm-commits] [llvm] r50874 - in /llvm/trunk: lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/vec_set-E.ll Message-ID: <200805082235.m48MZ2II012969@zion.cs.uiuc.edu> Author: evancheng Date: Thu May 8 17:35:02 2008 New Revision: 50874 URL: http://llvm.org/viewvc/llvm-project?rev=50874&view=rev Log: Use movq to move low half of XMM register and zero-extend the rest. Added: llvm/trunk/test/CodeGen/X86/vec_set-E.ll Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=50874&r1=50873&r2=50874&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Thu May 8 17:35:02 2008 @@ -2916,7 +2916,8 @@ def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc, VR128:$src, MOVL_shuffle_mask)), (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>; - +def : Pat<(v2f64 (X86zvmovl (v2f64 VR128:$src))), + (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>; // FIXME: Temporary workaround since 2-wide shuffle is broken. def : Pat<(int_x86_sse2_movs_d VR128:$src1, VR128:$src2), Added: llvm/trunk/test/CodeGen/X86/vec_set-E.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_set-E.ll?rev=50874&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_set-E.ll (added) +++ llvm/trunk/test/CodeGen/X86/vec_set-E.ll Thu May 8 17:35:02 2008 @@ -0,0 +1,10 @@ +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep movq + +define i32 @t(float %X) nounwind { + %tmp11 = insertelement <4 x float> undef, float %X, i32 0 + %tmp12 = insertelement <4 x float> %tmp11, float %X, i32 1 + %tmp27 = insertelement <4 x float> %tmp12, float 0.000000e+00, i32 2 + %tmp28 = insertelement <4 x float> %tmp27, float 0.000000e+00, i32 3 + store <4 x float> %tmp28, <4 x float>* null, align 16 + ret i32 0 +} From evan.cheng at apple.com Thu May 8 17:35:18 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 8 May 2008 15:35:18 -0700 Subject: [llvm-commits] [llvm] r50838 - in /llvm/trunk: lib/Target/X86/X86ISelDAGToDAG.cpp lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h lib/Target/X86/X86InstrMMX.td lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/vec_set-5.ll test/CodeGen/X86/vec_set-6.ll test/CodeGen/X86/vec_set-C.ll test/CodeGen/X86/vec_set-D.ll In-Reply-To: <1E30D774-ABD3-4892-977A-A39060506179@apple.com> References: <200805080057.m480vJW2019730@zion.cs.uiuc.edu> <1E30D774-ABD3-4892-977A-A39060506179@apple.com> Message-ID: <1184CCA1-EB1F-4A2C-B130-7995F41F17AA@apple.com> Fixed. Evan On May 8, 2008, at 2:45 PM, Dan Gohman wrote: > Hi Evan, > > This is causing regressions on x86 in > UnitTests/Vector/build > UnitTests/Vector/simple > . > > llc is aborting with this message: > > $ llc -f Output/build.llvm.bc -o Output/build.llc.s > Cannot yet select: 0x14081f0: v2f64 = X86ISD::ZEXT_VMOVL 0x1407fd0 > > Can you investigate? > > Thanks, > > Dan > > On May 7, 2008, at 5:57 PM, Evan Cheng wrote: > >> Author: evancheng >> Date: Wed May 7 19:57:18 2008 >> New Revision: 50838 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=50838&view=rev >> Log: >> Handle vector move / load which zero the destination register top >> bits (i.e. movd, movq, movss (addr), movsd (addr)) with X86 specific >> dag combine. >> >> Added: >> llvm/trunk/test/CodeGen/X86/vec_set-C.ll >> llvm/trunk/test/CodeGen/X86/vec_set-D.ll >> Modified: >> llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp >> llvm/trunk/lib/Target/X86/X86ISelLowering.cpp >> llvm/trunk/lib/Target/X86/X86ISelLowering.h >> llvm/trunk/lib/Target/X86/X86InstrMMX.td >> llvm/trunk/lib/Target/X86/X86InstrSSE.td >> llvm/trunk/test/CodeGen/X86/vec_set-5.ll >> llvm/trunk/test/CodeGen/X86/vec_set-6.ll >> >> Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=50838&r1=50837&r2=50838&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) >> +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Wed May 7 >> 19:57:18 2008 >> @@ -975,38 +975,19 @@ >> >> // Also handle the case where we explicitly require zeros in the top >> // elements. This is a vector shuffle from the zero vector. >> - if (N.getOpcode() == ISD::VECTOR_SHUFFLE && N.Val->hasOneUse() && >> + if (N.getOpcode() == X86ISD::ZEXT_VMOVL && N.Val->hasOneUse() && >> // Check to see if the top elements are all zeros (or bitcast >> of zeros). >> - ISD::isBuildVectorAllZeros(N.getOperand(0).Val) && >> - N.getOperand(1).getOpcode() == ISD::SCALAR_TO_VECTOR && >> - N.getOperand(1).Val->hasOneUse() && >> - ISD::isNON_EXTLoad(N.getOperand(1).getOperand(0).Val) && >> - N.getOperand(1).getOperand(0).hasOneUse()) { >> - // Check to see if the shuffle mask is 4/L/L/L or 2/L, where L >> is something >> - // from the LHS. >> - unsigned >> VecWidth=MVT::getVectorNumElements(N.getOperand(0).getValueType()); >> - SDOperand ShufMask = N.getOperand(2); >> - assert(ShufMask.getOpcode() == ISD::BUILD_VECTOR && "Invalid >> shuf mask!"); >> - if (ConstantSDNode *C = >> dyn_cast(ShufMask.getOperand(0))) { >> - if (C->getValue() == VecWidth) { >> - for (unsigned i = 1; i != VecWidth; ++i) { >> - if (ShufMask.getOperand(i).getOpcode() == ISD::UNDEF) { >> - // ok. >> - } else { >> - ConstantSDNode *C = >> cast(ShufMask.getOperand(i)); >> - if (C->getValue() >= VecWidth) return false; >> - } >> - } >> - } >> - >> - // Okay, this is a zero extending load. Fold it. >> - LoadSDNode *LD = >> cast(N.getOperand(1).getOperand(0)); >> - if (!SelectAddr(Op, LD->getBasePtr(), Base, Scale, Index, >> Disp)) >> - return false; >> - OutChain = LD->getChain(); >> - InChain = SDOperand(LD, 1); >> - return true; >> - } >> + N.getOperand(0).getOpcode() == ISD::SCALAR_TO_VECTOR && >> + N.getOperand(0).Val->hasOneUse() && >> + ISD::isNON_EXTLoad(N.getOperand(0).getOperand(0).Val) && >> + N.getOperand(0).getOperand(0).hasOneUse()) { >> + // Okay, this is a zero extending load. Fold it. >> + LoadSDNode *LD = >> cast(N.getOperand(0).getOperand(0)); >> + if (!SelectAddr(Op, LD->getBasePtr(), Base, Scale, Index, Disp)) >> + return false; >> + OutChain = LD->getChain(); >> + InChain = SDOperand(LD, 1); >> + return true; >> } >> return false; >> } >> >> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=50838&r1=50837&r2=50838&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) >> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed May 7 >> 19:57:18 2008 >> @@ -2605,11 +2605,16 @@ >> } >> >> /// isScalarLoadToVector - Returns true if the node is a scalar load >> that >> -/// is promoted to a vector. >> -static inline bool isScalarLoadToVector(SDNode *N) { >> +/// is promoted to a vector. It also returns the LoadSDNode by >> reference if >> +/// required. >> +static bool isScalarLoadToVector(SDNode *N, LoadSDNode **LD = >> NULL) { >> if (N->getOpcode() == ISD::SCALAR_TO_VECTOR) { >> N = N->getOperand(0).Val; >> - return ISD::isNON_EXTLoad(N); >> + if (ISD::isNON_EXTLoad(N)) { >> + if (LD) >> + *LD = cast(N); >> + return true; >> + } >> } >> return false; >> } >> @@ -3082,8 +3087,16 @@ >> return SDOperand(); >> >> // Let legalizer expand 2-wide build_vectors. >> - if (EVTBits == 64) >> + if (EVTBits == 64) { >> + if (NumNonZero == 1) { >> + // One half is zero or undef. >> + unsigned Idx = CountTrailingZeros_32(NonZeros); >> + SDOperand V2 = DAG.getNode(ISD::SCALAR_TO_VECTOR, VT, >> + Op.getOperand(Idx)); >> + return getShuffleVectorZeroOrUndef(V2, Idx, true, DAG); >> + } >> return SDOperand(); >> + } >> >> // If element VT is < 32 bits, convert it to inserts into a zero >> vector. >> if (EVTBits == 8 && NumElems == 16) { >> @@ -3131,13 +3144,6 @@ >> } >> } >> >> - // Take advantage of the fact GR32 to VR128 scalar_to_vector >> (i.e. movd) >> - // clears the upper bits. >> - // FIXME: we can do the same for v4f32 case when we know both >> parts of >> - // the lower half come from scalar_to_vector (loadf32). We >> should do >> - // that in post legalizer dag combiner with target specific >> hooks. >> - if (MVT::isInteger(EVT) && (NonZeros & (0x3 << 2)) == 0) >> - return V[0]; >> MVT::ValueType MaskVT = >> MVT::getIntVectorWithNumElements(NumElems); >> MVT::ValueType EVT = MVT::getVectorElementType(MaskVT); >> SmallVector MaskVec; >> @@ -3475,6 +3481,38 @@ >> &MaskVec[0], MaskVec.size())); >> } >> >> +/// getZextVMoveL - Return a zero-extending vector move low node. >> +/// >> +static SDOperand getZextVMoveL(MVT::ValueType VT, MVT::ValueType >> OpVT, >> + SDOperand SrcOp, SelectionDAG &DAG, >> + const X86Subtarget *Subtarget) { >> + if (VT == MVT::v2f64 || VT == MVT::v4f32) { >> + LoadSDNode *LD = NULL; >> + if (!isScalarLoadToVector(SrcOp.Val, &LD)) >> + LD = dyn_cast(SrcOp); >> + if (!LD) { >> + // movssrr and movsdrr do not clear top bits. Try to use >> movd, movq >> + // instead. >> + MVT::ValueType EVT = (OpVT == MVT::v2f64) ? MVT::i64 : >> MVT::i32; >> + if ((EVT != MVT::i64 || Subtarget->is64Bit()) && >> + SrcOp.getOpcode() == ISD::SCALAR_TO_VECTOR && >> + SrcOp.getOperand(0).getOpcode() == ISD::BIT_CONVERT && >> + SrcOp.getOperand(0).getOperand(0).getValueType() == EVT) { >> + // PR2108 >> + OpVT = (OpVT == MVT::v2f64) ? MVT::v2i64 : MVT::v4i32; >> + return DAG.getNode(ISD::BIT_CONVERT, VT, >> + DAG.getNode(X86ISD::ZEXT_VMOVL, OpVT, >> + >> DAG.getNode(ISD::SCALAR_TO_VECTOR, OpVT, >> + >> SrcOp.getOperand(0).getOperand(0)))); >> + } >> + } >> + } >> + >> + return DAG.getNode(ISD::BIT_CONVERT, VT, >> + DAG.getNode(X86ISD::ZEXT_VMOVL, OpVT, >> + DAG.getNode(ISD::BIT_CONVERT, >> OpVT, SrcOp))); >> +} >> + >> SDOperand >> X86TargetLowering::LowerVECTOR_SHUFFLE(SDOperand Op, SelectionDAG >> &DAG) { >> SDOperand V1 = Op.getOperand(0); >> @@ -3515,27 +3553,33 @@ >> // FIXME: Figure out a cleaner way to do this. >> // Try to make use of movq to zero out the top part. >> if (ISD::isBuildVectorAllZeros(V2.Val)) { >> - SDOperand NewOp = RewriteAsNarrowerShuffle(V1, V2, VT, >> PermMask, DAG, *this); >> + SDOperand NewOp = RewriteAsNarrowerShuffle(V1, V2, VT, >> PermMask, >> + DAG, *this); >> if (NewOp.Val) { >> SDOperand NewV1 = NewOp.getOperand(0); >> SDOperand NewV2 = NewOp.getOperand(1); >> SDOperand NewMask = NewOp.getOperand(2); >> if (isCommutedMOVL(NewMask.Val, true, false)) { >> NewOp = CommuteVectorShuffle(NewOp, NewV1, NewV2, NewMask, >> DAG); >> - NewOp = DAG.getNode(ISD::VECTOR_SHUFFLE, >> NewOp.getValueType(), >> - NewV1, NewV2, getMOVLMask(2, DAG)); >> - return DAG.getNode(ISD::BIT_CONVERT, VT, >> LowerVECTOR_SHUFFLE(NewOp, DAG)); >> + return getZextVMoveL(VT, NewOp.getValueType(), NewV2, >> DAG, Subtarget); >> } >> } >> } else if (ISD::isBuildVectorAllZeros(V1.Val)) { >> - SDOperand NewOp= RewriteAsNarrowerShuffle(V1, V2, VT, >> PermMask, DAG, *this); >> + SDOperand NewOp= RewriteAsNarrowerShuffle(V1, V2, VT, >> PermMask, >> + DAG, *this); >> if (NewOp.Val && X86::isMOVLMask(NewOp.getOperand(2).Val)) >> - return DAG.getNode(ISD::BIT_CONVERT, VT, >> LowerVECTOR_SHUFFLE(NewOp, DAG)); >> + return getZextVMoveL(VT, NewOp.getValueType(), >> NewOp.getOperand(1), >> + DAG, Subtarget); >> } >> } >> >> - if (X86::isMOVLMask(PermMask.Val)) >> - return (V1IsUndef) ? V2 : Op; >> + if (X86::isMOVLMask(PermMask.Val)) { >> + if (V1IsUndef) >> + return V2; >> + if (ISD::isBuildVectorAllZeros(V1.Val)) >> + return getZextVMoveL(VT, VT, V2, DAG, Subtarget); >> + return Op; >> + } >> >> if (X86::isMOVSHDUPMask(PermMask.Val) || >> X86::isMOVSLDUPMask(PermMask.Val) || >> @@ -5629,8 +5673,9 @@ >> case X86ISD::EH_RETURN: return "X86ISD::EH_RETURN"; >> case X86ISD::TC_RETURN: return "X86ISD::TC_RETURN"; >> case X86ISD::FNSTCW16m: return "X86ISD::FNSTCW16m"; >> - case X86ISD::LCMPXCHG_DAG: return "x86ISD::LCMPXCHG_DAG"; >> - case X86ISD::LCMPXCHG8_DAG: return "x86ISD::LCMPXCHG8_DAG"; >> + case X86ISD::LCMPXCHG_DAG: return "X86ISD::LCMPXCHG_DAG"; >> + case X86ISD::LCMPXCHG8_DAG: return "X86ISD::LCMPXCHG8_DAG"; >> + case X86ISD::ZEXT_VMOVL: return "X86ISD::ZEXT_VMOVL"; >> } >> } >> >> @@ -6192,16 +6237,46 @@ >> return false; >> } >> >> -static bool isBaseAlignment16(SDNode *Base, MachineFrameInfo *MFI, >> - const X86Subtarget *Subtarget) { >> +static bool isBaseAlignmentOfN(unsigned N, SDNode *Base, >> MachineFrameInfo *MFI, >> + const X86Subtarget *Subtarget) { >> GlobalValue *GV; >> int64_t Offset = 0; >> if (isGAPlusOffset(Base, GV, Offset)) >> - return (GV->getAlignment() >= 16 && (Offset % 16) == 0); >> + return (GV->getAlignment() >= N && (Offset % N) == 0); >> // DAG combine handles the stack object case. >> return false; >> } >> >> +static bool EltsFromConsecutiveLoads(SDNode *N, SDOperand PermMask, >> + unsigned NumElems, >> MVT::ValueType EVT, >> + MachineFrameInfo *MFI, >> + SelectionDAG &DAG, SDNode >> *&Base) { >> + Base = NULL; >> + for (unsigned i = 0; i < NumElems; ++i) { >> + SDOperand Idx = PermMask.getOperand(i); >> + if (Idx.getOpcode() == ISD::UNDEF) { >> + if (!Base) >> + return false; >> + continue; >> + } >> + >> + unsigned Index = cast(Idx)->getValue(); >> + SDOperand Elt = getShuffleScalarElt(N, Index, DAG); >> + if (!Elt.Val || >> + (Elt.getOpcode() != ISD::UNDEF && ! >> ISD::isNON_EXTLoad(Elt.Val))) >> + return false; >> + if (!Base) { >> + Base = Elt.Val; >> + continue; >> + } >> + if (Elt.getOpcode() == ISD::UNDEF) >> + continue; >> + >> + if (!isConsecutiveLoad(Elt.Val, Base, i, >> MVT::getSizeInBits(EVT)/8,MFI)) >> + return false; >> + } >> + return true; >> +} >> >> /// PerformShuffleCombine - Combine a vector_shuffle that is equal to >> /// build_vector load1, load2, load3, load4, <0, 1, 2, 3> into a 128- >> bit load >> @@ -6209,36 +6284,17 @@ >> /// order. >> static SDOperand PerformShuffleCombine(SDNode *N, SelectionDAG &DAG, >> const X86Subtarget >> *Subtarget) { >> - MachineFunction &MF = DAG.getMachineFunction(); >> - MachineFrameInfo *MFI = MF.getFrameInfo(); >> + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); >> MVT::ValueType VT = N->getValueType(0); >> MVT::ValueType EVT = MVT::getVectorElementType(VT); >> SDOperand PermMask = N->getOperand(2); >> unsigned NumElems = PermMask.getNumOperands(); >> SDNode *Base = NULL; >> - for (unsigned i = 0; i < NumElems; ++i) { >> - SDOperand Elt = PermMask.getOperand(i); >> - if (Elt.getOpcode() == ISD::UNDEF) { >> - if (!Base) >> - return SDOperand(); >> - continue; >> - } >> - >> - unsigned Idx = cast(Elt)->getValue(); >> - SDOperand Arg = getShuffleScalarElt(N, Idx, DAG); >> - if (!Arg.Val || !ISD::isNON_EXTLoad(Arg.Val)) >> - return SDOperand(); >> - if (!Base) { >> - Base = Arg.Val; >> - continue; >> - } >> - >> - if (!isConsecutiveLoad(Arg.Val, Base, i, >> MVT::getSizeInBits(EVT)/8,MFI)) >> - return SDOperand(); >> - } >> + if (!EltsFromConsecutiveLoads(N, PermMask, NumElems, EVT, MFI, >> DAG, Base)) >> + return SDOperand(); >> >> LoadSDNode *LD = cast(Base); >> - if (isBaseAlignment16(Base->getOperand(1).Val, MFI, Subtarget)) >> + if (isBaseAlignmentOfN(16, Base->getOperand(1).Val, MFI, >> Subtarget)) >> return DAG.getLoad(VT, LD->getChain(), LD->getBasePtr(), LD- >>> getSrcValue(), >> LD->getSrcValueOffset(), LD->isVolatile()); >> return DAG.getLoad(VT, LD->getChain(), LD->getBasePtr(), LD- >>> getSrcValue(), >> @@ -6319,12 +6375,13 @@ >> } >> >> /// PerformSTORECombine - Do target-specific dag combines on STORE >> nodes. >> -static SDOperand PerformSTORECombine(StoreSDNode *St, SelectionDAG >> &DAG, >> +static SDOperand PerformSTORECombine(SDNode *N, SelectionDAG &DAG, >> const X86Subtarget *Subtarget) { >> // Turn load->store of MMX types into GPR load/stores. This >> avoids clobbering >> // the FP state in cases where an emms may be missing. >> // A preferable solution to the general problem is to figure out >> the right >> // places to insert EMMS. This qualifies as a quick hack. >> + StoreSDNode *St = cast(N); >> if (MVT::isVector(St->getValue().getValueType()) && >> MVT::getSizeInBits(St->getValue().getValueType()) == 64 && >> isa(St->getValue()) && >> @@ -6442,8 +6499,7 @@ >> default: break; >> case ISD::VECTOR_SHUFFLE: return PerformShuffleCombine(N, DAG, >> Subtarget); >> case ISD::SELECT: return PerformSELECTCombine(N, DAG, >> Subtarget); >> - case ISD::STORE: >> - return PerformSTORECombine(cast(N), DAG, >> Subtarget); >> + case ISD::STORE: return PerformSTORECombine(N, DAG, >> Subtarget); >> case X86ISD::FXOR: >> case X86ISD::FOR: return PerformFORCombine(N, DAG); >> case X86ISD::FAND: return PerformFANDCombine(N, DAG); >> >> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=50838&r1=50837&r2=50838&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) >> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Wed May 7 19:57:18 >> 2008 >> @@ -181,10 +181,10 @@ >> /// in order to obtain suitable precision. >> FRSQRT, FRCP, >> >> - // Thread Local Storage >> + // TLSADDR, THREAThread - Thread Local Storage. >> TLSADDR, THREAD_POINTER, >> >> - // Exception Handling helpers >> + // EH_RETURN - Exception Handling helpers. >> EH_RETURN, >> >> /// TC_RETURN - Tail call return. >> @@ -194,12 +194,15 @@ >> /// operand #3 optional in flag >> TC_RETURN, >> >> - // compare and swap >> + // LCMPXCHG_DAG, LCMPXCHG8_DAG - Compare and swap. >> LCMPXCHG_DAG, >> LCMPXCHG8_DAG, >> >> - // Store FP control world into i16 memory >> - FNSTCW16m >> + // FNSTCW16m - Store FP control world into i16 memory. >> + FNSTCW16m, >> + >> + // ZEXT_VMOVL - Vector move low and zero extend. >> + ZEXT_VMOVL >> }; >> } >> >> >> Modified: llvm/trunk/lib/Target/X86/X86InstrMMX.td >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrMMX.td?rev=50838&r1=50837&r2=50838&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/X86/X86InstrMMX.td (original) >> +++ llvm/trunk/lib/Target/X86/X86InstrMMX.td Wed May 7 19:57:18 2008 >> @@ -200,18 +200,14 @@ >> // movd to MMX register zero-extends >> def MMX_MOVZDI2PDIrr : MMXI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins >> GR32:$src), >> "movd\t{$src, $dst|$dst, $src}", >> - [(set VR64:$dst, >> - (v2i32 (vector_shuffle immAllZerosV, >> - (v2i32 (scalar_to_vector >> GR32:$src)), >> - MMX_MOVL_shuffle_mask)))]>; >> + [(set VR64:$dst, >> + (v2i32 (X86zvmovl (v2i32 (scalar_to_vector >> GR32:$src)))))]>; >> let AddedComplexity = 20 in >> def MMX_MOVZDI2PDIrm : MMXI<0x6E, MRMSrcMem, (outs VR64:$dst), (ins >> i32mem:$src), >> "movd\t{$src, $dst|$dst, $src}", >> - [(set VR64:$dst, >> - (v2i32 (vector_shuffle immAllZerosV, >> - (v2i32 (scalar_to_vector >> - (loadi32 addr: >> $src))), >> - MMX_MOVL_shuffle_mask)))]>; >> + [(set VR64:$dst, >> + (v2i32 (X86zvmovl (v2i32 >> + (scalar_to_vector (loadi32 addr: >> $src))))))]>; >> >> // Arithmetic Instructions >> >> @@ -564,14 +560,10 @@ >> // Move scalar to XMM zero-extended >> // movd to XMM register zero-extends >> let AddedComplexity = 15 in { >> - def : Pat<(v8i8 (vector_shuffle immAllZerosV_bc, >> - (bc_v8i8 (v2i32 (scalar_to_vector GR32:$src))), >> - MMX_MOVL_shuffle_mask)), >> - (MMX_MOVZDI2PDIrr GR32:$src)>; >> - def : Pat<(v4i16 (vector_shuffle immAllZerosV_bc, >> - (bc_v4i16 (v2i32 (scalar_to_vector GR32:$src))), >> - MMX_MOVL_shuffle_mask)), >> - (MMX_MOVZDI2PDIrr GR32:$src)>; >> + def : Pat<(v8i8 (X86zvmovl (bc_v8i8 (v2i32 (scalar_to_vector >> GR32:$src))))), >> + (MMX_MOVZDI2PDIrr GR32:$src)>; >> + def : Pat<(v4i16 (X86zvmovl (bc_v8i8 (v2i32 (scalar_to_vector >> GR32:$src))))), >> + (MMX_MOVZDI2PDIrr GR32:$src)>; >> } >> >> // Scalar to v4i16 / v8i8. The source may be a GR32, but only the >> lower >> >> Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=50838&r1=50837&r2=50838&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) >> +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Wed May 7 19:57:18 2008 >> @@ -47,6 +47,7 @@ >> def X86insrtps : SDNode<"X86ISD::INSERTPS", >> SDTypeProfile<1, 3, [SDTCisVT<0, v4f32>, >> SDTCisSameAs<0,1>, >> SDTCisVT<2, f32>, >> SDTCisPtrTy<3>]>>; >> +def X86zvmovl : SDNode<"X86ISD::ZEXT_VMOVL", SDTUnaryOp>; >> >> // >> = >> = >> = >> ----------------------------------------------------------------------= >> ==// >> // SSE Complex Patterns >> @@ -1007,10 +1008,11 @@ >> let AddedComplexity = 20 in >> def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins >> f32mem:$src), >> "movss\t{$src, $dst|$dst, $src}", >> - [(set VR128:$dst, (v4f32 (vector_shuffle >> immAllZerosV_bc, >> - (v4f32 (scalar_to_vector (loadf32 >> addr:$src))), >> - >> MOVL_shuffle_mask)))]>; >> + [(set VR128:$dst, (v4f32 (X86zvmovl (v4f32 >> (scalar_to_vector >> + (loadf32 addr: >> $src))))))]>; >> >> +def : Pat<(v4f32 (X86zvmovl (memopv4f32 addr:$src))), >> + (MOVZSS2PSrm addr:$src)>; >> >> // >> = >> = >> = >> ----------------------------------------------------------------------= >> ==// >> // SSE2 Instructions >> @@ -2264,51 +2266,36 @@ >> def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins >> f64mem:$src), >> "movsd\t{$src, $dst|$dst, $src}", >> [(set VR128:$dst, >> - (v2f64 (vector_shuffle immAllZerosV_bc, >> - (v2f64 (scalar_to_vector >> - (loadf64 addr:$src))), >> - MOVL_shuffle_mask)))]>; >> + (v2f64 (X86zvmovl (v2f64 (scalar_to_vector >> + (loadf64 addr: >> $src))))))]>; >> + >> +def : Pat<(v2f64 (X86zvmovl (memopv2f64 addr:$src))), >> + (MOVZSD2PDrm addr:$src)>; >> >> // movd / movq to XMM register zero-extends >> let AddedComplexity = 15 in { >> def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins >> GR32:$src), >> "movd\t{$src, $dst|$dst, $src}", >> - [(set VR128:$dst, >> - (v4i32 (vector_shuffle immAllZerosV, >> - (v4i32 (scalar_to_vector >> GR32:$src)), >> - MOVL_shuffle_mask)))]>; >> + [(set VR128:$dst, (v4i32 (X86zvmovl >> + (v4i32 (scalar_to_vector >> GR32:$src)))))]>; >> // This is X86-64 only. >> def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins >> GR64:$src), >> "mov{d|q}\t{$src, $dst|$dst, $src}", >> - [(set VR128:$dst, >> - (v2i64 (vector_shuffle immAllZerosV_bc, >> - (v2i64 (scalar_to_vector >> GR64:$src)), >> - MOVL_shuffle_mask)))]>; >> + [(set VR128:$dst, (v2i64 (X86zvmovl >> + (v2i64 (scalar_to_vector >> GR64:$src)))))]>; >> } >> >> -// Handle the v2f64 form of 'MOVZQI2PQIrr' for PR2108. FIXME: this >> would be >> -// better written as a dag combine xform. >> -let AddedComplexity = 15 in >> -def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc, >> - (v2f64 (scalar_to_vector >> - (f64 (bitconvert >> GR64:$src)))), >> - MOVL_shuffle_mask)), >> - (MOVZQI2PQIrr GR64:$src)>, Requires<[HasSSE2]>; >> - >> - >> let AddedComplexity = 20 in { >> def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins >> i32mem:$src), >> "movd\t{$src, $dst|$dst, $src}", >> [(set VR128:$dst, >> - (v4i32 (vector_shuffle immAllZerosV, >> - (v4i32 (scalar_to_vector (loadi32 >> addr:$src))), >> - MOVL_shuffle_mask)))]>; >> + (v4i32 (X86zvmovl (v4i32 (scalar_to_vector >> + (loadi32 addr: >> $src))))))]>; >> def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem: >> $src), >> "movq\t{$src, $dst|$dst, $src}", >> [(set VR128:$dst, >> - (v2i64 (vector_shuffle immAllZerosV_bc, >> - (v2i64 (scalar_to_vector (loadi64 >> addr:$src))), >> - MOVL_shuffle_mask)))]>, XS, >> + (v2i64 (X86zvmovl (v2i64 (scalar_to_vector >> + (loadi64 addr: >> $src))))))]>, XS, >> Requires<[HasSSE2]>; >> } >> >> @@ -2317,17 +2304,14 @@ >> let AddedComplexity = 15 in >> def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins >> VR128:$src), >> "movq\t{$src, $dst|$dst, $src}", >> - [(set VR128:$dst, (v2i64 (vector_shuffle >> immAllZerosV_bc, >> - VR128:$src, >> - MOVL_shuffle_mask)))]>, >> + [(set VR128:$dst, (v2i64 (X86zvmovl (v2i64 >> VR128:$src))))]>, >> XS, Requires<[HasSSE2]>; >> >> let AddedComplexity = 20 in >> def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins >> i128mem:$src), >> "movq\t{$src, $dst|$dst, $src}", >> - [(set VR128:$dst, (v2i64 (vector_shuffle >> immAllZerosV_bc, >> - (memopv2i64 addr:$src), >> - MOVL_shuffle_mask)))]>, >> + [(set VR128:$dst, (v2i64 (X86zvmovl >> + (memopv2i64 addr: >> $src))))]>, >> XS, Requires<[HasSSE2]>; >> >> // >> = >> = >> = >> ----------------------------------------------------------------------= >> ==// >> @@ -2774,11 +2758,9 @@ >> // movd to XMM register zero-extends >> let AddedComplexity = 15 in { >> // Zeroing a VR128 then do a MOVS{S|D} to the lower bits. >> -def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc, >> - (v2f64 (scalar_to_vector FR64:$src)), >> MOVL_shuffle_mask)), >> +def : Pat<(v2f64 (X86zvmovl (v2f64 (scalar_to_vector FR64:$src)))), >> (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>; >> -def : Pat<(v4f32 (vector_shuffle immAllZerosV_bc, >> - (v4f32 (scalar_to_vector FR32:$src)), >> MOVL_shuffle_mask)), >> +def : Pat<(v4f32 (X86zvmovl (v4f32 (scalar_to_vector FR32:$src)))), >> (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE2]>; >> } >> >> >> Modified: llvm/trunk/test/CodeGen/X86/vec_set-5.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_set-5.ll?rev=50838&r1=50837&r2=50838&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/test/CodeGen/X86/vec_set-5.ll (original) >> +++ llvm/trunk/test/CodeGen/X86/vec_set-5.ll Wed May 7 19:57:18 2008 >> @@ -1,8 +1,7 @@ >> ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -o %t -f >> ; RUN: grep movlhps %t | count 1 >> -; RUN: grep unpcklps %t | count 1 >> -; RUN: grep punpckldq %t | count 1 >> ; RUN: grep movq %t | count 1 >> +; RUN: grep movsd %t | count 1 >> >> define <4 x float> @test1(float %a, float %b) nounwind { >> %tmp = insertelement <4 x float> zeroinitializer, float %a, i32 >> 0 ; <<4 x float>> [#uses=1] >> >> Modified: llvm/trunk/test/CodeGen/X86/vec_set-6.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_set-6.ll?rev=50838&r1=50837&r2=50838&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/test/CodeGen/X86/vec_set-6.ll (original) >> +++ llvm/trunk/test/CodeGen/X86/vec_set-6.ll Wed May 7 19:57:18 2008 >> @@ -1,5 +1,6 @@ >> ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -o %t -f >> -; RUN: grep unpcklps %t | count 1 >> +; RUN: grep movss %t | count 1 >> +; RUN: grep movups %t | count 1 >> ; RUN: grep shufps %t | count 1 >> >> define <4 x float> @test(float %a, float %b, float %c) nounwind { >> >> Added: llvm/trunk/test/CodeGen/X86/vec_set-C.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_set-C.ll?rev=50838&view=auto >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/test/CodeGen/X86/vec_set-C.ll (added) >> +++ llvm/trunk/test/CodeGen/X86/vec_set-C.ll Wed May 7 19:57:18 2008 >> @@ -0,0 +1,7 @@ >> +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep movq >> +; RUN: llvm-as < %s | llc -march=x86-64 -mattr=+sse2 | grep movd >> + >> +define <2 x i64> @t1(i64 %x) nounwind { >> + %tmp8 = insertelement <2 x i64> zeroinitializer, i64 %x, i32 0 >> + ret <2 x i64> %tmp8 >> +} >> >> Added: llvm/trunk/test/CodeGen/X86/vec_set-D.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_set-D.ll?rev=50838&view=auto >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/test/CodeGen/X86/vec_set-D.ll (added) >> +++ llvm/trunk/test/CodeGen/X86/vec_set-D.ll Wed May 7 19:57:18 2008 >> @@ -0,0 +1,7 @@ >> +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep movq >> + >> +define <4 x i32> @t(i32 %x, i32 %y) nounwind { >> + %tmp1 = insertelement <4 x i32> zeroinitializer, i32 %x, i32 0 >> + %tmp2 = insertelement <4 x i32> %tmp1, i32 %y, i32 1 >> + ret <4 x i32> %tmp2 >> +} >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dpatel at apple.com Thu May 8 17:46:28 2008 From: dpatel at apple.com (Devang Patel) Date: Thu, 08 May 2008 22:46:28 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50875 - in /llvm-gcc-4.2/trunk: build_gcc gcc/config.gcc Message-ID: <200805082246.m48MkTfO013347@zion.cs.uiuc.edu> Author: dpatel Date: Thu May 8 17:46:28 2008 New Revision: 50875 URL: http://llvm.org/viewvc/llvm-project?rev=50875&view=rev Log: Disable ppc64 multilib for now. Modified: llvm-gcc-4.2/trunk/build_gcc llvm-gcc-4.2/trunk/gcc/config.gcc Modified: llvm-gcc-4.2/trunk/build_gcc URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/build_gcc?rev=50875&r1=50874&r2=50875&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/build_gcc (original) +++ llvm-gcc-4.2/trunk/build_gcc Thu May 8 17:46:28 2008 @@ -397,9 +397,9 @@ .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/ || exit 1 if [ $h = 'powerpc' ] ; then cp -p $DIR/dst-$h-$t$DEST_ROOT/lib/ppc64/libgomp.a \ - .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/ppc64/ || exit 1 + .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/ppc64/ cp -p $DIR/dst-$h-$t$DEST_ROOT/lib/ppc64/libgomp.spec \ - .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/ppc64/ || exit 1 + .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/ppc64/ elif [ $h = 'i686' ] ; then cp -p $DIR/dst-$h-$t$DEST_ROOT/lib/x86_64/libgomp.a \ .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/x86_64/ || exit 1 Modified: llvm-gcc-4.2/trunk/gcc/config.gcc URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config.gcc?rev=50875&r1=50874&r2=50875&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config.gcc (original) +++ llvm-gcc-4.2/trunk/gcc/config.gcc Thu May 8 17:46:28 2008 @@ -1765,7 +1765,12 @@ # APPLE LOCAL mainline candidate 2006-06-22 4512244 extra_parts="${extra_parts} crt2.o" case ${target} in - *-darwin1[0-9]* | *-darwin[8-9]*) + # LLVM LOCAL begin + *-darwin1[0-9]*) + tm_file="${tm_file} rs6000/darwin8.h" + ;; + *-darwin[8-9]*) + # LLVM LOCAL end tmake_file="${tmake_file} rs6000/t-darwin8" tm_file="${tm_file} rs6000/darwin8.h" ;; From kremenek at apple.com Thu May 8 17:50:54 2008 From: kremenek at apple.com (Ted Kremenek) Date: Thu, 08 May 2008 22:50:54 -0000 Subject: [llvm-commits] [llvm] r50876 - /llvm/tags/checker/checker-26/ Message-ID: <200805082250.m48MosqG013544@zion.cs.uiuc.edu> Author: kremenek Date: Thu May 8 17:50:53 2008 New Revision: 50876 URL: http://llvm.org/viewvc/llvm-project?rev=50876&view=rev Log: Tagging checker-26. Added: llvm/tags/checker/checker-26/ - copied from r50875, llvm/trunk/ From asl at math.spbu.ru Thu May 8 18:11:07 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Thu, 08 May 2008 23:11:07 -0000 Subject: [llvm-commits] [llvm] r50878 - /llvm/trunk/lib/VMCore/Verifier.cpp Message-ID: <200805082311.m48NB7jl014111@zion.cs.uiuc.edu> Author: asl Date: Thu May 8 18:11:06 2008 New Revision: 50878 URL: http://llvm.org/viewvc/llvm-project?rev=50878&view=rev Log: Check for validity of aliasee pointer before dereference. Modified: llvm/trunk/lib/VMCore/Verifier.cpp Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=50878&r1=50877&r2=50878&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Thu May 8 18:11:06 2008 @@ -367,9 +367,11 @@ Assert1(GA.hasExternalLinkage() || GA.hasInternalLinkage() || GA.hasWeakLinkage(), "Alias should have external or external weak linkage!", &GA); + Assert1(GA.getAliasee(), + "Aliasee cannot be NULL!", &GA); Assert1(GA.getType() == GA.getAliasee()->getType(), "Alias and aliasee types should match!", &GA); - + if (!isa(GA.getAliasee())) { const ConstantExpr *CE = dyn_cast(GA.getAliasee()); Assert1(CE && CE->getOpcode() == Instruction::BitCast && From dpatel at apple.com Thu May 8 19:54:06 2008 From: dpatel at apple.com (Devang Patel) Date: Fri, 09 May 2008 00:54:06 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50879 - /llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Message-ID: <200805090054.m490s6dA017154@zion.cs.uiuc.edu> Author: dpatel Date: Thu May 8 19:54:05 2008 New Revision: 50879 URL: http://llvm.org/viewvc/llvm-project?rev=50879&view=rev Log: Vectors bigger than 128 are returned using sret. This fixes few failures in compat.exp for x86-64 darwin target. (from Tak branch) Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=50879&r1=50878&r2=50879&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Thu May 8 19:54:05 2008 @@ -830,9 +830,9 @@ if (TREE_INT_CST_LOW(TYPE_SIZE(type))==64 && TYPE_VECTOR_SUBPARTS(type)>1) return true; - if (TREE_INT_CST_LOW(TYPE_SIZE(type))>128) - return true; } + if (TREE_INT_CST_LOW(TYPE_SIZE(type))>128) + return true; return false; } From kledzik at apple.com Thu May 8 20:09:59 2008 From: kledzik at apple.com (Nick Kledzik) Date: Fri, 09 May 2008 01:09:59 -0000 Subject: [llvm-commits] [llvm] r50880 - in /llvm/trunk/tools/lto2: LTOModule.cpp LTOModule.h Message-ID: <200805090109.m4919xpD017566@zion.cs.uiuc.edu> Author: kledzik Date: Thu May 8 20:09:59 2008 New Revision: 50880 URL: http://llvm.org/viewvc/llvm-project?rev=50880&view=rev Log: use getMemBufferCopy if supplied buffer is not already zero terminated Modified: llvm/trunk/tools/lto2/LTOModule.cpp llvm/trunk/tools/lto2/LTOModule.h Modified: llvm/trunk/tools/lto2/LTOModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto2/LTOModule.cpp?rev=50880&r1=50879&r2=50880&view=diff ============================================================================== --- llvm/trunk/tools/lto2/LTOModule.cpp (original) +++ llvm/trunk/tools/lto2/LTOModule.cpp Thu May 8 20:09:59 2008 @@ -23,6 +23,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MathExtras.h" #include "llvm/System/Path.h" +#include "llvm/System/Process.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Target/TargetAsmInfo.h" @@ -46,8 +47,7 @@ bool LTOModule::isBitcodeFileForTarget(const void* mem, size_t length, const char* triplePrefix) { - MemoryBuffer* buffer = MemoryBuffer::getMemBuffer((char*)mem, - (char*)mem+length); + MemoryBuffer* buffer = makeBuffer(mem, length); if ( buffer == NULL ) return false; return isTargetMatch(buffer, triplePrefix); @@ -91,11 +91,26 @@ return makeLTOModule(buffer.get(), errMsg); } + +MemoryBuffer* LTOModule::makeBuffer(const void* mem, size_t length) +{ + // MemoryBuffer requires the byte past end of the buffer to be a zero. + // We might get lucky and already be that way, otherwise make a copy. + // Also if next byte is on a different page, don't assume it is readable. + const char* startPtr = (char*)mem; + const char* endPtr = startPtr+length; + if ( (((uintptr_t)endPtr & (sys::Process::GetPageSize()-1)) == 0) + || (*endPtr != 0) ) + return MemoryBuffer::getMemBufferCopy(startPtr, endPtr); + else + return MemoryBuffer::getMemBuffer(startPtr, endPtr); +} + + LTOModule* LTOModule::makeLTOModule(const void* mem, size_t length, std::string& errMsg) { - OwningPtr buffer(MemoryBuffer::getMemBuffer((char*)mem, - (char*)mem+length)); + OwningPtr buffer(makeBuffer(mem, length)); if ( !buffer ) return NULL; return makeLTOModule(buffer.get(), errMsg); Modified: llvm/trunk/tools/lto2/LTOModule.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto2/LTOModule.h?rev=50880&r1=50879&r2=50880&view=diff ============================================================================== --- llvm/trunk/tools/lto2/LTOModule.h (original) +++ llvm/trunk/tools/lto2/LTOModule.h Thu May 8 20:09:59 2008 @@ -81,6 +81,7 @@ static LTOModule* makeLTOModule(llvm::MemoryBuffer* buffer, std::string& errMsg); + static llvm::MemoryBuffer* makeBuffer(const void* mem, size_t length); typedef llvm::StringMap StringSet; From clattner at apple.com Thu May 8 23:41:13 2008 From: clattner at apple.com (Chris Lattner) Date: Thu, 8 May 2008 21:41:13 -0700 Subject: [llvm-commits] [llvm] r50861 - in /llvm/trunk: docs/Passes.html lib/Transforms/IPO/StripDeadPrototypes.cpp lib/Transforms/IPO/StructRetPromotion.cpp lib/Transforms/Scalar/CodeGenPrepare.cpp lib/Transforms/Scalar/JumpThreading.cpp lib/Transforms/Scalar/LoopDeletion.cpp In-Reply-To: <20080508184822.GE27072@katherina.student.utwente.nl> References: <200805081746.m48HkZLA002042@zion.cs.uiuc.edu> <4DCA2C8A-919E-42D9-939D-18D2667A08B6@apple.com> <20080508184822.GE27072@katherina.student.utwente.nl> Message-ID: On May 8, 2008, at 11:48 AM, Matthijs Kooijman wrote: > Hi, > >> For the changes to the JumpThreading Class, I don't think doxygen >> will pick up the comments at the top of the file (but correct me if I >> am wrong). > From what I've seen, none of the other passes have duplicate > documentation > like this? I agree that having comments in the API docs is quite > desirable, > but wouldn't it be better to make the per-file comments doxygen > style as well > then (and perhaps add a reference)? The substantial documentation should go in a doxygen comment above the class, with only a small comment in the file header. The JumpThreading pass was the preferred way to do this. Other passes that aren't following that style should be updated. -Chris From sabre at nondot.org Thu May 8 23:43:14 2008 From: sabre at nondot.org (Chris Lattner) Date: Fri, 09 May 2008 04:43:14 -0000 Subject: [llvm-commits] [llvm] r50881 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200805090443.m494hEfv023693@zion.cs.uiuc.edu> Author: lattner Date: Thu May 8 23:43:13 2008 New Revision: 50881 URL: http://llvm.org/viewvc/llvm-project?rev=50881&view=rev Log: restore doxygen comment. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=50881&r1=50880&r2=50881&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Thu May 8 23:43:13 2008 @@ -9,23 +9,6 @@ // // This file implements the Jump Threading pass. // -// Jump threading tries to find distinct threads of control flow running through -// a basic block. This pass looks at blocks that have multiple predecessors and -// multiple successors. If one or more of the predecessors of the block can be -// proven to always cause a jump to one of the successors, we forward the edge -// from the predecessor to the successor by duplicating the contents of this -// block. -// -// An example of when this can occur is code like this: -// -// if () { ... -// X = 4; -// } -// if (X < 3) { -// -// In this case, the unconditional branch at the end of the first if can be -// revectored to the false side of the second if. -// //===----------------------------------------------------------------------===// #define DEBUG_TYPE "jump-threading" @@ -50,6 +33,22 @@ cl::init(6), cl::Hidden); namespace { + /// This pass performs 'jump threading', which looks at blocks that have + /// multiple predecessors and multiple successors. If one or more of the + /// predecessors of the block can be proven to always jump to one of the + /// successors, we forward the edge from the predecessor to the successor by + /// duplicating the contents of this block. + /// + /// An example of when this can occur is code like this: + /// + /// if () { ... + /// X = 4; + /// } + /// if (X < 3) { + /// + /// In this case, the unconditional branch at the end of the first if can be + /// revectored to the false side of the second if. + /// class VISIBILITY_HIDDEN JumpThreading : public FunctionPass { public: static char ID; // Pass identification From lattner at apple.com Thu May 8 23:47:53 2008 From: lattner at apple.com (Tanya Lattner) Date: Thu, 8 May 2008 21:47:53 -0700 Subject: [llvm-commits] [llvm] r50880 - in /llvm/trunk/tools/lto2: LTOModule.cpp LTOModule.h In-Reply-To: <200805090109.m4919xpD017566@zion.cs.uiuc.edu> References: <200805090109.m4919xpD017566@zion.cs.uiuc.edu> Message-ID: <66645B23-09A1-45A4-8A95-D428862BA0A2@apple.com> Can you add some doxygen style (///) comments for makeBuffer? Thanks, Tanya On May 8, 2008, at 6:09 PM, Nick Kledzik wrote: > Author: kledzik > Date: Thu May 8 20:09:59 2008 > New Revision: 50880 > > URL: http://llvm.org/viewvc/llvm-project?rev=50880&view=rev > Log: > use getMemBufferCopy if supplied buffer is > not already zero terminated > > Modified: > llvm/trunk/tools/lto2/LTOModule.cpp > llvm/trunk/tools/lto2/LTOModule.h > > Modified: llvm/trunk/tools/lto2/LTOModule.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto2/ > LTOModule.cpp?rev=50880&r1=50879&r2=50880&view=diff > > ====================================================================== > ======== > --- llvm/trunk/tools/lto2/LTOModule.cpp (original) > +++ llvm/trunk/tools/lto2/LTOModule.cpp Thu May 8 20:09:59 2008 > @@ -23,6 +23,7 @@ > #include "llvm/Support/MemoryBuffer.h" > #include "llvm/Support/MathExtras.h" > #include "llvm/System/Path.h" > +#include "llvm/System/Process.h" > #include "llvm/Target/TargetMachine.h" > #include "llvm/Target/TargetMachineRegistry.h" > #include "llvm/Target/TargetAsmInfo.h" > @@ -46,8 +47,7 @@ > bool LTOModule::isBitcodeFileForTarget(const void* mem, size_t > length, > const char* triplePrefix) > { > - MemoryBuffer* buffer = MemoryBuffer::getMemBuffer((char*)mem, > - (char*)mem > +length); > + MemoryBuffer* buffer = makeBuffer(mem, length); > if ( buffer == NULL ) > return false; > return isTargetMatch(buffer, triplePrefix); > @@ -91,11 +91,26 @@ > return makeLTOModule(buffer.get(), errMsg); > } > > + > +MemoryBuffer* LTOModule::makeBuffer(const void* mem, size_t length) > +{ > + // MemoryBuffer requires the byte past end of the buffer to be a > zero. > + // We might get lucky and already be that way, otherwise make a > copy. > + // Also if next byte is on a different page, don't assume it is > readable. > + const char* startPtr = (char*)mem; > + const char* endPtr = startPtr+length; > + if ( (((uintptr_t)endPtr & (sys::Process::GetPageSize()-1)) == 0) > + || (*endPtr != 0) ) > + return MemoryBuffer::getMemBufferCopy(startPtr, endPtr); > + else > + return MemoryBuffer::getMemBuffer(startPtr, endPtr); > +} > + > + > LTOModule* LTOModule::makeLTOModule(const void* mem, size_t length, > > std::string& errMsg) > { > - OwningPtr buffer(MemoryBuffer::getMemBuffer > ((char*)mem, > - (char*) > mem+length)); > + OwningPtr buffer(makeBuffer(mem, length)); > if ( !buffer ) > return NULL; > return makeLTOModule(buffer.get(), errMsg); > > Modified: llvm/trunk/tools/lto2/LTOModule.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto2/ > LTOModule.h?rev=50880&r1=50879&r2=50880&view=diff > > ====================================================================== > ======== > --- llvm/trunk/tools/lto2/LTOModule.h (original) > +++ llvm/trunk/tools/lto2/LTOModule.h Thu May 8 20:09:59 2008 > @@ -81,6 +81,7 @@ > > static LTOModule* makeLTOModule(llvm::MemoryBuffer* buffer, > > std::string& errMsg); > + static llvm::MemoryBuffer* makeBuffer(const void* mem, size_t > length); > > typedef llvm::StringMap StringSet; > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Fri May 9 00:19:28 2008 From: sabre at nondot.org (Chris Lattner) Date: Fri, 09 May 2008 05:19:28 -0000 Subject: [llvm-commits] [llvm] r50882 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/not.ll test/Transforms/InstCombine/sub.ll Message-ID: <200805090519.m495JTt9024663@zion.cs.uiuc.edu> Author: lattner Date: Fri May 9 00:19:28 2008 New Revision: 50882 URL: http://llvm.org/viewvc/llvm-project?rev=50882&view=rev Log: Implement PR2298. This transforms: ~x < ~y --> y < x -x == -y --> x == y Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/test/Transforms/InstCombine/not.ll llvm/trunk/test/Transforms/InstCombine/sub.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=50882&r1=50881&r2=50882&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Fri May 9 00:19:28 2008 @@ -5658,8 +5658,21 @@ return R; } + // ~x < ~y --> y < x + { Value *A, *B; + if (match(Op0, m_Not(m_Value(A))) && + match(Op1, m_Not(m_Value(B)))) + return new ICmpInst(I.getPredicate(), B, A); + } + if (I.isEquality()) { Value *A, *B, *C, *D; + + // -x == -y --> x == y + if (match(Op0, m_Neg(m_Value(A))) && + match(Op1, m_Neg(m_Value(B)))) + return new ICmpInst(I.getPredicate(), A, B); + if (match(Op0, m_Xor(m_Value(A), m_Value(B)))) { if (A == Op1 || B == Op1) { // (A^B) == A -> B == 0 Value *OtherVal = A == Op1 ? B : A; Modified: llvm/trunk/test/Transforms/InstCombine/not.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/not.ll?rev=50882&r1=50881&r2=50882&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/not.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/not.ll Fri May 9 00:19:28 2008 @@ -42,3 +42,13 @@ ret i32 %d } +; PR2298 +define i8 @test6(i32 %a, i32 %b) zeroext nounwind { +entry: + %tmp1not = xor i32 %a, -1 ; [#uses=1] + %tmp2not = xor i32 %b, -1 ; [#uses=1] + %tmp3 = icmp slt i32 %tmp1not, %tmp2not ; [#uses=1] + %retval67 = zext i1 %tmp3 to i8 ; [#uses=1] + ret i8 %retval67 +} + Modified: llvm/trunk/test/Transforms/InstCombine/sub.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/sub.ll?rev=50882&r1=50881&r2=50882&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/sub.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/sub.ll Fri May 9 00:19:28 2008 @@ -134,3 +134,13 @@ %tmp.4 = icmp ne i32 %tmp.2, %g ; [#uses=1] ret i1 %tmp.4 } + +; PR2298 +define i8 @test22(i32 %a, i32 %b) zeroext nounwind { + %tmp2 = sub i32 0, %a ; [#uses=1] + %tmp4 = sub i32 0, %b ; [#uses=1] + %tmp5 = icmp eq i32 %tmp2, %tmp4 ; [#uses=1] + %retval89 = zext i1 %tmp5 to i8 ; [#uses=1] + ret i8 %retval89 +} + From sabre at nondot.org Fri May 9 00:20:27 2008 From: sabre at nondot.org (Chris Lattner) Date: Fri, 09 May 2008 05:20:27 -0000 Subject: [llvm-commits] [llvm] r50883 - in /llvm/trunk/include/llvm: InstrTypes.h Support/PatternMatch.h Message-ID: <200805090520.m495KRP1024711@zion.cs.uiuc.edu> Author: lattner Date: Fri May 9 00:20:27 2008 New Revision: 50883 URL: http://llvm.org/viewvc/llvm-project?rev=50883&view=rev Log: add support for pattern matching 'neg' Modified: llvm/trunk/include/llvm/InstrTypes.h llvm/trunk/include/llvm/Support/PatternMatch.h Modified: llvm/trunk/include/llvm/InstrTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InstrTypes.h?rev=50883&r1=50882&r2=50883&view=diff ============================================================================== --- llvm/trunk/include/llvm/InstrTypes.h (original) +++ llvm/trunk/include/llvm/InstrTypes.h Fri May 9 00:20:27 2008 @@ -236,10 +236,8 @@ /// swapOperands - Exchange the two operands to this instruction. /// This instruction is safe to use on any binary instruction and - /// does not modify the semantics of the instruction. If the - /// instruction is order dependent (SetLT f.e.) the opcode is - /// changed. If the instruction cannot be reversed (ie, it's a Div), - /// then return true. + /// does not modify the semantics of the instruction. If the instruction + /// cannot be reversed (ie, it's a Div), then return true. /// bool swapOperands(); Modified: llvm/trunk/include/llvm/Support/PatternMatch.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PatternMatch.h?rev=50883&r1=50882&r2=50883&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/PatternMatch.h (original) +++ llvm/trunk/include/llvm/Support/PatternMatch.h Fri May 9 00:20:27 2008 @@ -385,6 +385,35 @@ inline not_match m_Not(const LHS &L) { return L; } +template +struct neg_match { + LHS_t L; + + neg_match(const LHS_t &LHS) : L(LHS) {} + + template + bool match(OpTy *V) { + if (Instruction *I = dyn_cast(V)) + if (I->getOpcode() == Instruction::Sub) + return matchIfNeg(I->getOperand(0), I->getOperand(1)); + if (ConstantExpr *CE = dyn_cast(V)) + if (CE->getOpcode() == Instruction::Sub) + return matchIfNeg(CE->getOperand(0), CE->getOperand(1)); + if (ConstantInt *CI = dyn_cast(V)) + return L.match(ConstantExpr::getNeg(CI)); + return false; + } +private: + bool matchIfNeg(Value *LHS, Value *RHS) { + return LHS == ConstantExpr::getZeroValueForNegationExpr(LHS->getType()) && + L.match(RHS); + } +}; + +template +inline neg_match m_Neg(const LHS &L) { return L; } + + //===----------------------------------------------------------------------===// // Matchers for control flow // From nicolas.geoffray at lip6.fr Fri May 9 01:02:22 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 09 May 2008 06:02:22 -0000 Subject: [llvm-commits] [vmkit] r50889 - in /vmkit/trunk/lib/Mvm/GCMmap2: MvmGC.h gc.cpp Message-ID: <200805090602.m4962Mir026232@zion.cs.uiuc.edu> Author: geoffray Date: Fri May 9 01:02:22 2008 New Revision: 50889 URL: http://llvm.org/viewvc/llvm-project?rev=50889&view=rev Log: Add an extern "C" function for LLVM runtime lib. Modified: vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp Modified: vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h?rev=50889&r1=50888&r2=50889&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h Fri May 9 01:02:22 2008 @@ -100,5 +100,10 @@ STATIC void setMinMemory(size_t); }; +#ifdef MULTIPLE_GC +extern "C" gc* gcmalloc(size_t sz, VirtualTable* VT, Collector* GC); +#else +extern "C" gc* gcmalloc(size_t sz, VirtualTable* VT); +#endif #endif Modified: vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp?rev=50889&r1=50888&r2=50889&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp Fri May 9 01:02:22 2008 @@ -260,3 +260,14 @@ return (Collector*)GCCollector::o2node((void*)o)->meta; } #endif + +#ifdef MULTIPLE_GC +extern "C" gc* gcmalloc(size_t sz, VirtualTable* VT, Collector* GC) { + return (gc*)((GCCollector*)GC)->gcmalloc(VT, sz); +} +#else +extern "C" gc* gcmalloc(size_t sz, VirtualTable* VT) { + return (gc*)GCCollector::gcmalloc(VT, sz); +} +#endif + From isanbard at gmail.com Fri May 9 02:01:39 2008 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 09 May 2008 07:01:39 -0000 Subject: [llvm-commits] [llvm] r50893 - /llvm/tags/Apple/llvmCore-2041/ Message-ID: <200805090701.m4971dOA027815@zion.cs.uiuc.edu> Author: void Date: Fri May 9 02:01:38 2008 New Revision: 50893 URL: http://llvm.org/viewvc/llvm-project?rev=50893&view=rev Log: Creating llvmCore-2041 branch Added: llvm/tags/Apple/llvmCore-2041/ - copied from r50892, llvm/trunk/ From isanbard at gmail.com Fri May 9 02:01:45 2008 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 09 May 2008 07:01:45 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50894 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2041/ Message-ID: <200805090701.m4971jCj027826@zion.cs.uiuc.edu> Author: void Date: Fri May 9 02:01:45 2008 New Revision: 50894 URL: http://llvm.org/viewvc/llvm-project?rev=50894&view=rev Log: Creating llvmgcc42-2041 branch Added: llvm-gcc-4.2/tags/Apple/llvmgcc42-2041/ - copied from r50893, llvm-gcc-4.2/trunk/ From foldr at codedgers.com Fri May 9 03:27:26 2008 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Fri, 09 May 2008 08:27:26 -0000 Subject: [llvm-commits] [llvm] r50895 - in /llvm/trunk: tools/llvmc2/Common.td utils/TableGen/LLVMCConfigurationEmitter.cpp Message-ID: <200805090827.m498RQ7m005820@zion.cs.uiuc.edu> Author: foldr Date: Fri May 9 03:27:26 2008 New Revision: 50895 URL: http://llvm.org/viewvc/llvm-project?rev=50895&view=rev Log: Reapply 50867: A small refactoring (extract method) + some comment fixes. Fixed the build breakage, sorry for that. Modified: llvm/trunk/tools/llvmc2/Common.td llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Modified: llvm/trunk/tools/llvmc2/Common.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Common.td?rev=50895&r1=50894&r2=50895&view=diff ============================================================================== --- llvm/trunk/tools/llvmc2/Common.td (original) +++ llvm/trunk/tools/llvmc2/Common.td Fri May 9 03:27:26 2008 @@ -15,7 +15,7 @@ list properties = l; } -// Special Tool instance - graph root. +// Special Tool instance - the root node of the compilation graph. def root : Tool<[]>; @@ -47,6 +47,7 @@ // Possible edge properties +// 'Atomic' properties. def switch_on; def parameter_equals; def element_in_list; Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=50895&r1=50894&r2=50895&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Fri May 9 03:27:26 2008 @@ -163,8 +163,8 @@ std::string Help; unsigned Flags; - // We need t provide a default constructor since - // StringMap can only store DefaultConstructible objects + // We need to provide a default constructor because + // StringMap can only store DefaultConstructible objects. GlobalOptionDescription() : OptionDescription(), Flags(0) {} @@ -222,9 +222,9 @@ }; -// Tool-local option description +// Tool-local option description. -// Properties without arguments are implemented as flags +// Properties without arguments are implemented as flags. namespace ToolOptionDescriptionFlags { enum ToolOptionDescriptionFlags { StopCompilation = 0x1, Forward = 0x2, UnpackValues = 0x4}; @@ -314,7 +314,7 @@ /// CollectProperties - Function object for iterating over a list of -/// tool property records +/// tool property records. class CollectProperties { private: @@ -569,7 +569,8 @@ /// CollectToolProperties - Gather information from the parsed -/// TableGen data (basically a wrapper for CollectProperties). +/// TableGen data (basically a wrapper for the CollectProperties +/// function object). void CollectToolProperties (RecordVector::const_iterator B, RecordVector::const_iterator E, ToolPropertiesList& TPList, @@ -589,12 +590,50 @@ } } -/// EmitOptionPropertyHandlingCode - Used by EmitGenerateActionMethod. +/// EmitForwardOptionPropertyHandlingCode - Helper function used to +/// implement EmitOptionPropertyHandlingCode(). Emits code for +/// handling the (forward) option property. +void EmitForwardOptionPropertyHandlingCode (const ToolOptionDescription& D, + std::ostream& O) { + switch (D.Type) { + case OptionType::Switch: + O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n"; + break; + case OptionType::Parameter: + O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n"; + O << Indent3 << "vec.push_back(" << D.GenVariableName() << ");\n"; + break; + case OptionType::Prefix: + O << Indent3 << "vec.push_back(\"-" << D.Name << "\" + " + << D.GenVariableName() << ");\n"; + break; + case OptionType::PrefixList: + O << Indent3 << "for (" << D.GenTypeDeclaration() + << "::iterator B = " << D.GenVariableName() << ".begin(),\n" + << Indent3 << "E = " << D.GenVariableName() << ".end(); B != E; ++B)\n" + << Indent4 << "vec.push_back(\"-" << D.Name << "\" + " + << "*B);\n"; + break; + case OptionType::ParameterList: + O << Indent3 << "for (" << D.GenTypeDeclaration() + << "::iterator B = " << D.GenVariableName() << ".begin(),\n" + << Indent3 << "E = " << D.GenVariableName() + << ".end() ; B != E; ++B) {\n" + << Indent4 << "vec.push_back(\"-" << D.Name << "\");\n" + << Indent4 << "vec.push_back(*B);\n" + << Indent3 << "}\n"; + break; + } +} + +/// EmitOptionPropertyHandlingCode - Helper function used by +/// EmitGenerateActionMethod(). Emits code that handles option +/// properties. void EmitOptionPropertyHandlingCode (const ToolProperties& P, const ToolOptionDescription& D, std::ostream& O) { - // if clause + // Start of the if-clause. O << Indent2 << "if ("; if (D.Type == OptionType::Switch) O << D.GenVariableName(); @@ -603,7 +642,7 @@ O <<") {\n"; - // Handle option properties that take an argument + // Handle option properties that take an argument. for (OptionPropertyList::const_iterator B = D.Props.begin(), E = D.Props.end(); B!=E; ++B) { const OptionProperty& val = *B; @@ -622,37 +661,8 @@ // Handle flags // (forward) property - if (D.isForward()) { - switch (D.Type) { - case OptionType::Switch: - O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n"; - break; - case OptionType::Parameter: - O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n"; - O << Indent3 << "vec.push_back(" << D.GenVariableName() << ");\n"; - break; - case OptionType::Prefix: - O << Indent3 << "vec.push_back(\"-" << D.Name << "\" + " - << D.GenVariableName() << ");\n"; - break; - case OptionType::PrefixList: - O << Indent3 << "for (" << D.GenTypeDeclaration() - << "::iterator B = " << D.GenVariableName() << ".begin(),\n" - << Indent3 << "E = " << D.GenVariableName() << ".end(); B != E; ++B)\n" - << Indent4 << "vec.push_back(\"-" << D.Name << "\" + " - << "*B);\n"; - break; - case OptionType::ParameterList: - O << Indent3 << "for (" << D.GenTypeDeclaration() - << "::iterator B = " << D.GenVariableName() << ".begin(),\n" - << Indent3 << "E = " << D.GenVariableName() - << ".end() ; B != E; ++B) {\n" - << Indent4 << "vec.push_back(\"-" << D.Name << "\");\n" - << Indent4 << "vec.push_back(*B);\n" - << Indent3 << "}\n"; - break; - } - } + if (D.isForward()) + EmitForwardOptionPropertyHandlingCode(D, O); // (unpack_values) property if (D.isUnpackValues()) { @@ -673,16 +683,15 @@ } } - // close if clause + // End of the if-clause. O << Indent2 << "}\n"; } -// EmitGenerateActionMethod - Emit one of two versions of -// GenerateAction method. -void EmitGenerateActionMethod (const ToolProperties& P, int V, std::ostream& O) +// EmitGenerateActionMethod - Emit one of two versions of the +// Tool::GenerateAction() method. +void EmitGenerateActionMethod (const ToolProperties& P, bool V, std::ostream& O) { - assert(V==1 || V==2); - if (V==1) + if (V) O << Indent1 << "Action GenerateAction(const PathVector& inFiles,\n"; else O << Indent1 << "Action GenerateAction(const sys::Path& inFile,\n"; @@ -701,7 +710,7 @@ const std::string& cmd = *I; O << Indent2; if (cmd == "$INFILE") { - if (V==1) + if (V) O << "for (PathVector::const_iterator B = inFiles.begin()" << ", E = inFiles.end();\n" << Indent2 << "B != E; ++B)\n" @@ -717,14 +726,14 @@ } } - // For every understood option, emit handling code + // For every understood option, emit handling code. for (ToolOptionDescriptions::const_iterator B = P.OptDescs.begin(), E = P.OptDescs.end(); B != E; ++B) { const ToolOptionDescription& val = B->second; EmitOptionPropertyHandlingCode(P, val, O); } - // Handle Sink property + // Handle the Sink property. if (P.isSink()) { O << Indent2 << "if (!" << SinkOptionName << ".empty()) {\n" << Indent3 << "vec.insert(vec.end(), " @@ -736,8 +745,8 @@ << Indent1 << "}\n\n"; } -/// EmitGenerateActionMethods - Emit two GenerateAction methods for a given -/// Tool class. +/// EmitGenerateActionMethods - Emit two GenerateAction() methods for +/// a given Tool class. void EmitGenerateActionMethods (const ToolProperties& P, std::ostream& O) { if (!P.isJoin()) @@ -748,12 +757,13 @@ << " is not a Join tool!\");\n" << Indent1 << "}\n\n"; else - EmitGenerateActionMethod(P, 1, O); + EmitGenerateActionMethod(P, true, O); - EmitGenerateActionMethod(P, 2, O); + EmitGenerateActionMethod(P, false, O); } -/// EmitIsLastMethod - Emit IsLast() method for a given Tool class +/// EmitIsLastMethod - Emit the IsLast() method for a given Tool +/// class. void EmitIsLastMethod (const ToolProperties& P, std::ostream& O) { O << Indent1 << "bool IsLast() const {\n" << Indent2 << "bool last = false;\n"; From nicolas.geoffray at lip6.fr Fri May 9 05:34:15 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 09 May 2008 10:34:15 -0000 Subject: [llvm-commits] [vmkit] r50896 - in /vmkit/trunk: include/mvm/JIT.h lib/Mvm/JIT.cpp Message-ID: <200805091034.m49AYFLe009795@zion.cs.uiuc.edu> Author: geoffray Date: Fri May 9 05:34:11 2008 New Revision: 50896 URL: http://llvm.org/viewvc/llvm-project?rev=50896&view=rev Log: Add a constantPtrSize LLVM Constant for getting the size of a pointer. Modified: vmkit/trunk/include/mvm/JIT.h vmkit/trunk/lib/Mvm/JIT.cpp Modified: vmkit/trunk/include/mvm/JIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=50896&r1=50895&r2=50896&view=diff ============================================================================== --- vmkit/trunk/include/mvm/JIT.h (original) +++ vmkit/trunk/include/mvm/JIT.h Fri May 9 05:34:11 2008 @@ -143,6 +143,7 @@ extern llvm::ConstantFP* constantFloatMinusZero; extern llvm::ConstantFP* constantDoubleMinusZero; extern llvm::Constant* constantPtrNull; +extern llvm::ConstantInt* constantPtrSize; extern const llvm::PointerType* ptrType; extern const llvm::Type* arrayPtrType; Modified: vmkit/trunk/lib/Mvm/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/JIT.cpp?rev=50896&r1=50895&r2=50896&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/JIT.cpp Fri May 9 05:34:11 2008 @@ -551,6 +551,7 @@ constantFloatMinusZero = ConstantFP::get(Type::FloatTy, -0.0f); constantPtrNull = Constant::getNullValue(ptrType); + constantPtrSize = ConstantInt::get(Type::Int32Ty, sizeof(void*)); arrayPtrType = PointerType::getUnqual(ArrayType::get(Type::Int8Ty, 0)); mvm::jit::protectEngine = mvm::Lock::allocNormal(); @@ -642,6 +643,7 @@ llvm::ConstantFP* mvm::jit::constantFloatMinusZero; llvm::ConstantFP* mvm::jit::constantDoubleMinusZero; llvm::Constant* mvm::jit::constantPtrNull; +llvm::ConstantInt* mvm::jit::constantPtrSize; const llvm::PointerType* mvm::jit::ptrType; const llvm::Type* mvm::jit::arrayPtrType; From ggreif at gmail.com Fri May 9 06:44:52 2008 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 09 May 2008 11:44:52 -0000 Subject: [llvm-commits] [llvm] r50897 - /llvm/trunk/test/LLVMC/ Message-ID: <200805091145.m49Bj0sw011804@zion.cs.uiuc.edu> Author: ggreif Date: Fri May 9 06:44:30 2008 New Revision: 50897 URL: http://llvm.org/viewvc/llvm-project?rev=50897&view=rev Log: ignore Output dir Modified: llvm/trunk/test/LLVMC/ (props changed) Propchange: llvm/trunk/test/LLVMC/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Fri May 9 06:44:30 2008 @@ -0,0 +1 @@ +Output From ggreif at gmail.com Fri May 9 06:50:24 2008 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 09 May 2008 11:50:24 -0000 Subject: [llvm-commits] [llvm] r50898 - /llvm/trunk/tools/llvmc2/ Message-ID: <200805091150.m49BoWBJ012001@zion.cs.uiuc.edu> Author: ggreif Date: Fri May 9 06:49:54 2008 New Revision: 50898 URL: http://llvm.org/viewvc/llvm-project?rev=50898&view=rev Log: ignore AutoGenerated.inc, it is created by TableGen Modified: llvm/trunk/tools/llvmc2/ (props changed) Propchange: llvm/trunk/tools/llvmc2/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Fri May 9 06:49:54 2008 @@ -1,3 +1,4 @@ Tools.inc +AutoGenerated.inc Debug Release From ggreif at gmail.com Fri May 9 06:56:59 2008 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 09 May 2008 11:56:59 -0000 Subject: [llvm-commits] [llvm] r50899 - in /llvm/trunk/test: Analysis/PostDominators/ Transforms/LoopDeletion/ Message-ID: <200805091157.m49Bv9UM012224@zion.cs.uiuc.edu> Author: ggreif Date: Fri May 9 06:56:35 2008 New Revision: 50899 URL: http://llvm.org/viewvc/llvm-project?rev=50899&view=rev Log: ignore Output dirs Modified: llvm/trunk/test/Analysis/PostDominators/ (props changed) llvm/trunk/test/Transforms/LoopDeletion/ (props changed) Propchange: llvm/trunk/test/Analysis/PostDominators/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Fri May 9 06:56:35 2008 @@ -0,0 +1 @@ +Output Propchange: llvm/trunk/test/Transforms/LoopDeletion/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Fri May 9 06:56:35 2008 @@ -0,0 +1 @@ +Output From baldrick at free.fr Fri May 9 07:20:24 2008 From: baldrick at free.fr (Duncan Sands) Date: Fri, 09 May 2008 12:20:24 -0000 Subject: [llvm-commits] [llvm] r50900 - /llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp Message-ID: <200805091220.m49CKTW2012942@zion.cs.uiuc.edu> Author: baldrick Date: Fri May 9 07:20:10 2008 New Revision: 50900 URL: http://llvm.org/viewvc/llvm-project?rev=50900&view=rev Log: Fix a type and formatting. Modified: llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp Modified: llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp?rev=50900&r1=50899&r2=50900&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp Fri May 9 07:20:10 2008 @@ -92,7 +92,7 @@ assert (F->getReturnType() == Type::VoidTy && "Invalid function return type"); Function::arg_iterator AI = F->arg_begin(); const llvm::PointerType *FArgType = dyn_cast(AI->getType()); - assert (FArgType && "Invalid sret paramater type"); + assert (FArgType && "Invalid sret parameter type"); const llvm::StructType *STy = dyn_cast(FArgType->getElementType()); assert (STy && "Invalid sret parameter element type"); @@ -149,7 +149,7 @@ return true; } - // Check if it is ok to perform this promotion. +// Check if it is ok to perform this promotion. bool SRETPromotion::isSafeToUpdateAllCallers(Function *F) { if (F->use_empty()) From sabre at nondot.org Fri May 9 10:07:35 2008 From: sabre at nondot.org (Chris Lattner) Date: Fri, 09 May 2008 15:07:35 -0000 Subject: [llvm-commits] [llvm] r50901 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200805091507.m49F7ZAS017940@zion.cs.uiuc.edu> Author: lattner Date: Fri May 9 10:07:33 2008 New Revision: 50901 URL: http://llvm.org/viewvc/llvm-project?rev=50901&view=rev Log: don't sink invokes, even if they are readonly. This fixes a crash on kimwitu++. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=50901&r1=50900&r2=50901&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Fri May 9 10:07:33 2008 @@ -11233,7 +11233,8 @@ assert(I->hasOneUse() && "Invariants didn't hold!"); // Cannot move control-flow-involving, volatile loads, vaarg, etc. - if (isa(I) || I->mayWriteToMemory()) return false; + if (isa(I) || I->mayWriteToMemory() || isa(I)) + return false; // Do not sink alloca instructions out of the entry block. if (isa(I) && I->getParent() == From gohman at apple.com Fri May 9 11:14:55 2008 From: gohman at apple.com (Dan Gohman) Date: Fri, 9 May 2008 09:14:55 -0700 (PDT) Subject: [llvm-commits] PATCH for PIC16 target. In-Reply-To: References: Message-ID: <59215.76.126.208.186.1210349695.squirrel@webmail.apple.com> Hello Sanjiv, I'm starting to review these files. As I begin, I have a few questions. How is PIC16 different from existing LLVM targets? Did you encounter any problems in developing this target for LLVM? Is there anything in LLVM that you had to work around, or that poses a challenge for PIC16? How is PIC16 similar to existing LLVM targets? Which other targets is this code based on, or were relevant as examples? Thanks, Dan On Thu, May 8, 2008 5:13 am, Sanjiv.Gupta at microchip.com wrote: > Please find attached files for Microchip's PIC16 backend. > These files are to be placed under a new directory lib/Target/PIC16. > Though the current PIC16 backend can handle few very elementary cases > for code generation, these files enable basic llvm framework for PIC16 > target. > > The code builds on linux/mingw platforms without warnings/errors. > > I will send a separate patch for configure. > > - Sanjiv > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From baldrick at free.fr Fri May 9 11:28:42 2008 From: baldrick at free.fr (Duncan Sands) Date: Fri, 09 May 2008 16:28:42 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50902 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200805091628.m49GSgk5020253@zion.cs.uiuc.edu> Author: baldrick Date: Fri May 9 11:28:41 2008 New Revision: 50902 URL: http://llvm.org/viewvc/llvm-project?rev=50902&view=rev Log: Tweak the handling of gimple temporaries: use the gcc method for detecting such temporaries rather than rolling our own. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=50902&r1=50901&r2=50902&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Fri May 9 11:28:41 2008 @@ -66,6 +66,7 @@ #include "rtl.h" #include "libfuncs.h" #include "tree-flow.h" +#include "tree-gimple.h" extern int get_pointer_alignment (tree exp, unsigned int max_align); extern enum machine_mode reg_raw_mode[FIRST_PSEUDO_REGISTER]; } @@ -261,15 +262,14 @@ } } -/// isGCC_SSA_Temporary - Return true if this is an SSA temporary that we can +/// isGimpleTemporary - Return true if this is a gimple temporary that we can /// directly compile into an LLVM temporary. This saves us from creating an /// alloca and creating loads/stores of that alloca (a compile-time win). We -/// can only do this if the value is a first class llvm value and if it's a -/// "gimple_formal_tmp_var". -static bool isGCC_SSA_Temporary(tree decl) { - return TREE_CODE(decl) == VAR_DECL && - DECL_GIMPLE_FORMAL_TEMP_P(decl) && !TREE_ADDRESSABLE(decl) && - !isAggregateTreeType(TREE_TYPE(decl)); +/// can only do this if the value is a first class llvm value and if it's a +/// "gimple_formal_tmp_reg". +static bool isGimpleTemporary(tree decl) { + return is_gimple_formal_tmp_reg(decl) && + !isAggregateTreeType(TREE_TYPE(decl)); } /// isStructWithVarSizeArrayAtEnd - Return true if this StructType contains a @@ -1583,9 +1583,9 @@ TREE_STATIC(decl) || DECL_EXTERNAL(decl) || type == error_mark_node) return; - // SSA temporaries are handled specially: their DECL_LLVM is set when the + // Gimple temporaries are handled specially: their DECL_LLVM is set when the // definition is encountered. - if (isGCC_SSA_Temporary(decl)) + if (isGimpleTemporary(decl)) return; // If this is just the rotten husk of a variable that the gimplifier @@ -2162,8 +2162,8 @@ /// requires an r-value, this method emits the lvalue computation, then loads /// the result. Value *TreeToLLVM::EmitLoadOfLValue(tree exp, const MemRef *DestLoc) { - // If this is an SSA value, don't emit a load, just use the result. - if (isGCC_SSA_Temporary(exp)) { + // If this is a gimple temporary, don't emit a load, just use the result. + if (isGimpleTemporary(exp)) { assert(DECL_LLVM_SET_P(exp) && "Definition not found before use!"); return DECL_LLVM(exp); } else if (TREE_CODE(exp) == VAR_DECL && DECL_REGISTER(exp) && @@ -2791,12 +2791,12 @@ tree lhs = TREE_OPERAND (exp, 0); tree rhs = TREE_OPERAND (exp, 1); - // If this is the definition of an SSA variable, set its DECL_LLVM to the + // If this is the definition of a gimple temporary, set its DECL_LLVM to the // RHS. bool LHSSigned = !TYPE_UNSIGNED(TREE_TYPE(lhs)); bool RHSSigned = !TYPE_UNSIGNED(TREE_TYPE(rhs)); - if (isGCC_SSA_Temporary(lhs)) { - // If DECL_LLVM is already set, this is a multiply defined GCC temporary. + if (isGimpleTemporary(lhs)) { + // If DECL_LLVM is already set, this is a multiply defined gimple temporary. if (DECL_LLVM_SET_P(lhs)) { HandleMultiplyDefinedGCCTemp(lhs); return EmitMODIFY_EXPR(exp, DestLoc); @@ -5276,8 +5276,8 @@ } } - assert(!isGCC_SSA_Temporary(exp) && - "Cannot use an SSA temporary as an l-value"); + assert(!isGimpleTemporary(exp) && + "Cannot use a gimple temporary as an l-value"); Value *Decl = DECL_LLVM(exp); if (Decl == 0) { From kledzik at apple.com Fri May 9 13:44:41 2008 From: kledzik at apple.com (Nick Kledzik) Date: Fri, 09 May 2008 18:44:41 -0000 Subject: [llvm-commits] [llvm] r50908 - /llvm/trunk/tools/lto2/LTOModule.cpp Message-ID: <200805091844.m49IifGQ024449@zion.cs.uiuc.edu> Author: kledzik Date: Fri May 9 13:44:41 2008 New Revision: 50908 URL: http://llvm.org/viewvc/llvm-project?rev=50908&view=rev Log: use doxygen comments for makeBuffer() Modified: llvm/trunk/tools/lto2/LTOModule.cpp Modified: llvm/trunk/tools/lto2/LTOModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto2/LTOModule.cpp?rev=50908&r1=50907&r2=50908&view=diff ============================================================================== --- llvm/trunk/tools/lto2/LTOModule.cpp (original) +++ llvm/trunk/tools/lto2/LTOModule.cpp Fri May 9 13:44:41 2008 @@ -91,12 +91,12 @@ return makeLTOModule(buffer.get(), errMsg); } - +/// makeBuffer - create a MemoryBuffer from a memory range. +/// MemoryBuffer requires the byte past end of the buffer to be a zero. +/// We might get lucky and already be that way, otherwise make a copy. +/// Also if next byte is on a different page, don't assume it is readable. MemoryBuffer* LTOModule::makeBuffer(const void* mem, size_t length) { - // MemoryBuffer requires the byte past end of the buffer to be a zero. - // We might get lucky and already be that way, otherwise make a copy. - // Also if next byte is on a different page, don't assume it is readable. const char* startPtr = (char*)mem; const char* endPtr = startPtr+length; if ( (((uintptr_t)endPtr & (sys::Process::GetPageSize()-1)) == 0) From kledzik at apple.com Fri May 9 13:45:30 2008 From: kledzik at apple.com (Nick Kledzik) Date: Fri, 9 May 2008 11:45:30 -0700 Subject: [llvm-commits] [llvm] r50880 - in /llvm/trunk/tools/lto2: LTOModule.cpp LTOModule.h In-Reply-To: <66645B23-09A1-45A4-8A95-D428862BA0A2@apple.com> References: <200805090109.m4919xpD017566@zion.cs.uiuc.edu> <66645B23-09A1-45A4-8A95-D428862BA0A2@apple.com> Message-ID: <643AE340-4BCC-4BC5-858E-EFEBF2A5A483@apple.com> Committed in revision 50908. -Nick On May 8, 2008, at 9:47 PM, Tanya Lattner wrote: > Can you add some doxygen style (///) comments for makeBuffer? > > Thanks, > Tanya > > On May 8, 2008, at 6:09 PM, Nick Kledzik wrote: > >> Author: kledzik >> Date: Thu May 8 20:09:59 2008 >> New Revision: 50880 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=50880&view=rev >> Log: >> use getMemBufferCopy if supplied buffer is >> not already zero terminated >> >> Modified: >> llvm/trunk/tools/lto2/LTOModule.cpp >> llvm/trunk/tools/lto2/LTOModule.h >> >> Modified: llvm/trunk/tools/lto2/LTOModule.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto2/LTOModule.cpp?rev=50880&r1=50879&r2=50880&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/tools/lto2/LTOModule.cpp (original) >> +++ llvm/trunk/tools/lto2/LTOModule.cpp Thu May 8 20:09:59 2008 >> @@ -23,6 +23,7 @@ >> #include "llvm/Support/MemoryBuffer.h" >> #include "llvm/Support/MathExtras.h" >> #include "llvm/System/Path.h" >> +#include "llvm/System/Process.h" >> #include "llvm/Target/TargetMachine.h" >> #include "llvm/Target/TargetMachineRegistry.h" >> #include "llvm/Target/TargetAsmInfo.h" >> @@ -46,8 +47,7 @@ >> bool LTOModule::isBitcodeFileForTarget(const void* mem, size_t >> length, >> const char* triplePrefix) >> { >> - MemoryBuffer* buffer = MemoryBuffer::getMemBuffer((char*)mem, >> - (char*)mem >> +length); >> + MemoryBuffer* buffer = makeBuffer(mem, length); >> if ( buffer == NULL ) >> return false; >> return isTargetMatch(buffer, triplePrefix); >> @@ -91,11 +91,26 @@ >> return makeLTOModule(buffer.get(), errMsg); >> } >> >> + >> +MemoryBuffer* LTOModule::makeBuffer(const void* mem, size_t length) >> +{ >> + // MemoryBuffer requires the byte past end of the buffer to be a >> zero. >> + // We might get lucky and already be that way, otherwise make a >> copy. >> + // Also if next byte is on a different page, don't assume it is >> readable. >> + const char* startPtr = (char*)mem; >> + const char* endPtr = startPtr+length; >> + if ( (((uintptr_t)endPtr & (sys::Process::GetPageSize()-1)) == 0) >> + || (*endPtr != 0) ) >> + return MemoryBuffer::getMemBufferCopy(startPtr, endPtr); >> + else >> + return MemoryBuffer::getMemBuffer(startPtr, endPtr); >> +} >> + >> + >> LTOModule* LTOModule::makeLTOModule(const void* mem, size_t length, >> >> std::string& errMsg) >> { >> - OwningPtr >> buffer(MemoryBuffer::getMemBuffer((char*)mem, >> - >> (char*)mem+length)); >> + OwningPtr buffer(makeBuffer(mem, length)); >> if ( !buffer ) >> return NULL; >> return makeLTOModule(buffer.get(), errMsg); >> >> Modified: llvm/trunk/tools/lto2/LTOModule.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto2/LTOModule.h?rev=50880&r1=50879&r2=50880&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/tools/lto2/LTOModule.h (original) >> +++ llvm/trunk/tools/lto2/LTOModule.h Thu May 8 20:09:59 2008 >> @@ -81,6 +81,7 @@ >> >> static LTOModule* makeLTOModule(llvm::MemoryBuffer* buffer, >> >> std::string& errMsg); >> + static llvm::MemoryBuffer* makeBuffer(const void* mem, size_t >> length); >> >> typedef llvm::StringMap StringSet; >> >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From foldr at codedgers.com Fri May 9 14:11:28 2008 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Fri, 09 May 2008 19:11:28 -0000 Subject: [llvm-commits] [llvm] r50910 - in /llvm/trunk/tools/llvmc2: Example.td Graph.td Makefile Message-ID: <200805091911.m49JBSfs025272@zion.cs.uiuc.edu> Author: foldr Date: Fri May 9 14:11:28 2008 New Revision: 50910 URL: http://llvm.org/viewvc/llvm-project?rev=50910&view=rev Log: Rename Example.td to Graph.td. Added: llvm/trunk/tools/llvmc2/Graph.td - copied, changed from r50908, llvm/trunk/tools/llvmc2/Example.td Removed: llvm/trunk/tools/llvmc2/Example.td Modified: llvm/trunk/tools/llvmc2/Makefile Removed: llvm/trunk/tools/llvmc2/Example.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Example.td?rev=50909&view=auto ============================================================================== --- llvm/trunk/tools/llvmc2/Example.td (original) +++ llvm/trunk/tools/llvmc2/Example.td (removed) @@ -1,47 +0,0 @@ -//===- Example.td - LLVMCC toolchain descriptions ---------*- tablegen -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains compilation graph description used by llvmcc. -// -//===----------------------------------------------------------------------===// - -include "Common.td" -include "Tools.td" - -// Toolchains - -def CompilationGraph : CompilationGraph<[ - Edge, - Edge, - Edge, - Edge, - - Edge, - Edge, - Edge, - - OptionalEdge, - OptionalEdge, - OptionalEdge, - Edge, - - Edge, - Edge, - OptionalEdge, - - - Edge, - OptionalEdge - ]>; Copied: llvm/trunk/tools/llvmc2/Graph.td (from r50908, llvm/trunk/tools/llvmc2/Example.td) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Graph.td?p2=llvm/trunk/tools/llvmc2/Graph.td&p1=llvm/trunk/tools/llvmc2/Example.td&r1=50908&r2=50910&rev=50910&view=diff ============================================================================== (empty) Modified: llvm/trunk/tools/llvmc2/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Makefile?rev=50910&r1=50909&r2=50910&view=diff ============================================================================== --- llvm/trunk/tools/llvmc2/Makefile (original) +++ llvm/trunk/tools/llvmc2/Makefile Fri May 9 14:11:28 2008 @@ -14,7 +14,7 @@ include $(LEVEL)/Makefile.common -TOOLS_SOURCE=Example.td Tools.td Common.td +TOOLS_SOURCE=Graph.td Tools.td Common.td # TOFIX: integrate this part into Makefile.rules? # The degree of horrorshowness in that file is too much for me atm. From evan.cheng at apple.com Fri May 9 14:56:32 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 09 May 2008 19:56:32 -0000 Subject: [llvm-commits] [llvm] r50911 - /llvm/trunk/test/CodeGen/X86/vec_set-E.ll Message-ID: <200805091956.m49JuWFJ026579@zion.cs.uiuc.edu> Author: evancheng Date: Fri May 9 14:56:32 2008 New Revision: 50911 URL: http://llvm.org/viewvc/llvm-project?rev=50911&view=rev Log: Simplify test. Modified: llvm/trunk/test/CodeGen/X86/vec_set-E.ll Modified: llvm/trunk/test/CodeGen/X86/vec_set-E.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_set-E.ll?rev=50911&r1=50910&r2=50911&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_set-E.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_set-E.ll Fri May 9 14:56:32 2008 @@ -1,10 +1,9 @@ ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep movq -define i32 @t(float %X) nounwind { +define <4 x float> @t(float %X) nounwind { %tmp11 = insertelement <4 x float> undef, float %X, i32 0 %tmp12 = insertelement <4 x float> %tmp11, float %X, i32 1 %tmp27 = insertelement <4 x float> %tmp12, float 0.000000e+00, i32 2 %tmp28 = insertelement <4 x float> %tmp27, float 0.000000e+00, i32 3 - store <4 x float> %tmp28, <4 x float>* null, align 16 - ret i32 0 + ret <4 x float> %tmp28 } From edwintorok at gmail.com Fri May 9 15:35:45 2008 From: edwintorok at gmail.com (Torok Edwin) Date: Fri, 09 May 2008 20:35:45 -0000 Subject: [llvm-commits] [llvm] r50912 - /llvm/trunk/lib/Analysis/LibCallAliasAnalysis.cpp Message-ID: <200805092035.m49KZkXX027737@zion.cs.uiuc.edu> Author: edwin Date: Fri May 9 15:35:45 2008 New Revision: 50912 URL: http://llvm.org/viewvc/llvm-project?rev=50912&view=rev Log: put LibCallAliasAnalysis into anonymous namespace to avoid clashes on ::X Modified: llvm/trunk/lib/Analysis/LibCallAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/LibCallAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LibCallAliasAnalysis.cpp?rev=50912&r1=50911&r2=50912&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LibCallAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/LibCallAliasAnalysis.cpp Fri May 9 15:35:45 2008 @@ -18,7 +18,7 @@ #include "llvm/Target/TargetData.h" using namespace llvm; -namespace llvm { +namespace { /// LibCallAliasAnalysis - Alias analysis driven from LibCallInfo. struct LibCallAliasAnalysis : public FunctionPass, AliasAnalysis { static char ID; // Class identification From edwintorok at gmail.com Fri May 9 15:38:19 2008 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Fri, 09 May 2008 23:38:19 +0300 Subject: [llvm-commits] LibCallAliasAnalysis should be in anonymous namespace In-Reply-To: <20080508214106.GJ27072@katherina.student.utwente.nl> References: <48236B1A.3030309@gmail.com> <20080508214106.GJ27072@katherina.student.utwente.nl> Message-ID: <4824B63B.5040205@gmail.com> Matthijs Kooijman wrote: > Hi, > > >> -namespace llvm { >> +namespace { >> /// LibCallAliasAnalysis - Alias analysis driven from LibCallInfo. >> struct LibCallAliasAnalysis : public FunctionPass, AliasAnalysis { >> static char ID; // Class identification >> > Following other examples, shouldn't there also be a VISIBILITY_HIDDEN put in > there somewhere? Probably yes, however I don't understand what implications VISIBILITY_HIDDEN has, so I have only commited the namespace change for now. I would leave the VISIBILITY_HIDDEN stuff till after the release. --Edwin From clattner at apple.com Fri May 9 16:05:33 2008 From: clattner at apple.com (Chris Lattner) Date: Fri, 9 May 2008 14:05:33 -0700 Subject: [llvm-commits] LibCallAliasAnalysis should be in anonymous namespace In-Reply-To: <4824B63B.5040205@gmail.com> References: <48236B1A.3030309@gmail.com> <20080508214106.GJ27072@katherina.student.utwente.nl> <4824B63B.5040205@gmail.com> Message-ID: On May 9, 2008, at 1:38 PM, T?r?k Edwin wrote: > Matthijs Kooijman wrote: >> Hi, >> >> >>> -namespace llvm { >>> +namespace { >>> /// LibCallAliasAnalysis - Alias analysis driven from LibCallInfo. >>> struct LibCallAliasAnalysis : public FunctionPass, AliasAnalysis { >>> static char ID; // Class identification >>> >> Following other examples, shouldn't there also be a >> VISIBILITY_HIDDEN put in >> there somewhere? > > Probably yes, however I don't understand what implications > VISIBILITY_HIDDEN has, > so I have only commited the namespace change for now. > I would leave the VISIBILITY_HIDDEN stuff till after the release. Marking stuff VISIBILITY_HIDDEN was a horrible hack to work around a bug in GCC's older than 4.2. This bug manifested itself in poor performance, not a correctness issue. I think I was the only one who cared about this before, and now care about 4.2... so I'm ok if we decide to remove this entirely. That said, we could wait a couple release to remove all of them, because gcc's prior to 4.2 are still in wide use. -Chris From dpatel at apple.com Fri May 9 16:07:57 2008 From: dpatel at apple.com (Devang Patel) Date: Fri, 09 May 2008 21:07:57 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50914 - /llvm-gcc-4.2/trunk/gcc/testsuite/g++.old-deja/g++.pt/const2.C Message-ID: <200805092107.m49L7veL028799@zion.cs.uiuc.edu> Author: dpatel Date: Fri May 9 16:07:57 2008 New Revision: 50914 URL: http://llvm.org/viewvc/llvm-project?rev=50914&view=rev Log: remove extra check Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.old-deja/g++.pt/const2.C Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.old-deja/g++.pt/const2.C URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.old-deja/g%2B%2B.pt/const2.C?rev=50914&r1=50913&r2=50914&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/g++.old-deja/g++.pt/const2.C (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.old-deja/g++.pt/const2.C Fri May 9 16:07:57 2008 @@ -1,8 +1,7 @@ // { dg-do link } // This test should get a linker error for the reference to A::i. // { dg-error "i" "" { target *-*-* } 0 } -// APPLE LOCAL 5317196 -// { dg-error ".*" "" { target *-*-darwin* } 0 } +// LLVM LOCAL remove extra check template struct B { static const int i = 3; }; template struct A { static const int i = B::i; }; From dalej at apple.com Fri May 9 16:24:35 2008 From: dalej at apple.com (Dale Johannesen) Date: Fri, 09 May 2008 21:24:35 -0000 Subject: [llvm-commits] [llvm] r50916 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp Message-ID: <200805092124.m49LOZhb029238@zion.cs.uiuc.edu> Author: johannes Date: Fri May 9 16:24:35 2008 New Revision: 50916 URL: http://llvm.org/viewvc/llvm-project?rev=50916&view=rev Log: Rewrite tail merging algorithm to handle the case where there are multiple blocks with a large number of common tail instructions more efficiently (compile time optimization). Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=50916&r1=50915&r2=50916&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Fri May 9 16:24:35 2008 @@ -72,7 +72,10 @@ MachineBasicBlock *SplitMBBAt(MachineBasicBlock &CurMBB, MachineBasicBlock::iterator BBI1); - std::vector > MergePotentials; + typedef std::pair MergePotentialsElt; + std::vector MergePotentials; + typedef std::vector::iterator MPIterator; + const TargetRegisterInfo *RegInfo; RegScavenger *RS; // Branch optzn. @@ -506,129 +509,153 @@ bool BranchFolder::TryMergeBlocks(MachineBasicBlock *SuccBB, MachineBasicBlock* PredBB) { + // We cannot jump to the entry block, which affects various choices below. + MachineBasicBlock *Entry = MergePotentials.begin()->second-> + getParent()->begin(); + // It doesn't make sense to save a single instruction since tail merging // will add a jump. // FIXME: Ask the target to provide the threshold? unsigned minCommonTailLength = (SuccBB ? 1 : 2) + 1; MadeChange = false; + DOUT << "\nTryMergeBlocks " << MergePotentials.size(); // Sort by hash value so that blocks with identical end sequences sort // together. std::stable_sort(MergePotentials.begin(), MergePotentials.end(), MergeCompare); // Walk through equivalence sets looking for actual exact matches. while (MergePotentials.size() > 1) { - unsigned CurHash = (MergePotentials.end()-1)->first; - unsigned PrevHash = (MergePotentials.end()-2)->first; - MachineBasicBlock *CurMBB = (MergePotentials.end()-1)->second; - - // If there is nothing that matches the hash of the current basic block, - // give up. - if (CurHash != PrevHash) { - if (SuccBB && CurMBB != PredBB) - FixTail(CurMBB, SuccBB, TII); - MergePotentials.pop_back(); - continue; - } + unsigned CurHash = prior(MergePotentials.end())->first; - // Look through all the pairs of blocks that have the same hash as this - // one, and find the pair that has the largest number of instructions in - // common. - // Since instructions may get combined later (e.g. single stores into - // store multiple) this measure is not particularly accurate. - MachineBasicBlock::iterator BBI1, BBI2; - - unsigned FoundI = ~0U, FoundJ = ~0U; + // Look through all the other blocks that have the same hash as this + // one, and build a vector of all those that have the (same) largest number + // of instructions in common. + // Order of elements in SameTails is the reverse of the order in which + // those blocks appear in MergePotentials (where they are not necessarily + // consecutive). + typedef std::pair SameTailElt; + std::vector SameTails; + unsigned maxCommonTailLength = 0U; - for (int i = MergePotentials.size()-1; - i != -1 && MergePotentials[i].first == CurHash; --i) { - for (int j = i-1; - j != -1 && MergePotentials[j].first == CurHash; --j) { - MachineBasicBlock::iterator TrialBBI1, TrialBBI2; + SameTails.clear(); + MachineBasicBlock::iterator TrialBBI1, TrialBBI2; + MPIterator HighestMPIter = prior(MergePotentials.end()); + for (MPIterator CurMPIter = prior(MergePotentials.end()), + B = MergePotentials.begin(); + CurMPIter!=B && CurMPIter->first==CurHash; + --CurMPIter) { + for (MPIterator I = prior(CurMPIter); I->first==CurHash ; --I) { unsigned CommonTailLen = ComputeCommonTailLength( - MergePotentials[i].second, - MergePotentials[j].second, - TrialBBI1, TrialBBI2); - if (CommonTailLen >= minCommonTailLength && - CommonTailLen > maxCommonTailLength) { - FoundI = i; - FoundJ = j; - maxCommonTailLength = CommonTailLen; - BBI1 = TrialBBI1; - BBI2 = TrialBBI2; + CurMPIter->second, + I->second, + TrialBBI1, TrialBBI2); + if (CommonTailLen >= minCommonTailLength) { + if (CommonTailLen > maxCommonTailLength) { + SameTails.clear(); + maxCommonTailLength = CommonTailLen; + HighestMPIter = CurMPIter; + SameTails.push_back(std::make_pair(CurMPIter, TrialBBI1)); + } + if (HighestMPIter == CurMPIter && + CommonTailLen == maxCommonTailLength) + SameTails.push_back(std::make_pair(I, TrialBBI2)); } + if (I==B) + break; } } // If we didn't find any pair that has at least minCommonTailLength - // instructions in common, bail out. All entries with this - // hash code can go away now. - if (FoundI == ~0U) { - for (int i = MergePotentials.size()-1; - i != -1 && MergePotentials[i].first == CurHash; --i) { + // instructions in common, remove all blocks with this hash code and retry. + if (SameTails.empty()) { + for (MPIterator CurMPIter = prior(MergePotentials.end()), + B = MergePotentials.begin(); + CurMPIter->first==CurHash; + --CurMPIter) { // Put the unconditional branch back, if we need one. - CurMBB = MergePotentials[i].second; + MachineBasicBlock *CurMBB = CurMPIter->second; if (SuccBB && CurMBB != PredBB) FixTail(CurMBB, SuccBB, TII); - MergePotentials.pop_back(); + MergePotentials.erase(CurMPIter); + if (CurMPIter==B) + break; } continue; } - // Otherwise, move the block(s) to the right position(s). So that - // BBI1/2 will be valid, the last must be I and the next-to-last J. - if (FoundI != MergePotentials.size()-1) - std::swap(MergePotentials[FoundI], *(MergePotentials.end()-1)); - if (FoundJ != MergePotentials.size()-2) - std::swap(MergePotentials[FoundJ], *(MergePotentials.end()-2)); + // If one of the blocks is the entire common tail (and not the entry + // block, which we can't jump to), treat all blocks with this same + // tail at once. + unsigned int i; + for (i=0; isecond; + if (MBB->begin() == SameTails[i].second && MBB != Entry) + break; + } + if (i!=SameTails.size()) { + MachineBasicBlock *MBB = SameTails[i].first->second; + // MBB is common tail. Adjust all other BB's to jump to this one. + // Traversal must be forwards so erases work. + DOUT << "\nUsing common tail " << MBB->getNumber() << " for "; + for (unsigned int j=0; jsecond->getNumber() << ","; + // Hack the end off BB j, making it jump to BB i instead. + ReplaceTailWithBranchTo(SameTails[j].second, MBB); + // This modifies BB j, so remove it from the worklist. + MergePotentials.erase(SameTails[j].first); + } + DOUT << "\n"; + // We leave i in the worklist in case there are other blocks that + // match it with a smaller number of instructions. + MadeChange = true; + continue; + } + + // Otherwise, merge the 2 blocks in SameTails that are latest in + // MergePotentials; these are at indices 0 and 1 in SameTails. + MachineBasicBlock::iterator BBI1 = (SameTails[0]).second; + MachineBasicBlock::iterator BBI2 = (SameTails[1]).second; + MachineBasicBlock *MBB1 = (SameTails[0]).first->second; + MachineBasicBlock *MBB2 = (SameTails[1]).first->second; - CurMBB = (MergePotentials.end()-1)->second; - MachineBasicBlock *MBB2 = (MergePotentials.end()-2)->second; + DOUT << "\nMerging " << MBB1->getNumber() << "," << + MBB2->getNumber() << ", size " << maxCommonTailLength; - // If neither block is the entire common tail, split the tail of one block - // to make it redundant with the other tail. Also, we cannot jump to the + // Neither block is the entire common tail; split the tail of one block + // to make it redundant with the other tail. We cannot jump to the // entry block, so if one block is the entry block, split the other one. - MachineBasicBlock *Entry = CurMBB->getParent()->begin(); - if (CurMBB->begin() == BBI1 && CurMBB != Entry) - ; // CurMBB is common tail - else if (MBB2->begin() == BBI2 && MBB2 != Entry) - ; // MBB2 is common tail - else { - if (0) { // Enable this to disable partial tail merges. - MergePotentials.pop_back(); - continue; - } - - MachineBasicBlock::iterator TrialBBI1, TrialBBI2; - unsigned CommonTailLen = ComputeCommonTailLength(CurMBB, MBB2, - TrialBBI1, TrialBBI2); - if (CommonTailLen < minCommonTailLength) - continue; - // Decide whether we want to split CurMBB or MBB2. - if (ShouldSplitFirstBlock(CurMBB, BBI1, MBB2, BBI2, PredBB)) { - CurMBB = SplitMBBAt(*CurMBB, BBI1); - BBI1 = CurMBB->begin(); - MergePotentials.back().second = CurMBB; - } else { - MBB2 = SplitMBBAt(*MBB2, BBI2); - BBI2 = MBB2->begin(); - (MergePotentials.end()-2)->second = MBB2; - } + // The second half of the split block will remain in SameTails, and will + // consist entirely of common code. Thus in the case where there are multiple + // blocks that would all need to be split, the next iteration of the + // outer loop will handle all the rest of them. + + // Decide whether we want to split MBB1 or MBB2. + if (ShouldSplitFirstBlock(MBB1, BBI1, MBB2, BBI2, PredBB)) { + MBB1 = SplitMBBAt(*MBB1, BBI1); + BBI1 = MBB1->begin(); + SameTails[0].first->second = MBB1; + } else { + MBB2 = SplitMBBAt(*MBB2, BBI2); + BBI2 = MBB2->begin(); + SameTails[1].first->second = MBB2; } if (MBB2->begin() == BBI2 && MBB2 != Entry) { - // Hack the end off CurMBB, making it jump to MBBI@ instead. + // Hack the end off MBB1, making it jump to MBB2 instead. ReplaceTailWithBranchTo(BBI1, MBB2); - // This modifies CurMBB, so remove it from the worklist. - MergePotentials.pop_back(); + // This modifies MBB1, so remove it from the worklist. + MergePotentials.erase(SameTails[0].first); } else { - assert(CurMBB->begin() == BBI1 && CurMBB != Entry && + assert(MBB1->begin() == BBI1 && MBB1 != Entry && "Didn't split block correctly?"); - // Hack the end off MBB2, making it jump to CurMBB instead. - ReplaceTailWithBranchTo(BBI2, CurMBB); + // Hack the end off MBB2, making it jump to MBB1 instead. + ReplaceTailWithBranchTo(BBI2, MBB1); // This modifies MBB2, so remove it from the worklist. - MergePotentials.erase(MergePotentials.end()-2); + MergePotentials.erase(SameTails[1].first); } MadeChange = true; } @@ -648,7 +675,8 @@ MergePotentials.push_back(std::make_pair(HashEndOfMBB(I, 2U), I)); } // See if we can do any tail merging on those. - if (MergePotentials.size() < TailMergeThreshold) + if (MergePotentials.size() < TailMergeThreshold && + MergePotentials.size() >= 2) MadeChange |= TryMergeBlocks(NULL, NULL); // Look at blocks (IBB) with multiple predecessors (PBB). From evan.cheng at apple.com Fri May 9 16:50:23 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 09 May 2008 21:50:23 -0000 Subject: [llvm-commits] [llvm] r50917 - /llvm/trunk/include/llvm/Target/TargetLowering.h Message-ID: <200805092150.m49LoNJK029903@zion.cs.uiuc.edu> Author: evancheng Date: Fri May 9 16:50:23 2008 New Revision: 50917 URL: http://llvm.org/viewvc/llvm-project?rev=50917&view=rev Log: Make OpActionsCapacity multiple of 4. Modified: llvm/trunk/include/llvm/Target/TargetLowering.h Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=50917&r1=50916&r2=50917&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Fri May 9 16:50:23 2008 @@ -1341,7 +1341,7 @@ MVT::ValueType TransformToType[MVT::LAST_VALUETYPE]; // Defines the capacity of the TargetLowering::OpActions table - static const int OpActionsCapacity = 173; + static const int OpActionsCapacity = 176; /// OpActions - For each operation and each value type, keep a LegalizeAction /// that indicates how instruction selection should deal with the operation. @@ -1381,7 +1381,8 @@ /// TargetDAGCombineArray - Targets can specify ISD nodes that they would /// like PerformDAGCombine callbacks for by calling setTargetDAGCombine(), /// which sets a bit in this array. - unsigned char TargetDAGCombineArray[168/(sizeof(unsigned char)*8)]; + unsigned char + TargetDAGCombineArray[OpActionsCapacity/(sizeof(unsigned char)*8)]; /// PromoteToType - For operations that must be promoted to a specific type, /// this holds the destination type. This map should be sparse, so don't hold From evan.cheng at apple.com Fri May 9 16:53:03 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 09 May 2008 21:53:03 -0000 Subject: [llvm-commits] [llvm] r50918 - in /llvm/trunk: lib/Target/X86/X86ISelDAGToDAG.cpp lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h lib/Target/X86/X86InstrMMX.td lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/vec_set-C.ll test/CodeGen/X86/vec_set-F.ll Message-ID: <200805092153.m49Lr3Vp029987@zion.cs.uiuc.edu> Author: evancheng Date: Fri May 9 16:53:03 2008 New Revision: 50918 URL: http://llvm.org/viewvc/llvm-project?rev=50918&view=rev Log: Handle a few more cases of folding load i64 into xmm and zero top bits. Note, some of the code will be moved into target independent part of DAG combiner in a subsequent patch. Added: llvm/trunk/test/CodeGen/X86/vec_set-F.ll Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h llvm/trunk/lib/Target/X86/X86InstrMMX.td llvm/trunk/lib/Target/X86/X86InstrSSE.td llvm/trunk/test/CodeGen/X86/vec_set-C.ll Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=50918&r1=50917&r2=50918&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Fri May 9 16:53:03 2008 @@ -975,7 +975,7 @@ // Also handle the case where we explicitly require zeros in the top // elements. This is a vector shuffle from the zero vector. - if (N.getOpcode() == X86ISD::ZEXT_VMOVL && N.Val->hasOneUse() && + if (N.getOpcode() == X86ISD::VZEXT_MOVL && N.Val->hasOneUse() && // Check to see if the top elements are all zeros (or bitcast of zeros). N.getOperand(0).getOpcode() == ISD::SCALAR_TO_VECTOR && N.getOperand(0).Val->hasOneUse() && Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=50918&r1=50917&r2=50918&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri May 9 16:53:03 2008 @@ -715,6 +715,7 @@ // We have target-specific dag combine patterns for the following nodes: setTargetDAGCombine(ISD::VECTOR_SHUFFLE); + setTargetDAGCombine(ISD::BUILD_VECTOR); setTargetDAGCombine(ISD::SELECT); setTargetDAGCombine(ISD::STORE); @@ -3481,9 +3482,9 @@ &MaskVec[0], MaskVec.size())); } -/// getZextVMoveL - Return a zero-extending vector move low node. +/// getVZextMovL - Return a zero-extending vector move low node. /// -static SDOperand getZextVMoveL(MVT::ValueType VT, MVT::ValueType OpVT, +static SDOperand getVZextMovL(MVT::ValueType VT, MVT::ValueType OpVT, SDOperand SrcOp, SelectionDAG &DAG, const X86Subtarget *Subtarget) { if (VT == MVT::v2f64 || VT == MVT::v4f32) { @@ -3501,7 +3502,7 @@ // PR2108 OpVT = (OpVT == MVT::v2f64) ? MVT::v2i64 : MVT::v4i32; return DAG.getNode(ISD::BIT_CONVERT, VT, - DAG.getNode(X86ISD::ZEXT_VMOVL, OpVT, + DAG.getNode(X86ISD::VZEXT_MOVL, OpVT, DAG.getNode(ISD::SCALAR_TO_VECTOR, OpVT, SrcOp.getOperand(0).getOperand(0)))); } @@ -3509,7 +3510,7 @@ } return DAG.getNode(ISD::BIT_CONVERT, VT, - DAG.getNode(X86ISD::ZEXT_VMOVL, OpVT, + DAG.getNode(X86ISD::VZEXT_MOVL, OpVT, DAG.getNode(ISD::BIT_CONVERT, OpVT, SrcOp))); } @@ -3561,14 +3562,14 @@ SDOperand NewMask = NewOp.getOperand(2); if (isCommutedMOVL(NewMask.Val, true, false)) { NewOp = CommuteVectorShuffle(NewOp, NewV1, NewV2, NewMask, DAG); - return getZextVMoveL(VT, NewOp.getValueType(), NewV2, DAG, Subtarget); + return getVZextMovL(VT, NewOp.getValueType(), NewV2, DAG, Subtarget); } } } else if (ISD::isBuildVectorAllZeros(V1.Val)) { SDOperand NewOp= RewriteAsNarrowerShuffle(V1, V2, VT, PermMask, DAG, *this); if (NewOp.Val && X86::isMOVLMask(NewOp.getOperand(2).Val)) - return getZextVMoveL(VT, NewOp.getValueType(), NewOp.getOperand(1), + return getVZextMovL(VT, NewOp.getValueType(), NewOp.getOperand(1), DAG, Subtarget); } } @@ -3577,7 +3578,7 @@ if (V1IsUndef) return V2; if (ISD::isBuildVectorAllZeros(V1.Val)) - return getZextVMoveL(VT, VT, V2, DAG, Subtarget); + return getVZextMovL(VT, VT, V2, DAG, Subtarget); return Op; } @@ -5675,7 +5676,8 @@ case X86ISD::FNSTCW16m: return "X86ISD::FNSTCW16m"; case X86ISD::LCMPXCHG_DAG: return "X86ISD::LCMPXCHG_DAG"; case X86ISD::LCMPXCHG8_DAG: return "X86ISD::LCMPXCHG8_DAG"; - case X86ISD::ZEXT_VMOVL: return "X86ISD::ZEXT_VMOVL"; + case X86ISD::VZEXT_MOVL: return "X86ISD::VZEXT_MOVL"; + case X86ISD::VZEXT_LOAD: return "X86ISD::VZEXT_LOAD"; } } @@ -6302,6 +6304,55 @@ LD->getAlignment()); } +static SDNode *getBuildPairElt(SDNode *N, unsigned i) { + SDOperand Elt = N->getOperand(i); + if (Elt.getOpcode() != ISD::MERGE_VALUES) + return Elt.Val; + return Elt.getOperand(Elt.ResNo).Val; +} + +static SDOperand PerformBuildVectorCombine(SDNode *N, SelectionDAG &DAG, + const X86Subtarget *Subtarget) { + // Ignore single operand BUILD_VECTOR. + if (N->getNumOperands() == 1) + return SDOperand(); + + MVT::ValueType VT = N->getValueType(0); + MVT::ValueType EVT = MVT::getVectorElementType(VT); + if ((EVT != MVT::i64 && EVT != MVT::f64) || Subtarget->is64Bit()) + // We are looking for load i64 and zero extend. We want to transform + // it before legalizer has a chance to expand it. Also look for i64 + // BUILD_PAIR bit casted to f64. + return SDOperand(); + // This must be an insertion into a zero vector. + SDOperand HighElt = N->getOperand(1); + if (HighElt.getOpcode() != ISD::UNDEF && + !isZeroNode(HighElt)) + return SDOperand(); + + // Value must be a load. + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); + SDNode *Base = N->getOperand(0).Val; + if (!isa(Base)) { + if (Base->getOpcode() == ISD::BIT_CONVERT) + Base = Base->getOperand(0).Val; + if (Base->getOpcode() != ISD::BUILD_PAIR) + return SDOperand(); + SDNode *Pair = Base; + Base = getBuildPairElt(Pair, 0); + if (!ISD::isNON_EXTLoad(Base)) + return SDOperand(); + SDNode *NextLD = getBuildPairElt(Pair, 1); + if (!ISD::isNON_EXTLoad(NextLD) || + !isConsecutiveLoad(NextLD, Base, 1, 4/*32 bits*/, MFI)) + return SDOperand(); + } + LoadSDNode *LD = cast(Base); + + // Transform it into VZEXT_LOAD addr. + return DAG.getNode(X86ISD::VZEXT_LOAD, VT, LD->getChain(), LD->getBasePtr()); +} + /// PerformSELECTCombine - Do target-specific dag combines on SELECT nodes. static SDOperand PerformSELECTCombine(SDNode *N, SelectionDAG &DAG, const X86Subtarget *Subtarget) { @@ -6498,6 +6549,7 @@ switch (N->getOpcode()) { default: break; case ISD::VECTOR_SHUFFLE: return PerformShuffleCombine(N, DAG, Subtarget); + case ISD::BUILD_VECTOR: return PerformBuildVectorCombine(N, DAG, Subtarget); case ISD::SELECT: return PerformSELECTCombine(N, DAG, Subtarget); case ISD::STORE: return PerformSTORECombine(N, DAG, Subtarget); case X86ISD::FXOR: Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=50918&r1=50917&r2=50918&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Fri May 9 16:53:03 2008 @@ -201,8 +201,11 @@ // FNSTCW16m - Store FP control world into i16 memory. FNSTCW16m, - // ZEXT_VMOVL - Vector move low and zero extend. - ZEXT_VMOVL + // VZEXT_MOVL - Vector move low and zero extend. + VZEXT_MOVL, + + // VZEXT_LOAD - Load, scalar_to_vector, and zero extend. + VZEXT_LOAD }; } Modified: llvm/trunk/lib/Target/X86/X86InstrMMX.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrMMX.td?rev=50918&r1=50917&r2=50918&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrMMX.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrMMX.td Fri May 9 16:53:03 2008 @@ -201,12 +201,12 @@ def MMX_MOVZDI2PDIrr : MMXI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR32:$src), "movd\t{$src, $dst|$dst, $src}", [(set VR64:$dst, - (v2i32 (X86zvmovl (v2i32 (scalar_to_vector GR32:$src)))))]>; + (v2i32 (X86vzmovl (v2i32 (scalar_to_vector GR32:$src)))))]>; let AddedComplexity = 20 in def MMX_MOVZDI2PDIrm : MMXI<0x6E, MRMSrcMem, (outs VR64:$dst), (ins i32mem:$src), "movd\t{$src, $dst|$dst, $src}", [(set VR64:$dst, - (v2i32 (X86zvmovl (v2i32 + (v2i32 (X86vzmovl (v2i32 (scalar_to_vector (loadi32 addr:$src))))))]>; // Arithmetic Instructions @@ -560,9 +560,9 @@ // Move scalar to XMM zero-extended // movd to XMM register zero-extends let AddedComplexity = 15 in { - def : Pat<(v8i8 (X86zvmovl (bc_v8i8 (v2i32 (scalar_to_vector GR32:$src))))), + def : Pat<(v8i8 (X86vzmovl (bc_v8i8 (v2i32 (scalar_to_vector GR32:$src))))), (MMX_MOVZDI2PDIrr GR32:$src)>; - def : Pat<(v4i16 (X86zvmovl (bc_v8i8 (v2i32 (scalar_to_vector GR32:$src))))), + def : Pat<(v4i16 (X86vzmovl (bc_v4i16 (v2i32 (scalar_to_vector GR32:$src))))), (MMX_MOVZDI2PDIrr GR32:$src)>; } Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=50918&r1=50917&r2=50918&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Fri May 9 16:53:03 2008 @@ -47,7 +47,10 @@ def X86insrtps : SDNode<"X86ISD::INSERTPS", SDTypeProfile<1, 3, [SDTCisVT<0, v4f32>, SDTCisSameAs<0,1>, SDTCisVT<2, f32>, SDTCisPtrTy<3>]>>; -def X86zvmovl : SDNode<"X86ISD::ZEXT_VMOVL", SDTUnaryOp>; +def X86vzmovl : SDNode<"X86ISD::VZEXT_MOVL", + SDTypeProfile<1, 1, [SDTCisSameAs<0,1>]>>; +def X86vzload : SDNode<"X86ISD::VZEXT_LOAD", SDTLoad, + [SDNPHasChain, SDNPMayLoad]>; //===----------------------------------------------------------------------===// // SSE Complex Patterns @@ -1008,10 +1011,10 @@ let AddedComplexity = 20 in def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src), "movss\t{$src, $dst|$dst, $src}", - [(set VR128:$dst, (v4f32 (X86zvmovl (v4f32 (scalar_to_vector + [(set VR128:$dst, (v4f32 (X86vzmovl (v4f32 (scalar_to_vector (loadf32 addr:$src))))))]>; -def : Pat<(v4f32 (X86zvmovl (memopv4f32 addr:$src))), +def : Pat<(v4f32 (X86vzmovl (memopv4f32 addr:$src))), (MOVZSS2PSrm addr:$src)>; //===----------------------------------------------------------------------===// @@ -2266,22 +2269,23 @@ def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src), "movsd\t{$src, $dst|$dst, $src}", [(set VR128:$dst, - (v2f64 (X86zvmovl (v2f64 (scalar_to_vector + (v2f64 (X86vzmovl (v2f64 (scalar_to_vector (loadf64 addr:$src))))))]>; -def : Pat<(v2f64 (X86zvmovl (memopv2f64 addr:$src))), +def : Pat<(v2f64 (X86vzmovl (memopv2f64 addr:$src))), (MOVZSD2PDrm addr:$src)>; +def : Pat<(v2f64 (X86vzload addr:$src)), (MOVZSD2PDrm addr:$src)>; // movd / movq to XMM register zero-extends let AddedComplexity = 15 in { def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src), "movd\t{$src, $dst|$dst, $src}", - [(set VR128:$dst, (v4i32 (X86zvmovl + [(set VR128:$dst, (v4i32 (X86vzmovl (v4i32 (scalar_to_vector GR32:$src)))))]>; // This is X86-64 only. def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src), "mov{d|q}\t{$src, $dst|$dst, $src}", - [(set VR128:$dst, (v2i64 (X86zvmovl + [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 (scalar_to_vector GR64:$src)))))]>; } @@ -2289,28 +2293,30 @@ def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src), "movd\t{$src, $dst|$dst, $src}", [(set VR128:$dst, - (v4i32 (X86zvmovl (v4i32 (scalar_to_vector + (v4i32 (X86vzmovl (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>; def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src), "movq\t{$src, $dst|$dst, $src}", [(set VR128:$dst, - (v2i64 (X86zvmovl (v2i64 (scalar_to_vector + (v2i64 (X86vzmovl (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>, XS, Requires<[HasSSE2]>; } +def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>; + // Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in // IA32 document. movq xmm1, xmm2 does clear the high bits. let AddedComplexity = 15 in def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "movq\t{$src, $dst|$dst, $src}", - [(set VR128:$dst, (v2i64 (X86zvmovl (v2i64 VR128:$src))))]>, + [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>, XS, Requires<[HasSSE2]>; let AddedComplexity = 20 in def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), "movq\t{$src, $dst|$dst, $src}", - [(set VR128:$dst, (v2i64 (X86zvmovl + [(set VR128:$dst, (v2i64 (X86vzmovl (memopv2i64 addr:$src))))]>, XS, Requires<[HasSSE2]>; @@ -2758,9 +2764,9 @@ // movd to XMM register zero-extends let AddedComplexity = 15 in { // Zeroing a VR128 then do a MOVS{S|D} to the lower bits. -def : Pat<(v2f64 (X86zvmovl (v2f64 (scalar_to_vector FR64:$src)))), +def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))), (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>; -def : Pat<(v4f32 (X86zvmovl (v4f32 (scalar_to_vector FR32:$src)))), +def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))), (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE2]>; } @@ -2916,7 +2922,7 @@ def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc, VR128:$src, MOVL_shuffle_mask)), (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>; -def : Pat<(v2f64 (X86zvmovl (v2f64 VR128:$src))), +def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))), (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>; // FIXME: Temporary workaround since 2-wide shuffle is broken. Modified: llvm/trunk/test/CodeGen/X86/vec_set-C.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_set-C.ll?rev=50918&r1=50917&r2=50918&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_set-C.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_set-C.ll Fri May 9 16:53:03 2008 @@ -1,4 +1,5 @@ ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep movq +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep mov | count 1 ; RUN: llvm-as < %s | llc -march=x86-64 -mattr=+sse2 | grep movd define <2 x i64> @t1(i64 %x) nounwind { Added: llvm/trunk/test/CodeGen/X86/vec_set-F.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_set-F.ll?rev=50918&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_set-F.ll (added) +++ llvm/trunk/test/CodeGen/X86/vec_set-F.ll Fri May 9 16:53:03 2008 @@ -0,0 +1,19 @@ +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep movq +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep movsd +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep mov | count 3 + +define <2 x i64> @t1(<2 x i64>* %ptr) nounwind { + %tmp45 = bitcast <2 x i64>* %ptr to <2 x i32>* + %tmp615 = load <2 x i32>* %tmp45 + %tmp7 = bitcast <2 x i32> %tmp615 to i64 + %tmp8 = insertelement <2 x i64> zeroinitializer, i64 %tmp7, i32 0 + ret <2 x i64> %tmp8 +} + +define <2 x i64> @t2(i64 %x) nounwind { + %tmp717 = bitcast i64 %x to double + %tmp8 = insertelement <2 x double> undef, double %tmp717, i32 0 + %tmp9 = insertelement <2 x double> %tmp8, double 0.000000e+00, i32 1 + %tmp11 = bitcast <2 x double> %tmp9 to <2 x i64> + ret <2 x i64> %tmp11 +} From dalej at apple.com Fri May 9 18:28:24 2008 From: dalej at apple.com (Dale Johannesen) Date: Fri, 09 May 2008 23:28:24 -0000 Subject: [llvm-commits] [llvm] r50921 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp Message-ID: <200805092328.m49NSO4f032661@zion.cs.uiuc.edu> Author: johannes Date: Fri May 9 18:28:24 2008 New Revision: 50921 URL: http://llvm.org/viewvc/llvm-project?rev=50921&view=rev Log: Remove an evil vector bool. Cosmetic refactoring, no functional change. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=50921&r1=50920&r2=50921&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Fri May 9 18:28:24 2008 @@ -71,10 +71,15 @@ MachineBasicBlock *NewDest); MachineBasicBlock *SplitMBBAt(MachineBasicBlock &CurMBB, MachineBasicBlock::iterator BBI1); + unsigned ComputeSameTails(unsigned CurHash, unsigned minCommonTailLength); + void RemoveBlocksWithHash(unsigned CurHash, MachineBasicBlock* SuccBB, + MachineBasicBlock* PredBB); typedef std::pair MergePotentialsElt; - std::vector MergePotentials; typedef std::vector::iterator MPIterator; + std::vector MergePotentials; + typedef std::pair SameTailElt; + std::vector SameTails; const TargetRegisterInfo *RegInfo; RegScavenger *RS; @@ -221,8 +226,7 @@ // If a jump table was merge with another one, walk the function rewriting // references to jump tables to reference the new JT ID's. Keep track of // whether we see a jump table idx, if not, we can delete the JT. - std::vector JTIsLive; - JTIsLive.resize(JTs.size()); + BitVector JTIsLive(JTs.size()); for (MachineFunction::iterator BB = MF.begin(), E = MF.end(); BB != E; ++BB) { for (MachineBasicBlock::iterator I = BB->begin(), E = BB->end(); @@ -234,7 +238,7 @@ Op.setIndex(NewIdx); // Remember that this JT is live. - JTIsLive[NewIdx] = true; + JTIsLive.set(NewIdx); } } @@ -242,7 +246,7 @@ // indirect jump was unreachable (and thus deleted) or because the jump // table was merged with some other one. for (unsigned i = 0, e = JTIsLive.size(); i != e; ++i) - if (!JTIsLive[i]) { + if (!JTIsLive.test(i)) { JTI->RemoveJumpTable(i); EverMadeChange = true; } @@ -468,7 +472,7 @@ if (I != MF->end() && !TII->AnalyzeBranch(*CurMBB, TBB, FBB, Cond)) { MachineBasicBlock *NextBB = I; - if (TBB == NextBB && Cond.size() && !FBB) { + if (TBB == NextBB && !Cond.empty() && !FBB) { if (!TII->ReverseBranchCondition(Cond)) { TII->RemoveBranch(*CurMBB); TII->InsertBranch(*CurMBB, SuccBB, NULL, Cond); @@ -499,6 +503,68 @@ } } +/// ComputeSameTails - Look through all the blocks in MergePotentials that have +/// hash CurHash (guaranteed to match the last element). Build the vector +/// SameTails of all those that have the (same) largest number of instructions +/// in common of any pair of these blocks. SameTails entries contain an +/// iterator into MergePotentials (from which the MachineBasicBlock can be +/// found) and a MachineBasicBlock::iterator into that MBB indicating the +/// instruction where the matching code sequence begins. +/// Order of elements in SameTails is the reverse of the order in which +/// those blocks appear in MergePotentials (where they are not necessarily +/// consecutive). +unsigned BranchFolder::ComputeSameTails(unsigned CurHash, + unsigned minCommonTailLength) { + unsigned maxCommonTailLength = 0U; + SameTails.clear(); + MachineBasicBlock::iterator TrialBBI1, TrialBBI2; + MPIterator HighestMPIter = prior(MergePotentials.end()); + for (MPIterator CurMPIter = prior(MergePotentials.end()), + B = MergePotentials.begin(); + CurMPIter!=B && CurMPIter->first==CurHash; + --CurMPIter) { + for (MPIterator I = prior(CurMPIter); I->first==CurHash ; --I) { + unsigned CommonTailLen = ComputeCommonTailLength( + CurMPIter->second, + I->second, + TrialBBI1, TrialBBI2); + if (CommonTailLen >= minCommonTailLength) { + if (CommonTailLen > maxCommonTailLength) { + SameTails.clear(); + maxCommonTailLength = CommonTailLen; + HighestMPIter = CurMPIter; + SameTails.push_back(std::make_pair(CurMPIter, TrialBBI1)); + } + if (HighestMPIter == CurMPIter && + CommonTailLen == maxCommonTailLength) + SameTails.push_back(std::make_pair(I, TrialBBI2)); + } + if (I==B) + break; + } + } + return maxCommonTailLength; +} + +/// RemoveBlocksWithHash - Remove all blocks with hash CurHash from +/// MergePotentials, restoring branches at ends of blocks as appropriate. +void BranchFolder::RemoveBlocksWithHash(unsigned CurHash, + MachineBasicBlock* SuccBB, + MachineBasicBlock* PredBB) { + for (MPIterator CurMPIter = prior(MergePotentials.end()), + B = MergePotentials.begin(); + CurMPIter->first==CurHash; + --CurMPIter) { + // Put the unconditional branch back, if we need one. + MachineBasicBlock *CurMBB = CurMPIter->second; + if (SuccBB && CurMBB != PredBB) + FixTail(CurMBB, SuccBB, TII); + MergePotentials.erase(CurMPIter); + if (CurMPIter==B) + break; + } +} + // See if any of the blocks in MergePotentials (which all have a common single // successor, or all have no successor) can be tail-merged. If there is a // successor, any blocks in MergePotentials that are not tail-merged and @@ -520,67 +586,24 @@ MadeChange = false; DOUT << "\nTryMergeBlocks " << MergePotentials.size(); + // Sort by hash value so that blocks with identical end sequences sort // together. - std::stable_sort(MergePotentials.begin(), MergePotentials.end(), MergeCompare); + std::stable_sort(MergePotentials.begin(), MergePotentials.end(),MergeCompare); // Walk through equivalence sets looking for actual exact matches. while (MergePotentials.size() > 1) { unsigned CurHash = prior(MergePotentials.end())->first; - // Look through all the other blocks that have the same hash as this - // one, and build a vector of all those that have the (same) largest number - // of instructions in common. - // Order of elements in SameTails is the reverse of the order in which - // those blocks appear in MergePotentials (where they are not necessarily - // consecutive). - typedef std::pair SameTailElt; - std::vector SameTails; - - unsigned maxCommonTailLength = 0U; - SameTails.clear(); - MachineBasicBlock::iterator TrialBBI1, TrialBBI2; - MPIterator HighestMPIter = prior(MergePotentials.end()); - for (MPIterator CurMPIter = prior(MergePotentials.end()), - B = MergePotentials.begin(); - CurMPIter!=B && CurMPIter->first==CurHash; - --CurMPIter) { - for (MPIterator I = prior(CurMPIter); I->first==CurHash ; --I) { - unsigned CommonTailLen = ComputeCommonTailLength( - CurMPIter->second, - I->second, - TrialBBI1, TrialBBI2); - if (CommonTailLen >= minCommonTailLength) { - if (CommonTailLen > maxCommonTailLength) { - SameTails.clear(); - maxCommonTailLength = CommonTailLen; - HighestMPIter = CurMPIter; - SameTails.push_back(std::make_pair(CurMPIter, TrialBBI1)); - } - if (HighestMPIter == CurMPIter && - CommonTailLen == maxCommonTailLength) - SameTails.push_back(std::make_pair(I, TrialBBI2)); - } - if (I==B) - break; - } - } + // Build SameTails, identifying the set of blocks with this hash code + // and with the maximum number of instructions in common. + unsigned maxCommonTailLength = ComputeSameTails(CurHash, + minCommonTailLength); // If we didn't find any pair that has at least minCommonTailLength // instructions in common, remove all blocks with this hash code and retry. if (SameTails.empty()) { - for (MPIterator CurMPIter = prior(MergePotentials.end()), - B = MergePotentials.begin(); - CurMPIter->first==CurHash; - --CurMPIter) { - // Put the unconditional branch back, if we need one. - MachineBasicBlock *CurMBB = CurMPIter->second; - if (SuccBB && CurMBB != PredBB) - FixTail(CurMBB, SuccBB, TII); - MergePotentials.erase(CurMPIter); - if (CurMPIter==B) - break; - } + RemoveBlocksWithHash(CurHash, SuccBB, PredBB); continue; } @@ -629,9 +652,9 @@ // entry block, so if one block is the entry block, split the other one. // The second half of the split block will remain in SameTails, and will - // consist entirely of common code. Thus in the case where there are multiple - // blocks that would all need to be split, the next iteration of the - // outer loop will handle all the rest of them. + // consist entirely of common code. Thus in the case where there are + // multiple blocks that would all need to be split, the next iteration of + // the outer loop will handle all the rest of them. // Decide whether we want to split MBB1 or MBB2. if (ShouldSplitFirstBlock(MBB1, BBI1, MBB2, BBI2, PredBB)) { @@ -717,7 +740,7 @@ // Failing case: IBB is the target of a cbr, and // we cannot reverse the branch. std::vector NewCond(Cond); - if (Cond.size() && TBB==IBB) { + if (!Cond.empty() && TBB==IBB) { if (TII->ReverseBranchCondition(NewCond)) continue; // This is the QBB case described above @@ -747,9 +770,9 @@ } } // Remove the unconditional branch at the end, if any. - if (TBB && (Cond.size()==0 || FBB)) { + if (TBB && (Cond.empty() || FBB)) { TII->RemoveBranch(*PBB); - if (Cond.size()) + if (!Cond.empty()) // reinsert conditional branch only, for now TII->InsertBranch(*PBB, (TBB==IBB) ? FBB : TBB, 0, NewCond); } From evan.cheng at apple.com Fri May 9 18:37:55 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 09 May 2008 23:37:55 -0000 Subject: [llvm-commits] [llvm] r50922 - in /llvm/trunk: lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/vec_set-G.ll Message-ID: <200805092337.m49NbteZ000438@zion.cs.uiuc.edu> Author: evancheng Date: Fri May 9 18:37:55 2008 New Revision: 50922 URL: http://llvm.org/viewvc/llvm-project?rev=50922&view=rev Log: Add a pattern to do move the low element of a v4f32 and zero extend the rest. Added: llvm/trunk/test/CodeGen/X86/vec_set-G.ll Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=50922&r1=50921&r2=50922&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Fri May 9 18:37:55 2008 @@ -2768,6 +2768,8 @@ (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>; def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))), (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE2]>; +def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))), + (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE2]>; } // Splat v2f64 / v2i64 Added: llvm/trunk/test/CodeGen/X86/vec_set-G.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_set-G.ll?rev=50922&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_set-G.ll (added) +++ llvm/trunk/test/CodeGen/X86/vec_set-G.ll Fri May 9 18:37:55 2008 @@ -0,0 +1,9 @@ +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep movss + +define fastcc void @t(<4 x float> %A) nounwind { + %tmp41896 = extractelement <4 x float> %A, i32 0 ; [#uses=1] + %tmp14082 = insertelement <4 x float> < float 0.000000e+00, float undef, float undef, float undef >, float %tmp41896, i32 1 ; <<4 x float>> [#uses=1] + %tmp14083 = insertelement <4 x float> %tmp14082, float 0.000000e+00, i32 2 ; <<4 x float>> [#uses=1] + store <4 x float> %tmp14083, <4 x float>* null, align 16 + ret void +} From isanbard at gmail.com Fri May 9 19:12:52 2008 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 10 May 2008 00:12:52 -0000 Subject: [llvm-commits] [llvm] r50926 - /llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Message-ID: <200805100012.m4A0CqhX001396@zion.cs.uiuc.edu> Author: void Date: Fri May 9 19:12:52 2008 New Revision: 50926 URL: http://llvm.org/viewvc/llvm-project?rev=50926&view=rev Log: Cosmetic changes: - Comment fixes. - Moar whitespace. - Made ivars "private" by default. No functionality change. Modified: llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Modified: llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp?rev=50926&r1=50925&r2=50926&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp (original) +++ llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Fri May 9 19:12:52 2008 @@ -49,26 +49,31 @@ STATISTIC(Num3AddrSunk, "Number of 3-address instructions sunk"); namespace { - struct VISIBILITY_HIDDEN TwoAddressInstructionPass - : public MachineFunctionPass { + class VISIBILITY_HIDDEN TwoAddressInstructionPass + : public MachineFunctionPass { const TargetInstrInfo *TII; const TargetRegisterInfo *TRI; MachineRegisterInfo *MRI; LiveVariables *LV; + bool Sink3AddrInstruction(MachineBasicBlock *MBB, MachineInstr *MI, + unsigned Reg, + MachineBasicBlock::iterator OldPos); public: static char ID; // Pass identification, replacement for typeid TwoAddressInstructionPass() : MachineFunctionPass((intptr_t)&ID) {} - virtual void getAnalysisUsage(AnalysisUsage &AU) const; + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); + AU.addPreserved(); + AU.addPreservedID(MachineLoopInfoID); + AU.addPreservedID(MachineDominatorsID); + AU.addPreservedID(PHIEliminationID); + MachineFunctionPass::getAnalysisUsage(AU); + } - /// runOnMachineFunction - pass entry point + /// runOnMachineFunction - Pass entry point. bool runOnMachineFunction(MachineFunction&); - - private: - bool Sink3AddrInstruction(MachineBasicBlock *MBB, MachineInstr *MI, - unsigned Reg, - MachineBasicBlock::iterator OldPos); }; char TwoAddressInstructionPass::ID = 0; @@ -78,19 +83,11 @@ const PassInfo *llvm::TwoAddressInstructionPassID = X.getPassInfo(); -void TwoAddressInstructionPass::getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired(); - AU.addPreserved(); - AU.addPreservedID(MachineLoopInfoID); - AU.addPreservedID(MachineDominatorsID); - AU.addPreservedID(PHIEliminationID); - MachineFunctionPass::getAnalysisUsage(AU); -} - /// Sink3AddrInstruction - A two-address instruction has been converted to a /// three-address instruction to avoid clobbering a register. Try to sink it -/// past the instruction that would kill the above mentioned register to -/// reduce register pressure. +/// past the instruction that would kill the above mentioned register to reduce +/// register pressure. +/// bool TwoAddressInstructionPass::Sink3AddrInstruction(MachineBasicBlock *MBB, MachineInstr *MI, unsigned SavedReg, MachineBasicBlock::iterator OldPos) { @@ -101,6 +98,7 @@ unsigned DefReg = 0; SmallSet UseRegs; + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { const MachineOperand &MO = MI->getOperand(i); if (!MO.isRegister()) @@ -123,6 +121,7 @@ // Find the instruction that kills SavedReg. MachineInstr *KillMI = NULL; + for (MachineRegisterInfo::use_iterator UI = MRI->use_begin(SavedReg), UE = MRI->use_end(); UI != UE; ++UI) { MachineOperand &UseMO = UI.getOperand(); @@ -131,19 +130,23 @@ KillMI = UseMO.getParent(); break; } + if (!KillMI || KillMI->getParent() != MBB) return false; - // If any of the definitions are used by another instruction between - // the position and the kill use, then it's not safe to sink it. - // FIXME: This can be sped up if there is an easy way to query whether - // an instruction if before or after another instruction. Then we can - // use MachineRegisterInfo def / use instead. + // If any of the definitions are used by another instruction between the + // position and the kill use, then it's not safe to sink it. + // + // FIXME: This can be sped up if there is an easy way to query whether an + // instruction if before or after another instruction. Then we can use + // MachineRegisterInfo def / use instead. MachineOperand *KillMO = NULL; MachineBasicBlock::iterator KillPos = KillMI; ++KillPos; + for (MachineBasicBlock::iterator I = next(OldPos); I != KillPos; ++I) { MachineInstr *OtherMI = I; + for (unsigned i = 0, e = OtherMI->getNumOperands(); i != e; ++i) { MachineOperand &MO = OtherMI->getOperand(i); if (!MO.isRegister()) @@ -153,6 +156,7 @@ continue; if (DefReg == MOReg) return false; + if (MO.isKill()) { if (OtherMI == KillMI && MOReg == SavedReg) // Save the operand that kills the register. We want unset the kill @@ -181,8 +185,7 @@ return true; } -/// runOnMachineFunction - Reduce two-address instructions to two -/// operands. +/// runOnMachineFunction - Reduce two-address instructions to two operands. /// bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) { DOUT << "Machine Function\n"; @@ -203,8 +206,8 @@ mi != me; ) { MachineBasicBlock::iterator nmi = next(mi); const TargetInstrDesc &TID = mi->getDesc(); - bool FirstTied = true; + for (unsigned si = 1, e = TID.getNumOperands(); si < e; ++si) { int ti = TID.getOperandConstraint(si, TOI::TIED_TO); if (ti == -1) @@ -214,15 +217,16 @@ ++NumTwoAddressInstrs; DOUT << '\t'; DEBUG(mi->print(*cerr.stream(), &TM)); } + FirstTied = false; assert(mi->getOperand(si).isRegister() && mi->getOperand(si).getReg() && mi->getOperand(si).isUse() && "two address instruction invalid"); - // if the two operands are the same we just remove the use + // If the two operands are the same we just remove the use // and mark the def as def&use, otherwise we have to insert a copy. if (mi->getOperand(ti).getReg() != mi->getOperand(si).getReg()) { - // rewrite: + // Rewrite: // a = b op c // to: // a = b @@ -257,9 +261,11 @@ assert(mi->getOperand(3-si).isRegister() && "Not a proper commutative instruction!"); unsigned regC = mi->getOperand(3-si).getReg(); + if (mi->killsRegister(regC)) { DOUT << "2addr: COMMUTING : " << *mi; MachineInstr *NewMI = TII->commuteInstruction(mi); + if (NewMI == 0) { DOUT << "2addr: COMMUTING FAILED!\n"; } else { @@ -285,7 +291,7 @@ // FIXME: This assumes there are no more operands which are tied // to another register. #ifndef NDEBUG - for (unsigned i = si+1, e = TID.getNumOperands(); i < e; ++i) + for (unsigned i = si + 1, e = TID.getNumOperands(); i < e; ++i) assert(TID.getOperandConstraint(i, TOI::TIED_TO) == -1); #endif @@ -293,19 +299,22 @@ DOUT << "2addr: CONVERTING 2-ADDR: " << *mi; DOUT << "2addr: TO 3-ADDR: " << *New; bool Sunk = false; + if (New->findRegisterUseOperand(regB, false, TRI)) // FIXME: Temporary workaround. If the new instruction doesn't // uses regB, convertToThreeAddress must have created more // then one instruction. Sunk = Sink3AddrInstruction(mbbi, New, regB, mi); - mbbi->erase(mi); // Nuke the old inst. + + mbbi->erase(mi); // Nuke the old inst. + if (!Sunk) { mi = New; nmi = next(mi); } + ++NumConvertedTo3Addr; - // Done with this instruction. - break; + break; // Done with this instruction. } } } @@ -317,17 +326,19 @@ MachineBasicBlock::iterator prevMi = prior(mi); DOUT << "\t\tprepend:\t"; DEBUG(prevMi->print(*cerr.stream(), &TM)); - // update live variables for regB + // Update live variables for regB. LiveVariables::VarInfo& varInfoB = LV->getVarInfo(regB); + // regB is used in this BB. varInfoB.UsedBlocks[mbbi->getNumber()] = true; + if (LV->removeVirtualRegisterKilled(regB, mbbi, mi)) LV->addVirtualRegisterKilled(regB, prevMi); if (LV->removeVirtualRegisterDead(regB, mbbi, mi)) LV->addVirtualRegisterDead(regB, prevMi); - // replace all occurences of regB with regA + // Replace all occurences of regB with regA. for (unsigned i = 0, e = mi->getNumOperands(); i != e; ++i) { if (mi->getOperand(i).isRegister() && mi->getOperand(i).getReg() == regB) @@ -341,6 +352,7 @@ DOUT << "\t\trewrite to:\t"; DEBUG(mi->print(*cerr.stream(), &TM)); } + mi = nmi; } } From evan.cheng at apple.com Fri May 9 19:17:50 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 10 May 2008 00:17:50 -0000 Subject: [llvm-commits] [llvm] r50927 - in /llvm/trunk: lib/CodeGen/PHIElimination.cpp test/CodeGen/X86/2008-05-09-PHIElimBug.ll Message-ID: <200805100017.m4A0HoAl001530@zion.cs.uiuc.edu> Author: evancheng Date: Fri May 9 19:17:50 2008 New Revision: 50927 URL: http://llvm.org/viewvc/llvm-project?rev=50927&view=rev Log: If all sources of a PHI node are defined by an implicit_def, just emit an implicit_def instead of a copy. Added: llvm/trunk/test/CodeGen/X86/2008-05-09-PHIElimBug.ll Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=50927&r1=50926&r2=50927&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Fri May 9 19:17:50 2008 @@ -127,11 +127,15 @@ return true; } -static bool isSourceDefinedByImplicitDef(MachineInstr *MPhi, unsigned SrcIdx, +static bool isSourceDefinedByImplicitDef(MachineInstr *MPhi, MachineRegisterInfo *MRI) { - unsigned SrcReg = MPhi->getOperand(SrcIdx*2+1).getReg(); - MachineInstr *DefMI = MRI->getVRegDef(SrcReg); - return DefMI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF; + for (unsigned i = 1; i != MPhi->getNumOperands(); i += 2) { + unsigned SrcReg = MPhi->getOperand(i).getReg(); + MachineInstr *DefMI = MRI->getVRegDef(SrcReg); + if (!DefMI || DefMI->getOpcode() != TargetInstrInfo::IMPLICIT_DEF) + return false; + } + return true; } /// LowerAtomicPHINode - Lower the PHI node at the top of the specified block, @@ -156,9 +160,9 @@ // into the phi node destination. // const TargetInstrInfo *TII = MF.getTarget().getInstrInfo(); - if (NumSrcs == 1 && isSourceDefinedByImplicitDef(MPhi, 0, MRI)) - // If the only source of a PHI node is an implicit_def, just emit an - // implicit_def instead of a copy. + if (isSourceDefinedByImplicitDef(MPhi, MRI)) + // If all sources of a PHI node are implicit_def, just emit an implicit_def + // instead of a copy. BuildMI(MBB, AfterPHIsIt, TII->get(TargetInstrInfo::IMPLICIT_DEF), DestReg); else TII->copyRegToReg(MBB, AfterPHIsIt, DestReg, IncomingReg, RC, RC); Added: llvm/trunk/test/CodeGen/X86/2008-05-09-PHIElimBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-05-09-PHIElimBug.ll?rev=50927&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-05-09-PHIElimBug.ll (added) +++ llvm/trunk/test/CodeGen/X86/2008-05-09-PHIElimBug.ll Fri May 9 19:17:50 2008 @@ -0,0 +1,25 @@ +; RUN: llvm-as < %s | llc -march=x86 + + %struct.V = type { <4 x float>, <4 x float>, <4 x float>, <4 x float>, <4 x float>, <4 x float>, <4 x float>, <4 x i32>, float*, float*, float*, float*, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, i32, i32, i32, i32, i32, i32, i32, i32 } + +define fastcc void @t() nounwind { +entry: + br i1 false, label %bb23816.preheader, label %bb23821 + +bb23816.preheader: ; preds = %entry + %tmp23735 = and i32 0, 2 ; [#uses=0] + br label %bb23830 + +bb23821: ; preds = %entry + br i1 false, label %bb23830, label %bb23827 + +bb23827: ; preds = %bb23821 + %tmp23829 = getelementptr %struct.V* null, i32 0, i32 42 ; [#uses=0] + br label %bb23830 + +bb23830: ; preds = %bb23827, %bb23821, %bb23816.preheader + %scaledInDst.2.reg2mem.5 = phi i8 [ undef, %bb23827 ], [ undef, %bb23821 ], [ undef, %bb23816.preheader ] ; [#uses=1] + %toBool35047 = icmp eq i8 %scaledInDst.2.reg2mem.5, 0 ; [#uses=1] + %bothcond39107 = or i1 %toBool35047, false ; [#uses=0] + unreachable +} From evan.cheng at apple.com Fri May 9 19:58:42 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 10 May 2008 00:58:42 -0000 Subject: [llvm-commits] [llvm] r50928 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200805100058.m4A0wg34002592@zion.cs.uiuc.edu> Author: evancheng Date: Fri May 9 19:58:41 2008 New Revision: 50928 URL: http://llvm.org/viewvc/llvm-project?rev=50928&view=rev Log: If movl top bits are undef, let it be selected to movlps, etc. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=50928&r1=50927&r2=50928&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri May 9 19:58:41 2008 @@ -6326,8 +6326,7 @@ return SDOperand(); // This must be an insertion into a zero vector. SDOperand HighElt = N->getOperand(1); - if (HighElt.getOpcode() != ISD::UNDEF && - !isZeroNode(HighElt)) + if (!isZeroNode(HighElt)) return SDOperand(); // Value must be a load. From evan.cheng at apple.com Fri May 9 19:59:18 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 10 May 2008 00:59:18 -0000 Subject: [llvm-commits] [llvm] r50929 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <200805100059.m4A0xIxc002625@zion.cs.uiuc.edu> Author: evancheng Date: Fri May 9 19:59:18 2008 New Revision: 50929 URL: http://llvm.org/viewvc/llvm-project?rev=50929&view=rev Log: Some clean up. Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=50929&r1=50928&r2=50929&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Fri May 9 19:59:18 2008 @@ -675,20 +675,21 @@ def MOVLPSrm : PSI<0x12, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2), "movlps\t{$src2, $dst|$dst, $src2}", - [(set VR128:$dst, - (v4f32 (vector_shuffle VR128:$src1, - (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))), - MOVLP_shuffle_mask)))]>; + [(set VR128:$dst, + (v4f32 (vector_shuffle VR128:$src1, + (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))), + MOVLP_shuffle_mask)))]>; def MOVHPSrm : PSI<0x16, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2), "movhps\t{$src2, $dst|$dst, $src2}", - [(set VR128:$dst, - (v4f32 (vector_shuffle VR128:$src1, - (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))), - MOVHP_shuffle_mask)))]>; + [(set VR128:$dst, + (v4f32 (vector_shuffle VR128:$src1, + (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))), + MOVHP_shuffle_mask)))]>; } // AddedComplexity } // Constraints = "$src1 = $dst" + def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src), "movlps\t{$src, $dst|$dst, $src}", [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)), @@ -2265,16 +2266,17 @@ // Move to lower bits of a VR128 and zeroing upper bits. // Loading from memory automatically zeroing upper bits. -let AddedComplexity = 20 in - def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src), - "movsd\t{$src, $dst|$dst, $src}", - [(set VR128:$dst, - (v2f64 (X86vzmovl (v2f64 (scalar_to_vector - (loadf64 addr:$src))))))]>; +let AddedComplexity = 20 in { +def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src), + "movsd\t{$src, $dst|$dst, $src}", + [(set VR128:$dst, + (v2f64 (X86vzmovl (v2f64 (scalar_to_vector + (loadf64 addr:$src))))))]>; def : Pat<(v2f64 (X86vzmovl (memopv2f64 addr:$src))), - (MOVZSD2PDrm addr:$src)>; + (MOVZSD2PDrm addr:$src)>; def : Pat<(v2f64 (X86vzload addr:$src)), (MOVZSD2PDrm addr:$src)>; +} // movd / movq to XMM register zero-extends let AddedComplexity = 15 in { @@ -2301,9 +2303,9 @@ (v2i64 (X86vzmovl (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>, XS, Requires<[HasSSE2]>; -} def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>; +} // Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in // IA32 document. movq xmm1, xmm2 does clear the high bits. From gohman at apple.com Fri May 9 20:26:14 2008 From: gohman at apple.com (Dan Gohman) Date: Sat, 10 May 2008 01:26:14 -0000 Subject: [llvm-commits] [llvm] r50930 - in /llvm/trunk/lib/Target/X86: X86ISelLowering.cpp X86ISelLowering.h Message-ID: <200805100126.m4A1QE6K003385@zion.cs.uiuc.edu> Author: djg Date: Fri May 9 20:26:14 2008 New Revision: 50930 URL: http://llvm.org/viewvc/llvm-project?rev=50930&view=rev Log: For now, abort when an ISD::VAARG is encountered on x86-64, rather than silently generate invalid code. llvm-gcc does not currently use VAArgInst; it lowers va_arg in the front-end. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=50930&r1=50929&r2=50930&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri May 9 20:26:14 2008 @@ -327,12 +327,14 @@ // VASTART needs to be custom lowered to use the VarArgsFrameIndex setOperationAction(ISD::VASTART , MVT::Other, Custom); - setOperationAction(ISD::VAARG , MVT::Other, Expand); setOperationAction(ISD::VAEND , MVT::Other, Expand); - if (Subtarget->is64Bit()) + if (Subtarget->is64Bit()) { + setOperationAction(ISD::VAARG , MVT::Other, Custom); setOperationAction(ISD::VACOPY , MVT::Other, Custom); - else + } else { + setOperationAction(ISD::VAARG , MVT::Other, Expand); setOperationAction(ISD::VACOPY , MVT::Other, Expand); + } setOperationAction(ISD::STACKSAVE, MVT::Other, Expand); setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand); @@ -4976,6 +4978,17 @@ return DAG.getNode(ISD::TokenFactor, MVT::Other, &MemOps[0], MemOps.size()); } +SDOperand X86TargetLowering::LowerVAARG(SDOperand Op, SelectionDAG &DAG) { + // X86-64 va_list is a struct { i32, i32, i8*, i8* }. + assert(Subtarget->is64Bit() && "This code only handles 64-bit va_arg!"); + SDOperand Chain = Op.getOperand(0); + SDOperand SrcPtr = Op.getOperand(1); + SDOperand SrcSV = Op.getOperand(2); + + assert(0 && "VAArgInst is not yet implemented for x86-64!"); + abort(); +} + SDOperand X86TargetLowering::LowerVACOPY(SDOperand Op, SelectionDAG &DAG) { // X86-64 va_list is a struct { i32, i32, i8*, i8* }. assert(Subtarget->is64Bit() && "This code only handles 64-bit va_copy!"); @@ -5598,6 +5611,7 @@ case ISD::RET: return LowerRET(Op, DAG); case ISD::FORMAL_ARGUMENTS: return LowerFORMAL_ARGUMENTS(Op, DAG); case ISD::VASTART: return LowerVASTART(Op, DAG); + case ISD::VAARG: return LowerVAARG(Op, DAG); case ISD::VACOPY: return LowerVACOPY(Op, DAG); case ISD::INTRINSIC_WO_CHAIN: return LowerINTRINSIC_WO_CHAIN(Op, DAG); case ISD::RETURNADDR: return LowerRETURNADDR(Op, DAG); Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=50930&r1=50929&r2=50930&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Fri May 9 20:26:14 2008 @@ -517,6 +517,7 @@ SDOperand LowerDYNAMIC_STACKALLOC(SDOperand Op, SelectionDAG &DAG); SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG); SDOperand LowerVASTART(SDOperand Op, SelectionDAG &DAG); + SDOperand LowerVAARG(SDOperand Op, SelectionDAG &DAG); SDOperand LowerVACOPY(SDOperand Op, SelectionDAG &DAG); SDOperand LowerINTRINSIC_WO_CHAIN(SDOperand Op, SelectionDAG &DAG); SDOperand LowerRETURNADDR(SDOperand Op, SelectionDAG &DAG); From evan.cheng at apple.com Fri May 9 21:22:25 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 10 May 2008 02:22:25 -0000 Subject: [llvm-commits] [llvm] r50931 - /llvm/trunk/test/CodeGen/X86/vec_shuffle-2.ll Message-ID: <200805100222.m4A2MPnH005193@zion.cs.uiuc.edu> Author: evancheng Date: Fri May 9 21:22:25 2008 New Revision: 50931 URL: http://llvm.org/viewvc/llvm-project?rev=50931&view=rev Log: Add nounwind. Modified: llvm/trunk/test/CodeGen/X86/vec_shuffle-2.ll Modified: llvm/trunk/test/CodeGen/X86/vec_shuffle-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_shuffle-2.ll?rev=50931&r1=50930&r2=50931&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_shuffle-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_shuffle-2.ll Fri May 9 21:22:25 2008 @@ -3,7 +3,7 @@ ; RUN: grep pshuflw %t | count 1 ; RUN: grep movhps %t | count 1 -define void @test1(<2 x i64>* %res, <2 x i64>* %A) { +define void @test1(<2 x i64>* %res, <2 x i64>* %A) nounwind { %tmp = load <2 x i64>* %A ; <<2 x i64>> [#uses=1] %tmp.upgrd.1 = bitcast <2 x i64> %tmp to <8 x i16> ; <<8 x i16>> [#uses=8] %tmp0 = extractelement <8 x i16> %tmp.upgrd.1, i32 0 ; [#uses=1] @@ -27,7 +27,7 @@ ret void } -define void @test2(<4 x float>* %r, <2 x i32>* %A) { +define void @test2(<4 x float>* %r, <2 x i32>* %A) nounwind { %tmp = load <4 x float>* %r ; <<4 x float>> [#uses=2] %tmp.upgrd.3 = bitcast <2 x i32>* %A to double* ; [#uses=1] %tmp.upgrd.4 = load double* %tmp.upgrd.3 ; [#uses=1] From tonic at nondot.org Fri May 9 23:05:13 2008 From: tonic at nondot.org (Tanya Lattner) Date: Sat, 10 May 2008 04:05:13 -0000 Subject: [llvm-commits] [llvm] r50932 - /llvm/branches/release_23/ Message-ID: <200805100405.m4A45Dbh008458@zion.cs.uiuc.edu> Author: tbrethou Date: Fri May 9 23:05:12 2008 New Revision: 50932 URL: http://llvm.org/viewvc/llvm-project?rev=50932&view=rev Log: Creating 2.3 release branch. Added: llvm/branches/release_23/ - copied from r50931, llvm/trunk/ From tonic at nondot.org Fri May 9 23:05:46 2008 From: tonic at nondot.org (Tanya Lattner) Date: Sat, 10 May 2008 04:05:46 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50933 - /llvm-gcc-4.2/branches/release_23/ Message-ID: <200805100405.m4A45kkt008484@zion.cs.uiuc.edu> Author: tbrethou Date: Fri May 9 23:05:46 2008 New Revision: 50933 URL: http://llvm.org/viewvc/llvm-project?rev=50933&view=rev Log: Creating 2.3 release branch. Added: llvm-gcc-4.2/branches/release_23/ - copied from r50932, llvm-gcc-4.2/trunk/ From tonic at nondot.org Fri May 9 23:06:17 2008 From: tonic at nondot.org (Tanya Lattner) Date: Sat, 10 May 2008 04:06:17 -0000 Subject: [llvm-commits] [test-suite] r50934 - /test-suite/branches/release_23/ Message-ID: <200805100406.m4A46HuA008510@zion.cs.uiuc.edu> Author: tbrethou Date: Fri May 9 23:06:17 2008 New Revision: 50934 URL: http://llvm.org/viewvc/llvm-project?rev=50934&view=rev Log: Creating 2.3 release branch. Added: test-suite/branches/release_23/ - copied from r50933, test-suite/trunk/ From tonic at nondot.org Fri May 9 23:20:38 2008 From: tonic at nondot.org (Tanya Lattner) Date: Sat, 10 May 2008 04:20:38 -0000 Subject: [llvm-commits] [llvm] r50935 - in /llvm/trunk: autoconf/configure.ac configure Message-ID: <200805100420.m4A4KdTm009655@zion.cs.uiuc.edu> Author: tbrethou Date: Fri May 9 23:20:38 2008 New Revision: 50935 URL: http://llvm.org/viewvc/llvm-project?rev=50935&view=rev Log: Set to 2.4 and regenerate configure. 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=50935&r1=50934&r2=50935&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Fri May 9 23:20:38 2008 @@ -31,7 +31,7 @@ dnl===-----------------------------------------------------------------------=== dnl Initialize autoconf and define the package name, version number and dnl email address for reporting bugs. -AC_INIT([[llvm]],[[2.3svn]],[llvmbugs at cs.uiuc.edu]) +AC_INIT([[llvm]],[[2.4svn]],[llvmbugs at cs.uiuc.edu]) dnl Provide a copyright substitution and ensure the copyright notice is included dnl in the output of --version option of the generated configure script. Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=50935&r1=50934&r2=50935&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Fri May 9 23:20:38 2008 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.60 for llvm 2.3svn. +# Generated by GNU Autoconf 2.60 for llvm 2.4svn. # # Report bugs to . # @@ -715,8 +715,8 @@ # Identity of this package. PACKAGE_NAME='llvm' PACKAGE_TARNAME='-llvm-' -PACKAGE_VERSION='2.3svn' -PACKAGE_STRING='llvm 2.3svn' +PACKAGE_VERSION='2.4svn' +PACKAGE_STRING='llvm 2.4svn' PACKAGE_BUGREPORT='llvmbugs at cs.uiuc.edu' ac_unique_file="lib/VMCore/Module.cpp" @@ -1459,7 +1459,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures llvm 2.3svn to adapt to many kinds of systems. +\`configure' configures llvm 2.4svn to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1525,7 +1525,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of llvm 2.3svn:";; + short | recursive ) echo "Configuration of llvm 2.4svn:";; esac cat <<\_ACEOF @@ -1660,7 +1660,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -llvm configure 2.3svn +llvm configure 2.4svn generated by GNU Autoconf 2.60 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1676,7 +1676,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by llvm $as_me 2.3svn, which was +It was created by llvm $as_me 2.4svn, which was generated by GNU Autoconf 2.60. Invocation command line was $ $0 $@ @@ -4773,7 +4773,7 @@ spu) TARGETS_TO_BUILD="CellSPU $TARGETS_TO_BUILD" ;; cbe) TARGETS_TO_BUILD="CBackend $TARGETS_TO_BUILD" ;; msil) TARGETS_TO_BUILD="MSIL $TARGETS_TO_BUILD" ;; - cpp) TARGETS_TO_BUILD="CppBackend $TARGETS_TO_BUILD" ;; + cpp) TARGETS_TO_BUILD="CppBackend $TARGETS_TO_BUILD" ;; *) { { echo "$as_me:$LINENO: error: Unrecognized target $a_target" >&5 echo "$as_me: error: Unrecognized target $a_target" >&2;} { (exit 1); exit 1; }; } ;; @@ -10631,7 +10631,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 12778 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -14493,11 +14493,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:14495: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14496: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14499: \$? = $ac_status" >&5 + echo "$as_me:14500: \$? = $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. @@ -14761,11 +14761,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:14763: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14764: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14767: \$? = $ac_status" >&5 + echo "$as_me:14768: \$? = $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. @@ -14865,11 +14865,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:14867: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14868: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14871: \$? = $ac_status" >&5 + echo "$as_me:14872: \$? = $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 @@ -17317,7 +17317,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:19788: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:19791: \$? = $ac_status" >&5 + echo "$as_me:19792: \$? = $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. @@ -19889,11 +19889,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:19891: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19892: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:19895: \$? = $ac_status" >&5 + echo "$as_me:19896: \$? = $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 @@ -21459,11 +21459,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:21461: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21462: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:21465: \$? = $ac_status" >&5 + echo "$as_me:21466: \$? = $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. @@ -21563,11 +21563,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:21565: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21566: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:21569: \$? = $ac_status" >&5 + echo "$as_me:21570: \$? = $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 @@ -23798,11 +23798,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:23800: $lt_compile\"" >&5) + (eval echo "\"\$as_me:23801: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:23804: \$? = $ac_status" >&5 + echo "$as_me:23805: \$? = $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. @@ -24066,11 +24066,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:24068: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24069: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24072: \$? = $ac_status" >&5 + echo "$as_me:24073: \$? = $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. @@ -24170,11 +24170,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:24172: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24173: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:24176: \$? = $ac_status" >&5 + echo "$as_me:24177: \$? = $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 @@ -34711,7 +34711,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by llvm $as_me 2.3svn, which was +This file was extended by llvm $as_me 2.4svn, which was generated by GNU Autoconf 2.60. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -34764,7 +34764,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -llvm config.status 2.3svn +llvm config.status 2.4svn configured by $0, generated by GNU Autoconf 2.60, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" From tonic at nondot.org Fri May 9 23:23:48 2008 From: tonic at nondot.org (Tanya Lattner) Date: Sat, 10 May 2008 04:23:48 -0000 Subject: [llvm-commits] [test-suite] r50936 - /test-suite/trunk/autoconf/configure.ac Message-ID: <200805100423.m4A4NmYH009951@zion.cs.uiuc.edu> Author: tbrethou Date: Fri May 9 23:23:48 2008 New Revision: 50936 URL: http://llvm.org/viewvc/llvm-project?rev=50936&view=rev Log: (empty) Modified: test-suite/trunk/autoconf/configure.ac Modified: test-suite/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/autoconf/configure.ac?rev=50936&r1=50935&r2=50936&view=diff ============================================================================== --- test-suite/trunk/autoconf/configure.ac (original) +++ test-suite/trunk/autoconf/configure.ac Fri May 9 23:23:48 2008 @@ -1,5 +1,5 @@ dnl Initialize autoconf -AC_INIT([[LLVM-TEST]],[[2.3svn]],[llvmbugs at cs.uiuc.edu]) +AC_INIT([[LLVM-TEST]],[[2.4svn]],[llvmbugs at cs.uiuc.edu]) dnl Place all of the extra autoconf files into the config subdirectory AC_CONFIG_AUX_DIR([autoconf]) From tonic at nondot.org Fri May 9 23:24:10 2008 From: tonic at nondot.org (Tanya Lattner) Date: Sat, 10 May 2008 04:24:10 -0000 Subject: [llvm-commits] [test-suite] r50937 - /test-suite/trunk/configure Message-ID: <200805100424.m4A4OAsC009973@zion.cs.uiuc.edu> Author: tbrethou Date: Fri May 9 23:24:10 2008 New Revision: 50937 URL: http://llvm.org/viewvc/llvm-project?rev=50937&view=rev Log: Setting to 2.4 and regenerating configure. Modified: test-suite/trunk/configure Modified: test-suite/trunk/configure URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/configure?rev=50937&r1=50936&r2=50937&view=diff ============================================================================== --- test-suite/trunk/configure (original) +++ test-suite/trunk/configure Fri May 9 23:24:10 2008 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.60 for LLVM-TEST 2.3svn. +# Generated by GNU Autoconf 2.60 for LLVM-TEST 2.4svn. # # Report bugs to . # @@ -713,8 +713,8 @@ # Identity of this package. PACKAGE_NAME='LLVM-TEST' PACKAGE_TARNAME='-llvm-test-' -PACKAGE_VERSION='2.3svn' -PACKAGE_STRING='LLVM-TEST 2.3svn' +PACKAGE_VERSION='2.4svn' +PACKAGE_STRING='LLVM-TEST 2.4svn' PACKAGE_BUGREPORT='llvmbugs at cs.uiuc.edu' ac_unique_file="SingleSource/Benchmarks/Makefile" @@ -1389,7 +1389,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures LLVM-TEST 2.3svn to adapt to many kinds of systems. +\`configure' configures LLVM-TEST 2.4svn to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1454,7 +1454,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of LLVM-TEST 2.3svn:";; + short | recursive ) echo "Configuration of LLVM-TEST 2.4svn:";; esac cat <<\_ACEOF @@ -1576,7 +1576,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -LLVM-TEST configure 2.3svn +LLVM-TEST configure 2.4svn generated by GNU Autoconf 2.60 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1590,7 +1590,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by LLVM-TEST $as_me 2.3svn, which was +It was created by LLVM-TEST $as_me 2.4svn, which was generated by GNU Autoconf 2.60. Invocation command line was $ $0 $@ @@ -21257,7 +21257,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by LLVM-TEST $as_me 2.3svn, which was +This file was extended by LLVM-TEST $as_me 2.4svn, which was generated by GNU Autoconf 2.60. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -21304,7 +21304,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -LLVM-TEST config.status 2.3svn +LLVM-TEST config.status 2.4svn configured by $0, generated by GNU Autoconf 2.60, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" From tonic at nondot.org Fri May 9 23:27:00 2008 From: tonic at nondot.org (Tanya Lattner) Date: Sat, 10 May 2008 04:27:00 -0000 Subject: [llvm-commits] [llvm] r50938 - in /llvm/branches/release_23: autoconf/configure.ac configure Message-ID: <200805100427.m4A4R04Y010302@zion.cs.uiuc.edu> Author: tbrethou Date: Fri May 9 23:26:59 2008 New Revision: 50938 URL: http://llvm.org/viewvc/llvm-project?rev=50938&view=rev Log: 2.3 release, regenerate configure. Modified: llvm/branches/release_23/autoconf/configure.ac llvm/branches/release_23/configure Modified: llvm/branches/release_23/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_23/autoconf/configure.ac?rev=50938&r1=50937&r2=50938&view=diff ============================================================================== --- llvm/branches/release_23/autoconf/configure.ac (original) +++ llvm/branches/release_23/autoconf/configure.ac Fri May 9 23:26:59 2008 @@ -31,7 +31,7 @@ dnl===-----------------------------------------------------------------------=== dnl Initialize autoconf and define the package name, version number and dnl email address for reporting bugs. -AC_INIT([[llvm]],[[2.3svn]],[llvmbugs at cs.uiuc.edu]) +AC_INIT([[llvm]],[[2.3]],[llvmbugs at cs.uiuc.edu]) dnl Provide a copyright substitution and ensure the copyright notice is included dnl in the output of --version option of the generated configure script. Modified: llvm/branches/release_23/configure URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_23/configure?rev=50938&r1=50937&r2=50938&view=diff ============================================================================== --- llvm/branches/release_23/configure (original) +++ llvm/branches/release_23/configure Fri May 9 23:26:59 2008 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.60 for llvm 2.3svn. +# Generated by GNU Autoconf 2.60 for llvm 2.3. # # Report bugs to . # @@ -715,8 +715,8 @@ # Identity of this package. PACKAGE_NAME='llvm' PACKAGE_TARNAME='-llvm-' -PACKAGE_VERSION='2.3svn' -PACKAGE_STRING='llvm 2.3svn' +PACKAGE_VERSION='2.3' +PACKAGE_STRING='llvm 2.3' PACKAGE_BUGREPORT='llvmbugs at cs.uiuc.edu' ac_unique_file="lib/VMCore/Module.cpp" @@ -1459,7 +1459,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures llvm 2.3svn to adapt to many kinds of systems. +\`configure' configures llvm 2.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1525,7 +1525,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of llvm 2.3svn:";; + short | recursive ) echo "Configuration of llvm 2.3:";; esac cat <<\_ACEOF @@ -1660,7 +1660,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -llvm configure 2.3svn +llvm configure 2.3 generated by GNU Autoconf 2.60 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1676,7 +1676,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by llvm $as_me 2.3svn, which was +It was created by llvm $as_me 2.3, which was generated by GNU Autoconf 2.60. Invocation command line was $ $0 $@ @@ -4773,7 +4773,7 @@ spu) TARGETS_TO_BUILD="CellSPU $TARGETS_TO_BUILD" ;; cbe) TARGETS_TO_BUILD="CBackend $TARGETS_TO_BUILD" ;; msil) TARGETS_TO_BUILD="MSIL $TARGETS_TO_BUILD" ;; - cpp) TARGETS_TO_BUILD="CppBackend $TARGETS_TO_BUILD" ;; + cpp) TARGETS_TO_BUILD="CppBackend $TARGETS_TO_BUILD" ;; *) { { echo "$as_me:$LINENO: error: Unrecognized target $a_target" >&5 echo "$as_me: error: Unrecognized target $a_target" >&2;} { (exit 1); exit 1; }; } ;; @@ -10631,7 +10631,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 12778 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -14493,11 +14493,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:14495: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14496: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14499: \$? = $ac_status" >&5 + echo "$as_me:14500: \$? = $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. @@ -14761,11 +14761,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:14763: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14764: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14767: \$? = $ac_status" >&5 + echo "$as_me:14768: \$? = $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. @@ -14865,11 +14865,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:14867: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14868: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14871: \$? = $ac_status" >&5 + echo "$as_me:14872: \$? = $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 @@ -17317,7 +17317,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:19788: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:19791: \$? = $ac_status" >&5 + echo "$as_me:19792: \$? = $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. @@ -19889,11 +19889,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:19891: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19892: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:19895: \$? = $ac_status" >&5 + echo "$as_me:19896: \$? = $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 @@ -21459,11 +21459,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:21461: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21462: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:21465: \$? = $ac_status" >&5 + echo "$as_me:21466: \$? = $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. @@ -21563,11 +21563,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:21565: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21566: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:21569: \$? = $ac_status" >&5 + echo "$as_me:21570: \$? = $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 @@ -23798,11 +23798,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:23800: $lt_compile\"" >&5) + (eval echo "\"\$as_me:23801: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:23804: \$? = $ac_status" >&5 + echo "$as_me:23805: \$? = $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. @@ -24066,11 +24066,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:24068: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24069: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24072: \$? = $ac_status" >&5 + echo "$as_me:24073: \$? = $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. @@ -24170,11 +24170,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:24172: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24173: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:24176: \$? = $ac_status" >&5 + echo "$as_me:24177: \$? = $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 @@ -34711,7 +34711,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by llvm $as_me 2.3svn, which was +This file was extended by llvm $as_me 2.3, which was generated by GNU Autoconf 2.60. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -34764,7 +34764,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -llvm config.status 2.3svn +llvm config.status 2.3 configured by $0, generated by GNU Autoconf 2.60, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" From tonic at nondot.org Fri May 9 23:31:18 2008 From: tonic at nondot.org (Tanya Lattner) Date: Sat, 10 May 2008 04:31:18 -0000 Subject: [llvm-commits] [test-suite] r50939 - in /test-suite/branches/release_23: autoconf/configure.ac configure Message-ID: <200805100431.m4A4VJ0i010633@zion.cs.uiuc.edu> Author: tbrethou Date: Fri May 9 23:31:18 2008 New Revision: 50939 URL: http://llvm.org/viewvc/llvm-project?rev=50939&view=rev Log: 2.3 release, regenerate configure. Modified: test-suite/branches/release_23/autoconf/configure.ac test-suite/branches/release_23/configure Modified: test-suite/branches/release_23/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/test-suite/branches/release_23/autoconf/configure.ac?rev=50939&r1=50938&r2=50939&view=diff ============================================================================== --- test-suite/branches/release_23/autoconf/configure.ac (original) +++ test-suite/branches/release_23/autoconf/configure.ac Fri May 9 23:31:18 2008 @@ -1,5 +1,5 @@ dnl Initialize autoconf -AC_INIT([[LLVM-TEST]],[[2.3svn]],[llvmbugs at cs.uiuc.edu]) +AC_INIT([[LLVM-TEST]],[[2.3]],[llvmbugs at cs.uiuc.edu]) dnl Place all of the extra autoconf files into the config subdirectory AC_CONFIG_AUX_DIR([autoconf]) Modified: test-suite/branches/release_23/configure URL: http://llvm.org/viewvc/llvm-project/test-suite/branches/release_23/configure?rev=50939&r1=50938&r2=50939&view=diff ============================================================================== --- test-suite/branches/release_23/configure (original) +++ test-suite/branches/release_23/configure Fri May 9 23:31:18 2008 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.60 for LLVM-TEST 2.3svn. +# Generated by GNU Autoconf 2.60 for LLVM-TEST 2.3. # # Report bugs to . # @@ -713,8 +713,8 @@ # Identity of this package. PACKAGE_NAME='LLVM-TEST' PACKAGE_TARNAME='-llvm-test-' -PACKAGE_VERSION='2.3svn' -PACKAGE_STRING='LLVM-TEST 2.3svn' +PACKAGE_VERSION='2.3' +PACKAGE_STRING='LLVM-TEST 2.3' PACKAGE_BUGREPORT='llvmbugs at cs.uiuc.edu' ac_unique_file="SingleSource/Benchmarks/Makefile" @@ -1389,7 +1389,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures LLVM-TEST 2.3svn to adapt to many kinds of systems. +\`configure' configures LLVM-TEST 2.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1454,7 +1454,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of LLVM-TEST 2.3svn:";; + short | recursive ) echo "Configuration of LLVM-TEST 2.3:";; esac cat <<\_ACEOF @@ -1576,7 +1576,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -LLVM-TEST configure 2.3svn +LLVM-TEST configure 2.3 generated by GNU Autoconf 2.60 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1590,7 +1590,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by LLVM-TEST $as_me 2.3svn, which was +It was created by LLVM-TEST $as_me 2.3, which was generated by GNU Autoconf 2.60. Invocation command line was $ $0 $@ @@ -21257,7 +21257,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by LLVM-TEST $as_me 2.3svn, which was +This file was extended by LLVM-TEST $as_me 2.3, which was generated by GNU Autoconf 2.60. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -21304,7 +21304,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -LLVM-TEST config.status 2.3svn +LLVM-TEST config.status 2.3 configured by $0, generated by GNU Autoconf 2.60, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" From evan.cheng at apple.com Sat May 10 01:46:49 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 10 May 2008 06:46:49 -0000 Subject: [llvm-commits] [llvm] r50940 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/2008-05-09-ShuffleLoweringBug.ll Message-ID: <200805100646.m4A6kni1014049@zion.cs.uiuc.edu> Author: evancheng Date: Sat May 10 01:46:49 2008 New Revision: 50940 URL: http://llvm.org/viewvc/llvm-project?rev=50940&view=rev Log: When transforming a vector_shuffle to a load, the base address must not be an undef. Added: llvm/trunk/test/CodeGen/X86/2008-05-09-ShuffleLoweringBug.ll Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=50940&r1=50939&r2=50940&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sat May 10 01:46:49 2008 @@ -6283,6 +6283,8 @@ return false; if (!Base) { Base = Elt.Val; + if (Base->getOpcode() == ISD::UNDEF) + return false; continue; } if (Elt.getOpcode() == ISD::UNDEF) Added: llvm/trunk/test/CodeGen/X86/2008-05-09-ShuffleLoweringBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-05-09-ShuffleLoweringBug.ll?rev=50940&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-05-09-ShuffleLoweringBug.ll (added) +++ llvm/trunk/test/CodeGen/X86/2008-05-09-ShuffleLoweringBug.ll Sat May 10 01:46:49 2008 @@ -0,0 +1,10 @@ +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 + +define fastcc void @glgVectorFloatConversion() nounwind { + %tmp12745 = load <4 x float>* null, align 16 ; <<4 x float>> [#uses=1] + %tmp12773 = insertelement <4 x float> %tmp12745, float 1.000000e+00, i32 1 ; <<4 x float>> [#uses=1] + %tmp12774 = insertelement <4 x float> %tmp12773, float 0.000000e+00, i32 2 ; <<4 x float>> [#uses=1] + %tmp12775 = insertelement <4 x float> %tmp12774, float 1.000000e+00, i32 3 ; <<4 x float>> [#uses=1] + store <4 x float> %tmp12775, <4 x float>* null, align 16 + unreachable +} From resistor at mac.com Sat May 10 02:10:25 2008 From: resistor at mac.com (Owen Anderson) Date: Sat, 10 May 2008 07:10:25 -0000 Subject: [llvm-commits] [llvm] r50941 - /llvm/trunk/tools/opt/opt.cpp Message-ID: <200805100710.m4A7AP6j014644@zion.cs.uiuc.edu> Author: resistor Date: Sat May 10 02:10:24 2008 New Revision: 50941 URL: http://llvm.org/viewvc/llvm-project?rev=50941&view=rev Log: Re-enable loop deletion by default. Modified: llvm/trunk/tools/opt/opt.cpp Modified: llvm/trunk/tools/opt/opt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=50941&r1=50940&r2=50941&view=diff ============================================================================== --- llvm/trunk/tools/opt/opt.cpp (original) +++ llvm/trunk/tools/opt/opt.cpp Sat May 10 02:10:24 2008 @@ -282,6 +282,7 @@ addPass(PM, createLoopIndexSplitPass()); // Index split loops. addPass(PM, createInstructionCombiningPass()); // Clean up after LICM/reassoc addPass(PM, createIndVarSimplifyPass()); // Canonicalize indvars + addPass(PM, createLoopDeletionPass()); // Delete dead loops addPass(PM, createLoopUnrollPass()); // Unroll small loops addPass(PM, createInstructionCombiningPass()); // Clean up after the unroller addPass(PM, createGVNPass()); // Remove redundancies From resistor at mac.com Sat May 10 02:21:33 2008 From: resistor at mac.com (Owen Anderson) Date: Sat, 10 May 2008 07:21:33 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50942 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200805100721.m4A7LXXU014943@zion.cs.uiuc.edu> Author: resistor Date: Sat May 10 02:21:32 2008 New Revision: 50942 URL: http://llvm.org/viewvc/llvm-project?rev=50942&view=rev Log: Re-enable loop deletion. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=50942&r1=50941&r2=50942&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Sat May 10 02:21:32 2008 @@ -379,6 +379,7 @@ PM->add(createLoopIndexSplitPass()); // Split loop index PM->add(createInstructionCombiningPass()); // Clean up after LICM/reassoc PM->add(createIndVarSimplifyPass()); // Canonicalize indvars + PM->add(createLoopDeletionPass()); // Delete dead loops if (flag_unroll_loops) PM->add(createLoopUnrollPass()); // Unroll small loops PM->add(createInstructionCombiningPass()); // Clean up after the unroller From ggreif at gmail.com Sat May 10 03:32:32 2008 From: ggreif at gmail.com (Gabor Greif) Date: Sat, 10 May 2008 08:32:32 -0000 Subject: [llvm-commits] [llvm] r50943 - in /llvm/trunk: CREDITS.TXT include/llvm/Constants.h include/llvm/GlobalAlias.h include/llvm/GlobalVariable.h include/llvm/InstrTypes.h include/llvm/Instruction.h include/llvm/Instructions.h include/llvm/OperandTraits.h include/llvm/Use.h include/llvm/User.h include/llvm/Value.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Reader/BitcodeReader.h lib/VMCore/ConstantFold.cpp lib/VMCore/Constants.cpp lib/VMCore/Globals.cpp lib/VMCore/Instructions.cpp lib/VMCore/Use.cpp Message-ID: <200805100832.m4A8WX9o024674@zion.cs.uiuc.edu> Author: ggreif Date: Sat May 10 03:32:32 2008 New Revision: 50943 URL: http://llvm.org/viewvc/llvm-project?rev=50943&view=rev Log: merge of use-diet branch to trunk Added: llvm/trunk/include/llvm/OperandTraits.h - copied unchanged from r50813, llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h llvm/trunk/lib/VMCore/Use.cpp - copied unchanged from r50813, llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Modified: llvm/trunk/CREDITS.TXT llvm/trunk/include/llvm/Constants.h llvm/trunk/include/llvm/GlobalAlias.h llvm/trunk/include/llvm/GlobalVariable.h llvm/trunk/include/llvm/InstrTypes.h llvm/trunk/include/llvm/Instruction.h llvm/trunk/include/llvm/Instructions.h llvm/trunk/include/llvm/Use.h llvm/trunk/include/llvm/User.h llvm/trunk/include/llvm/Value.h llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h llvm/trunk/lib/VMCore/ConstantFold.cpp llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/Globals.cpp llvm/trunk/lib/VMCore/Instructions.cpp Modified: llvm/trunk/CREDITS.TXT URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CREDITS.TXT?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/CREDITS.TXT (original) +++ llvm/trunk/CREDITS.TXT Sat May 10 03:32:32 2008 @@ -110,6 +110,10 @@ D: Miscellaneous bug fixes D: Register allocation refactoring +N: Gabor Greif +E: ggreif at gmail.com +D: Improvements for space efficiency + N: Gordon Henriksen E: gordonhenriksen at mac.com D: Pluggable GC support Modified: llvm/trunk/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constants.h (original) +++ llvm/trunk/include/llvm/Constants.h Sat May 10 03:32:32 2008 @@ -22,6 +22,7 @@ #include "llvm/Constant.h" #include "llvm/Type.h" +#include "llvm/OperandTraits.h" #include "llvm/ADT/APInt.h" #include "llvm/ADT/APFloat.h" @@ -318,7 +319,6 @@ ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT protected: ConstantArray(const ArrayType *T, const std::vector &Val); - ~ConstantArray(); public: /// get() - Static factory methods - Return objects of the specified value static Constant *get(const ArrayType *T, const std::vector &); @@ -336,6 +336,9 @@ /// null termination. static Constant *get(const std::string &Initializer, bool AddNull = true); + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); + /// getType - Specialize the getType() method to always return an ArrayType, /// which reduces the amount of casting needed in parts of the compiler. /// @@ -374,6 +377,11 @@ } }; +template <> +struct OperandTraits : VariadicOperandTraits<> { +}; + +DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantArray, Constant) //===----------------------------------------------------------------------===// // ConstantStruct - Constant Struct Declarations @@ -384,7 +392,6 @@ ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT protected: ConstantStruct(const StructType *T, const std::vector &Val); - ~ConstantStruct(); public: /// get() - Static factory methods - Return objects of the specified value /// @@ -396,6 +403,9 @@ return get(std::vector(Vals, Vals+NumVals), Packed); } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); + /// getType() specialization - Reduce amount of casting... /// inline const StructType *getType() const { @@ -419,6 +429,12 @@ } }; +template <> +struct OperandTraits : VariadicOperandTraits<> { +}; + +DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantStruct, Constant) + //===----------------------------------------------------------------------===// /// ConstantVector - Constant Vector Declarations /// @@ -428,7 +444,6 @@ ConstantVector(const ConstantVector &); // DO NOT IMPLEMENT protected: ConstantVector(const VectorType *T, const std::vector &Val); - ~ConstantVector(); public: /// get() - Static factory methods - Return objects of the specified value static Constant *get(const VectorType *T, const std::vector &); @@ -438,6 +453,9 @@ return get(std::vector(Vals, Vals+NumVals)); } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); + /// getType - Specialize the getType() method to always return a VectorType, /// which reduces the amount of casting needed in parts of the compiler. /// @@ -475,6 +493,12 @@ } }; +template <> +struct OperandTraits : VariadicOperandTraits<> { +}; + +DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantVector, Constant) + //===----------------------------------------------------------------------===// /// ConstantPointerNull - a constant pointer value that points to null /// @@ -573,6 +597,9 @@ static Constant *getIntToPtr(Constant *C, const Type *Ty); static Constant *getBitCast (Constant *C, const Type *Ty); + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); + // @brief Convenience function for getting one of the casting operations // using a CastOps opcode. static Constant *getCast( @@ -709,13 +736,13 @@ virtual void destroyConstant(); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U); - /// Override methods to provide more type information... +/* /// Override methods to provide more type information... inline Constant *getOperand(unsigned i) { return cast(User::getOperand(i)); } inline Constant *getOperand(unsigned i) const { return const_cast(cast(User::getOperand(i))); - } + }*/ /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -725,6 +752,11 @@ } }; +template <> +struct OperandTraits : VariadicOperandTraits<1> { +}; + +DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantExpr, Constant) //===----------------------------------------------------------------------===// /// UndefValue - 'undef' values are things that do not have specified contents. Modified: llvm/trunk/include/llvm/GlobalAlias.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalAlias.h?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/include/llvm/GlobalAlias.h (original) +++ llvm/trunk/include/llvm/GlobalAlias.h Sat May 10 03:32:32 2008 @@ -16,6 +16,7 @@ #define LLVM_GLOBAL_ALIAS_H #include "llvm/GlobalValue.h" +#include "llvm/OperandTraits.h" namespace llvm { @@ -42,17 +43,19 @@ GlobalAlias *getPrev() { return Prev; } const GlobalAlias *getPrev() const { return Prev; } - Use Aliasee; public: - // allocate space for exactly zero operands + // allocate space for exactly one operand void *operator new(size_t s) { - return User::operator new(s, 0); + return User::operator new(s, 1); } /// GlobalAlias ctor - If a parent module is specified, the alias is /// automatically inserted into the end of the specified module's alias list. GlobalAlias(const Type *Ty, LinkageTypes Linkage, const std::string &Name = "", Constant* Aliasee = 0, Module *Parent = 0); + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + /// isDeclaration - Is this global variable lacking an initializer? If so, /// the global variable is defined in some other translation unit, and is thus /// only a declaration here. @@ -95,6 +98,12 @@ } }; +template <> +struct OperandTraits : FixedNumOperandTraits<1> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalAlias, Value) + } // End llvm namespace #endif Modified: llvm/trunk/include/llvm/GlobalVariable.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalVariable.h?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/include/llvm/GlobalVariable.h (original) +++ llvm/trunk/include/llvm/GlobalVariable.h Sat May 10 03:32:32 2008 @@ -21,6 +21,7 @@ #define LLVM_GLOBAL_VARIABLE_H #include "llvm/GlobalValue.h" +#include "llvm/OperandTraits.h" namespace llvm { @@ -44,26 +45,32 @@ bool isConstantGlobal : 1; // Is this a global constant? bool isThreadLocalSymbol : 1; // Is this symbol "Thread Local"? - Use Initializer; public: - // allocate space for exactly zero operands + // allocate space for exactly one operand void *operator new(size_t s) { - return User::operator new(s, 0); + return User::operator new(s, 1); } /// GlobalVariable ctor - If a parent module is specified, the global is /// automatically inserted into the end of the specified modules global list. GlobalVariable(const Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer = 0, const std::string &Name = "", - Module *Parent = 0, bool ThreadLocal = false, + Module *Parent = 0, bool ThreadLocal = false, unsigned AddressSpace = 0); /// GlobalVariable ctor - This creates a global and inserts it before the /// specified other global. GlobalVariable(const Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer, const std::string &Name, - GlobalVariable *InsertBefore, bool ThreadLocal = false, + GlobalVariable *InsertBefore, bool ThreadLocal = false, unsigned AddressSpace = 0); - + + ~GlobalVariable() { + NumOperands = 1; // FIXME: needed by operator delete + } + + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + /// isDeclaration - Is this global variable lacking an initializer? If so, /// the global variable is defined in some other translation unit, and is thus /// only a declaration here. @@ -79,24 +86,24 @@ /// illegal to call this method if the global is external, because we cannot /// tell what the value is initialized to! /// - inline Constant *getInitializer() const { + inline /*const FIXME*/ Constant *getInitializer() const { assert(hasInitializer() && "GV doesn't have initializer!"); - return reinterpret_cast(Initializer.get()); + return static_cast(Op<0>().get()); } inline Constant *getInitializer() { assert(hasInitializer() && "GV doesn't have initializer!"); - return reinterpret_cast(Initializer.get()); + return static_cast(Op<0>().get()); } inline void setInitializer(Constant *CPV) { if (CPV == 0) { if (hasInitializer()) { - Initializer.set(0); + Op<0>().set(0); NumOperands = 0; } } else { if (!hasInitializer()) NumOperands = 1; - Initializer.set(CPV); + Op<0>().set(CPV); } } @@ -141,6 +148,12 @@ const GlobalVariable *getPrev() const { return Prev; } }; +template <> +struct OperandTraits : OptionalOperandTraits<> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalVariable, Value) + } // End llvm namespace #endif Modified: llvm/trunk/include/llvm/InstrTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InstrTypes.h?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/include/llvm/InstrTypes.h (original) +++ llvm/trunk/include/llvm/InstrTypes.h Sat May 10 03:32:32 2008 @@ -17,6 +17,7 @@ #define LLVM_INSTRUCTION_TYPES_H #include "llvm/Instruction.h" +#include "llvm/OperandTraits.h" namespace llvm { @@ -78,22 +79,22 @@ } }; + //===----------------------------------------------------------------------===// // UnaryInstruction Class //===----------------------------------------------------------------------===// class UnaryInstruction : public Instruction { void *operator new(size_t, unsigned); // Do not implement - Use Op; - // avoiding warning: 'this' : used in base member initializer list - UnaryInstruction* this_() { return this; } protected: - UnaryInstruction(const Type *Ty, unsigned iType, Value *V, Instruction *IB =0) - : Instruction(Ty, iType, &Op, 1, IB), Op(V, this_()) { + UnaryInstruction(const Type *Ty, unsigned iType, Value *V, Instruction *IB = 0) + : Instruction(Ty, iType, &Op<0>(), 1, IB) { + Op<0>() = V; } UnaryInstruction(const Type *Ty, unsigned iType, Value *V, BasicBlock *IAE) - : Instruction(Ty, iType, &Op, 1, IAE), Op(V, this_()) { + : Instruction(Ty, iType, &Op<0>(), 1, IAE) { + Op<0>() = V; } public: // allocate space for exactly one operand @@ -104,16 +105,8 @@ // Out of line virtual method, so the vtable, etc has a home. ~UnaryInstruction(); - // Transparently provide more efficient getOperand methods. - Value *getOperand(unsigned i) const { - assert(i == 0 && "getOperand() out of range!"); - return Op; - } - void setOperand(unsigned i, Value *Val) { - assert(i == 0 && "setOperand() out of range!"); - Op = Val; - } - unsigned getNumOperands() const { return 1; } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const UnaryInstruction *) { return true; } @@ -130,13 +123,18 @@ } }; +template <> +struct OperandTraits : FixedNumOperandTraits<1> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(UnaryInstruction, Value) + //===----------------------------------------------------------------------===// // BinaryOperator Class //===----------------------------------------------------------------------===// class BinaryOperator : public Instruction { void *operator new(size_t, unsigned); // Do not implement - Use Ops[2]; protected: void init(BinaryOps iType); BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty, @@ -150,15 +148,7 @@ } /// Transparently provide more efficient getOperand methods. - Value *getOperand(unsigned i) const { - assert(i < 2 && "getOperand() out of range!"); - return Ops[i]; - } - void setOperand(unsigned i, Value *Val) { - assert(i < 2 && "setOperand() out of range!"); - Ops[i] = Val; - } - unsigned getNumOperands() const { return 2; } + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); /// create() - Construct a binary instruction, given the opcode and the two /// operands. Optionally (if InstBefore is specified) insert the instruction @@ -251,6 +241,12 @@ } }; +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BinaryOperator, Value) + //===----------------------------------------------------------------------===// // CastInst Class //===----------------------------------------------------------------------===// @@ -497,6 +493,7 @@ /// This class is the base class for the comparison instructions. /// @brief Abstract base class of comparison instructions. +// FIXME: why not derive from BinaryOperator? class CmpInst: public Instruction { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT CmpInst(); // do not implement @@ -507,8 +504,6 @@ CmpInst(Instruction::OtherOps op, unsigned short pred, Value *LHS, Value *RHS, const std::string &Name, BasicBlock *InsertAtEnd); - Use Ops[2]; // CmpInst instructions always have 2 operands, optimize - public: // allocate space for exactly two operands void *operator new(size_t s) { @@ -548,17 +543,7 @@ } /// @brief Provide more efficient getOperand methods. - Value *getOperand(unsigned i) const { - assert(i < 2 && "getOperand() out of range!"); - return Ops[i]; - } - void setOperand(unsigned i, Value *Val) { - assert(i < 2 && "setOperand() out of range!"); - Ops[i] = Val; - } - - /// @brief CmpInst instructions always have 2 operands. - unsigned getNumOperands() const { return 2; } + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); /// This is just a convenience that dispatches to the subclasses. /// @brief Swap the operands and adjust predicate accordingly to retain @@ -598,6 +583,14 @@ } }; + +// FIXME: these are redundant if CmpInst < BinaryOperator +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CmpInst, Value) + } // End llvm namespace #endif Modified: llvm/trunk/include/llvm/Instruction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instruction.h?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instruction.h (original) +++ llvm/trunk/include/llvm/Instruction.h Sat May 10 03:32:32 2008 @@ -20,7 +20,6 @@ namespace llvm { struct AssemblyAnnotationWriter; -class BinaryOperator; template class SymbolTableListTraits; Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Sat May 10 03:32:32 2008 @@ -21,10 +21,10 @@ #include "llvm/InstrTypes.h" #include "llvm/DerivedTypes.h" #include "llvm/ParameterAttributes.h" +#include "llvm/BasicBlock.h" namespace llvm { -class BasicBlock; class ConstantInt; class PointerType; class VectorType; @@ -288,11 +288,11 @@ /// class StoreInst : public Instruction { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Ops[2]; - StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store, Ops, 2) { - Ops[0].init(SI.Ops[0], this); - Ops[1].init(SI.Ops[1], this); + StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store, + &Op<0>(), 2) { + Op<0>().init(SI.Op<0>(), this); + Op<1>().init(SI.Op<1>(), this); setVolatile(SI.isVolatile()); setAlignment(SI.getAlignment()); @@ -329,15 +329,7 @@ } /// Transparently provide more efficient getOperand methods. - Value *getOperand(unsigned i) const { - assert(i < 2 && "getOperand() out of range!"); - return Ops[i]; - } - void setOperand(unsigned i, Value *Val) { - assert(i < 2 && "setOperand() out of range!"); - Ops[i] = Val; - } - unsigned getNumOperands() const { return 2; } + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); /// getAlignment - Return the alignment of the access that is being performed /// @@ -363,6 +355,11 @@ } }; +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(StoreInst, Value) //===----------------------------------------------------------------------===// // GetElementPtrInst Class @@ -380,14 +377,7 @@ /// access elements of arrays and structs /// class GetElementPtrInst : public Instruction { - GetElementPtrInst(const GetElementPtrInst &GEPI) - : Instruction(reinterpret_cast(GEPI.getType()), GetElementPtr, - 0, GEPI.getNumOperands()) { - Use *OL = OperandList = new Use[NumOperands]; - Use *GEPIOL = GEPI.OperandList; - for (unsigned i = 0, E = NumOperands; i != E; ++i) - OL[i].init(GEPIOL[i], this); - } + GetElementPtrInst(const GetElementPtrInst &GEPI); void init(Value *Ptr, Value* const *Idx, unsigned NumIdx); void init(Value *Ptr, Value *Idx); @@ -400,8 +390,9 @@ unsigned NumIdx = static_cast(std::distance(IdxBegin, IdxEnd)); if (NumIdx > 0) { - // This requires that the itoerator points to contiguous memory. - init(Ptr, &*IdxBegin, NumIdx); + // This requires that the iterator points to contiguous memory. + init(Ptr, &*IdxBegin, NumIdx); // FIXME: for the general case + // we have to build an array here } else { init(Ptr, 0, NumIdx); @@ -446,34 +437,21 @@ /// instruction, the second appends the new instruction to the specified /// BasicBlock. template - GetElementPtrInst(Value *Ptr, InputIterator IdxBegin, - InputIterator IdxEnd, - const std::string &Name = "", - Instruction *InsertBefore = 0) - : Instruction(PointerType::get( - checkType(getIndexedType(Ptr->getType(), - IdxBegin, IdxEnd, true)), - cast(Ptr->getType())->getAddressSpace()), - GetElementPtr, 0, 0, InsertBefore) { - init(Ptr, IdxBegin, IdxEnd, Name, - typename std::iterator_traits::iterator_category()); - } + inline GetElementPtrInst(Value *Ptr, InputIterator IdxBegin, + InputIterator IdxEnd, + unsigned Values, + const std::string &Name, + Instruction *InsertBefore); template - GetElementPtrInst(Value *Ptr, InputIterator IdxBegin, InputIterator IdxEnd, - const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(PointerType::get( - checkType(getIndexedType(Ptr->getType(), - IdxBegin, IdxEnd, true)), - cast(Ptr->getType())->getAddressSpace()), - GetElementPtr, 0, 0, InsertAtEnd) { - init(Ptr, IdxBegin, IdxEnd, Name, - typename std::iterator_traits::iterator_category()); - } + inline GetElementPtrInst(Value *Ptr, + InputIterator IdxBegin, InputIterator IdxEnd, + unsigned Values, + const std::string &Name, BasicBlock *InsertAtEnd); /// Constructors - These two constructors are convenience methods because one /// and two index getelementptr instructions are so common. - GetElementPtrInst(Value *Ptr, Value *Idx, - const std::string &Name = "", Instruction *InsertBefore = 0); + GetElementPtrInst(Value *Ptr, Value *Idx, const std::string &Name = "", + Instruction *InsertBefore = 0); GetElementPtrInst(Value *Ptr, Value *Idx, const std::string &Name, BasicBlock *InsertAtEnd); public: @@ -482,28 +460,40 @@ InputIterator IdxEnd, const std::string &Name = "", Instruction *InsertBefore = 0) { - return new(0/*FIXME*/) GetElementPtrInst(Ptr, IdxBegin, IdxEnd, Name, InsertBefore); + typename std::iterator_traits::difference_type Values = + 1 + std::distance(IdxBegin, IdxEnd); + return new(Values) + GetElementPtrInst(Ptr, IdxBegin, IdxEnd, Values, Name, InsertBefore); } template - static GetElementPtrInst *Create(Value *Ptr, InputIterator IdxBegin, InputIterator IdxEnd, - const std::string &Name, BasicBlock *InsertAtEnd) { - return new(0/*FIXME*/) GetElementPtrInst(Ptr, IdxBegin, IdxEnd, Name, InsertAtEnd); + static GetElementPtrInst *Create(Value *Ptr, + InputIterator IdxBegin, InputIterator IdxEnd, + const std::string &Name, + BasicBlock *InsertAtEnd) { + typename std::iterator_traits::difference_type Values = + 1 + std::distance(IdxBegin, IdxEnd); + return new(Values) + GetElementPtrInst(Ptr, IdxBegin, IdxEnd, Values, Name, InsertAtEnd); } - /// Constructors - These two constructors are convenience methods because one - /// and two index getelementptr instructions are so common. + /// Constructors - These two creators are convenience methods because one + /// index getelementptr instructions are so common. static GetElementPtrInst *Create(Value *Ptr, Value *Idx, - const std::string &Name = "", Instruction *InsertBefore = 0) { - return new(2/*FIXME*/) GetElementPtrInst(Ptr, Idx, Name, InsertBefore); + const std::string &Name = "", + Instruction *InsertBefore = 0) { + return new(2) GetElementPtrInst(Ptr, Idx, Name, InsertBefore); } static GetElementPtrInst *Create(Value *Ptr, Value *Idx, - const std::string &Name, BasicBlock *InsertAtEnd) { - return new(2/*FIXME*/) GetElementPtrInst(Ptr, Idx, Name, InsertAtEnd); + const std::string &Name, + BasicBlock *InsertAtEnd) { + return new(2) GetElementPtrInst(Ptr, Idx, Name, InsertAtEnd); } - ~GetElementPtrInst(); virtual GetElementPtrInst *clone() const; + /// 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()); @@ -570,6 +560,51 @@ } }; +template <> +struct OperandTraits : VariadicOperandTraits<1> { +}; + +template +GetElementPtrInst::GetElementPtrInst(Value *Ptr, + InputIterator IdxBegin, + InputIterator IdxEnd, + unsigned Values, + const std::string &Name, + Instruction *InsertBefore) + : Instruction(PointerType::get(checkType( + getIndexedType(Ptr->getType(), + IdxBegin, IdxEnd, true)), + cast(Ptr->getType()) + ->getAddressSpace()), + GetElementPtr, + OperandTraits::op_end(this) - Values, + Values, InsertBefore) { + init(Ptr, IdxBegin, IdxEnd, Name, + typename std::iterator_traits::iterator_category()); +} +template +GetElementPtrInst::GetElementPtrInst(Value *Ptr, + InputIterator IdxBegin, + InputIterator IdxEnd, + unsigned Values, + const std::string &Name, + BasicBlock *InsertAtEnd) + : Instruction(PointerType::get(checkType( + getIndexedType(Ptr->getType(), + IdxBegin, IdxEnd, true)), + cast(Ptr->getType()) + ->getAddressSpace()), + GetElementPtr, + OperandTraits::op_end(this) - Values, + Values, InsertAtEnd) { + init(Ptr, IdxBegin, IdxEnd, Name, + typename std::iterator_traits::iterator_category()); +} + + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetElementPtrInst, Value) + + //===----------------------------------------------------------------------===// // ICmpInst Class //===----------------------------------------------------------------------===// @@ -723,7 +758,7 @@ /// @brief Swap operands and adjust predicate. void swapOperands() { SubclassData = getSwappedPredicate(); - std::swap(Ops[0], Ops[1]); + std::swap(Op<0>(), Op<1>()); } virtual ICmpInst *clone() const; @@ -847,7 +882,7 @@ /// @brief Swap operands and adjust predicate. void swapOperands() { SubclassData = getSwappedPredicate(); - std::swap(Ops[0], Ops[1]); + std::swap(Op<0>(), Op<1>()); } virtual FCmpInst *clone() const; @@ -900,13 +935,7 @@ /// @brief Construct a CallInst from a range of arguments template CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, - const std::string &Name = "", Instruction *InsertBefore = 0) - : Instruction(cast(cast(Func->getType()) - ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, InsertBefore) { - init(Func, ArgBegin, ArgEnd, Name, - typename std::iterator_traits::iterator_category()); - } + const std::string &Name, Instruction *InsertBefore); /// Construct a CallInst given a range of arguments. InputIterator /// must be a random-access iterator pointing to contiguous storage @@ -915,35 +944,29 @@ /// incur runtime overhead. /// @brief Construct a CallInst from a range of arguments template - CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, - const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(cast(cast(Func->getType()) - ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, InsertAtEnd) { - init(Func, ArgBegin, ArgEnd, Name, - typename std::iterator_traits::iterator_category()); - } + inline CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, + const std::string &Name, BasicBlock *InsertAtEnd); - CallInst(Value *F, Value *Actual, const std::string& Name = "", - Instruction *InsertBefore = 0); + CallInst(Value *F, Value *Actual, const std::string& Name, + Instruction *InsertBefore); CallInst(Value *F, Value *Actual, const std::string& Name, BasicBlock *InsertAtEnd); - explicit CallInst(Value *F, const std::string &Name = "", - Instruction *InsertBefore = 0); + explicit CallInst(Value *F, const std::string &Name, + Instruction *InsertBefore); CallInst(Value *F, const std::string &Name, BasicBlock *InsertAtEnd); public: template - static CallInst *Create(Value *Func, InputIterator ArgBegin, - InputIterator ArgEnd, + static CallInst *Create(Value *Func, + InputIterator ArgBegin, InputIterator ArgEnd, const std::string &Name = "", Instruction *InsertBefore = 0) { return new(ArgEnd - ArgBegin + 1) CallInst(Func, ArgBegin, ArgEnd, Name, InsertBefore); } template - static CallInst *Create(Value *Func, InputIterator ArgBegin, - InputIterator ArgEnd, const std::string &Name, - BasicBlock *InsertAtEnd) { + static CallInst *Create(Value *Func, + InputIterator ArgBegin, InputIterator ArgEnd, + const std::string &Name, BasicBlock *InsertAtEnd) { return new(ArgEnd - ArgBegin + 1) CallInst(Func, ArgBegin, ArgEnd, Name, InsertAtEnd); } @@ -967,6 +990,9 @@ ~CallInst(); virtual CallInst *clone() const; + + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); bool isTailCall() const { return SubclassData & 1; } void setTailCall(bool isTailCall = true) { @@ -1050,6 +1076,36 @@ } }; +template <> +struct OperandTraits : VariadicOperandTraits<1> { +}; + +template +CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, + const std::string &Name, BasicBlock *InsertAtEnd) + : Instruction(cast(cast(Func->getType()) + ->getElementType())->getReturnType(), + Instruction::Call, + OperandTraits::op_end(this) - (ArgEnd - ArgBegin + 1), + ArgEnd - ArgBegin + 1, InsertAtEnd) { + init(Func, ArgBegin, ArgEnd, Name, + typename std::iterator_traits::iterator_category()); +} + +template +CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, + const std::string &Name, Instruction *InsertBefore) + : Instruction(cast(cast(Func->getType()) + ->getElementType())->getReturnType(), + Instruction::Call, + OperandTraits::op_end(this) - (ArgEnd - ArgBegin + 1), + ArgEnd - ArgBegin + 1, InsertBefore) { + init(Func, ArgBegin, ArgEnd, Name, + typename std::iterator_traits::iterator_category()); +} + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CallInst, Value) + //===----------------------------------------------------------------------===// // SelectInst Class //===----------------------------------------------------------------------===// @@ -1057,27 +1113,27 @@ /// SelectInst - This class represents the LLVM 'select' instruction. /// class SelectInst : public Instruction { - Use Ops[3]; - void init(Value *C, Value *S1, Value *S2) { - Ops[0].init(C, this); - Ops[1].init(S1, this); - Ops[2].init(S2, this); + Op<0>() = C; + Op<1>() = S1; + Op<2>() = S2; } SelectInst(const SelectInst &SI) - : Instruction(SI.getType(), SI.getOpcode(), Ops, 3) { - init(SI.Ops[0], SI.Ops[1], SI.Ops[2]); + : Instruction(SI.getType(), SI.getOpcode(), &Op<0>(), 3) { + init(SI.Op<0>(), SI.Op<1>(), SI.Op<2>()); } - SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "", - Instruction *InsertBefore = 0) - : Instruction(S1->getType(), Instruction::Select, Ops, 3, InsertBefore) { + SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name, + Instruction *InsertBefore) + : Instruction(S1->getType(), Instruction::Select, + &Op<0>(), 3, InsertBefore) { init(C, S1, S2); setName(Name); } SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(S1->getType(), Instruction::Select, Ops, 3, InsertAtEnd) { + : Instruction(S1->getType(), Instruction::Select, + &Op<0>(), 3, InsertAtEnd) { init(C, S1, S2); setName(Name); } @@ -1092,20 +1148,12 @@ return new(3) SelectInst(C, S1, S2, Name, InsertAtEnd); } - Value *getCondition() const { return Ops[0]; } - Value *getTrueValue() const { return Ops[1]; } - Value *getFalseValue() const { return Ops[2]; } + Value *getCondition() const { return Op<0>(); } + Value *getTrueValue() const { return Op<1>(); } + Value *getFalseValue() const { return Op<2>(); } /// Transparently provide more efficient getOperand methods. - Value *getOperand(unsigned i) const { - assert(i < 3 && "getOperand() out of range!"); - return Ops[i]; - } - void setOperand(unsigned i, Value *Val) { - assert(i < 3 && "setOperand() out of range!"); - Ops[i] = Val; - } - unsigned getNumOperands() const { return 3; } + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); OtherOps getOpcode() const { return static_cast(Instruction::getOpcode()); @@ -1123,6 +1171,12 @@ } }; +template <> +struct OperandTraits : FixedNumOperandTraits<3> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SelectInst, Value) + //===----------------------------------------------------------------------===// // VAArgInst Class //===----------------------------------------------------------------------===// @@ -1165,17 +1219,16 @@ /// element from a VectorType value /// class ExtractElementInst : public Instruction { - Use Ops[2]; ExtractElementInst(const ExtractElementInst &EE) : - Instruction(EE.getType(), ExtractElement, Ops, 2) { - Ops[0].init(EE.Ops[0], this); - Ops[1].init(EE.Ops[1], this); + Instruction(EE.getType(), ExtractElement, &Op<0>(), 2) { + Op<0>().init(EE.Op<0>(), this); + Op<1>().init(EE.Op<1>(), this); } public: // allocate space for exactly two operands void *operator new(size_t s) { - return User::operator new(s, 2); // FIXME: unsigned Idx forms of constructor? + return User::operator new(s, 2); // FIXME: "unsigned Idx" forms of ctor? } ExtractElementInst(Value *Vec, Value *Idx, const std::string &Name = "", Instruction *InsertBefore = 0); @@ -1193,15 +1246,7 @@ virtual ExtractElementInst *clone() const; /// Transparently provide more efficient getOperand methods. - Value *getOperand(unsigned i) const { - assert(i < 2 && "getOperand() out of range!"); - return Ops[i]; - } - void setOperand(unsigned i, Value *Val) { - assert(i < 2 && "setOperand() out of range!"); - Ops[i] = Val; - } - unsigned getNumOperands() const { return 2; } + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ExtractElementInst *) { return true; } @@ -1213,6 +1258,12 @@ } }; +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementInst, Value) + //===----------------------------------------------------------------------===// // InsertElementInst Class //===----------------------------------------------------------------------===// @@ -1221,7 +1272,6 @@ /// element into a VectorType value /// class InsertElementInst : public Instruction { - Use Ops[3]; InsertElementInst(const InsertElementInst &IE); InsertElementInst(Value *Vec, Value *NewElt, Value *Idx, const std::string &Name = "",Instruction *InsertBefore = 0); @@ -1236,14 +1286,14 @@ return new(IE.getNumOperands()) InsertElementInst(IE); } static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx, - const std::string &Name = "",Instruction *InsertBefore = 0) { + const std::string &Name = "", + Instruction *InsertBefore = 0) { return new(3) InsertElementInst(Vec, NewElt, Idx, Name, InsertBefore); } static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx, const std::string &Name = "", Instruction *InsertBefore = 0) { - return new(3/*FIXME*/) - InsertElementInst(Vec, NewElt, Idx, Name, InsertBefore); + return new(3) InsertElementInst(Vec, NewElt, Idx, Name, InsertBefore); } static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx, const std::string &Name, @@ -1253,8 +1303,7 @@ static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx, const std::string &Name, BasicBlock *InsertAtEnd) { - return new(3/*FIXME*/) - InsertElementInst(Vec, NewElt, Idx, Name, InsertAtEnd); + return new(3) InsertElementInst(Vec, NewElt, Idx, Name, InsertAtEnd); } /// isValidOperands - Return true if an insertelement instruction can be @@ -1271,15 +1320,7 @@ } /// Transparently provide more efficient getOperand methods. - Value *getOperand(unsigned i) const { - assert(i < 3 && "getOperand() out of range!"); - return Ops[i]; - } - void setOperand(unsigned i, Value *Val) { - assert(i < 3 && "setOperand() out of range!"); - Ops[i] = Val; - } - unsigned getNumOperands() const { return 3; } + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const InsertElementInst *) { return true; } @@ -1291,6 +1332,12 @@ } }; +template <> +struct OperandTraits : FixedNumOperandTraits<3> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertElementInst, Value) + //===----------------------------------------------------------------------===// // ShuffleVectorInst Class //===----------------------------------------------------------------------===// @@ -1299,7 +1346,6 @@ /// input vectors. /// class ShuffleVectorInst : public Instruction { - Use Ops[3]; ShuffleVectorInst(const ShuffleVectorInst &IE); public: // allocate space for exactly three operands @@ -1325,19 +1371,7 @@ } /// Transparently provide more efficient getOperand methods. - const Value *getOperand(unsigned i) const { - assert(i < 3 && "getOperand() out of range!"); - return Ops[i]; - } - Value *getOperand(unsigned i) { - assert(i < 3 && "getOperand() out of range!"); - return Ops[i]; - } - void setOperand(unsigned i, Value *Val) { - assert(i < 3 && "setOperand() out of range!"); - Ops[i] = Val; - } - unsigned getNumOperands() const { return 3; } + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); /// getMaskValue - Return the index from the shuffle mask for the specified /// output result. This is either -1 if the element is undef or a number less @@ -1354,6 +1388,11 @@ } }; +template <> +struct OperandTraits : FixedNumOperandTraits<3> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ShuffleVectorInst, Value) //===----------------------------------------------------------------------===// // PHINode Class @@ -1406,6 +1445,9 @@ virtual PHINode *clone() const; + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + /// getNumIncomingValues - Return the number of incoming edges /// unsigned getNumIncomingValues() const { return getNumOperands()/2; } @@ -1427,10 +1469,10 @@ /// getIncomingBlock - Return incoming basic block number x /// BasicBlock *getIncomingBlock(unsigned i) const { - return reinterpret_cast(getOperand(i*2+1)); + return static_cast(getOperand(i*2+1)); } void setIncomingBlock(unsigned i, BasicBlock *BB) { - setOperand(i*2+1, reinterpret_cast(BB)); + setOperand(i*2+1, BB); } unsigned getOperandNumForIncomingBlock(unsigned i) { return i*2+1; @@ -1449,7 +1491,7 @@ // Initialize some new operands. NumOperands = OpNo+2; OperandList[OpNo].init(V, this); - OperandList[OpNo+1].init(reinterpret_cast(BB), this); + OperandList[OpNo+1].init(BB, this); } /// removeIncomingValue - Remove an incoming value. This is useful if a @@ -1462,7 +1504,7 @@ /// Value *removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty = true); - Value *removeIncomingValue(const BasicBlock *BB, bool DeletePHIIfEmpty =true){ + Value *removeIncomingValue(const BasicBlock *BB, bool DeletePHIIfEmpty=true) { int Idx = getBasicBlockIndex(BB); assert(Idx >= 0 && "Invalid basic block argument to remove!"); return removeIncomingValue(Idx, DeletePHIIfEmpty); @@ -1474,7 +1516,7 @@ int getBasicBlockIndex(const BasicBlock *BB) const { Use *OL = OperandList; for (unsigned i = 0, e = getNumOperands(); i != e; i += 2) - if (OL[i+1] == reinterpret_cast(BB)) return i/2; + if (OL[i+1].get() == BB) return i/2; return -1; } @@ -1499,6 +1541,13 @@ void resizeOperands(unsigned NumOperands); }; +template <> +struct OperandTraits : HungoffOperandTraits<2> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(PHINode, Value) + + //===----------------------------------------------------------------------===// // ReturnInst Class //===----------------------------------------------------------------------===// @@ -1508,7 +1557,6 @@ /// does not continue in this function any longer. /// class ReturnInst : public TerminatorInst { - Use RetVal; ReturnInst(const ReturnInst &RI); void init(Value * const* retVals, unsigned N); @@ -1517,20 +1565,19 @@ // ReturnInst() - 'ret void' instruction // ReturnInst( null) - 'ret void' instruction // ReturnInst(Value* X) - 'ret X' instruction - // ReturnInst( null, Inst *) - 'ret void' instruction, insert before I + // ReturnInst( null, Inst *I) - 'ret void' instruction, insert before I // ReturnInst(Value* X, Inst *I) - 'ret X' instruction, insert before I - // ReturnInst( null, BB *B) - 'ret void' instruction, insert @ end of BB - // ReturnInst(Value* X, BB *B) - 'ret X' instruction, insert @ end of BB + // ReturnInst( null, BB *B) - 'ret void' instruction, insert @ end of B + // ReturnInst(Value* X, BB *B) - 'ret X' instruction, insert @ end of B // ReturnInst(Value* X, N) - 'ret X,X+1...X+N-1' instruction - // ReturnInst(Value* X, N, Inst *) - 'ret X,X+1...X+N-1', insert before I - // ReturnInst(Value* X, N, BB *) - 'ret X,X+1...X+N-1', insert @ end of BB + // ReturnInst(Value* X, N, Inst *I) - 'ret X,X+1...X+N-1', insert before I + // ReturnInst(Value* X, N, BB *B) - 'ret X,X+1...X+N-1', insert @ end of B // // NOTE: If the Value* passed is of type void then the constructor behaves as // if it was passed NULL. explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0); ReturnInst(Value *retVal, BasicBlock *InsertAtEnd); - ReturnInst(Value * const* retVals, unsigned N); - ReturnInst(Value * const* retVals, unsigned N, Instruction *InsertBefore); + ReturnInst(Value * const* retVals, unsigned N, Instruction *InsertBefore = 0); ReturnInst(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd); explicit ReturnInst(BasicBlock *InsertAtEnd); public: @@ -1540,11 +1587,8 @@ static ReturnInst* Create(Value *retVal, BasicBlock *InsertAtEnd) { return new(!!retVal) ReturnInst(retVal, InsertAtEnd); } - static ReturnInst* Create(Value * const* retVals, unsigned N) { - return new(N) ReturnInst(retVals, N); - } static ReturnInst* Create(Value * const* retVals, unsigned N, - Instruction *InsertBefore) { + Instruction *InsertBefore = 0) { return new(N) ReturnInst(retVals, N, InsertBefore); } static ReturnInst* Create(Value * const* retVals, unsigned N, @@ -1555,18 +1599,18 @@ return new(0) ReturnInst(InsertAtEnd); } virtual ~ReturnInst(); + inline void operator delete(void*); virtual ReturnInst *clone() const; - Value *getOperand(unsigned n = 0) const { - if (getNumOperands() > 1) - return TerminatorInst::getOperand(n); - else - return RetVal; - } + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + /// Convenience accessor Value *getReturnValue(unsigned n = 0) const { - return getOperand(n); + return n < getNumOperands() + ? getOperand(n) + : 0; } unsigned getNumSuccessors() const { return 0; } @@ -1585,6 +1629,18 @@ virtual void setSuccessorV(unsigned idx, BasicBlock *B); }; +template <> +struct OperandTraits : VariadicOperandTraits<> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ReturnInst, Value) +void ReturnInst::operator delete(void *it) { + ReturnInst* me(static_cast(it)); + Use::zap(OperandTraits::op_begin(me), + OperandTraits::op_end(me), + true); +} + //===----------------------------------------------------------------------===// // BranchInst Class //===----------------------------------------------------------------------===// @@ -1596,7 +1652,6 @@ /// Ops list - Branches are strange. The operands are ordered: /// TrueDest, FalseDest, Cond. This makes some accessors faster because /// they don't have to check for cond/uncond branchness. - Use Ops[3]; BranchInst(const BranchInst &BI); void AssertOK(); // BranchInst constructors (where {B, T, F} are blocks, and C is a condition): @@ -1616,28 +1671,29 @@ static BranchInst *Create(BasicBlock *IfTrue, Instruction *InsertBefore = 0) { return new(1) BranchInst(IfTrue, InsertBefore); } - static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, - Instruction *InsertBefore = 0) { + static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse, + Value *Cond, Instruction *InsertBefore = 0) { return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertBefore); } static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *InsertAtEnd) { return new(1) BranchInst(IfTrue, InsertAtEnd); } - static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, - BasicBlock *InsertAtEnd) { + static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse, + Value *Cond, BasicBlock *InsertAtEnd) { return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertAtEnd); } - /// Transparently provide more efficient getOperand methods. - Value *getOperand(unsigned i) const { - assert(i < getNumOperands() && "getOperand() out of range!"); - return Ops[i]; - } - void setOperand(unsigned i, Value *Val) { - assert(i < getNumOperands() && "setOperand() out of range!"); - Ops[i] = Val; + ~BranchInst() + { + if (NumOperands == 1) + { + NumOperands = (Use*)this - OperandList; + } } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + virtual BranchInst *clone() const; bool isUnconditional() const { return getNumOperands() == 1; } @@ -1657,12 +1713,12 @@ // targeting the specified block. // FIXME: Eliminate this ugly method. void setUnconditionalDest(BasicBlock *Dest) { + Op<0>() = Dest; if (isConditional()) { // Convert this to an uncond branch. + Op<1>().set(0); + Op<2>().set(0); NumOperands = 1; - Ops[1].set(0); - Ops[2].set(0); } - setOperand(0, reinterpret_cast(Dest)); } unsigned getNumSuccessors() const { return 1+isConditional(); } @@ -1674,7 +1730,7 @@ void setSuccessor(unsigned idx, BasicBlock *NewSucc) { assert(idx < getNumSuccessors() && "Successor # out of range for Branch!"); - setOperand(idx, reinterpret_cast(NewSucc)); + setOperand(idx, NewSucc); } // Methods for support type inquiry through isa, cast, and dyn_cast: @@ -1691,6 +1747,15 @@ virtual void setSuccessorV(unsigned idx, BasicBlock *B); }; +template <> +struct OperandTraits : HungoffOperandTraits<> { + // we need to access operands via OperandList, since + // the NumOperands may change from 3 to 1 + static inline void *allocate(unsigned); // FIXME +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BranchInst, Value) + //===----------------------------------------------------------------------===// // SwitchInst Class //===----------------------------------------------------------------------===// @@ -1699,6 +1764,7 @@ /// SwitchInst - Multiway switch /// class SwitchInst : public TerminatorInst { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT unsigned ReservedSpace; // Operand[0] = Value to switch on // Operand[1] = Default basic block destination @@ -1707,6 +1773,10 @@ SwitchInst(const SwitchInst &RI); void init(Value *Value, BasicBlock *Default, unsigned NumCases); void resizeOperands(unsigned No); + // allocate space for exactly zero operands + void *operator new(size_t s) { + return User::operator new(s, 0); + } /// SwitchInst ctor - Create a new switch instruction, specifying a value to /// switch on and a default destination. The number of additional cases can /// be specified here to make memory allocation more efficient. This @@ -1721,18 +1791,19 @@ SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases, BasicBlock *InsertAtEnd); public: - static SwitchInst *Create(Value *Value, BasicBlock *Default, unsigned NumCases, - Instruction *InsertBefore = 0) { - return new(NumCases/*FIXME*/) - SwitchInst(Value, Default, NumCases, InsertBefore); - } - static SwitchInst *Create(Value *Value, BasicBlock *Default, unsigned NumCases, - BasicBlock *InsertAtEnd) { - return new(NumCases/*FIXME*/) - SwitchInst(Value, Default, NumCases, InsertAtEnd); + static SwitchInst *Create(Value *Value, BasicBlock *Default, + unsigned NumCases, Instruction *InsertBefore = 0) { + return new SwitchInst(Value, Default, NumCases, InsertBefore); + } + static SwitchInst *Create(Value *Value, BasicBlock *Default, + unsigned NumCases, BasicBlock *InsertAtEnd) { + return new SwitchInst(Value, Default, NumCases, InsertAtEnd); } ~SwitchInst(); + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + // Accessor Methods for Switch stmt Value *getCondition() const { return getOperand(0); } void setCondition(Value *V) { setOperand(0, V); } @@ -1805,7 +1876,7 @@ } void setSuccessor(unsigned idx, BasicBlock *NewSucc) { assert(idx < getNumSuccessors() && "Successor # out of range for switch!"); - setOperand(idx*2+1, reinterpret_cast(NewSucc)); + setOperand(idx*2+1, NewSucc); } // getSuccessorValue - Return the value associated with the specified @@ -1829,6 +1900,13 @@ virtual void setSuccessorV(unsigned idx, BasicBlock *B); }; +template <> +struct OperandTraits : HungoffOperandTraits<2> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SwitchInst, Value) + + //===----------------------------------------------------------------------===// // InvokeInst Class //===----------------------------------------------------------------------===// @@ -1866,15 +1944,10 @@ /// /// @brief Construct an InvokeInst from a range of arguments template - InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, - InputIterator ArgBegin, InputIterator ArgEnd, - const std::string &Name = "", Instruction *InsertBefore = 0) - : TerminatorInst(cast(cast(Func->getType()) - ->getElementType())->getReturnType(), - Instruction::Invoke, 0, 0, InsertBefore) { - init(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, - typename std::iterator_traits::iterator_category()); - } + inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, + InputIterator ArgBegin, InputIterator ArgEnd, + unsigned Values, + const std::string &Name, Instruction *InsertBefore); /// Construct an InvokeInst given a range of arguments. /// InputIterator must be a random-access iterator pointing to @@ -1884,38 +1957,36 @@ /// /// @brief Construct an InvokeInst from a range of arguments template - InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, - InputIterator ArgBegin, InputIterator ArgEnd, - const std::string &Name, BasicBlock *InsertAtEnd) - : TerminatorInst(cast(cast(Func->getType()) - ->getElementType())->getReturnType(), - Instruction::Invoke, 0, 0, InsertAtEnd) { - init(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, - typename std::iterator_traits::iterator_category()); - } + inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, + InputIterator ArgBegin, InputIterator ArgEnd, + unsigned Values, + const std::string &Name, BasicBlock *InsertAtEnd); public: template - static InvokeInst *Create(Value *Func, BasicBlock *IfNormal, - BasicBlock *IfException, + static InvokeInst *Create(Value *Func, + BasicBlock *IfNormal, BasicBlock *IfException, InputIterator ArgBegin, InputIterator ArgEnd, const std::string &Name = "", Instruction *InsertBefore = 0) { - return new(ArgEnd - ArgBegin + 3) - InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, InsertBefore); + unsigned Values(ArgEnd - ArgBegin + 3); + return new(Values) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd, + Values, Name, InsertBefore); } template - static InvokeInst *Create(Value *Func, BasicBlock *IfNormal, - BasicBlock *IfException, + static InvokeInst *Create(Value *Func, + BasicBlock *IfNormal, BasicBlock *IfException, InputIterator ArgBegin, InputIterator ArgEnd, const std::string &Name, BasicBlock *InsertAtEnd) { - return new(ArgEnd - ArgBegin + 3) - InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, InsertAtEnd); + unsigned Values(ArgEnd - ArgBegin + 3); + return new(Values) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd, + Values, Name, InsertAtEnd); } - ~InvokeInst(); - virtual InvokeInst *clone() const; + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + /// getCallingConv/setCallingConv - Get or set the calling convention of this /// function call. unsigned getCallingConv() const { return SubclassData; } @@ -1985,11 +2056,11 @@ return cast(getOperand(2)); } void setNormalDest(BasicBlock *B) { - setOperand(1, reinterpret_cast(B)); + setOperand(1, B); } void setUnwindDest(BasicBlock *B) { - setOperand(2, reinterpret_cast(B)); + setOperand(2, B); } BasicBlock *getSuccessor(unsigned i) const { @@ -1999,7 +2070,7 @@ void setSuccessor(unsigned idx, BasicBlock *NewSucc) { assert(idx < 2 && "Successor # out of range for invoke!"); - setOperand(idx+1, reinterpret_cast(NewSucc)); + setOperand(idx+1, NewSucc); } unsigned getNumSuccessors() const { return 2; } @@ -2018,6 +2089,40 @@ virtual void setSuccessorV(unsigned idx, BasicBlock *B); }; +template <> +struct OperandTraits : VariadicOperandTraits<3> { +}; + +template +InvokeInst::InvokeInst(Value *Func, + BasicBlock *IfNormal, BasicBlock *IfException, + InputIterator ArgBegin, InputIterator ArgEnd, + unsigned Values, + const std::string &Name, Instruction *InsertBefore) + : TerminatorInst(cast(cast(Func->getType()) + ->getElementType())->getReturnType(), + Instruction::Invoke, + OperandTraits::op_end(this) - Values, + Values, InsertBefore) { + init(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, + typename std::iterator_traits::iterator_category()); +} +template +InvokeInst::InvokeInst(Value *Func, + BasicBlock *IfNormal, BasicBlock *IfException, + InputIterator ArgBegin, InputIterator ArgEnd, + unsigned Values, + const std::string &Name, BasicBlock *InsertAtEnd) + : TerminatorInst(cast(cast(Func->getType()) + ->getElementType())->getReturnType(), + Instruction::Invoke, + OperandTraits::op_end(this) - Values, + Values, InsertAtEnd) { + init(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, + typename std::iterator_traits::iterator_category()); +} + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InvokeInst, Value) //===----------------------------------------------------------------------===// // UnwindInst Class @@ -2572,11 +2677,10 @@ /// class GetResultInst : public /*FIXME: Unary*/Instruction { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Aggr; unsigned Idx; GetResultInst(const GetResultInst &GRI) : - Instruction(GRI.getType(), Instruction::GetResult, &Aggr, 1) { - Aggr.init(GRI.Aggr, this); + Instruction(GRI.getType(), Instruction::GetResult, &Op<0>(), 1) { + Op<0>().init(GRI.Op<0>(), this); Idx = GRI.Idx; } @@ -2585,9 +2689,9 @@ void *operator new(size_t s) { return User::operator new(s, 1); } - explicit GetResultInst(Value *Aggr, unsigned index, - const std::string &Name = "", - Instruction *InsertBefore = 0); + GetResultInst(Value *Aggr, unsigned index, + const std::string &Name = "", + Instruction *InsertBefore = 0); /// isValidOperands - Return true if an getresult instruction can be /// formed with the specified operands. @@ -2607,7 +2711,8 @@ return Idx; } - unsigned getNumOperands() const { return 1; } + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const GetResultInst *) { return true; } @@ -2619,6 +2724,14 @@ } }; +// FIXME: these are redundant if GetResultInst < UnaryInstruction +template <> +struct OperandTraits : FixedNumOperandTraits<1> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetResultInst, Value) + + } // End llvm namespace #endif Modified: llvm/trunk/include/llvm/Use.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Use.h?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/include/llvm/Use.h (original) +++ llvm/trunk/include/llvm/Use.h Sat May 10 03:32:32 2008 @@ -26,6 +26,40 @@ //===----------------------------------------------------------------------===// +// Generic Tagging Functions +//===----------------------------------------------------------------------===// + +/// Tag - generic tag type for (at least 32 bit) pointers +enum Tag { noTag, tagOne, tagTwo, tagThree }; + +/// addTag - insert tag bits into an (untagged) pointer +template +inline T *addTag(const T *P, TAG Tag) { + return reinterpret_cast(ptrdiff_t(P) | Tag); +} + +/// stripTag - remove tag bits from a pointer, +/// making it dereferencable +template +inline T *stripTag(const T *P) { + return reinterpret_cast(ptrdiff_t(P) & ~MASK); +} + +/// extractTag - extract tag bits from a pointer +template +inline TAG extractTag(const T *P) { + return TAG(ptrdiff_t(P) & MASK); +} + +/// transferTag - transfer tag bits from a pointer, +/// to an untagged pointer +template +inline T *transferTag(const T *From, const T *To) { + return reinterpret_cast((ptrdiff_t(From) & MASK) | ptrdiff_t(To)); +} + + +//===----------------------------------------------------------------------===// // Use Class //===----------------------------------------------------------------------===// @@ -35,20 +69,36 @@ public: inline void init(Value *V, User *U); - Use(Value *V, User *U) { init(V, U); } - Use(const Use &U) { init(U.Val, U.U); } +private: + /// Allow std::swap some intimacy + template friend void std::swap(U&, U&); + + /// Copy ctor - Only for std::swap + Use(const Use &U) { init(U.get(), 0); } + + /// Destructor - Only for zap() and std::swap inline ~Use() { - if (Val) removeFromList(); + if (get()) removeFromList(); } - /// Default ctor - This leaves the Use completely unitialized. The only thing + /// Default ctor - This leaves the Use completely uninitialized. The only thing /// that is valid to do with this use is to call the "init" method. - inline Use() : Val(0) {} + + inline Use() {} + enum PrevPtrTag { zeroDigitTag = noTag + , oneDigitTag = tagOne + , stopTag = tagTwo + , fullStopTag = tagThree }; + +public: operator Value*() const { return Val; } Value *get() const { return Val; } - User *getUser() const { return U; } + User *getUser() const; + const Use* getImpliedUser() const; + static Use *initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0); + static void zap(Use *Start, const Use *Stop, bool del = false); inline void set(Value *Val); @@ -57,7 +107,7 @@ return RHS; } const Use &operator=(const Use &RHS) { - set(RHS.Val); + set(RHS.get()); return *this; } @@ -66,19 +116,22 @@ Use *getNext() const { return Next; } private: - Use *Next, **Prev; Value *Val; - User *U; + Use *Next, **Prev; + void setPrev(Use **NewPrev) { + Prev = transferTag(Prev, NewPrev); + } void addToList(Use **List) { Next = *List; - if (Next) Next->Prev = &Next; - Prev = List; + if (Next) Next->setPrev(&Next); + setPrev(List); *List = this; } void removeFromList() { - *Prev = Next; - if (Next) Next->Prev = Prev; + Use **StrippedPrev = stripTag(Prev); + *StrippedPrev = Next; + if (Next) Next->setPrev(StrippedPrev); } friend class Value; @@ -138,7 +191,7 @@ // Retrieve a reference to the current User UserTy *operator*() const { - assert(U && "Cannot increment end iterator!"); + assert(U && "Cannot dereference end iterator!"); return U->getUser(); } Modified: llvm/trunk/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/User.h?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/include/llvm/User.h (original) +++ llvm/trunk/include/llvm/User.h Sat May 10 03:32:32 2008 @@ -23,15 +23,203 @@ namespace llvm { +/*============================================================================== + + + ----------------------------------------------------------------- + --- Interaction and relationship between User and Use objects --- + ----------------------------------------------------------------- + + +A subclass of User can choose between incorporating its Use objects +or refer to them out-of-line by means of a pointer. A mixed variant +(some Uses inline others hung off) is impractical and breaks the invariant +that the Use objects belonging to the same User form a contiguous array. + +We have 2 different layouts in the User (sub)classes: + +Layout a) +The Use object(s) are inside (resp. at fixed offset) of the User +object and there are a fixed number of them. + +Layout b) +The Use object(s) are referenced by a pointer to an +array from the User object and there may be a variable +number of them. + +Initially each layout will possess a direct pointer to the +start of the array of Uses. Though not mandatory for layout a), +we stick to this redundancy for the sake of simplicity. +The User object will also store the number of Use objects it +has. (Theoretically this information can also be calculated +given the scheme presented below.) + +Special forms of allocation operators (operator new) +will enforce the following memory layouts: + + +# Layout a) will be modelled by prepending the User object +# by the Use[] array. +# +# ...---.---.---.---.-------... +# | P | P | P | P | User +# '''---'---'---'---'-------''' + + +# Layout b) will be modelled by pointing at the Use[] array. +# +# .-------... +# | User +# '-------''' +# | +# v +# .---.---.---.---... +# | P | P | P | P | +# '---'---'---'---''' + + (In the above figures 'P' stands for the Use** that + is stored in each Use object in the member Use::Prev) + + +Since the Use objects will be deprived of the direct pointer to +their User objects, there must be a fast and exact method to +recover it. This is accomplished by the following scheme: + +A bit-encoding in the 2 LSBits of the Use::Prev will allow to find the +start of the User object: + +00 --> binary digit 0 +01 --> binary digit 1 +10 --> stop and calc (s) +11 --> full stop (S) + +Given a Use*, all we have to do is to walk till we get +a stop and we either have a User immediately behind or +we have to walk to the next stop picking up digits +and calculating the offset: + +.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---------------- +| 1 | s | 1 | 0 | 1 | 0 | s | 1 | 1 | 0 | s | 1 | 1 | s | 1 | S | User (or User*) +'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---------------- + |+15 |+10 |+6 |+3 |+1 + | | | | |__> + | | | |__________> + | | |______________________> + | |______________________________________> + |__________________________________________________________> + + +Only the significant number of bits need to be stored between the +stops, so that the worst case is 20 memory accesses when there are +1000 Use objects. + +The following literate Haskell fragment demonstrates the concept: + +> import Test.QuickCheck +> +> digits :: Int -> [Char] -> [Char] +> digits 0 acc = '0' : acc +> digits 1 acc = '1' : acc +> digits n acc = digits (n `div` 2) $ digits (n `mod` 2) acc +> +> dist :: Int -> [Char] -> [Char] +> dist 0 [] = ['S'] +> dist 0 acc = acc +> dist 1 acc = let r = dist 0 acc in 's' : digits (length r) r +> dist n acc = dist (n - 1) $ dist 1 acc +> +> takeLast n ss = reverse $ take n $ reverse ss +> +> test = takeLast 40 $ dist 20 [] +> + +Printing gives: "1s100000s11010s10100s1111s1010s110s11s1S" + +The reverse algorithm computes the +length of the string just by examining +a certain prefix: + +> pref :: [Char] -> Int +> pref "S" = 1 +> pref ('s':'1':rest) = decode 2 1 rest +> pref (_:rest) = 1 + pref rest +> +> decode walk acc ('0':rest) = decode (walk + 1) (acc * 2) rest +> decode walk acc ('1':rest) = decode (walk + 1) (acc * 2 + 1) rest +> decode walk acc _ = walk + acc +> + +Now, as expected, printing gives 40. + +We can quickCheck this with following property: + +> testcase = dist 2000 [] +> testcaseLength = length testcase +> +> identityProp n = n > 0 && n <= testcaseLength ==> length arr == pref arr +> where arr = takeLast n testcase + +As expected gives: + +*Main> quickCheck identityProp +OK, passed 100 tests. + +Let's be a bit more exhaustive: + +> +> deepCheck p = check (defaultConfig { configMaxTest = 500 }) p +> + +And here is the result of : + +*Main> deepCheck identityProp +OK, passed 500 tests. + + +To maintain the invariant that the 2 LSBits of each Use** in Use +never change after being set up, setters of Use::Prev must re-tag the +new Use** on every modification. Accordingly getters must strip the +tag bits. + +For layout b) instead of the User we will find a pointer (User* with LSBit set). +Following this pointer brings us to the User. A portable trick will ensure +that the first bytes of User (if interpreted as a pointer) will never have +the LSBit set. + +==============================================================================*/ + +/// OperandTraits - Compile-time customization of +/// operand-related allocators and accessors +/// for use of the User class +template +struct OperandTraits; + +class User; + +/// OperandTraits - specialization to User +template <> +struct OperandTraits { + static inline Use *op_begin(User*); + static inline Use *op_end(User*); + static inline unsigned operands(const User*); + template + struct Layout { + typedef U overlay; + }; + static inline void *allocate(unsigned); +}; + class User : public Value { User(const User &); // Do not implement void *operator new(size_t); // Do not implement + template + friend struct HungoffOperandTraits; protected: /// OperandList - This is a pointer to the array of Users for this operand. /// For nodes of fixed arity (e.g. a binary operator) this array will live - /// embedded into the derived class. For nodes of variable arity - /// (e.g. ConstantArrays, CallInst, PHINodes, ReturnInst etc), this memory - /// will be dynamically allocated and should be destroyed by the classes + /// prefixed to the derived class. For nodes of resizable variable arity + /// (e.g. PHINodes, SwitchInst etc.), this memory will be dynamically + /// allocated and should be destroyed by the classes' /// virtual dtor. Use *OperandList; @@ -39,13 +227,43 @@ /// unsigned NumOperands; - void *operator new(size_t s, size_t) { - return ::operator new(s); + void *operator new(size_t s, unsigned Us) { + void *Storage = ::operator new(s + sizeof(Use) * Us); + Use *Start = static_cast(Storage); + Use *End = Start + Us; + User *Obj = reinterpret_cast(End); + Obj->OperandList = Start; + Obj->NumOperands = Us; + Use::initTags(Start, End); + return Obj; } User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps) : Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {} - + Use *allocHungoffUses(unsigned) const; + void dropHungoffUses(Use *U) { + if (OperandList == U) { + OperandList = 0; + NumOperands = 0; + } + Use::zap(U, U->getImpliedUser(), true); + } public: + ~User() { + Use::zap(OperandList, OperandList + NumOperands); + } + void operator delete(void *Usr) { + User *Start = static_cast(Usr); + Use *Storage = static_cast(Usr) - Start->NumOperands; + ::operator delete(Storage == Start->OperandList + ? Storage + : Usr); + } + template Use &Op() { + return OperandTraits::op_begin(this)[Idx]; + } + template const Use &Op() const { + return OperandTraits::op_begin(const_cast(this))[Idx]; + } Value *getOperand(unsigned i) const { assert(i < NumOperands && "getOperand() out of range!"); return OperandList[i]; @@ -93,6 +311,18 @@ } }; +inline Use *OperandTraits::op_begin(User *U) { + return U->op_begin(); +} + +inline Use *OperandTraits::op_end(User *U) { + return U->op_end(); +} + +inline unsigned OperandTraits::operands(const User *U) { + return U->getNumOperands(); +} + template<> struct simplify_type { typedef Value* SimpleType; Modified: llvm/trunk/include/llvm/Value.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Value.h?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/include/llvm/Value.h (original) +++ llvm/trunk/include/llvm/Value.h Sat May 10 03:32:32 2008 @@ -232,10 +232,9 @@ return OS; } -void Use::init(Value *v, User *user) { - Val = v; - U = user; - if (Val) Val->addUse(*this); +void Use::init(Value *V, User *user) { + Val = V; + if (V) V->addUse(*this); } void Use::set(Value *V) { Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Sat May 10 03:32:32 2008 @@ -23,6 +23,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/OperandTraits.h" using namespace llvm; void BitcodeReader::FreeState() { @@ -115,55 +116,81 @@ } } - +namespace llvm { namespace { /// @brief A class for maintaining the slot number definition /// as a placeholder for the actual definition for forward constants defs. class ConstantPlaceHolder : public ConstantExpr { ConstantPlaceHolder(); // DO NOT IMPLEMENT void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT - Use Op; public: // allocate space for exactly one operand void *operator new(size_t s) { return User::operator new(s, 1); } explicit ConstantPlaceHolder(const Type *Ty) - : ConstantExpr(Ty, Instruction::UserOp1, &Op, 1), - Op(UndefValue::get(Type::Int32Ty), this) { + : ConstantExpr(Ty, Instruction::UserOp1, &Op<0>(), 1) { + Op<0>() = UndefValue::get(Type::Int32Ty); } + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); }; } + + // FIXME: can we inherit this from ConstantExpr? +template <> +struct OperandTraits : FixedNumOperandTraits<1> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantPlaceHolder, Value) +} + +void BitcodeReaderValueList::resize(unsigned Desired) { + if (Desired > Capacity) { + // Since we expect many values to come from the bitcode file we better + // allocate the double amount, so that the array size grows exponentially + // at each reallocation. Also, add a small amount of 100 extra elements + // each time, to reallocate less frequently when the array is still small. + // + Capacity = Desired * 2 + 100; + Use *New = allocHungoffUses(Capacity); + Use *Old = OperandList; + unsigned Ops = getNumOperands(); + for (int i(Ops - 1); i >= 0; --i) + New[i] = Old[i].get(); + OperandList = New; + if (Old) Use::zap(Old, Old + Ops, true); + } +} + Constant *BitcodeReaderValueList::getConstantFwdRef(unsigned Idx, const Type *Ty) { if (Idx >= size()) { // Insert a bunch of null values. - Uses.resize(Idx+1); - OperandList = &Uses[0]; + resize(Idx + 1); NumOperands = Idx+1; } - if (Value *V = Uses[Idx]) { + if (Value *V = OperandList[Idx]) { assert(Ty == V->getType() && "Type mismatch in constant table!"); return cast(V); } // Create and return a placeholder, which will later be RAUW'd. Constant *C = new ConstantPlaceHolder(Ty); - Uses[Idx].init(C, this); + OperandList[Idx].init(C, this); return C; } Value *BitcodeReaderValueList::getValueFwdRef(unsigned Idx, const Type *Ty) { if (Idx >= size()) { // Insert a bunch of null values. - Uses.resize(Idx+1); - OperandList = &Uses[0]; + resize(Idx + 1); NumOperands = Idx+1; } - if (Value *V = Uses[Idx]) { + if (Value *V = OperandList[Idx]) { assert((Ty == 0 || Ty == V->getType()) && "Type mismatch in value table!"); return V; } @@ -173,7 +200,7 @@ // Create and return a placeholder, which will later be RAUW'd. Value *V = new Argument(Ty); - Uses[Idx].init(V, this); + OperandList[Idx].init(V, this); return V; } Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h Sat May 10 03:32:32 2008 @@ -17,7 +17,7 @@ #include "llvm/ModuleProvider.h" #include "llvm/ParameterAttributes.h" #include "llvm/Type.h" -#include "llvm/User.h" +#include "llvm/OperandTraits.h" #include "llvm/Bitcode/BitstreamReader.h" #include "llvm/Bitcode/LLVMBitCodes.h" #include "llvm/ADT/DenseMap.h" @@ -26,32 +26,43 @@ namespace llvm { class MemoryBuffer; +//===----------------------------------------------------------------------===// +// BitcodeReaderValueList Class +//===----------------------------------------------------------------------===// + class BitcodeReaderValueList : public User { - std::vector Uses; + unsigned Capacity; public: - BitcodeReaderValueList() : User(Type::VoidTy, Value::ArgumentVal, 0, 0) {} - + BitcodeReaderValueList() : User(Type::VoidTy, Value::ArgumentVal, 0, 0) + , Capacity(0) {} + + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + // vector compatibility methods unsigned size() const { return getNumOperands(); } + void resize(unsigned); void push_back(Value *V) { - Uses.push_back(Use(V, this)); - OperandList = &Uses[0]; - ++NumOperands; + unsigned OldOps(NumOperands), NewOps(NumOperands + 1); + resize(NewOps); + NumOperands = NewOps; + OperandList[OldOps] = V; } void clear() { - std::vector().swap(Uses); + if (OperandList) dropHungoffUses(OperandList); + Capacity = 0; } Value *operator[](unsigned i) const { return getOperand(i); } - Value *back() const { return Uses.back(); } - void pop_back() { Uses.pop_back(); --NumOperands; } + Value *back() const { return getOperand(size() - 1); } + void pop_back() { setOperand(size() - 1, 0); --NumOperands; } bool empty() const { return NumOperands == 0; } void shrinkTo(unsigned N) { assert(N <= NumOperands && "Invalid shrinkTo request!"); - Uses.resize(N); - NumOperands = N; + while (NumOperands > N) + pop_back(); } virtual void print(std::ostream&) const {} @@ -73,11 +84,20 @@ private: void initVal(unsigned Idx, Value *V) { - assert(Uses[Idx] == 0 && "Cannot init an already init'd Use!"); - Uses[Idx].init(V, this); + if (Idx >= size()) { + // Insert a bunch of null values. + resize(Idx * 2 + 1); + } + assert(getOperand(Idx) == 0 && "Cannot init an already init'd Use!"); + OperandList[Idx].init(V, this); } }; - + +template <> +struct OperandTraits : HungoffOperandTraits { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BitcodeReaderValueList, Value) class BitcodeReader : public ModuleProvider { MemoryBuffer *Buffer; Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ConstantFold.cpp (original) +++ llvm/trunk/lib/VMCore/ConstantFold.cpp Sat May 10 03:32:32 2008 @@ -332,10 +332,10 @@ if (const ConstantVector *CVal = dyn_cast(Val)) { if (const ConstantInt *CIdx = dyn_cast(Idx)) { - return const_cast(CVal->getOperand(CIdx->getZExtValue())); + return CVal->getOperand(CIdx->getZExtValue()); } else if (isa(Idx)) { // ee({w,x,y,z}, undef) -> w (an arbitrary value). - return const_cast(CVal->getOperand(0)); + return CVal->getOperand(0); } } return 0; @@ -401,7 +401,7 @@ /// return the specified element value. Otherwise return null. static Constant *GetVectorElement(const Constant *C, unsigned EltNo) { if (const ConstantVector *CV = dyn_cast(C)) - return const_cast(CV->getOperand(EltNo)); + return CV->getOperand(EltNo); const Type *EltTy = cast(C->getType())->getElementType(); if (isa(C)) @@ -1222,9 +1222,9 @@ if (const ConstantVector *CP2 = dyn_cast(C2)) { if (pred == FCmpInst::FCMP_OEQ || pred == FCmpInst::FCMP_UEQ) { for (unsigned i = 0, e = CP1->getNumOperands(); i != e; ++i) { - Constant *C= ConstantExpr::getFCmp(FCmpInst::FCMP_OEQ, - const_cast(CP1->getOperand(i)), - const_cast(CP2->getOperand(i))); + Constant *C = ConstantExpr::getFCmp(FCmpInst::FCMP_OEQ, + CP1->getOperand(i), + CP2->getOperand(i)); if (ConstantInt *CB = dyn_cast(C)) return CB; } @@ -1233,8 +1233,8 @@ } else if (pred == ICmpInst::ICMP_EQ) { for (unsigned i = 0, e = CP1->getNumOperands(); i != e; ++i) { Constant *C = ConstantExpr::getICmp(ICmpInst::ICMP_EQ, - const_cast(CP1->getOperand(i)), - const_cast(CP2->getOperand(i))); + CP1->getOperand(i), + CP2->getOperand(i)); if (ConstantInt *CB = dyn_cast(C)) return CB; } Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Sat May 10 03:32:32 2008 @@ -354,7 +354,9 @@ ConstantArray::ConstantArray(const ArrayType *T, const std::vector &V) - : Constant(T, ConstantArrayVal, new Use[V.size()], V.size()) { + : Constant(T, ConstantArrayVal, + OperandTraits::op_end(this) - V.size(), + V.size()) { assert(V.size() == T->getNumElements() && "Invalid initializer vector for constant array"); Use *OL = OperandList; @@ -369,13 +371,12 @@ } } -ConstantArray::~ConstantArray() { - delete [] OperandList; -} ConstantStruct::ConstantStruct(const StructType *T, const std::vector &V) - : Constant(T, ConstantStructVal, new Use[V.size()], V.size()) { + : Constant(T, ConstantStructVal, + OperandTraits::op_end(this) - V.size(), + V.size()) { assert(V.size() == T->getNumElements() && "Invalid initializer vector for constant structure"); Use *OL = OperandList; @@ -392,14 +393,12 @@ } } -ConstantStruct::~ConstantStruct() { - delete [] OperandList; -} - ConstantVector::ConstantVector(const VectorType *T, const std::vector &V) - : Constant(T, ConstantVectorVal, new Use[V.size()], V.size()) { + : Constant(T, ConstantVectorVal, + OperandTraits::op_end(this) - V.size(), + V.size()) { Use *OL = OperandList; for (std::vector::const_iterator I = V.begin(), E = V.end(); I != E; ++I, ++OL) { @@ -412,10 +411,8 @@ } } -ConstantVector::~ConstantVector() { - delete [] OperandList; -} +namespace llvm { // We declare several classes private to this file, so use an anonymous // namespace namespace { @@ -424,49 +421,54 @@ /// behind the scenes to implement unary constant exprs. class VISIBILITY_HIDDEN UnaryConstantExpr : public ConstantExpr { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Op; public: // allocate space for exactly one operand void *operator new(size_t s) { return User::operator new(s, 1); } UnaryConstantExpr(unsigned Opcode, Constant *C, const Type *Ty) - : ConstantExpr(Ty, Opcode, &Op, 1), Op(C, this) {} + : ConstantExpr(Ty, Opcode, &Op<0>(), 1) { + Op<0>() = C; + } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); }; /// BinaryConstantExpr - This class is private to Constants.cpp, and is used /// behind the scenes to implement binary constant exprs. class VISIBILITY_HIDDEN BinaryConstantExpr : public ConstantExpr { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Ops[2]; public: // allocate space for exactly two operands void *operator new(size_t s) { return User::operator new(s, 2); } BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2) - : ConstantExpr(C1->getType(), Opcode, Ops, 2) { - Ops[0].init(C1, this); - Ops[1].init(C2, this); + : ConstantExpr(C1->getType(), Opcode, &Op<0>(), 2) { + Op<0>().init(C1, this); + Op<1>().init(C2, this); } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); }; /// SelectConstantExpr - This class is private to Constants.cpp, and is used /// behind the scenes to implement select constant exprs. class VISIBILITY_HIDDEN SelectConstantExpr : public ConstantExpr { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Ops[3]; public: // allocate space for exactly three operands void *operator new(size_t s) { return User::operator new(s, 3); } SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3) - : ConstantExpr(C2->getType(), Instruction::Select, Ops, 3) { - Ops[0].init(C1, this); - Ops[1].init(C2, this); - Ops[2].init(C3, this); + : ConstantExpr(C2->getType(), Instruction::Select, &Op<0>(), 3) { + Op<0>().init(C1, this); + Op<1>().init(C2, this); + Op<2>().init(C3, this); } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); }; /// ExtractElementConstantExpr - This class is private to @@ -474,7 +476,6 @@ /// extractelement constant exprs. class VISIBILITY_HIDDEN ExtractElementConstantExpr : public ConstantExpr { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Ops[2]; public: // allocate space for exactly two operands void *operator new(size_t s) { @@ -482,10 +483,12 @@ } ExtractElementConstantExpr(Constant *C1, Constant *C2) : ConstantExpr(cast(C1->getType())->getElementType(), - Instruction::ExtractElement, Ops, 2) { - Ops[0].init(C1, this); - Ops[1].init(C2, this); + Instruction::ExtractElement, &Op<0>(), 2) { + Op<0>().init(C1, this); + Op<1>().init(C2, this); } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); }; /// InsertElementConstantExpr - This class is private to @@ -493,7 +496,6 @@ /// insertelement constant exprs. class VISIBILITY_HIDDEN InsertElementConstantExpr : public ConstantExpr { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Ops[3]; public: // allocate space for exactly three operands void *operator new(size_t s) { @@ -501,11 +503,13 @@ } InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3) : ConstantExpr(C1->getType(), Instruction::InsertElement, - Ops, 3) { - Ops[0].init(C1, this); - Ops[1].init(C2, this); - Ops[2].init(C3, this); + &Op<0>(), 3) { + Op<0>().init(C1, this); + Op<1>().init(C2, this); + Op<2>().init(C3, this); } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); }; /// ShuffleVectorConstantExpr - This class is private to @@ -513,7 +517,6 @@ /// shufflevector constant exprs. class VISIBILITY_HIDDEN ShuffleVectorConstantExpr : public ConstantExpr { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Ops[3]; public: // allocate space for exactly three operands void *operator new(size_t s) { @@ -521,32 +524,27 @@ } ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3) : ConstantExpr(C1->getType(), Instruction::ShuffleVector, - Ops, 3) { - Ops[0].init(C1, this); - Ops[1].init(C2, this); - Ops[2].init(C3, this); + &Op<0>(), 3) { + Op<0>().init(C1, this); + Op<1>().init(C2, this); + Op<2>().init(C3, this); } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); }; /// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is /// used behind the scenes to implement getelementpr constant exprs. class VISIBILITY_HIDDEN GetElementPtrConstantExpr : public ConstantExpr { GetElementPtrConstantExpr(Constant *C, const std::vector &IdxList, - const Type *DestTy) - : ConstantExpr(DestTy, Instruction::GetElementPtr, - new Use[IdxList.size()+1], IdxList.size()+1) { - OperandList[0].init(C, this); - for (unsigned i = 0, E = IdxList.size(); i != E; ++i) - OperandList[i+1].init(IdxList[i], this); - } + const Type *DestTy); public: static GetElementPtrConstantExpr *Create(Constant *C, const std::vector &IdxList, - const Type *DestTy) { - return new(IdxList.size() + 1/*FIXME*/) GetElementPtrConstantExpr(C, IdxList, DestTy); - } - ~GetElementPtrConstantExpr() { - delete [] OperandList; + const Type *DestTy) { + return new(IdxList.size() + 1) GetElementPtrConstantExpr(C, IdxList, DestTy); } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); }; // CompareConstantExpr - This class is private to Constants.cpp, and is used @@ -559,17 +557,77 @@ return User::operator new(s, 2); } unsigned short predicate; - Use Ops[2]; CompareConstantExpr(Instruction::OtherOps opc, unsigned short pred, Constant* LHS, Constant* RHS) - : ConstantExpr(Type::Int1Ty, opc, Ops, 2), predicate(pred) { - OperandList[0].init(LHS, this); - OperandList[1].init(RHS, this); + : ConstantExpr(Type::Int1Ty, opc, &Op<0>(), 2), predicate(pred) { + Op<0>().init(LHS, this); + Op<1>().init(RHS, this); } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); }; } // end anonymous namespace +template <> +struct OperandTraits : FixedNumOperandTraits<1> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(UnaryConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BinaryConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<3> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SelectConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<3> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertElementConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<3> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ShuffleVectorConstantExpr, Value) + + +template <> +struct OperandTraits : VariadicOperandTraits<1> { +}; + +GetElementPtrConstantExpr::GetElementPtrConstantExpr + (Constant *C, + const std::vector &IdxList, + const Type *DestTy) + : ConstantExpr(DestTy, Instruction::GetElementPtr, + OperandTraits::op_end(this) + - (IdxList.size()+1), + IdxList.size()+1) { + OperandList[0].init(C, this); + for (unsigned i = 0, E = IdxList.size(); i != E; ++i) + OperandList[i+1].init(IdxList[i], this); +} + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetElementPtrConstantExpr, Value) + + +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CompareConstantExpr, Value) + + +} // End llvm namespace + // Utility function for determining if a ConstantExpr is a CastOp or not. This // can't be inline because we don't want to #include Instruction.h into @@ -815,17 +873,29 @@ //===----------------------------------------------------------------------===// // Factory Function Implementation + +// The number of operands for each ConstantCreator::create method is +// determined by the ConstantTraits template. // ConstantCreator - A class that is used to create constants by // ValueMap*. This class should be partially specialized if there is // something strange that needs to be done to interface to the ctor for the // constant. // namespace llvm { + template + struct ConstantTraits; + + template + struct VISIBILITY_HIDDEN ConstantTraits< std::vector > { + static unsigned uses(const std::vector& v) { + return v.size(); + } + }; + template struct VISIBILITY_HIDDEN ConstantCreator { static ConstantClass *create(const TypeClass *Ty, const ValType &V) { - unsigned FIXME = 0; // = traits::uses(V) - return new(FIXME) ConstantClass(Ty, V); + return new(ConstantTraits::uses(V)) ConstantClass(Ty, V); } }; Modified: llvm/trunk/lib/VMCore/Globals.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Globals.cpp?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Globals.cpp (original) +++ llvm/trunk/lib/VMCore/Globals.cpp Sat May 10 03:32:32 2008 @@ -89,14 +89,13 @@ Module *ParentModule, bool ThreadLocal, unsigned AddressSpace) : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal, - &Initializer, InitVal != 0, Link, Name), + OperandTraits::op_begin(this), + InitVal != 0, Link, Name), isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) { if (InitVal) { assert(InitVal->getType() == Ty && "Initializer should be the same type as the GlobalVariable!"); - Initializer.init(InitVal, this); - } else { - Initializer.init(0, this); + Op<0>().init(InitVal, this); } LeakDetector::addGarbageObject(this); @@ -110,14 +109,13 @@ GlobalVariable *Before, bool ThreadLocal, unsigned AddressSpace) : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal, - &Initializer, InitVal != 0, Link, Name), + OperandTraits::op_begin(this), + InitVal != 0, Link, Name), isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) { if (InitVal) { assert(InitVal->getType() == Ty && "Initializer should be the same type as the GlobalVariable!"); - Initializer.init(InitVal, this); - } else { - Initializer.init(0, this); + Op<0>().init(InitVal, this); } LeakDetector::addGarbageObject(this); @@ -169,12 +167,12 @@ GlobalAlias::GlobalAlias(const Type *Ty, LinkageTypes Link, const std::string &Name, Constant* aliasee, Module *ParentModule) - : GlobalValue(Ty, Value::GlobalAliasVal, &Aliasee, 1, Link, Name) { + : GlobalValue(Ty, Value::GlobalAliasVal, &Op<0>(), 1, Link, Name) { LeakDetector::addGarbageObject(this); if (aliasee) assert(aliasee->getType() == Ty && "Alias and aliasee types should match!"); - Aliasee.init(aliasee, this); + Op<0>().init(aliasee, this); if (ParentModule) ParentModule->getAliasList().push_back(this); Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=50943&r1=50942&r2=50943&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Sat May 10 03:32:32 2008 @@ -100,18 +100,21 @@ TerminatorInst::~TerminatorInst() { } +//===----------------------------------------------------------------------===// +// UnaryInstruction Class +//===----------------------------------------------------------------------===// + // Out of line virtual method, so the vtable, etc has a home. UnaryInstruction::~UnaryInstruction() { } - //===----------------------------------------------------------------------===// // PHINode Class //===----------------------------------------------------------------------===// PHINode::PHINode(const PHINode &PN) : Instruction(PN.getType(), Instruction::PHI, - new Use[PN.getNumOperands()], PN.getNumOperands()), + allocHungoffUses(PN.getNumOperands()), PN.getNumOperands()), ReservedSpace(PN.getNumOperands()) { Use *OL = OperandList; for (unsigned i = 0, e = PN.getNumOperands(); i != e; i+=2) { @@ -121,7 +124,7 @@ } PHINode::~PHINode() { - delete [] OperandList; + dropHungoffUses(OperandList); } // removeIncomingValue - Remove an incoming value. This is useful if a @@ -164,8 +167,9 @@ /// 3. If NumOps == NumOperands, trim the reserved space. /// void PHINode::resizeOperands(unsigned NumOps) { + unsigned e = getNumOperands(); if (NumOps == 0) { - NumOps = (getNumOperands())*3/2; + NumOps = e*3/2; if (NumOps < 4) NumOps = 4; // 4 op PHI nodes are VERY common. } else if (NumOps*2 > NumOperands) { // No resize needed. @@ -177,14 +181,13 @@ } ReservedSpace = NumOps; - Use *NewOps = new Use[NumOps]; Use *OldOps = OperandList; - for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { + Use *NewOps = allocHungoffUses(NumOps); + for (unsigned i = 0; i != e; ++i) { NewOps[i].init(OldOps[i], this); - OldOps[i].set(0); } - delete [] OldOps; OperandList = NewOps; + if (OldOps) Use::zap(OldOps, OldOps + e, true); } /// hasConstantValue - If the specified PHI node always merges together the same @@ -241,12 +244,11 @@ //===----------------------------------------------------------------------===// CallInst::~CallInst() { - delete [] OperandList; } void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) { - NumOperands = NumParams+1; - Use *OL = OperandList = new Use[NumParams+1]; + assert(NumOperands == NumParams+1 && "NumOperands not set up?"); + Use *OL = OperandList; OL[0].init(Func, this); const FunctionType *FTy = @@ -265,8 +267,8 @@ } void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) { - NumOperands = 3; - Use *OL = OperandList = new Use[3]; + assert(NumOperands == 3 && "NumOperands not set up?"); + Use *OL = OperandList; OL[0].init(Func, this); OL[1].init(Actual1, this); OL[2].init(Actual2, this); @@ -287,8 +289,8 @@ } void CallInst::init(Value *Func, Value *Actual) { - NumOperands = 2; - Use *OL = OperandList = new Use[2]; + assert(NumOperands == 2 && "NumOperands not set up?"); + Use *OL = OperandList; OL[0].init(Func, this); OL[1].init(Actual, this); @@ -305,8 +307,8 @@ } void CallInst::init(Value *Func) { - NumOperands = 1; - Use *OL = OperandList = new Use[1]; + assert(NumOperands == 1 && "NumOperands not set up?"); + Use *OL = OperandList; OL[0].init(Func, this); const FunctionType *FTy = @@ -320,7 +322,9 @@ Instruction *InsertBefore) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, InsertBefore) { + Instruction::Call, + OperandTraits::op_end(this) - 2, + 2, InsertBefore) { init(Func, Actual); setName(Name); } @@ -329,7 +333,9 @@ BasicBlock *InsertAtEnd) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, InsertAtEnd) { + Instruction::Call, + OperandTraits::op_end(this) - 2, + 2, InsertAtEnd) { init(Func, Actual); setName(Name); } @@ -337,7 +343,9 @@ Instruction *InsertBefore) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, InsertBefore) { + Instruction::Call, + OperandTraits::op_end(this) - 1, + 1, InsertBefore) { init(Func); setName(Name); } @@ -346,13 +354,16 @@ BasicBlock *InsertAtEnd) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, InsertAtEnd) { + Instruction::Call, + OperandTraits::op_end(this) - 1, + 1, InsertAtEnd) { init(Func); setName(Name); } CallInst::CallInst(const CallInst &CI) - : Instruction(CI.getType(), Instruction::Call, new Use[CI.getNumOperands()], + : Instruction(CI.getType(), Instruction::Call, + OperandTraits::op_end(this) - CI.getNumOperands(), CI.getNumOperands()) { setParamAttrs(CI.getParamAttrs()); SubclassData = CI.SubclassData; @@ -384,14 +395,10 @@ // InvokeInst Implementation //===----------------------------------------------------------------------===// -InvokeInst::~InvokeInst() { - delete [] OperandList; -} - void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException, Value* const *Args, unsigned NumArgs) { - NumOperands = 3+NumArgs; - Use *OL = OperandList = new Use[3+NumArgs]; + assert(NumOperands == 3+NumArgs && "NumOperands not set up?"); + Use *OL = OperandList; OL[0].init(Fn, this); OL[1].init(IfNormal, this); OL[2].init(IfException, this); @@ -414,7 +421,8 @@ InvokeInst::InvokeInst(const InvokeInst &II) : TerminatorInst(II.getType(), Instruction::Invoke, - new Use[II.getNumOperands()], II.getNumOperands()) { + OperandTraits::op_end(this) - II.getNumOperands(), + II.getNumOperands()) { setParamAttrs(II.getParamAttrs()); SubclassData = II.SubclassData; Use *OL = OperandList, *InOL = II.OperandList; @@ -456,45 +464,51 @@ ReturnInst::ReturnInst(const ReturnInst &RI) : TerminatorInst(Type::VoidTy, Instruction::Ret, - &RetVal, RI.getNumOperands()) { + OperandTraits::op_end(this) - RI.getNumOperands(), + RI.getNumOperands()) { unsigned N = RI.getNumOperands(); - if (N == 1) - RetVal.init(RI.RetVal, this); + if (N == 1) + Op<0>().init(RI.Op<0>(), this); else if (N) { - Use *OL = OperandList = new Use[N]; + Use *OL = OperandList; for (unsigned i = 0; i < N; ++i) OL[i].init(RI.getOperand(i), this); } } ReturnInst::ReturnInst(Value *retVal, Instruction *InsertBefore) - : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertBefore) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, + OperandTraits::op_end(this) - (retVal != 0), + retVal != 0, InsertBefore) { if (retVal) init(&retVal, 1); } ReturnInst::ReturnInst(Value *retVal, BasicBlock *InsertAtEnd) - : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertAtEnd) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, + OperandTraits::op_end(this) - (retVal != 0), + retVal != 0, InsertAtEnd) { if (retVal) init(&retVal, 1); } ReturnInst::ReturnInst(BasicBlock *InsertAtEnd) - : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertAtEnd) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, + OperandTraits::op_end(this), + 0, InsertAtEnd) { } ReturnInst::ReturnInst(Value * const* retVals, unsigned N, Instruction *InsertBefore) - : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, N, InsertBefore) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, + OperandTraits::op_end(this) - N, + N, InsertBefore) { if (N != 0) init(retVals, N); } ReturnInst::ReturnInst(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd) - : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, N, InsertAtEnd) { - if (N != 0) - init(retVals, N); -} -ReturnInst::ReturnInst(Value * const* retVals, unsigned N) - : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, N) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, + OperandTraits::op_end(this) - N, + N, InsertAtEnd) { if (N != 0) init(retVals, N); } @@ -507,11 +521,11 @@ Value *V = *retVals; if (V->getType() == Type::VoidTy) return; - RetVal.init(V, this); + Op<0>().init(V, this); return; } - Use *OL = OperandList = new Use[NumOperands]; + Use *OL = OperandList; for (unsigned i = 0; i < NumOperands; ++i) { Value *V = *retVals++; assert(!isa(V) && @@ -537,8 +551,6 @@ } ReturnInst::~ReturnInst() { - if (NumOperands > 1) - delete [] OperandList; } //===----------------------------------------------------------------------===// @@ -603,33 +615,41 @@ } BranchInst::BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore) - : TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 1, InsertBefore) { + : TerminatorInst(Type::VoidTy, Instruction::Br, + OperandTraits::op_end(this) - 1, + 1, InsertBefore) { assert(IfTrue != 0 && "Branch destination may not be null!"); - Ops[0].init(reinterpret_cast(IfTrue), this); + Op<0>().init(reinterpret_cast(IfTrue), this); } BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, Instruction *InsertBefore) -: TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 3, InsertBefore) { - Ops[0].init(reinterpret_cast(IfTrue), this); - Ops[1].init(reinterpret_cast(IfFalse), this); - Ops[2].init(Cond, this); + : TerminatorInst(Type::VoidTy, Instruction::Br, + OperandTraits::op_end(this) - 3, + 3, InsertBefore) { + Op<0>().init(reinterpret_cast(IfTrue), this); + Op<1>().init(reinterpret_cast(IfFalse), this); + Op<2>().init(Cond, this); #ifndef NDEBUG AssertOK(); #endif } BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd) - : TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 1, InsertAtEnd) { + : TerminatorInst(Type::VoidTy, Instruction::Br, + OperandTraits::op_end(this) - 1, + 1, InsertAtEnd) { assert(IfTrue != 0 && "Branch destination may not be null!"); - Ops[0].init(reinterpret_cast(IfTrue), this); + Op<0>().init(reinterpret_cast(IfTrue), this); } BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, BasicBlock *InsertAtEnd) - : TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 3, InsertAtEnd) { - Ops[0].init(reinterpret_cast(IfTrue), this); - Ops[1].init(reinterpret_cast(IfFalse), this); - Ops[2].init(Cond, this); + : TerminatorInst(Type::VoidTy, Instruction::Br, + OperandTraits::op_end(this) - 3, + 3, InsertAtEnd) { + Op<0>().init(reinterpret_cast(IfTrue), this); + Op<1>().init(reinterpret_cast(IfFalse), this); + Op<2>().init(Cond, this); #ifndef NDEBUG AssertOK(); #endif @@ -637,7 +657,9 @@ BranchInst::BranchInst(const BranchInst &BI) : - TerminatorInst(Type::VoidTy, Instruction::Br, Ops, BI.getNumOperands()) { + TerminatorInst(Type::VoidTy, Instruction::Br, + OperandTraits::op_end(this) - BI.getNumOperands(), + BI.getNumOperands()) { OperandList[0].init(BI.getOperand(0), this); if (BI.getNumOperands() != 1) { assert(BI.getNumOperands() == 3 && "BR can have 1 or 3 operands!"); @@ -869,18 +891,24 @@ StoreInst::StoreInst(Value *val, Value *addr, Instruction *InsertBefore) - : Instruction(Type::VoidTy, Store, Ops, 2, InsertBefore) { - Ops[0].init(val, this); - Ops[1].init(addr, this); + : Instruction(Type::VoidTy, Store, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertBefore) { + Op<0>().init(val, this); + Op<1>().init(addr, this); setVolatile(false); setAlignment(0); AssertOK(); } StoreInst::StoreInst(Value *val, Value *addr, BasicBlock *InsertAtEnd) - : Instruction(Type::VoidTy, Store, Ops, 2, InsertAtEnd) { - Ops[0].init(val, this); - Ops[1].init(addr, this); + : Instruction(Type::VoidTy, Store, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertAtEnd) { + Op<0>().init(val, this); + Op<1>().init(addr, this); setVolatile(false); setAlignment(0); AssertOK(); @@ -888,9 +916,12 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, Instruction *InsertBefore) - : Instruction(Type::VoidTy, Store, Ops, 2, InsertBefore) { - Ops[0].init(val, this); - Ops[1].init(addr, this); + : Instruction(Type::VoidTy, Store, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertBefore) { + Op<0>().init(val, this); + Op<1>().init(addr, this); setVolatile(isVolatile); setAlignment(0); AssertOK(); @@ -898,9 +929,12 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, unsigned Align, Instruction *InsertBefore) - : Instruction(Type::VoidTy, Store, Ops, 2, InsertBefore) { - Ops[0].init(val, this); - Ops[1].init(addr, this); + : Instruction(Type::VoidTy, Store, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertBefore) { + Op<0>().init(val, this); + Op<1>().init(addr, this); setVolatile(isVolatile); setAlignment(Align); AssertOK(); @@ -908,9 +942,12 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, unsigned Align, BasicBlock *InsertAtEnd) - : Instruction(Type::VoidTy, Store, Ops, 2, InsertAtEnd) { - Ops[0].init(val, this); - Ops[1].init(addr, this); + : Instruction(Type::VoidTy, Store, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertAtEnd) { + Op<0>().init(val, this); + Op<1>().init(addr, this); setVolatile(isVolatile); setAlignment(Align); AssertOK(); @@ -918,9 +955,12 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, BasicBlock *InsertAtEnd) - : Instruction(Type::VoidTy, Store, Ops, 2, InsertAtEnd) { - Ops[0].init(val, this); - Ops[1].init(addr, this); + : Instruction(Type::VoidTy, Store, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertAtEnd) { + Op<0>().init(val, this); + Op<1>().init(addr, this); setVolatile(isVolatile); setAlignment(0); AssertOK(); @@ -940,8 +980,8 @@ } void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx) { - NumOperands = 1+NumIdx; - Use *OL = OperandList = new Use[NumOperands]; + assert(NumOperands == 1+NumIdx && "NumOperands not initialized?"); + Use *OL = OperandList; OL[0].init(Ptr, this); for (unsigned i = 0; i != NumIdx; ++i) @@ -949,17 +989,29 @@ } void GetElementPtrInst::init(Value *Ptr, Value *Idx) { - NumOperands = 2; - Use *OL = OperandList = new Use[2]; + assert(NumOperands == 2 && "NumOperands not initialized?"); + Use *OL = OperandList; OL[0].init(Ptr, this); OL[1].init(Idx, this); } +GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI) + : Instruction(reinterpret_cast(GEPI.getType()), GetElementPtr, + OperandTraits::op_end(this) - GEPI.getNumOperands(), + GEPI.getNumOperands()) { + Use *OL = OperandList; + Use *GEPIOL = GEPI.OperandList; + for (unsigned i = 0, E = NumOperands; i != E; ++i) + OL[i].init(GEPIOL[i], this); +} + GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, const std::string &Name, Instruction *InBe) : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx)), retrieveAddrSpace(Ptr)), - GetElementPtr, 0, 0, InBe) { + GetElementPtr, + OperandTraits::op_end(this) - 2, + 2, InBe) { init(Ptr, Idx); setName(Name); } @@ -968,15 +1020,13 @@ const std::string &Name, BasicBlock *IAE) : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx)), retrieveAddrSpace(Ptr)), - GetElementPtr, 0, 0, IAE) { + GetElementPtr, + OperandTraits::op_end(this) - 2, + 2, IAE) { init(Ptr, Idx); setName(Name); } -GetElementPtrInst::~GetElementPtrInst() { - delete[] OperandList; -} - // getIndexedType - Returns the type of the element that would be loaded with // a load instruction with the specified parameters. // @@ -1067,11 +1117,13 @@ const std::string &Name, Instruction *InsertBef) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, Ops, 2, InsertBef) { + ExtractElement, + OperandTraits::op_begin(this), + 2, InsertBef) { assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); - Ops[0].init(Val, this); - Ops[1].init(Index, this); + Op<0>().init(Val, this); + Op<1>().init(Index, this); setName(Name); } @@ -1079,12 +1131,14 @@ const std::string &Name, Instruction *InsertBef) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, Ops, 2, InsertBef) { + ExtractElement, + OperandTraits::op_begin(this), + 2, InsertBef) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); - Ops[0].init(Val, this); - Ops[1].init(Index, this); + Op<0>().init(Val, this); + Op<1>().init(Index, this); setName(Name); } @@ -1093,12 +1147,14 @@ const std::string &Name, BasicBlock *InsertAE) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, Ops, 2, InsertAE) { + ExtractElement, + OperandTraits::op_begin(this), + 2, InsertAE) { assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); - Ops[0].init(Val, this); - Ops[1].init(Index, this); + Op<0>().init(Val, this); + Op<1>().init(Index, this); setName(Name); } @@ -1106,13 +1162,15 @@ const std::string &Name, BasicBlock *InsertAE) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, Ops, 2, InsertAE) { + ExtractElement, + OperandTraits::op_begin(this), + 2, InsertAE) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); - Ops[0].init(Val, this); - Ops[1].init(Index, this); + Op<0>().init(Val, this); + Op<1>().init(Index, this); setName(Name); } @@ -1129,33 +1187,38 @@ //===----------------------------------------------------------------------===// InsertElementInst::InsertElementInst(const InsertElementInst &IE) - : Instruction(IE.getType(), InsertElement, Ops, 3) { - Ops[0].init(IE.Ops[0], this); - Ops[1].init(IE.Ops[1], this); - Ops[2].init(IE.Ops[2], this); + : Instruction(IE.getType(), InsertElement, + OperandTraits::op_begin(this), 3) { + Op<0>().init(IE.Op<0>(), this); + Op<1>().init(IE.Op<1>(), this); + Op<2>().init(IE.Op<2>(), this); } InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index, const std::string &Name, Instruction *InsertBef) - : Instruction(Vec->getType(), InsertElement, Ops, 3, InsertBef) { + : Instruction(Vec->getType(), InsertElement, + OperandTraits::op_begin(this), + 3, InsertBef) { assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); - Ops[0].init(Vec, this); - Ops[1].init(Elt, this); - Ops[2].init(Index, this); + Op<0>().init(Vec, this); + Op<1>().init(Elt, this); + Op<2>().init(Index, this); setName(Name); } InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV, const std::string &Name, Instruction *InsertBef) - : Instruction(Vec->getType(), InsertElement, Ops, 3, InsertBef) { + : Instruction(Vec->getType(), InsertElement, + OperandTraits::op_begin(this), + 3, InsertBef) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); - Ops[0].init(Vec, this); - Ops[1].init(Elt, this); - Ops[2].init(Index, this); + Op<0>().init(Vec, this); + Op<1>().init(Elt, this); + Op<2>().init(Index, this); setName(Name); } @@ -1163,27 +1226,31 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index, const std::string &Name, BasicBlock *InsertAE) - : Instruction(Vec->getType(), InsertElement, Ops, 3, InsertAE) { + : Instruction(Vec->getType(), InsertElement, + OperandTraits::op_begin(this), + 3, InsertAE) { assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); - Ops[0].init(Vec, this); - Ops[1].init(Elt, this); - Ops[2].init(Index, this); + Op<0>().init(Vec, this); + Op<1>().init(Elt, this); + Op<2>().init(Index, this); setName(Name); } InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV, const std::string &Name, BasicBlock *InsertAE) -: Instruction(Vec->getType(), InsertElement, Ops, 3, InsertAE) { +: Instruction(Vec->getType(), InsertElement, + OperandTraits::op_begin(this), + 3, InsertAE) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); - Ops[0].init(Vec, this); - Ops[1].init(Elt, this); - Ops[2].init(Index, this); + Op<0>().init(Vec, this); + Op<1>().init(Elt, this); + Op<2>().init(Index, this); setName(Name); } @@ -1206,34 +1273,42 @@ //===----------------------------------------------------------------------===// ShuffleVectorInst::ShuffleVectorInst(const ShuffleVectorInst &SV) - : Instruction(SV.getType(), ShuffleVector, Ops, 3) { - Ops[0].init(SV.Ops[0], this); - Ops[1].init(SV.Ops[1], this); - Ops[2].init(SV.Ops[2], this); + : Instruction(SV.getType(), ShuffleVector, + OperandTraits::op_begin(this), + OperandTraits::operands(this)) { + Op<0>().init(SV.Op<0>(), this); + Op<1>().init(SV.Op<1>(), this); + Op<2>().init(SV.Op<2>(), this); } ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, const std::string &Name, Instruction *InsertBefore) - : Instruction(V1->getType(), ShuffleVector, Ops, 3, InsertBefore) { + : Instruction(V1->getType(), ShuffleVector, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertBefore) { assert(isValidOperands(V1, V2, Mask) && "Invalid shuffle vector instruction operands!"); - Ops[0].init(V1, this); - Ops[1].init(V2, this); - Ops[2].init(Mask, this); + Op<0>().init(V1, this); + Op<1>().init(V2, this); + Op<2>().init(Mask, this); setName(Name); } ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(V1->getType(), ShuffleVector, Ops, 3, InsertAtEnd) { + : Instruction(V1->getType(), ShuffleVector, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertAtEnd) { assert(isValidOperands(V1, V2, Mask) && "Invalid shuffle vector instruction operands!"); - Ops[0].init(V1, this); - Ops[1].init(V2, this); - Ops[2].init(Mask, this); + Op<0>().init(V1, this); + Op<1>().init(V2, this); + Op<2>().init(Mask, this); setName(Name); } @@ -1275,9 +1350,12 @@ BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty, const std::string &Name, Instruction *InsertBefore) - : Instruction(Ty, iType, Ops, 2, InsertBefore) { - Ops[0].init(S1, this); - Ops[1].init(S2, this); + : Instruction(Ty, iType, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertBefore) { + Op<0>().init(S1, this); + Op<1>().init(S2, this); init(iType); setName(Name); } @@ -1285,9 +1363,12 @@ BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(Ty, iType, Ops, 2, InsertAtEnd) { - Ops[0].init(S1, this); - Ops[1].init(S2, this); + : Instruction(Ty, iType, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertAtEnd) { + Op<0>().init(S1, this); + Op<1>().init(S2, this); init(iType); setName(Name); } @@ -1482,7 +1563,7 @@ bool BinaryOperator::swapOperands() { if (!isCommutative()) return true; // Can't commute operands - std::swap(Ops[0], Ops[1]); + std::swap(Op<0>(), Op<1>()); return false; } @@ -2254,9 +2335,12 @@ CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS, const std::string &Name, Instruction *InsertBefore) - : Instruction(Type::Int1Ty, op, Ops, 2, InsertBefore) { - Ops[0].init(LHS, this); - Ops[1].init(RHS, this); + : Instruction(Type::Int1Ty, op, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertBefore) { + Op<0>().init(LHS, this); + Op<1>().init(RHS, this); SubclassData = predicate; setName(Name); if (op == Instruction::ICmp) { @@ -2283,12 +2367,15 @@ assert(Op0Ty->isFloatingPoint() && "Invalid operand types for FCmp instruction"); } - + CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(Type::Int1Ty, op, Ops, 2, InsertAtEnd) { - Ops[0].init(LHS, this); - Ops[1].init(RHS, this); + : Instruction(Type::Int1Ty, op, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertAtEnd) { + Op<0>().init(LHS, this); + Op<1>().init(RHS, this); SubclassData = predicate; setName(Name); if (op == Instruction::ICmp) { @@ -2548,7 +2635,7 @@ assert(Value && Default); ReservedSpace = 2+NumCases*2; NumOperands = 2; - OperandList = new Use[ReservedSpace]; + OperandList = allocHungoffUses(ReservedSpace); OperandList[0].init(Value, this); OperandList[1].init(Default, this); @@ -2576,7 +2663,7 @@ SwitchInst::SwitchInst(const SwitchInst &SI) : TerminatorInst(Type::VoidTy, Instruction::Switch, - new Use[SI.getNumOperands()], SI.getNumOperands()) { + allocHungoffUses(SI.getNumOperands()), SI.getNumOperands()) { Use *OL = OperandList, *InOL = SI.OperandList; for (unsigned i = 0, E = SI.getNumOperands(); i != E; i+=2) { OL[i].init(InOL[i], this); @@ -2585,7 +2672,7 @@ } SwitchInst::~SwitchInst() { - delete [] OperandList; + dropHungoffUses(OperandList); } @@ -2632,13 +2719,14 @@ /// resizeOperands - resize operands - This adjusts the length of the operands /// list according to the following behavior: /// 1. If NumOps == 0, grow the operand list in response to a push_back style -/// of operation. This grows the number of ops by 1.5 times. +/// of operation. This grows the number of ops by 3 times. /// 2. If NumOps > NumOperands, reserve space for NumOps operands. /// 3. If NumOps == NumOperands, trim the reserved space. /// void SwitchInst::resizeOperands(unsigned NumOps) { + unsigned e = getNumOperands(); if (NumOps == 0) { - NumOps = getNumOperands()/2*6; + NumOps = e*3; } else if (NumOps*2 > NumOperands) { // No resize needed. if (ReservedSpace >= NumOps) return; @@ -2649,14 +2737,13 @@ } ReservedSpace = NumOps; - Use *NewOps = new Use[NumOps]; + Use *NewOps = allocHungoffUses(NumOps); Use *OldOps = OperandList; - for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { + for (unsigned i = 0; i != e; ++i) { NewOps[i].init(OldOps[i], this); - OldOps[i].set(0); } - delete [] OldOps; OperandList = NewOps; + if (OldOps) Use::zap(OldOps, OldOps + e, true); } @@ -2678,9 +2765,12 @@ const std::string &Name, Instruction *InsertBef) : Instruction(cast(Aggregate->getType())->getElementType(Index), - GetResult, &Aggr, 1, InsertBef) { + GetResult, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertBef) { assert(isValidOperands(Aggregate, Index) && "Invalid GetResultInst operands!"); - Aggr.init(Aggregate, this); + Op<0>().init(Aggregate, this); Idx = Index; setName(Name); } @@ -2714,14 +2804,14 @@ } BinaryOperator *BinaryOperator::clone() const { - return create(getOpcode(), Ops[0], Ops[1]); + return create(getOpcode(), Op<0>(), Op<1>()); } FCmpInst* FCmpInst::clone() const { - return new FCmpInst(getPredicate(), Ops[0], Ops[1]); + return new FCmpInst(getPredicate(), Op<0>(), Op<1>()); } ICmpInst* ICmpInst::clone() const { - return new ICmpInst(getPredicate(), Ops[0], Ops[1]); + return new ICmpInst(getPredicate(), Op<0>(), Op<1>()); } MallocInst *MallocInst::clone() const { return new MallocInst(*this); } @@ -2757,7 +2847,7 @@ PHINode *PHINode::clone() const { return new PHINode(*this); } ReturnInst *ReturnInst::clone() const { return new(getNumOperands()) ReturnInst(*this); } BranchInst *BranchInst::clone() const { return new(getNumOperands()) BranchInst(*this); } -SwitchInst *SwitchInst::clone() const { return new(getNumOperands()) SwitchInst(*this); } +SwitchInst *SwitchInst::clone() const { return new SwitchInst(*this); } InvokeInst *InvokeInst::clone() const { return new(getNumOperands()) InvokeInst(*this); } UnwindInst *UnwindInst::clone() const { return new UnwindInst(); } UnreachableInst *UnreachableInst::clone() const { return new UnreachableInst();} From gabor at mac.com Sat May 10 03:50:54 2008 From: gabor at mac.com (Gabor Greif) Date: Sat, 10 May 2008 10:50:54 +0200 Subject: [llvm-commits] [llvm] r50943 - in /llvm/trunk: CREDITS.TXT include/llvm/Constants.h include/llvm/GlobalAlias.h include/llvm/GlobalVariable.h include/llvm/InstrTypes.h include/llvm/Instruction.h include/llvm/Instructions.h include/llvm/OperandTraits.h include/llvm/Use.h include/llvm/User.h include/llvm/Value.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Reader/BitcodeReader.h lib/VMCore/ConstantFold.cpp lib/VMCore/Constants.cpp lib/VMCore/Globals.cpp lib/VMCore/Instructions.cpp lib/VMCore/Use.cpp Message-ID: <79023444-4AB6-44D8-833B-299E24C9B7E5@mac.com> Nicholas, and all who still keep branches from the time where BasicBlock was still derived from User, now that I have checked in the use-diet changes, you will have some minor complication when synchronizing with trunk. Fortunately the effect is well-scoped and can be fixed easily by doing a simple: svn merge -r49379:HEAD \ https://llvm.org/svn/llvm-project/llvm/branches/ggreif/use-diet/lib/ VMCore/BasicBlock.cpp \ lib/VMCore/BasicBlock.cpp svn merge -r49379:HEAD \ https://llvm.org/svn/llvm-project/llvm/branches/ggreif/use-diet/ include/llvm/BasicBlock.h \ include/llvm/BasicBlock.h in your branch working copy. NOTE: You may need to tweak the "https://llvm.org" prefix to the URLs to change the protocol or add a username, though, but svn will give you a vague hint if this is needed. I am happy to give a helping hand if something goes awry. Cheers, Gabor From ggreif at gmail.com Sat May 10 04:36:59 2008 From: ggreif at gmail.com (Gabor Greif) Date: Sat, 10 May 2008 09:36:59 -0000 Subject: [llvm-commits] [llvm] r50944 - /llvm/trunk/include/llvm/Constants.h Message-ID: <200805100936.m4A9axTU026861@zion.cs.uiuc.edu> Author: ggreif Date: Sat May 10 04:36:58 2008 New Revision: 50944 URL: http://llvm.org/viewvc/llvm-project?rev=50944&view=rev Log: remove commented-out code, it is subsumed by DECLARE_TRANSPARENT_OPERAND_ACCESSORS Modified: llvm/trunk/include/llvm/Constants.h Modified: llvm/trunk/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=50944&r1=50943&r2=50944&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constants.h (original) +++ llvm/trunk/include/llvm/Constants.h Sat May 10 04:36:58 2008 @@ -736,15 +736,6 @@ virtual void destroyConstant(); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U); -/* /// Override methods to provide more type information... - inline Constant *getOperand(unsigned i) { - return cast(User::getOperand(i)); - } - inline Constant *getOperand(unsigned i) const { - return const_cast(cast(User::getOperand(i))); - }*/ - - /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ConstantExpr *) { return true; } static inline bool classof(const Value *V) { From isanbard at gmail.com Sat May 10 05:58:09 2008 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 10 May 2008 10:58:09 -0000 Subject: [llvm-commits] [llvm] r50946 - /llvm/trunk/include/llvm/Instructions.h Message-ID: <200805101058.m4AAwAQx029178@zion.cs.uiuc.edu> Author: void Date: Sat May 10 05:58:07 2008 New Revision: 50946 URL: http://llvm.org/viewvc/llvm-project?rev=50946&view=rev Log: Prevent warnings from the -Wshorten-64-to-32 flag. 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=50946&r1=50945&r2=50946&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Sat May 10 05:58:07 2008 @@ -1683,12 +1683,9 @@ return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertAtEnd); } - ~BranchInst() - { + ~BranchInst() { if (NumOperands == 1) - { - NumOperands = (Use*)this - OperandList; - } + NumOperands = (unsigned)(uintptr_t)((Use*)this - OperandList); } /// Transparently provide more efficient getOperand methods. From isanbard at gmail.com Sat May 10 06:26:55 2008 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 10 May 2008 11:26:55 -0000 Subject: [llvm-commits] [llvm] r50947 - /llvm/trunk/include/llvm/Instructions.h Message-ID: <200805101126.m4ABQtwn029901@zion.cs.uiuc.edu> Author: void Date: Sat May 10 06:26:52 2008 New Revision: 50947 URL: http://llvm.org/viewvc/llvm-project?rev=50947&view=rev Log: Prevent -W64-to-32-shortened warnings. 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=50947&r1=50946&r2=50947&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Sat May 10 06:26:52 2008 @@ -1087,7 +1087,7 @@ ->getElementType())->getReturnType(), Instruction::Call, OperandTraits::op_end(this) - (ArgEnd - ArgBegin + 1), - ArgEnd - ArgBegin + 1, InsertAtEnd) { + (unsigned)(ArgEnd - ArgBegin + 1), InsertAtEnd) { init(Func, ArgBegin, ArgEnd, Name, typename std::iterator_traits::iterator_category()); } @@ -1099,7 +1099,7 @@ ->getElementType())->getReturnType(), Instruction::Call, OperandTraits::op_end(this) - (ArgEnd - ArgBegin + 1), - ArgEnd - ArgBegin + 1, InsertBefore) { + (unsigned)(ArgEnd - ArgBegin + 1), InsertBefore) { init(Func, ArgBegin, ArgEnd, Name, typename std::iterator_traits::iterator_category()); } From isanbard at gmail.com Sat May 10 06:29:24 2008 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 10 May 2008 11:29:24 -0000 Subject: [llvm-commits] [llvm] r50948 - /llvm/tags/Apple/llvmCore-2042/ Message-ID: <200805101129.m4ABTOGi029967@zion.cs.uiuc.edu> Author: void Date: Sat May 10 06:29:24 2008 New Revision: 50948 URL: http://llvm.org/viewvc/llvm-project?rev=50948&view=rev Log: Creating llvmCore-2042 branch Added: llvm/tags/Apple/llvmCore-2042/ - copied from r50947, llvm/trunk/ From isanbard at gmail.com Sat May 10 06:29:30 2008 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 10 May 2008 11:29:30 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50949 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2042/ Message-ID: <200805101129.m4ABTUBG029981@zion.cs.uiuc.edu> Author: void Date: Sat May 10 06:29:30 2008 New Revision: 50949 URL: http://llvm.org/viewvc/llvm-project?rev=50949&view=rev Log: Creating llvmgcc42-2042 branch Added: llvm-gcc-4.2/tags/Apple/llvmgcc42-2042/ - copied from r50948, llvm-gcc-4.2/trunk/ From asl at math.spbu.ru Sat May 10 09:41:44 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 10 May 2008 14:41:44 -0000 Subject: [llvm-commits] [llvm] r50950 - /llvm/trunk/lib/Linker/LinkModules.cpp Message-ID: <200805101441.m4AEfi6s002710@zion.cs.uiuc.edu> Author: asl Date: Sat May 10 09:41:43 2008 New Revision: 50950 URL: http://llvm.org/viewvc/llvm-project?rev=50950&view=rev Log: Fix linking of internal aliases Modified: llvm/trunk/lib/Linker/LinkModules.cpp Modified: llvm/trunk/lib/Linker/LinkModules.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=50950&r1=50949&r2=50950&view=diff ============================================================================== --- llvm/trunk/lib/Linker/LinkModules.cpp (original) +++ llvm/trunk/lib/Linker/LinkModules.cpp Sat May 10 09:41:43 2008 @@ -627,20 +627,52 @@ GlobalAlias *NewGA = NULL; // Globals were already linked, thus we can just query ValueMap for variant - // of SAliasee in Dest + // of SAliasee in Dest. std::map::const_iterator VMI = ValueMap.find(SAliasee); assert(VMI != ValueMap.end() && "Aliasee not linked"); GlobalValue* DAliasee = cast(VMI->second); + GlobalValue* DGV = NULL; // Try to find something 'similar' to SGA in destination module. - if (GlobalAlias *DGA = Dest->getNamedAlias(SGA->getName())) { + if (!DGV && !SGA->hasInternalLinkage()) { + DGV = Dest->getNamedAlias(SGA->getName()); + // If types don't agree due to opaque types, try to resolve them. - if (RecursiveResolveTypes(SGA->getType(), DGA->getType(), - &Dest->getTypeSymbolTable(), "")) - return Error(Err, "Alias Collision on '" + SGA->getName()+ - "': aliases have different types"); + if (DGV && DGV->getType() != SGA->getType()) + if (RecursiveResolveTypes(SGA->getType(), DGV->getType(), + &Dest->getTypeSymbolTable(), "")) + return Error(Err, "Alias Collision on '" + SGA->getName()+ + "': aliases have different types"); + } + + if (!DGV && !SGA->hasInternalLinkage()) { + DGV = Dest->getGlobalVariable(SGA->getName()); + + // If types don't agree due to opaque types, try to resolve them. + if (DGV && DGV->getType() != SGA->getType()) + if (RecursiveResolveTypes(SGA->getType(), DGV->getType(), + &Dest->getTypeSymbolTable(), "")) + return Error(Err, "Alias Collision on '" + SGA->getName()+ + "': aliases have different types"); + } + + if (!DGV && !SGA->hasInternalLinkage()) { + DGV = Dest->getFunction(SGA->getName()); - // Now types are known to be the same, check whether aliasees equal. As + // If types don't agree due to opaque types, try to resolve them. + if (DGV && DGV->getType() != SGA->getType()) + if (RecursiveResolveTypes(SGA->getType(), DGV->getType(), + &Dest->getTypeSymbolTable(), "")) + return Error(Err, "Alias Collision on '" + SGA->getName()+ + "': aliases have different types"); + } + + // No linking to be performed on internal stuff. + if (DGV && DGV->hasInternalLinkage()) + DGV = NULL; + + if (GlobalAlias *DGA = dyn_cast_or_null(DGV)) { + // Types are known to be the same, check whether aliasees equal. As // globals are already linked we just need query ValueMap to find the // mapping. if (DAliasee == DGA->getAliasedGlobal()) { @@ -653,47 +685,41 @@ } else return Error(Err, "Alias Collision on '" + SGA->getName()+ "': aliases have different aliasees"); - } else if (GlobalVariable *DGV = Dest->getGlobalVariable(SGA->getName())) { - RecursiveResolveTypes(SGA->getType(), DGV->getType(), - &Dest->getTypeSymbolTable(), ""); - + } else if (GlobalVariable *DGVar = dyn_cast_or_null(DGV)) { // The only allowed way is to link alias with external declaration. - if (DGV->isDeclaration()) { + if (DGVar->isDeclaration()) { // But only if aliasee is global too... if (!isa(DAliasee)) - return Error(Err, "Global-Alias Collision on '" + SGA->getName() + - "': aliasee is not global variable"); + return Error(Err, "Global-Alias Collision on '" + SGA->getName() + + "': aliasee is not global variable"); NewGA = new GlobalAlias(SGA->getType(), SGA->getLinkage(), SGA->getName(), DAliasee, Dest); CopyGVAttributes(NewGA, SGA); // Any uses of DGV need to change to NewGA, with cast, if needed. - if (SGA->getType() != DGV->getType()) - DGV->replaceAllUsesWith(ConstantExpr::getBitCast(NewGA, - DGV->getType())); + if (SGA->getType() != DGVar->getType()) + DGVar->replaceAllUsesWith(ConstantExpr::getBitCast(NewGA, + DGVar->getType())); else - DGV->replaceAllUsesWith(NewGA); + DGVar->replaceAllUsesWith(NewGA); - // DGV will conflict with NewGA because they both had the same + // DGVar will conflict with NewGA because they both had the same // name. We must erase this now so ForceRenaming doesn't assert // because DGV might not have internal linkage. - DGV->eraseFromParent(); + DGVar->eraseFromParent(); // Proceed to 'common' steps } else return Error(Err, "Global-Alias Collision on '" + SGA->getName() + "': symbol multiple defined"); - } else if (Function *DF = Dest->getFunction(SGA->getName())) { - RecursiveResolveTypes(SGA->getType(), DF->getType(), - &Dest->getTypeSymbolTable(), ""); - + } else if (Function *DF = dyn_cast_or_null(DGV)) { // The only allowed way is to link alias with external declaration. if (DF->isDeclaration()) { // But only if aliasee is function too... if (!isa(DAliasee)) - return Error(Err, "Function-Alias Collision on '" + SGA->getName() + - "': aliasee is not function"); + return Error(Err, "Function-Alias Collision on '" + SGA->getName() + + "': aliasee is not function"); NewGA = new GlobalAlias(SGA->getType(), SGA->getLinkage(), SGA->getName(), DAliasee, Dest); @@ -716,7 +742,8 @@ return Error(Err, "Function-Alias Collision on '" + SGA->getName() + "': symbol multiple defined"); } else { - // Nothing similar found, just copy alias into destination module. + // No linking to be performed, simply create an identical version of the + // alias over in the dest module... NewGA = new GlobalAlias(SGA->getType(), SGA->getLinkage(), SGA->getName(), DAliasee, Dest); @@ -728,7 +755,7 @@ assert(NewGA && "No alias was created in destination module!"); // If the symbol table renamed the alias, but it is an externally visible - // symbol, DGV must be an global value with internal linkage. Rename it. + // symbol, DGA must be an global value with internal linkage. Rename it. if (NewGA->getName() != SGA->getName() && !NewGA->hasInternalLinkage()) ForceRenaming(NewGA, SGA->getName()); From baldrick at free.fr Sat May 10 11:43:10 2008 From: baldrick at free.fr (Duncan Sands) Date: Sat, 10 May 2008 16:43:10 -0000 Subject: [llvm-commits] [llvm] r50951 - /llvm/trunk/test/Transforms/InstCombine/2008-05-09-SinkOfInvoke.ll Message-ID: <200805101643.m4AGhA4T006918@zion.cs.uiuc.edu> Author: baldrick Date: Sat May 10 11:43:10 2008 New Revision: 50951 URL: http://llvm.org/viewvc/llvm-project?rev=50951&view=rev Log: Testcase for PR2303. Added: llvm/trunk/test/Transforms/InstCombine/2008-05-09-SinkOfInvoke.ll Added: llvm/trunk/test/Transforms/InstCombine/2008-05-09-SinkOfInvoke.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-05-09-SinkOfInvoke.ll?rev=50951&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2008-05-09-SinkOfInvoke.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/2008-05-09-SinkOfInvoke.ll Sat May 10 11:43:10 2008 @@ -0,0 +1,33 @@ +; RUN: llvm-as < %s | opt -instcombine -disable-output +; PR2303 + %"struct.std::ctype" = type { %"struct.std::locale::facet", i32*, i8, i32*, i32*, i16*, i8, [256 x i8], [256 x i8], i8 } + %"struct.std::locale::facet" = type { i32 (...)**, i32 } + +declare i32* @_ZNSt6locale5facet15_S_get_c_localeEv() + +declare i32** @__ctype_toupper_loc() readnone + +declare i32** @__ctype_tolower_loc() readnone + +define void @_ZNSt5ctypeIcEC2EPiPKtbm(%"struct.std::ctype"* %this, i32* %unnamed_arg, i16* %__table, i8 zeroext %__del, i64 %__refs) { +entry: + %tmp8 = invoke i32* @_ZNSt6locale5facet15_S_get_c_localeEv( ) + to label %invcont unwind label %lpad ; [#uses=0] + +invcont: ; preds = %entry + %tmp32 = invoke i32** @__ctype_toupper_loc( ) readnone + to label %invcont31 unwind label %lpad ; [#uses=0] + +invcont31: ; preds = %invcont + %tmp38 = invoke i32** @__ctype_tolower_loc( ) readnone + to label %invcont37 unwind label %lpad ; [#uses=1] + +invcont37: ; preds = %invcont31 + %tmp39 = load i32** %tmp38, align 8 ; [#uses=1] + %tmp41 = getelementptr %"struct.std::ctype"* %this, i32 0, i32 4 ; [#uses=1] + store i32* %tmp39, i32** %tmp41, align 8 + ret void + +lpad: ; preds = %invcont31, %invcont, %entry + unreachable +} From gabor at mac.com Sat May 10 12:57:38 2008 From: gabor at mac.com (Gabor Greif) Date: Sat, 10 May 2008 19:57:38 +0200 Subject: [llvm-commits] [llvm] r50946 - /llvm/trunk/include/llvm/Instructions.h Message-ID: <58481620-8FD2-4DEF-BCD8-36F6A620F837@mac.com> + NumOperands = (unsigned)(uintptr_t)((Use*)this - OperandList); Hi Bill, wouldn't + NumOperands = unsigned((Use*)this - OperandList); do the job? Cheers, Gabor PS: Sorry for these warnings, neither my solaris gcc 3.4.6, nor Apple gcc 4.0.1 has shown them. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080510/9880b1ed/attachment.html From isanbard at gmail.com Sat May 10 14:55:26 2008 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 10 May 2008 12:55:26 -0700 Subject: [llvm-commits] [llvm] r50946 - /llvm/trunk/include/llvm/Instructions.h In-Reply-To: <58481620-8FD2-4DEF-BCD8-36F6A620F837@mac.com> References: <58481620-8FD2-4DEF-BCD8-36F6A620F837@mac.com> Message-ID: On May 10, 2008, at 10:57 AM, Gabor Greif wrote: > + NumOperands = (unsigned)(uintptr_t)((Use*)this - OperandList); > > Hi Bill, > > wouldn't > > + NumOperands = unsigned((Use*)this - OperandList); > > do the job? > That would probably be okay. :-) I just wanted to make sure that the compiler wouldn't yell because of the cast from a pointer to (smaller) integral value. > PS: Sorry for these warnings, neither my > solaris gcc 3.4.6, nor Apple gcc 4.0.1 > has shown them. > No worries. I don't think that those compilers would have. You needed to compile an application with "-Wshorten-64-to-32 -Werror" in order to get the errors. I think you need to use "uintptr_t" instead of "unsigned" for the placement-new in User.h. -bw From isanbard at gmail.com Sat May 10 14:59:59 2008 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 10 May 2008 19:59:59 -0000 Subject: [llvm-commits] [llvm] r50952 - /llvm/trunk/include/llvm/Instructions.h Message-ID: <200805101959.m4AJxxpg015184@zion.cs.uiuc.edu> Author: void Date: Sat May 10 14:59:59 2008 New Revision: 50952 URL: http://llvm.org/viewvc/llvm-project?rev=50952&view=rev Log: Remove warnings when using -Wshorten-64-to-32. 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=50952&r1=50951&r2=50952&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Sat May 10 14:59:59 2008 @@ -960,14 +960,14 @@ InputIterator ArgBegin, InputIterator ArgEnd, const std::string &Name = "", Instruction *InsertBefore = 0) { - return new(ArgEnd - ArgBegin + 1) + return new((unsigned)(ArgEnd - ArgBegin + 1)) CallInst(Func, ArgBegin, ArgEnd, Name, InsertBefore); } template static CallInst *Create(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, const std::string &Name, BasicBlock *InsertAtEnd) { - return new(ArgEnd - ArgBegin + 1) + return new((unsigned)(ArgEnd - ArgBegin + 1)) CallInst(Func, ArgBegin, ArgEnd, Name, InsertAtEnd); } static CallInst *Create(Value *F, Value *Actual, const std::string& Name = "", @@ -1685,7 +1685,7 @@ ~BranchInst() { if (NumOperands == 1) - NumOperands = (unsigned)(uintptr_t)((Use*)this - OperandList); + NumOperands = (unsigned)((Use*)this - OperandList); } /// Transparently provide more efficient getOperand methods. From isanbard at gmail.com Sat May 10 15:00:39 2008 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 10 May 2008 20:00:39 -0000 Subject: [llvm-commits] [llvm] r50953 - /llvm/tags/Apple/llvmCore-2042/ Message-ID: <200805102000.m4AK0dTS015228@zion.cs.uiuc.edu> Author: void Date: Sat May 10 15:00:39 2008 New Revision: 50953 URL: http://llvm.org/viewvc/llvm-project?rev=50953&view=rev Log: Removing bad tag. Removed: llvm/tags/Apple/llvmCore-2042/ From isanbard at gmail.com Sat May 10 15:00:59 2008 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 10 May 2008 20:00:59 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50954 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2042/ Message-ID: <200805102000.m4AK0xkr015254@zion.cs.uiuc.edu> Author: void Date: Sat May 10 15:00:59 2008 New Revision: 50954 URL: http://llvm.org/viewvc/llvm-project?rev=50954&view=rev Log: Removing bad tag. Removed: llvm-gcc-4.2/tags/Apple/llvmgcc42-2042/ From isanbard at gmail.com Sat May 10 15:03:26 2008 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 10 May 2008 20:03:26 -0000 Subject: [llvm-commits] [llvm] r50955 - /llvm/tags/Apple/llvmCore-2042/ Message-ID: <200805102003.m4AK3QDN015335@zion.cs.uiuc.edu> Author: void Date: Sat May 10 15:03:26 2008 New Revision: 50955 URL: http://llvm.org/viewvc/llvm-project?rev=50955&view=rev Log: Creating llvmCore-2042 branch Added: llvm/tags/Apple/llvmCore-2042/ - copied from r50954, llvm/trunk/ From isanbard at gmail.com Sat May 10 15:03:32 2008 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 10 May 2008 20:03:32 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50956 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2042/ Message-ID: <200805102003.m4AK3W2V015347@zion.cs.uiuc.edu> Author: void Date: Sat May 10 15:03:32 2008 New Revision: 50956 URL: http://llvm.org/viewvc/llvm-project?rev=50956&view=rev Log: Creating llvmgcc42-2042 branch Added: llvm-gcc-4.2/tags/Apple/llvmgcc42-2042/ - copied from r50955, llvm-gcc-4.2/trunk/ From sabre at nondot.org Sat May 10 18:56:54 2008 From: sabre at nondot.org (Chris Lattner) Date: Sat, 10 May 2008 23:56:54 -0000 Subject: [llvm-commits] [llvm] r50957 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200805102356.m4ANutLb022290@zion.cs.uiuc.edu> Author: lattner Date: Sat May 10 18:56:54 2008 New Revision: 50957 URL: http://llvm.org/viewvc/llvm-project?rev=50957&view=rev Log: Simplify code by using SwitchInst::findCaseValue instead of reimplementing it. Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=50957&r1=50956&r2=50957&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Sat May 10 18:56:54 2008 @@ -448,20 +448,8 @@ (SCValue.isConstant() && !isa(SCValue.getConstant()))) { // All destinations are executable! Succs.assign(TI.getNumSuccessors(), true); - } else if (SCValue.isConstant()) { - Constant *CPV = SCValue.getConstant(); - // Make sure to skip the "default value" which isn't a value - for (unsigned i = 1, E = SI->getNumSuccessors(); i != E; ++i) { - if (SI->getSuccessorValue(i) == CPV) {// Found the right branch... - Succs[i] = true; - return; - } - } - - // Constant value not equal to any of the branches... must execute - // default branch then... - Succs[0] = true; - } + } else if (SCValue.isConstant()) + Succs[SI->findCaseValue(cast(SCValue.getConstant()))] = true; } else { assert(0 && "SCCP: Don't know how to handle this terminator!"); } From sabre at nondot.org Sat May 10 20:55:59 2008 From: sabre at nondot.org (Chris Lattner) Date: Sun, 11 May 2008 01:55:59 -0000 Subject: [llvm-commits] [llvm] r50958 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200805110155.m4B1txoS025439@zion.cs.uiuc.edu> Author: lattner Date: Sat May 10 20:55:59 2008 New Revision: 50958 URL: http://llvm.org/viewvc/llvm-project?rev=50958&view=rev Log: Fix various DOUTs to not call the extremely expensive Value::getName() method. DOUT statements are disabled when assertions are off, but the side effects of getName() are still evaluated. Just call getNameSTart, which is close enough and doesn't cause heap traffic. Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=50958&r1=50957&r2=50958&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Sat May 10 20:55:59 2008 @@ -179,7 +179,7 @@ /// MarkBlockExecutable - This method can be used by clients to mark all of /// the blocks that are known to be intrinsically live in the processed unit. void MarkBlockExecutable(BasicBlock *BB) { - DOUT << "Marking Block Executable: " << BB->getName() << "\n"; + DOUT << "Marking Block Executable: " << BB->getNameStart() << "\n"; BBExecutable.insert(BB); // Basic block is executable! BBWorkList.push_back(BB); // Add the block to the work list! } @@ -334,8 +334,8 @@ return; // This edge is already known to be executable! if (BBExecutable.count(Dest)) { - DOUT << "Marking Edge Executable: " << Source->getName() - << " -> " << Dest->getName() << "\n"; + DOUT << "Marking Edge Executable: " << Source->getNameStart() + << " -> " << Dest->getNameStart() << "\n"; // The destination is already executable, but we just made an edge // feasible that wasn't before. Revisit the PHI nodes in the block @@ -1451,7 +1451,7 @@ // and return true if the function was modified. // bool SCCP::runOnFunction(Function &F) { - DOUT << "SCCP on function '" << F.getName() << "'\n"; + DOUT << "SCCP on function '" << F.getNameStart() << "'\n"; SCCPSolver Solver; // Mark the first block of the function as being executable. @@ -1774,7 +1774,7 @@ GlobalVariable *GV = I->first; assert(!I->second.isOverdefined() && "Overdefined values should have been taken out of the map!"); - DOUT << "Found that GV '" << GV->getName()<< "' is constant!\n"; + DOUT << "Found that GV '" << GV->getNameStart() << "' is constant!\n"; while (!GV->use_empty()) { StoreInst *SI = cast(GV->use_back()); SI->eraseFromParent(); From nicholas at mxc.ca Sun May 11 02:48:46 2008 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 11 May 2008 00:48:46 -0700 Subject: [llvm-commits] paths on win32 Message-ID: <4826A4DE.8080006@mxc.ca> There's a problem on win32 where Paths can be created with \'s as path separators in them. The win32 sys::Path implementation normally canonicalize them into /'s, but using the constructor will bypass that. This is a problem because clients expect to be able to take any valid win32 path (which may have any mix of / and \) and construct a valid Path with it, through the constructor. This patch moves the constructor implementations out of include/llvm/System/Path.h and into lib/System/*/Path.inc. This fixes the bug, but there may be a small price in efficiency. Is this approach okay? (There are two other ways to fix the bug.) Nick -------------- next part -------------- A non-text attachment was scrubbed... Name: win32-path.patch Type: text/x-diff Size: 2152 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080511/8c7b5cb6/attachment.bin From asl at math.spbu.ru Sun May 11 06:21:16 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sun, 11 May 2008 15:21:16 +0400 Subject: [llvm-commits] paths on win32 In-Reply-To: <4826A4DE.8080006@mxc.ca> References: <4826A4DE.8080006@mxc.ca> Message-ID: <1210504876.8813.336.camel@localhost> Hi, Nick > This patch moves the constructor implementations out of > include/llvm/System/Path.h and into lib/System/*/Path.inc. This fixes > the bug, but there may be a small price in efficiency. Is this approach > okay? (There are two other ways to fix the bug.) Patch looks ok for me, please apply. Why do you need this hunk, btw?: ? std::string Path::getDirname() const { - return getDirnameCharSep(path, '\\'); + return getDirnameCharSep(path, '/'); } -- With best regards, Anton Korobeynikov. Faculty of Mathematics & Mechanics, Saint Petersburg State University. From asl at math.spbu.ru Sun May 11 09:33:16 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sun, 11 May 2008 14:33:16 -0000 Subject: [llvm-commits] [llvm] r50959 - /llvm/trunk/lib/Target/X86/README-SSE.txt Message-ID: <200805111433.m4BEXGJ8013870@zion.cs.uiuc.edu> Author: asl Date: Sun May 11 09:33:15 2008 New Revision: 50959 URL: http://llvm.org/viewvc/llvm-project?rev=50959&view=rev Log: Add note Modified: llvm/trunk/lib/Target/X86/README-SSE.txt Modified: llvm/trunk/lib/Target/X86/README-SSE.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README-SSE.txt?rev=50959&r1=50958&r2=50959&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/README-SSE.txt (original) +++ llvm/trunk/lib/Target/X86/README-SSE.txt Sun May 11 09:33:15 2008 @@ -835,3 +835,41 @@ just a matter of matching (scalar_to_vector (load x)) to movd. //===---------------------------------------------------------------------===// + +LLVM currently generates stack realignment code, when it is not necessary +needed. The problem is that we need to know about stack alignment too early, +before RA runs. + +At that point we don't know, whether there will be vector spill, or not. +Stack realignment logic is overly conservative here, but otherwise we can +produce unaligned loads/stores. + +Fixing this will require some huge RA changes. + +Testcase: +#include + +typedef short vSInt16 __attribute__ ((__vector_size__ (16))); + +static const vSInt16 a = {- 22725, - 12873, - 22725, - 12873, - 22725, - 12873, +- 22725, - 12873};; + +vSInt16 madd(vSInt16 b) +{ + return _mm_madd_epi16(a, b); +} + +Generated code (x86-32, linux): +madd: + pushl %ebp + movl %esp, %ebp + andl $-16, %esp + movaps .LCPI1_0, %xmm1 + pmaddwd %xmm1, %xmm0 + movl %ebp, %esp + popl %ebp + ret + +//===---------------------------------------------------------------------===// + + From nicholas at mxc.ca Sun May 11 12:36:37 2008 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 11 May 2008 10:36:37 -0700 Subject: [llvm-commits] paths on win32 In-Reply-To: <1210504876.8813.336.camel@localhost> References: <4826A4DE.8080006@mxc.ca> <1210504876.8813.336.camel@localhost> Message-ID: <48272EA5.5060708@mxc.ca> Anton Korobeynikov wrote: > Hi, Nick > >> This patch moves the constructor implementations out of >> include/llvm/System/Path.h and into lib/System/*/Path.inc. This fixes >> the bug, but there may be a small price in efficiency. Is this approach >> okay? (There are two other ways to fix the bug.) > Patch looks ok for me, please apply. Thanks! > Why do you need this hunk, btw?: > ? > std::string Path::getDirname() const { > - return getDirnameCharSep(path, '\\'); > + return getDirnameCharSep(path, '/'); > } > It's not needed for this change, but I'm quite sure it's a bug. "path" ought to never include \ after this change is in, so searching for \ doesn't make a whole lot of sense. Nick From nicholas at mxc.ca Sun May 11 12:37:40 2008 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 11 May 2008 17:37:40 -0000 Subject: [llvm-commits] [llvm] r50960 - in /llvm/trunk: include/llvm/System/Path.h lib/System/Unix/Path.inc lib/System/Win32/Path.inc Message-ID: <200805111737.m4BHbe48024311@zion.cs.uiuc.edu> Author: nicholas Date: Sun May 11 12:37:40 2008 New Revision: 50960 URL: http://llvm.org/viewvc/llvm-project?rev=50960&view=rev Log: Make constructors target-specific. This fixes problems where the path would include backslashes on Windows. This should fix llvm-ld problems on win32. Modified: llvm/trunk/include/llvm/System/Path.h llvm/trunk/lib/System/Unix/Path.inc llvm/trunk/lib/System/Win32/Path.inc Modified: llvm/trunk/include/llvm/System/Path.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Path.h?rev=50960&r1=50959&r2=50960&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Path.h (original) +++ llvm/trunk/include/llvm/System/Path.h Sun May 11 12:37:40 2008 @@ -180,7 +180,7 @@ /// of the path, use the isValid method. /// @param p The path to assign. /// @brief Construct a Path from a string. - explicit Path(const std::string& p) : path(p) {} + explicit Path(const std::string& p); /// This constructor will accept a character range as a path. No checking /// is done on this path to determine if it is valid. To determine @@ -188,8 +188,7 @@ /// @param StrStart A pointer to the first character of the path name /// @param StrLen The length of the path name at StrStart /// @brief Construct a Path from a string. - explicit Path(const char *StrStart, unsigned StrLen) - : path(StrStart, StrStart+StrLen) {} + Path(const char *StrStart, unsigned StrLen); /// @} /// @name Operators Modified: llvm/trunk/lib/System/Unix/Path.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Path.inc?rev=50960&r1=50959&r2=50960&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Path.inc (original) +++ llvm/trunk/lib/System/Unix/Path.inc Sun May 11 12:37:40 2008 @@ -75,6 +75,12 @@ extern const char sys::PathSeparator = ':'; +Path::Path(const std::string& p) + : path(p) {} + +Path::Path(const char *StrStart, unsigned StrLen) + : path(StrStart, StrLen) {} + bool Path::isValid() const { // Check some obvious things Modified: llvm/trunk/lib/System/Win32/Path.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Path.inc?rev=50960&r1=50959&r2=50960&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/Path.inc (original) +++ llvm/trunk/lib/System/Win32/Path.inc Sun May 11 12:37:40 2008 @@ -46,6 +46,16 @@ namespace sys { const char PathSeparator = ';'; +Path::Path(const std::string& p) + : path(p) { + FlipBackSlashes(path); +} + +Path::Path(const char *StrStart, unsigned StrLen) + : path(StrStart, StrLen) { + FlipBackSlashes(path); +} + bool Path::isValid() const { if (path.empty()) @@ -230,7 +240,7 @@ } std::string Path::getDirname() const { - return getDirnameCharSep(path, '\\'); + return getDirnameCharSep(path, '/'); } std::string From sabre at nondot.org Sun May 11 20:12:24 2008 From: sabre at nondot.org (Chris Lattner) Date: Mon, 12 May 2008 01:12:24 -0000 Subject: [llvm-commits] [llvm] r50961 - in /llvm/trunk: include/llvm/Analysis/SparsePropagation.h lib/Analysis/SparsePropagation.cpp Message-ID: <200805120112.m4C1COFv012328@zion.cs.uiuc.edu> Author: lattner Date: Sun May 11 20:12:24 2008 New Revision: 50961 URL: http://llvm.org/viewvc/llvm-project?rev=50961&view=rev Log: Add a new SparsePropagation analysis utility, which allows you to do SCCP like sparse lattice analysis with relative ease. Just pick your lattice function and implement the transfer function and you're good. Just make sure you don't break monotonicity ;-) Added: llvm/trunk/include/llvm/Analysis/SparsePropagation.h llvm/trunk/lib/Analysis/SparsePropagation.cpp Added: llvm/trunk/include/llvm/Analysis/SparsePropagation.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/SparsePropagation.h?rev=50961&view=auto ============================================================================== --- llvm/trunk/include/llvm/Analysis/SparsePropagation.h (added) +++ llvm/trunk/include/llvm/Analysis/SparsePropagation.h Sun May 11 20:12:24 2008 @@ -0,0 +1,178 @@ +//===- SparsePropagation.h - Sparse Conditional Property Propagation ------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements an abstract sparse conditional propagation algorithm, +// modeled after SCCP, but with a customizable lattice function. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ANALYSIS_SPARSE_PROPAGATION_H +#define LLVM_ANALYSIS_SPARSE_PROPAGATION_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SmallVector.h" +#include +#include + +namespace llvm { + class Value; + class Constant; + class Instruction; + class PHINode; + class TerminatorInst; + class BasicBlock; + class Function; + class SparseSolver; + +/// AbstractLatticeFunction - This class is implemented by the dataflow instance +/// to specify what the lattice values are and what how they handle merges etc. +/// This gives the client the power to compute lattice values from instructions, +/// constants, etc. The requirement is that lattice values must all fit into +/// a void*. If a void* is not sufficient, the implementation should use this +/// pointer to be a pointer into a uniquing set or something. +/// +class AbstractLatticeFunction { +public: + typedef void *LatticeVal; +private: + LatticeVal UndefVal, OverdefinedVal, UntrackedVal; +public: + AbstractLatticeFunction(LatticeVal undefVal, LatticeVal overdefinedVal, + LatticeVal untrackedVal) { + UndefVal = undefVal; + OverdefinedVal = overdefinedVal; + UntrackedVal = untrackedVal; + } + virtual ~AbstractLatticeFunction(); + + LatticeVal getUndefVal() const { return UndefVal; } + LatticeVal getOverdefinedVal() const { return OverdefinedVal; } + LatticeVal getUntrackedVal() const { return UntrackedVal; } + + /// IsUntrackedValue - If the specified Value is something that is obviously + /// uninteresting to the analysis (and would always return UntrackedVal), + /// this function can return true to avoid pointless work. + virtual bool IsUntrackedValue(Value *V) { + return false; + } + + /// ComputeConstant - Given a constant value, compute and return a lattice + /// value corresponding to the specified constant. + virtual LatticeVal ComputeConstant(Constant *C) { + return getOverdefinedVal(); // always safe + } + + /// GetConstant - If the specified lattice value is representable as an LLVM + /// constant value, return it. Otherwise return null. The returned value + /// must be in the same LLVM type as Val. + virtual Constant *GetConstant(LatticeVal LV, Value *Val, SparseSolver &SS) { + return 0; + } + + /// MergeValues - Compute and return the merge of the two specified lattice + /// values. Merging should only move one direction down the lattice to + /// guarantee convergence (toward overdefined). + virtual LatticeVal MergeValues(LatticeVal X, LatticeVal Y) { + return getOverdefinedVal(); // always safe, never useful. + } + + /// ComputeInstructionState - Given an instruction and a vector of its operand + /// values, compute the result value of the instruction. + virtual LatticeVal ComputeInstructionState(Instruction &I, SparseSolver &SS) { + return getOverdefinedVal(); // always safe, never useful. + } + + /// PrintValue - Render the specified lattice value to the specified stream. + virtual void PrintValue(LatticeVal V, std::ostream &OS); +}; + + +/// SparseSolver - This class is a general purpose solver for Sparse Conditional +/// Propagation with a programmable lattice function. +/// +class SparseSolver { + typedef AbstractLatticeFunction::LatticeVal LatticeVal; + + /// LatticeFunc - This is the object that knows the lattice and how to do + /// compute transfer functions. + AbstractLatticeFunction *LatticeFunc; + + DenseMap ValueState; // The state each value is in. + SmallPtrSet BBExecutable; // The bbs that are executable. + + std::vector InstWorkList; // Worklist of insts to process. + + std::vector BBWorkList; // The BasicBlock work list + + /// KnownFeasibleEdges - Entries in this set are edges which have already had + /// PHI nodes retriggered. + typedef std::pair Edge; + std::set KnownFeasibleEdges; + + SparseSolver(const SparseSolver&); // DO NOT IMPLEMENT + void operator=(const SparseSolver&); // DO NOT IMPLEMENT +public: + SparseSolver(AbstractLatticeFunction *Lattice) : LatticeFunc(Lattice) {} + ~SparseSolver() { + delete LatticeFunc; + } + + /// Solve - Solve for constants and executable blocks. + /// + void Solve(Function &F); + + void Print(Function &F, std::ostream &OS); + + /// getLatticeState - Return the LatticeVal object that corresponds to the + /// value. If an value is not in the map, it is returned as untracked, + /// unlike the getOrInitValueState method. + LatticeVal getLatticeState(Value *V) const { + DenseMap::iterator I = ValueState.find(V); + return I != ValueState.end() ? I->second : LatticeFunc->getUntrackedVal(); + } + + /// getOrInitValueState - Return the LatticeVal object that corresponds to the + /// value, initializing the value's state if it hasn't been entered into the + /// map yet. This function is necessary because not all values should start + /// out in the underdefined state... Arguments should be overdefined, and + /// constants should be marked as constants. + /// + LatticeVal getOrInitValueState(Value *V); + +private: + /// UpdateState - When the state for some instruction is potentially updated, + /// this function notices and adds I to the worklist if needed. + void UpdateState(Instruction &Inst, LatticeVal V); + + /// MarkBlockExecutable - This method can be used by clients to mark all of + /// the blocks that are known to be intrinsically live in the processed unit. + void MarkBlockExecutable(BasicBlock *BB); + + /// markEdgeExecutable - Mark a basic block as executable, adding it to the BB + /// work list if it is not already executable. + void markEdgeExecutable(BasicBlock *Source, BasicBlock *Dest); + + /// getFeasibleSuccessors - Return a vector of booleans to indicate which + /// successors are reachable from a given terminator instruction. + void getFeasibleSuccessors(TerminatorInst &TI, SmallVectorImpl &Succs); + + /// isEdgeFeasible - Return true if the control flow edge from the 'From' + /// basic block to the 'To' basic block is currently feasible... + bool isEdgeFeasible(BasicBlock *From, BasicBlock *To); + + void visitInst(Instruction &I); + void visitPHINode(PHINode &I); + void visitTerminatorInst(TerminatorInst &TI); + +}; + +} // end namespace llvm + +#endif // LLVM_ANALYSIS_SPARSE_PROPAGATION_H Added: llvm/trunk/lib/Analysis/SparsePropagation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/SparsePropagation.cpp?rev=50961&view=auto ============================================================================== --- llvm/trunk/lib/Analysis/SparsePropagation.cpp (added) +++ llvm/trunk/lib/Analysis/SparsePropagation.cpp Sun May 11 20:12:24 2008 @@ -0,0 +1,320 @@ +//===- SparsePropagation.cpp - Sparse Conditional Property Propagation ----===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements an abstract sparse conditional propagation algorithm, +// modeled after SCCP, but with a customizable lattice function. +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "sparseprop" +#include "llvm/Analysis/SparsePropagation.h" +#include "llvm/Constants.h" +#include "llvm/Function.h" +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/Streams.h" +using namespace llvm; + +//===----------------------------------------------------------------------===// +// AbstractLatticeFunction Implementation +//===----------------------------------------------------------------------===// + +AbstractLatticeFunction::~AbstractLatticeFunction() {} + +/// PrintValue - Render the specified lattice value to the specified stream. +void AbstractLatticeFunction::PrintValue(LatticeVal V, std::ostream &OS) { + if (V == UndefVal) + OS << "undefined"; + else if (V == OverdefinedVal) + OS << "overdefined"; + else if (V == UntrackedVal) + OS << "untracked"; + else + OS << "unknown lattice value"; +} + +//===----------------------------------------------------------------------===// +// SparseSolver Implementation +//===----------------------------------------------------------------------===// + +/// getOrInitValueState - Return the LatticeVal object that corresponds to the +/// value, initializing the value's state if it hasn't been entered into the +/// map yet. This function is necessary because not all values should start +/// out in the underdefined state... Arguments should be overdefined, and +/// constants should be marked as constants. +/// +SparseSolver::LatticeVal SparseSolver::getOrInitValueState(Value *V) { + DenseMap::iterator I = ValueState.find(V); + if (I != ValueState.end()) return I->second; // Common case, in the map + + LatticeVal LV; + if (LatticeFunc->IsUntrackedValue(V)) + return LatticeFunc->getUntrackedVal(); + else if (Constant *C = dyn_cast(V)) + LV = LatticeFunc->ComputeConstant(C); + else if (!isa(V)) + // Non-instructions (e.g. formal arguments) are overdefined. + LV = LatticeFunc->getOverdefinedVal(); + else + // All instructions are underdefined by default. + LV = LatticeFunc->getUndefVal(); + + // If this value is untracked, don't add it to the map. + if (LV == LatticeFunc->getUntrackedVal()) + return LV; + return ValueState[V] = LV; +} + +/// UpdateState - When the state for some instruction is potentially updated, +/// this function notices and adds I to the worklist if needed. +void SparseSolver::UpdateState(Instruction &Inst, LatticeVal V) { + DenseMap::iterator I = ValueState.find(&Inst); + if (I != ValueState.end() && I->second == V) + return; // No change. + + // An update. Visit uses of I. + ValueState[&Inst] = V; + InstWorkList.push_back(&Inst); +} + +/// MarkBlockExecutable - This method can be used by clients to mark all of +/// the blocks that are known to be intrinsically live in the processed unit. +void SparseSolver::MarkBlockExecutable(BasicBlock *BB) { + DOUT << "Marking Block Executable: " << BB->getNameStart() << "\n"; + BBExecutable.insert(BB); // Basic block is executable! + BBWorkList.push_back(BB); // Add the block to the work list! +} + +/// markEdgeExecutable - Mark a basic block as executable, adding it to the BB +/// work list if it is not already executable... +void SparseSolver::markEdgeExecutable(BasicBlock *Source, BasicBlock *Dest) { + if (!KnownFeasibleEdges.insert(Edge(Source, Dest)).second) + return; // This edge is already known to be executable! + + if (BBExecutable.count(Dest)) { + DOUT << "Marking Edge Executable: " << Source->getNameStart() + << " -> " << Dest->getNameStart() << "\n"; + + // The destination is already executable, but we just made an edge + // feasible that wasn't before. Revisit the PHI nodes in the block + // because they have potentially new operands. + for (BasicBlock::iterator I = Dest->begin(); isa(I); ++I) + visitPHINode(*cast(I)); + + } else { + MarkBlockExecutable(Dest); + } +} + + +/// getFeasibleSuccessors - Return a vector of booleans to indicate which +/// successors are reachable from a given terminator instruction. +void SparseSolver::getFeasibleSuccessors(TerminatorInst &TI, + SmallVectorImpl &Succs) { + Succs.resize(TI.getNumSuccessors()); + if (TI.getNumSuccessors() == 0) return; + + if (BranchInst *BI = dyn_cast(&TI)) { + if (BI->isUnconditional()) { + Succs[0] = true; + return; + } + + LatticeVal BCValue = getOrInitValueState(BI->getCondition()); + if (BCValue == LatticeFunc->getOverdefinedVal() || + BCValue == LatticeFunc->getUntrackedVal()) { + // Overdefined condition variables can branch either way. + Succs[0] = Succs[1] = true; + return; + } + + // If undefined, neither is feasible yet. + if (BCValue == LatticeFunc->getUndefVal()) + return; + + Constant *C = LatticeFunc->GetConstant(BCValue, BI->getCondition(), *this); + if (C == 0 || !isa(C)) { + // Non-constant values can go either way. + Succs[0] = Succs[1] = true; + return; + } + + // Constant condition variables mean the branch can only go a single way + Succs[C == ConstantInt::getFalse()] = true; + return; + } + + if (isa(TI)) { + // Invoke instructions successors are always executable. + // TODO: Could ask the lattice function if the value can throw. + Succs[0] = Succs[1] = true; + return; + } + + SwitchInst &SI = cast(TI); + LatticeVal SCValue = getOrInitValueState(SI.getCondition()); + if (SCValue == LatticeFunc->getOverdefinedVal() || + SCValue == LatticeFunc->getUntrackedVal()) { + // All destinations are executable! + Succs.assign(TI.getNumSuccessors(), true); + return; + } + + // If undefined, neither is feasible yet. + if (SCValue == LatticeFunc->getUndefVal()) + return; + + Constant *C = LatticeFunc->GetConstant(SCValue, SI.getCondition(), *this); + if (C == 0 || !isa(C)) { + // All destinations are executable! + Succs.assign(TI.getNumSuccessors(), true); + return; + } + + Succs[SI.findCaseValue(cast(C))] = true; +} + + +/// isEdgeFeasible - Return true if the control flow edge from the 'From' +/// basic block to the 'To' basic block is currently feasible... +bool SparseSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) { + SmallVector SuccFeasible; + TerminatorInst *TI = From->getTerminator(); + getFeasibleSuccessors(*TI, SuccFeasible); + + for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) + if (TI->getSuccessor(i) == To && SuccFeasible[i]) + return true; + + return false; +} + +void SparseSolver::visitTerminatorInst(TerminatorInst &TI) { + SmallVector SuccFeasible; + getFeasibleSuccessors(TI, SuccFeasible); + + BasicBlock *BB = TI.getParent(); + + // Mark all feasible successors executable... + for (unsigned i = 0, e = SuccFeasible.size(); i != e; ++i) + if (SuccFeasible[i]) + markEdgeExecutable(BB, TI.getSuccessor(i)); +} + +void SparseSolver::visitPHINode(PHINode &PN) { + LatticeVal PNIV = getOrInitValueState(&PN); + LatticeVal Overdefined = LatticeFunc->getOverdefinedVal(); + + // If this value is already overdefined (common) just return. + if (PNIV == Overdefined || PNIV == LatticeFunc->getUntrackedVal()) + return; // Quick exit + + // Super-extra-high-degree PHI nodes are unlikely to ever be interesting, + // and slow us down a lot. Just mark them overdefined. + if (PN.getNumIncomingValues() > 64) { + UpdateState(PN, Overdefined); + return; + } + + // Look at all of the executable operands of the PHI node. If any of them + // are overdefined, the PHI becomes overdefined as well. Otherwise, ask the + // transfer function to give us the merge of the incoming values. + for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) { + // If the edge is not yet known to be feasible, it doesn't impact the PHI. + if (!isEdgeFeasible(PN.getIncomingBlock(i), PN.getParent())) + continue; + + // Merge in this value. + LatticeVal OpVal = getOrInitValueState(PN.getIncomingValue(i)); + if (OpVal != PNIV) + PNIV = LatticeFunc->MergeValues(PNIV, OpVal); + + if (PNIV == Overdefined) + break; // Rest of input values don't matter. + } + + // Update the PHI with the compute value, which is the merge of the inputs. + UpdateState(PN, PNIV); +} + + +void SparseSolver::visitInst(Instruction &I) { + // PHIs are handled by the propagation logic, they are never passed into the + // transfer functions. + if (PHINode *PN = dyn_cast(&I)) + return visitPHINode(*PN); + + // Otherwise, ask the transfer function what the result is. If this is + // something that we care about, remember it. + LatticeVal IV = LatticeFunc->ComputeInstructionState(I, *this); + if (IV != LatticeFunc->getUntrackedVal()) + UpdateState(I, IV); + + if (TerminatorInst *TI = dyn_cast(&I)) + visitTerminatorInst(*TI); +} + +void SparseSolver::Solve(Function &F) { + MarkBlockExecutable(F.begin()); + + // Process the work lists until they are empty! + while (!BBWorkList.empty() || !InstWorkList.empty()) { + // Process the instruction work list. + while (!InstWorkList.empty()) { + Instruction *I = InstWorkList.back(); + InstWorkList.pop_back(); + + DOUT << "\nPopped off I-WL: " << *I; + + // "I" got into the work list because it made a transition. See if any + // users are both live and in need of updating. + for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); + UI != E; ++UI) { + Instruction *U = cast(*UI); + if (BBExecutable.count(U->getParent())) // Inst is executable? + visitInst(*U); + } + } + + // Process the basic block work list. + while (!BBWorkList.empty()) { + BasicBlock *BB = BBWorkList.back(); + BBWorkList.pop_back(); + + DOUT << "\nPopped off BBWL: " << *BB; + + // Notify all instructions in this basic block that they are newly + // executable. + for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) + visitInst(*I); + } + } +} + +void SparseSolver::Print(Function &F, std::ostream &OS) { + OS << "\nFUNCTION: " << F.getNameStr() << "\n"; + for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { + if (!BBExecutable.count(BB)) + OS << "INFEASIBLE: "; + OS << "\t"; + if (BB->hasName()) + OS << BB->getNameStr() << ":\n"; + else + OS << "; anon bb\n"; + for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { + LatticeFunc->PrintValue(getLatticeState(I), OS); + OS << *I; + } + + OS << "\n"; + } +} + From sabre at nondot.org Sun May 11 20:13:53 2008 From: sabre at nondot.org (Chris Lattner) Date: Mon, 12 May 2008 01:13:53 -0000 Subject: [llvm-commits] [llvm] r50962 - /llvm/trunk/lib/Analysis/SparsePropagation.cpp Message-ID: <200805120113.m4C1DrQD012374@zion.cs.uiuc.edu> Author: lattner Date: Sun May 11 20:13:53 2008 New Revision: 50962 URL: http://llvm.org/viewvc/llvm-project?rev=50962&view=rev Log: prune #includes. Modified: llvm/trunk/lib/Analysis/SparsePropagation.cpp Modified: llvm/trunk/lib/Analysis/SparsePropagation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/SparsePropagation.cpp?rev=50962&r1=50961&r2=50962&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/SparsePropagation.cpp (original) +++ llvm/trunk/lib/Analysis/SparsePropagation.cpp Sun May 11 20:13:53 2008 @@ -17,10 +17,7 @@ #include "llvm/Constants.h" #include "llvm/Function.h" #include "llvm/Instructions.h" -#include "llvm/Module.h" -#include "llvm/Pass.h" #include "llvm/Support/Debug.h" -#include "llvm/Support/Streams.h" using namespace llvm; //===----------------------------------------------------------------------===//