mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
SROA: Only split loads on byte boundaries
r199771 accidently broke the logic that makes sure that SROA only splits load on byte boundaries. If such a split happens, some bits get lost when reassembling loads of wider types, causing data corruption. Move the width check up to reject such splits early, avoiding the corruption. Fixes PR19250. Patch by: Björn Steinbrink <bsteinbr@gmail.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211082 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1032,11 +1032,6 @@ static Type *findCommonType(AllocaSlices::const_iterator B,
|
||||
UserTy = SI->getValueOperand()->getType();
|
||||
}
|
||||
|
||||
if (!UserTy || (Ty && Ty != UserTy))
|
||||
TyIsCommon = false; // Give up on anything but an iN type.
|
||||
else
|
||||
Ty = UserTy;
|
||||
|
||||
if (IntegerType *UserITy = dyn_cast_or_null<IntegerType>(UserTy)) {
|
||||
// If the type is larger than the partition, skip it. We only encounter
|
||||
// this for split integer operations where we want to use the type of the
|
||||
@@ -1051,6 +1046,13 @@ static Type *findCommonType(AllocaSlices::const_iterator B,
|
||||
if (!ITy || ITy->getBitWidth() < UserITy->getBitWidth())
|
||||
ITy = UserITy;
|
||||
}
|
||||
|
||||
// To avoid depending on the order of slices, Ty and TyIsCommon must not
|
||||
// depend on types skipped above.
|
||||
if (!UserTy || (Ty && Ty != UserTy))
|
||||
TyIsCommon = false; // Give up on anything but an iN type.
|
||||
else
|
||||
Ty = UserTy;
|
||||
}
|
||||
|
||||
return TyIsCommon ? Ty : ITy;
|
||||
|
||||
Reference in New Issue
Block a user