From: Chris Lattner Date: Sun, 10 Feb 2008 19:05:37 +0000 (+0000) Subject: Fix scalarrepl to not 'miscompile' undefined code, part #2. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=916c954bf20f48c3269542fc919ccb92a99496ee;p=oota-llvm.git Fix scalarrepl to not 'miscompile' undefined code, part #2. This fixes the store case, my previous patch just fixed the load case. rdar://5707076. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46932 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index c80f050730a..3929d0c9192 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1150,7 +1150,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) { // then 'or' into place. Value *SV = SI->getOperand(0); const Type *AllocaType = NewAI->getType()->getElementType(); - if (SV->getType() == AllocaType) { + if (SV->getType() == AllocaType && Offset == 0) { // All is well. } else if (const VectorType *PTy = dyn_cast(AllocaType)) { Value *Old = new LoadInst(NewAI, NewAI->getName()+".in", SI);