[llvm-commits] [llvm] r41029 - /llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
Author: dpatel Date: Sun Aug 12 02:02:51 2007 New Revision: 41029 URL: http://llvm.org/viewvc/llvm-project?rev=41029&view=rev Log: Split loops and do CFG cleanup. Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=41029&r1=41028&r2=41029&view=diff == --- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Sun Aug 12 02:02:51 2007 @@ -97,6 +97,9 @@ /// loop may not be eliminated. bool safeExitBlock(SplitInfo &SD, BasicBlock *BB); +/// removeBlocks - Remove basic block BB and all blocks dominated by BB. +void removeBlocks(BasicBlock *InBB); + /// Find cost of spliting loop L. unsigned findSplitCost(Loop *L, SplitInfo &SD); bool splitLoop(SplitInfo &SD); @@ -105,7 +108,9 @@ IndVar = NULL; IndVarIncrement = NULL; ExitCondition = NULL; - StartValue = ExitValue = NULL; + StartValue = NULL; + ExitValueNum = 0; + SplitData.clear(); } private: @@ -128,8 +133,8 @@ // Induction variable's initial value. Value *StartValue; -// Induction variable's final loop exit value. -Value *ExitValue; +// Induction variable's final loop exit value operand number in exit condition.. +unsigned ExitValueNum; }; char LoopIndexSplit::ID = 0; @@ -285,15 +290,15 @@ SCEVHandle SH1 = SE->getSCEV(V1); if (SH0->isLoopInvariant(L) && isa(SH1)) { -ExitValue = V0; +ExitValueNum = 0; findIndVar(V1, L); } else if (SH1->isLoopInvariant(L) && isa(SH0)) { -ExitValue = V1; +ExitValueNum = 1; findIndVar(V0, L); } - if (!ExitValue || !IndVar) + if (!IndVar) ExitCondition = NULL; else if (IndVar) { BasicBlock *Preheader = L->getLoopPreheader(); @@ -430,7 +435,8 @@ Terminator); Instruction *C2 = new ICmpInst(SignedPredicate ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, - SD.SplitValue, ExitValue, "lisplit", + SD.SplitValue, + ExitCondition->getOperand(ExitValueNum), "lisplit", Terminator); Instruction *NSplitCond = BinaryOperator::createAnd(C1, C2, "lisplit", Terminator); @@ -580,6 +586,45 @@ return Cost; } +/// removeBlocks - Remove basic block BB and all blocks dominated by BB. +void LoopIndexSplit::removeBlocks(BasicBlock *InBB) { + + SmallVector WorkList; + WorkList.push_back(InBB); + while (!WorkList.empty()) { +BasicBlock *BB = WorkList.back(); WorkList.pop_back(); + +// First process all successor +for (succ_iterator SI = succ_begin(BB), E = succ_end(BB); SI != E; ++SI) { + BasicBlock *SuccBB = *SI; + if (DT->dominates(BB, SuccBB)) { +WorkList.push_back(SuccBB); +continue; + } + + // If SuccBB is not dominated by BB then it is not removed, however remove + // any PHI incoming edge from BB. + for(BasicBlock::iterator SBI = SuccBB->begin(), SBE = SuccBB->end(); + SBI != SBE; ++SBI) { +if (PHINode *PN = dyn_cast(SBI)) + PN->removeIncomingValue(BB); +else + break; + } +} + +// Now delete BB; +for(BasicBlock::iterator BBI = BB->begin(), BBE = BB->end(); +BBI != BBE; ++BBI) { + Instruction *I = BBI; + I->replaceAllUsesWith(UndefValue::get(I->getType())); + I->eraseFromParent(); +} +LI->removeBlock(BB); +BB->eraseFromParent(); + } +} + bool LoopIndexSplit::splitLoop(SplitInfo &SD) { BasicBlock *Preheader = L->getLoopPreheader(); @@ -600,9 +645,12 @@ else { Value *C1 = new ICmpInst(SignedPredicate ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, -SD.SplitValue, ExitValue, "lsplit.ev", +SD.SplitValue, + ExitCondition->getOperand(ExitValueNum), + "lsplit.ev", Preheader->getTerminator()); -TLExitValue = new SelectInst(C1, SD.SplitValue, ExitValue, +TLExitValue = new SelectInst(C1, SD.SplitValue, + ExitCondition->getOperand(ExitValueNum), "lsplit.ev", Preheader->getTerminator()); Value *C2 = new ICmpInst(SignedPredicate ? @@ -613,28 +661,62 @@ "lsplit.sv", Preheader->getTerminator()); } - //[*] Split Exit Edge. + //[*] Clone loop. Avoid true destination of split condition and + //the blocks dominated by true destination.
[llvm-commits] [llvm] r41033 - in /llvm/trunk/include/llvm: ADT/DenseMap.h ADT/SmallVector.h Analysis/Dominators.h Analysis/LoopInfo.h Assembly/PrintModulePass.h GlobalValue.h Pass.h PassManagers.h Pa
Author: reid Date: Sun Aug 12 03:12:35 2007 New Revision: 41033 URL: http://llvm.org/viewvc/llvm-project?rev=41033&view=rev Log: Change casts from old style to new style. This helps document the details better, gives the compiler a chance to validate the cast and reduces warnings if the user turns on -Wold-style-cast option. Modified: llvm/trunk/include/llvm/ADT/DenseMap.h llvm/trunk/include/llvm/ADT/SmallVector.h llvm/trunk/include/llvm/Analysis/Dominators.h llvm/trunk/include/llvm/Analysis/LoopInfo.h llvm/trunk/include/llvm/Assembly/PrintModulePass.h llvm/trunk/include/llvm/GlobalValue.h llvm/trunk/include/llvm/Pass.h llvm/trunk/include/llvm/PassManagers.h llvm/trunk/include/llvm/PassSupport.h llvm/trunk/include/llvm/SymbolTableListTraits.h llvm/trunk/include/llvm/Target/TargetData.h Modified: llvm/trunk/include/llvm/ADT/DenseMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMap.h?rev=41033&r1=41032&r2=41033&view=diff == --- llvm/trunk/include/llvm/ADT/DenseMap.h (original) +++ llvm/trunk/include/llvm/ADT/DenseMap.h Sun Aug 12 03:12:35 2007 @@ -32,11 +32,11 @@ // Provide DenseMapKeyInfo for all pointers. template struct DenseMapKeyInfo { - static inline T* getEmptyKey() { return (T*)-1; } - static inline T* getTombstoneKey() { return (T*)-2; } + static inline T* getEmptyKey() { return reinterpret_cast(-1); } + static inline T* getTombstoneKey() { return reinterpret_cast(-2); } static unsigned getHashValue(const T *PtrVal) { -return (unsigned)((uintptr_t)PtrVal >> 4) ^ - (unsigned)((uintptr_t)PtrVal >> 9); +return (unsigned(uintptr_t(PtrVal)) >> 4) ^ + (unsigned(uintptr_t(PtrVal)) >> 9); } static bool isPod() { return true; } }; @@ -69,7 +69,7 @@ P->second.~ValueT(); P->first.~KeyT(); } -delete[] (char*)Buckets; +delete[] reinterpret_cast(Buckets); } typedef DenseMapIterator iterator; @@ -258,7 +258,7 @@ NumBuckets = InitBuckets; assert(InitBuckets && (InitBuckets & InitBuckets-1) == 0 && "# initial buckets must be a power of two!"); -Buckets = (BucketT*)new char[sizeof(BucketT)*InitBuckets]; +Buckets = reinterpret_cast(new char[sizeof(BucketT)*InitBuckets]); // Initialize all the keys to EmptyKey. const KeyT EmptyKey = getEmptyKey(); for (unsigned i = 0; i != InitBuckets; ++i) @@ -272,7 +272,7 @@ // Double the number of buckets. NumBuckets <<= 1; NumTombstones = 0; -Buckets = (BucketT*)new char[sizeof(BucketT)*NumBuckets]; +Buckets = reinterpret_cast(new char[sizeof(BucketT)*NumBuckets]); // Initialize all the keys to EmptyKey. const KeyT EmptyKey = getEmptyKey(); @@ -298,7 +298,7 @@ } // Free the old table. -delete[] (char*)OldBuckets; +delete[] reinterpret_cast(OldBuckets); } void shrink_and_clear() { @@ -309,7 +309,7 @@ NumBuckets = NumEntries > 32 ? 1 << (Log2_32_Ceil(NumEntries) + 1) : 64; NumTombstones = 0; -Buckets = (BucketT*)new char[sizeof(BucketT)*NumBuckets]; +Buckets = reinterpret_cast(new char[sizeof(BucketT)*NumBuckets]); // Initialize all the keys to EmptyKey. const KeyT EmptyKey = getEmptyKey(); @@ -327,7 +327,7 @@ } // Free the old table. -delete[] (char*)OldBuckets; +delete[] reinterpret_cast(OldBuckets); NumEntries = 0; } Modified: llvm/trunk/include/llvm/ADT/SmallVector.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallVector.h?rev=41033&r1=41032&r2=41033&view=diff == --- llvm/trunk/include/llvm/ADT/SmallVector.h (original) +++ llvm/trunk/include/llvm/ADT/SmallVector.h Sun Aug 12 03:12:35 2007 @@ -73,7 +73,9 @@ public: // Default ctor - Initialize to empty. SmallVectorImpl(unsigned N) -: Begin((T*)&FirstEl), End((T*)&FirstEl), Capacity((T*)&FirstEl+N) { +: Begin(reinterpret_cast(&FirstEl)), + End(reinterpret_cast(&FirstEl)), + Capacity(reinterpret_cast(&FirstEl)+N) { } ~SmallVectorImpl() { @@ -82,7 +84,7 @@ // If this wasn't grown from the inline copy, deallocate the old space. if (!isSmall()) - delete[] (char*)Begin; + delete[] reinterpret_cast(Begin); } typedef size_t size_type; @@ -285,7 +287,8 @@ /// isSmall - Return true if this is a smallvector which has not had dynamic /// memory allocated for it. bool isSmall() const { -return (void*)Begin == (void*)&FirstEl; +return reinterpret_cast(Begin) == + reinterpret_cast(&FirstEl); } /// grow - double the size of the allocated memory, guaranteeing space for at @@ -323,7 +326,7 @@ // If this wasn't grown from the inline copy, deallocate the old space. if (!isSmall()) -
Re: [llvm-commits] Trampoline support (pointers nested funtions)
On Thursday 2 August 2007 02:55:57 Chris Lattner wrote: > > On Jul 31, 2007, at 3:08 PM, Evan Cheng wrote: > > >>> Also, isn't the static chain register described in > >>> X86CallingConv.td? > >> > >> It is, but it's hard to use here. The problem is that when > >> lowering the > >> init.trampoline intrinsic you only have a pointer to the target > >> function. > >> From this pointer you would like to find out which register a certain > >> parameter will be passed in for that function. Not so easy! It's > >> like > >> having a call instruction without having the arguments. In order to > >> exploit X86CallingConv.td, you have to use all the lowering > >> machinery, > >> which isn't adapted to this case. For example, you could try to > >> synthesize > >> a fake call. Or you could pretend to be lowering the target > >> function. I > >> tried it, and it can be done with a lot of horrible hacking. But > >> it's not > >> worth it. It's much simpler to simply grab the calling convention > >> and use > >> that, which unfortunately means keeping LowerTRAMPOLINE and > >> X86CallingConv.td in sync. Personally I can live with that, > >> especially since > >> I've seen the alternative and it still wakes me up screaming at > >> night :) > >> But maybe you can see a reasonable way of doing it? > > > > Seems like a deficiency in CCState class. Chris, your thoughts? > > Isn't the argument always a pointer, and thus always the same thing > for a particular calling conv? It is, but that's not the problem: the problem is that you need to know how the *other* arguments are lowered in order to know whether there was a register left for the static chain argument, or whether an argument that would have been passed in a register if the static chain wasn't there is not passed in a register if the static chain is there (these are all error conditions). Only a problem on X86. Ciao, Duncan. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r41034 - in /llvm/trunk/test/Transforms/InstCombine: align-inc.ll load.ll
Author: lattner Date: Sun Aug 12 11:55:14 2007 New Revision: 41034 URL: http://llvm.org/viewvc/llvm-project?rev=41034&view=rev Log: oops, forgot to commit this. Modified: llvm/trunk/test/Transforms/InstCombine/align-inc.ll llvm/trunk/test/Transforms/InstCombine/load.ll Modified: llvm/trunk/test/Transforms/InstCombine/align-inc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/align-inc.ll?rev=41034&r1=41033&r2=41034&view=diff == --- llvm/trunk/test/Transforms/InstCombine/align-inc.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/align-inc.ll Sun Aug 12 11:55:14 2007 @@ -1,7 +1,7 @@ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {GLOBAL.*align 16} ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {tmp = load} [EMAIL PROTECTED] = internal constant [4 x i32] zeroinitializer [EMAIL PROTECTED] = internal global [4 x i32] zeroinitializer declare <16 x i8> @llvm.x86.sse2.loadu.dq(i8*) Modified: llvm/trunk/test/Transforms/InstCombine/load.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/load.ll?rev=41034&r1=41033&r2=41034&view=diff == --- llvm/trunk/test/Transforms/InstCombine/load.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/load.ll Sun Aug 12 11:55:14 2007 @@ -1,7 +1,6 @@ ; This test makes sure that these instructions are properly eliminated. ; ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep load -; END. %X = constant int 42 %X2 = constant int 47 ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r41039 - /llvm/trunk/tools/Makefile
Author: reid Date: Sun Aug 12 19:25:47 2007 New Revision: 41039 URL: http://llvm.org/viewvc/llvm-project?rev=41039&view=rev Log: Don't build llvm-stub twice. Modified: llvm/trunk/tools/Makefile Modified: llvm/trunk/tools/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/Makefile?rev=41039&r1=41038&r2=41039&view=diff == --- llvm/trunk/tools/Makefile (original) +++ llvm/trunk/tools/Makefile Sun Aug 12 19:25:47 2007 @@ -16,7 +16,7 @@ llc llvm-ranlib llvm-ar llvm-nm \ llvm-ld llvmc llvm-prof llvm-link \ lli gccas gccld llvm-extract llvm-db llvm2cpp \ -bugpoint llvm-stub llvm-bcanalyzer llvm-stub +bugpoint llvm-bcanalyzer llvm-stub include $(LEVEL)/Makefile.config ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r41040 - /llvm/trunk/utils/findmisopt
Author: reid Date: Mon Aug 13 01:19:51 2007 New Revision: 41040 URL: http://llvm.org/viewvc/llvm-project?rev=41040&view=rev Log: Make use of the llvm-ld tool's new ability to read input from stdin to extract the list of link time passes to be run, just as for opt, with the -debug-pass=Arguments option. Modified: llvm/trunk/utils/findmisopt Modified: llvm/trunk/utils/findmisopt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/findmisopt?rev=41040&r1=41039&r2=41040&view=diff == --- llvm/trunk/utils/findmisopt (original) +++ llvm/trunk/utils/findmisopt Mon Aug 13 01:19:51 2007 @@ -73,6 +73,13 @@ echo "Unoptimized program: $prog" echo " Optimized program: $optprog" +# Define the list of optimizations to run. This comprises the same set of +# optimizations that opt -std-compile-opts and gccld run, in the same order. +opt_switches=`llvm-as < /dev/null -o - | opt -std-compile-opts -disable-output -debug-pass=Arguments 2>&1 | sed 's/Pass Arguments: //'` +ld_switches=`llvm-as < /dev/null -o - | llvm-ld - -debug-pass=Arguments 2>&1 | sed 's/Pass Arguments: //'` +all_switches="$opt_switches $ld_switches" +echo "Passes : $all_switches" + # Create output directory if it doesn't exist if [ -f "$outdir" ] ; then echo "$outdir is not a directory" @@ -92,13 +99,6 @@ "$prog" $args > "$out" 2>&1 <$input ex1=$? -# Define the list of optimizations to run. This comprises the same set of -# optimizations that opt -std-compile-opts and gccld run, in the same order. -opt_switches=`llvm-as < /dev/null -o - | opt -std-compile-opts -disable-output -debug-pass=Arguments 2>&1 | sed 's/Pass Arguments: //'` -ld_switches=`llvm-as < /dev/null -o - | llvm-ld - -std-link-opts -disable-output -debug-pass=Arguments 2>&1 | sed 's/Pass Arguments: //'` -all_switches="$opt_switches $ld_switches" -echo "Passes : $all_switches" - # Current set of switches is empty function tryit { switches_to_use="$1" ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm-gcc-4.0] r41041 - /llvm-gcc-4.0/trunk/ModuleInfo.txt
Author: reid Date: Mon Aug 13 01:35:23 2007 New Revision: 41041 URL: http://llvm.org/viewvc/llvm-project?rev=41041&view=rev Log: Using a pipeline with these commands doesn't work. Fortunately, there's a workaround with the make -C option. Modified: llvm-gcc-4.0/trunk/ModuleInfo.txt Modified: llvm-gcc-4.0/trunk/ModuleInfo.txt URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/ModuleInfo.txt?rev=41041&r1=41040&r2=41041&view=diff == --- llvm-gcc-4.0/trunk/ModuleInfo.txt (original) +++ llvm-gcc-4.0/trunk/ModuleInfo.txt Mon Aug 13 01:35:23 2007 @@ -1,4 +1,4 @@ DepModule: llvm BuildCmd: ./build-for-llvm-top.sh -CleanCmd: cd ../build.llvm-gcc-4.0 ; make clean -InstallCmd: cd ../build.llvm-gcc-4.0 ; make install +CleanCmd: make clean -C ../build.llvm-gcc-4.0 +InstallCmd: make install -C ../build.llvm-gcc-4.0 ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm-top] r41042 - in /llvm-top/trunk: install library.sh
Author: reid Date: Mon Aug 13 01:37:41 2007 New Revision: 41042 URL: http://llvm.org/viewvc/llvm-project?rev=41042&view=rev Log: Fix problems with the install script checking out dependencies into a subdirectory, caused by not returning to $LLVM_TOP on each iteration. Also, add more debugging output. Modified: llvm-top/trunk/install llvm-top/trunk/library.sh Modified: llvm-top/trunk/install URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/install?rev=41042&r1=41041&r2=41042&view=diff == --- llvm-top/trunk/install (original) +++ llvm-top/trunk/install Mon Aug 13 01:37:41 2007 @@ -38,13 +38,16 @@ # sorted in dependence order by get_module_dependencies for mod in $MODULE_DEPENDENCIES ; do get_module_info $mod InstallCmd - if test ! -z "$MODULE_INFO_VALUE" ; then + TheCommand="$MODULE_INFO_VALUE" + if test ! -z "$TheCommand" ; then msg 1 Installing module $mod cd $LLVM_TOP/$mod -$MODULE_INFO_VALUE || die $? "Install of module $mod failed." +msg 2 Install command for "$mod" is "$TheCommand" +$TheCommand || die $? "Install of module $mod failed." else msg 2 Module $mod has no InstallCmd in the ModuleInfo.txt fi + cd $LLVM_TOP done # Report what happened. Modified: llvm-top/trunk/library.sh URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/library.sh?rev=41042&r1=41041&r2=41042&view=diff == --- llvm-top/trunk/library.sh (original) +++ llvm-top/trunk/library.sh Mon Aug 13 01:37:41 2007 @@ -127,13 +127,15 @@ get_module_info() { local module="$1" local item_name="$2" + local item_value="" msg 2 "Getting '$item_name' module info for '$module'" if test ! -d "$module" ; then checkout_a_module "$module" || die $? "Checkout failed." fi + msg 2 "Getting module info from $module/ModuleInfo.txt" local module_info="$module/ModuleInfo.txt" if test -f "$module_info" ; then -local item_value=`grep -i "$item_name:" $module_info | \ +item_value=`grep -i "$item_name:" $module_info | \ sed -e "s/$item_name: *//g"` if test "$?" -ne 0 ; then die $? "Searching file '$module_info for $item_name' failed." @@ -213,12 +215,13 @@ msg 1 "Building module '$module'" get_module_info $module BuildCmd if test -z "$MODULE_INFO_VALUE" ; then -msg 2 "Module $module has no BuildCmd entry so it will not be built." +msg 1 "Module $module has no BuildCmd entry so it will not be built." return 0 fi local build_cmd="$MODULE_INFO_VALUE MODULE=$module $build_args" msg 2 "Build Command: $build_cmd" - cd $LLVM_TOP/$module + cd "$LLVM_TOP/$module" $build_cmd || die $? "Build of module '$module' failed." + cd "$LLVM_TOP" } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits