Fix bug in emitGEPOperation with large struct-member offsets.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18201 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Brian Gaeke 2004-11-24 04:07:33 +00:00
parent 69efbdd4f3
commit 31e575901f
2 changed files with 24 additions and 4 deletions

View File

@ -1059,8 +1059,18 @@ void V8ISel::emitGEPOperation (MachineBasicBlock *MBB,
unsigned memberOffset =
TD.getStructLayout (StTy)->MemberOffsets[fieldIndex];
// Emit an ADD to add memberOffset to the basePtr.
BuildMI (*MBB, IP, V8::ADDri, 2,
nextBasePtrReg).addReg (basePtrReg).addZImm (memberOffset);
// We might have to copy memberOffset into a register first, if it's
// big.
if (memberOffset + 4096 < 8191) {
BuildMI (*MBB, IP, V8::ADDri, 2,
nextBasePtrReg).addReg (basePtrReg).addSImm (memberOffset);
} else {
unsigned offsetReg = makeAnotherReg (Type::IntTy);
copyConstantToRegister (MBB, IP,
ConstantInt::get(Type::IntTy, memberOffset), offsetReg);
BuildMI (*MBB, IP, V8::ADDrr, 2,
nextBasePtrReg).addReg (basePtrReg).addReg (offsetReg);
}
// The next type is the member of the structure selected by the
// index.
Ty = StTy->getElementType (fieldIndex);

View File

@ -1059,8 +1059,18 @@ void V8ISel::emitGEPOperation (MachineBasicBlock *MBB,
unsigned memberOffset =
TD.getStructLayout (StTy)->MemberOffsets[fieldIndex];
// Emit an ADD to add memberOffset to the basePtr.
BuildMI (*MBB, IP, V8::ADDri, 2,
nextBasePtrReg).addReg (basePtrReg).addZImm (memberOffset);
// We might have to copy memberOffset into a register first, if it's
// big.
if (memberOffset + 4096 < 8191) {
BuildMI (*MBB, IP, V8::ADDri, 2,
nextBasePtrReg).addReg (basePtrReg).addSImm (memberOffset);
} else {
unsigned offsetReg = makeAnotherReg (Type::IntTy);
copyConstantToRegister (MBB, IP,
ConstantInt::get(Type::IntTy, memberOffset), offsetReg);
BuildMI (*MBB, IP, V8::ADDrr, 2,
nextBasePtrReg).addReg (basePtrReg).addReg (offsetReg);
}
// The next type is the member of the structure selected by the
// index.
Ty = StTy->getElementType (fieldIndex);