[llvm-branch-commits] [llvm-branch] r93850 - in /llvm/branches/Apple/Zoidberg: lib/Transforms/Scalar/ScalarReplAggregates.cpp test/Transforms/ScalarRepl/2010-01-18-SelfCopy.ll
Bob Wilson
bob.wilson at apple.com
Mon Jan 18 20:35:09 PST 2010
Author: bwilson
Date: Mon Jan 18 22:35:08 2010
New Revision: 93850
URL: http://llvm.org/viewvc/llvm-project?rev=93850&view=rev
Log:
--- Merging r93848 into '.':
A test/Transforms/ScalarRepl/2010-01-18-SelfCopy.ll
U lib/Transforms/Scalar/ScalarReplAggregates.cpp
Added:
llvm/branches/Apple/Zoidberg/test/Transforms/ScalarRepl/2010-01-18-SelfCopy.ll
- copied unchanged from r93848, llvm/trunk/test/Transforms/ScalarRepl/2010-01-18-SelfCopy.ll
Modified:
llvm/branches/Apple/Zoidberg/lib/Transforms/Scalar/ScalarReplAggregates.cpp
Modified: llvm/branches/Apple/Zoidberg/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=93850&r1=93849&r2=93850&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Transforms/Scalar/ScalarReplAggregates.cpp Mon Jan 18 22:35:08 2010
@@ -752,9 +752,16 @@
}
break;
}
- // If OtherPtr has already been rewritten, this intrinsic will be dead.
- if (OtherPtr == NewElts[0])
+ // Copying the alloca to itself is a no-op: just delete it.
+ if (OtherPtr == AI || OtherPtr == NewElts[0]) {
+ // This code will run twice for a no-op memcpy -- once for each operand.
+ // Put only one reference to MI on the DeadInsts list.
+ for (SmallVector<Value*, 32>::const_iterator I = DeadInsts.begin(),
+ E = DeadInsts.end(); I != E; ++I)
+ if (*I == MI) return;
+ DeadInsts.push_back(MI);
return;
+ }
if (ConstantExpr *BCE = dyn_cast<ConstantExpr>(OtherPtr))
if (BCE->getOpcode() == Instruction::BitCast)
@@ -779,10 +786,7 @@
Value *OtherElt = 0;
unsigned OtherEltAlign = MemAlignment;
- if (OtherPtr == AI) {
- OtherElt = NewElts[i];
- OtherEltAlign = 0;
- } else if (OtherPtr) {
+ if (OtherPtr) {
Value *Idx[2] = { Zero,
ConstantInt::get(Type::getInt32Ty(MI->getContext()), i) };
OtherElt = GetElementPtrInst::CreateInBounds(OtherPtr, Idx, Idx + 2,
More information about the llvm-branch-commits
mailing list