Fix Transforms/ScalarRepl/2005-12-14-UnionPromoteCrash.ll, a crash on undefined

behavior in 126.gcc on big-endian systems.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24708 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-12-14 17:23:59 +00:00
parent fa1fb11cdc
commit 6860f6a01c

View File

@ -539,7 +539,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 (Offset)
if (Offset && Offset < NV->getType()->getPrimitiveSizeInBits())
NV = new ShiftInst(Instruction::Shr, NV,
ConstantUInt::get(Type::UByteTy, Offset),
LI->getName(), LI);
@ -563,7 +563,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) {
SV = new CastInst(SV, SV->getType()->getUnsignedVersion(),
SV->getName(), SI);
SV = new CastInst(SV, Old->getType(), SV->getName(), SI);
if (Offset)
if (Offset && Offset < SV->getType()->getPrimitiveSizeInBits())
SV = new ShiftInst(Instruction::Shl, SV,
ConstantUInt::get(Type::UByteTy, Offset),
SV->getName()+".adj", SI);