llvm.org GIT mirror llvm / 6847858
[mips] Fix unsigned/signed type error MipsFastISel uses a a class to represent addresses with a signed member to represent the offset. MipsFastISel::emitStore, emitLoad and computeAddress all treated the offset as being positive. In cases where the offset was actually negative and a frame pointer was used, this would cause the constant synthesis routine to crash as it would generate an unexpected instruction sequence when frame indexes are replaced. Reviewers: vkalintiris Differential Revision: https://reviews.llvm.org/D26192 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287099 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Dardis 2 years ago
2 changed file(s) with 21 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
437437 }
438438 case Instruction::GetElementPtr: {
439439 Address SavedAddr = Addr;
440 uint64_t TmpOffset = Addr.getOffset();
440 int64_t TmpOffset = Addr.getOffset();
441441 // Iterate through the GEP folding the constants into offsets where
442442 // we can.
443443 gep_type_iterator GTI = gep_type_begin(U);
755755 if (Addr.isFIBase()) {
756756 unsigned FI = Addr.getFI();
757757 unsigned Align = 4;
758 unsigned Offset = Addr.getOffset();
758 int64_t Offset = Addr.getOffset();
759759 MachineFrameInfo &MFI = MF->getFrameInfo();
760760 MachineMemOperand *MMO = MF->getMachineMemOperand(
761761 MachinePointerInfo::getFixedStack(*MF, FI), MachineMemOperand::MOLoad,
806806 if (Addr.isFIBase()) {
807807 unsigned FI = Addr.getFI();
808808 unsigned Align = 4;
809 unsigned Offset = Addr.getOffset();
809 int64_t Offset = Addr.getOffset();
810810 MachineFrameInfo &MFI = MF->getFrameInfo();
811811 MachineMemOperand *MMO = MF->getMachineMemOperand(
812812 MachinePointerInfo::getFixedStack(*MF, FI), MachineMemOperand::MOStore,
0 ; RUN: llc < %s -march=mipsel -mcpu=mips32 -fast-isel -disable-fp-elim -relocation-model=pic < %s
1
2 ; Test that negative array access don't crash constant synthesis when fast isel
3 ; generates negative offsets.
4
5 define i16 @test() {
6 %a = alloca [4 x i16], align 4
7 %arrayidx = getelementptr inbounds [4 x i16], [4 x i16]* %a, i32 0, i32 -2
8 %b = load i16, i16* %arrayidx, align 2
9 ret i16 %b
10 }
11
12 define void @test2() {
13 %a = alloca [4 x i16], align 4
14 %arrayidx = getelementptr inbounds [4 x i16], [4 x i16]* %a, i32 0, i32 -2
15 store i16 2, i16* %arrayidx, align 2
16 ret void
17 }