diff options
author | Chris Lattner <sabre@nondot.org> | 2008-01-30 00:39:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-01-30 00:39:15 +0000 |
commit | b1534530c2be08779acc66382cee467b01e9097d (patch) | |
tree | 89c7e5283190fb0beeb3936eb25ce75f40037a45 /lib | |
parent | 9a4c92c2b43e51ac531e0dbc319855635a14f905 (diff) | |
download | external_llvm-b1534530c2be08779acc66382cee467b01e9097d.zip external_llvm-b1534530c2be08779acc66382cee467b01e9097d.tar.gz external_llvm-b1534530c2be08779acc66382cee467b01e9097d.tar.bz2 |
Fix a bug where scalarrepl would discard offset if type would match.
In practice this can only happen on code with already undefined behavior,
but this is still a good thing to handle correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46539 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/ScalarReplAggregates.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index fc4a6aa..c80f050 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1078,7 +1078,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) { if (LoadInst *LI = dyn_cast<LoadInst>(User)) { // The load is a bit extract from NewAI shifted right by Offset bits. Value *NV = new LoadInst(NewAI, LI->getName(), LI); - if (NV->getType() == LI->getType()) { + if (NV->getType() == LI->getType() && Offset == 0) { // We win, no conversion needed. } else if (const VectorType *PTy = dyn_cast<VectorType>(NV->getType())) { // If the result alloca is a vector type, this is either an element @@ -1232,7 +1232,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) { SI->eraseFromParent(); } else if (BitCastInst *CI = dyn_cast<BitCastInst>(User)) { - ConvertUsesToScalar(CI, NewAI, Offset); + ConvertUsesToScalar(CI, NewAI, Offset); CI->eraseFromParent(); } else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(User)) { const PointerType *AggPtrTy = |