From sabre at nondot.org Sun Oct 29 23:08:05 2006 From: sabre at nondot.org (Chris Lattner) Date: Sun, 29 Oct 2006 23:08:05 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/ADT/SmallVector.h Message-ID: <200610300508.k9U585eN014053@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/ADT: SmallVector.h updated: 1.21 -> 1.22 --- Log message: add a new form of insert. --- Diffs of the changes: (+48 -1) SmallVector.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 48 insertions(+), 1 deletion(-) Index: llvm/include/llvm/ADT/SmallVector.h diff -u llvm/include/llvm/ADT/SmallVector.h:1.21 llvm/include/llvm/ADT/SmallVector.h:1.22 --- llvm/include/llvm/ADT/SmallVector.h:1.21 Sun Oct 29 21:39:20 2006 +++ llvm/include/llvm/ADT/SmallVector.h Sun Oct 29 23:07:51 2006 @@ -207,6 +207,54 @@ goto Retry; } + template + iterator insert(iterator I, ItTy From, ItTy To) { + if (I == End) { // Important special case for empty vector. + append(From, To); + return end()-1; + } + + unsigned NumToInsert = std::distance(From, To); + // Convert iterator to elt# to avoid invalidating iterator when we reserve() + unsigned InsertElt = I-begin(); + + // Ensure there is enough space. + reserve(size() + NumToInsert); + + // Uninvalidate the iterator. + I = begin()+InsertElt; + + // If we already have this many elements in the collection, append the + // dest elements at the end, then copy over the appropriate elements. Since + // we already reserved space, we know that this won't reallocate the vector. + if (size() >= NumToInsert) { + T *OldEnd = End; + append(End-NumToInsert, End); + + // Copy the existing elements that get replaced. + std::copy(I, OldEnd-NumToInsert, I+NumToInsert); + + std::copy(From, To, I); + return I; + } + + // Otherwise, we're inserting more elements than exist already, and we're + // not inserting at the end. + + // Copy over the elements that we're about to overwrite. + T *OldEnd = End; + End += NumToInsert; + unsigned NumOverwritten = OldEnd-I; + std::uninitialized_copy(I, OldEnd, End-NumOverwritten); + + // Replace the overwritten part. + std::copy(From, From+NumOverwritten, I); + + // Insert the non-overwritten middle part. + std::uninitialized_copy(From+NumOverwritten, To, OldEnd); + return I; + } + const SmallVectorImpl &operator=(const SmallVectorImpl &RHS); private: @@ -224,7 +272,6 @@ for (; S != E; ++S) new (S) T(Elt); } - void destroy_range(T *S, T *E) { while (S != E) { From sabre at nondot.org Sun Oct 29 23:24:17 2006 From: sabre at nondot.org (Chris Lattner) Date: Sun, 29 Oct 2006 23:24:17 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/2006-08-21-ExtraMovInst.ll Message-ID: <200610300524.k9U5OHcg014580@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/X86: 2006-08-21-ExtraMovInst.ll updated: 1.1 -> 1.2 --- Log message: fix this regtest --- Diffs of the changes: (+1 -1) 2006-08-21-ExtraMovInst.ll | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/test/Regression/CodeGen/X86/2006-08-21-ExtraMovInst.ll diff -u llvm/test/Regression/CodeGen/X86/2006-08-21-ExtraMovInst.ll:1.1 llvm/test/Regression/CodeGen/X86/2006-08-21-ExtraMovInst.ll:1.2 --- llvm/test/Regression/CodeGen/X86/2006-08-21-ExtraMovInst.ll:1.1 Mon Aug 21 02:33:33 2006 +++ llvm/test/Regression/CodeGen/X86/2006-08-21-ExtraMovInst.ll Sun Oct 29 23:24:03 2006 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -fast -march=x86 -mcpu=i386 | not grep 'movl %eax, %edx' +; RUN: llvm-as < %s | llc -march=x86 -mcpu=i386 | not grep 'movl %eax, %edx' int %foo(int %t, int %C) { entry: