llvm.org GIT mirror llvm / b5b84f9
ARM fix: Miscompilation when frame pointer can't be eliminated. Uninitialized frame pointer register is used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33703 91177308-0d34-0410-b5e6-96231b3b80d8 Lauro Ramos Venancio 13 years ago
4 changed file(s) with 12 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
572572 // There is alloca()'s in this function, must reference off the frame
573573 // pointer instead.
574574 FrameReg = getFrameRegister(MF);
575 if (STI.isTargetDarwin())
576 Offset -= AFI->getFramePtrSpillOffset();
575 Offset -= AFI->getFramePtrSpillOffset();
577576 }
578577
579578 unsigned Opcode = MI.getOpcode();
881880 }
882881 }
883882
883 if (hasFP(MF)) {
884 MF.changePhyRegUsed(FramePtr, true);
885 NumGPRSpills++;
886 CanEliminateFrame = false;
887 }
888
884889 if (!CanEliminateFrame) {
885890 AFI->setHasStackFrame(true);
886891
892897 UnspilledCS1GPRs.erase(std::find(UnspilledCS1GPRs.begin(),
893898 UnspilledCS1GPRs.end(), (unsigned)ARM::LR));
894899 ForceLRSpill = false;
895 }
896
897 if (STI.isTargetDarwin()) {
898 MF.changePhyRegUsed(FramePtr, true);
899 NumGPRSpills++;
900900 }
901901
902902 // If stack and double are 8-byte aligned and we are spilling an odd number
10291029 ++MBBI;
10301030
10311031 // Point FP to the stack slot that contains the previous FP.
1032 if (STI.isTargetDarwin())
1032 if (hasFP(MF))
10331033 BuildMI(MBB, MBBI, TII.get(isThumb ? ARM::tADDrSPi : ARM::ADDri), FramePtr)
10341034 .addFrameIndex(FramePtrSpillFI).addImm(0);
10351035
11151115 if (isThumb)
11161116 emitSPUpdate(MBB, MBBI, NumBytes, isThumb, TII);
11171117 else {
1118 if (STI.isTargetDarwin()) {
1118 if (hasFP(MF)){
11191119 NumBytes = AFI->getFramePtrSpillOffset() - NumBytes;
11201120 // Reset SP based on frame pointer only if the stack frame extends beyond
11211121 // frame pointer stack slot.
11301130 } else if (NumBytes) {
11311131 emitSPUpdate(MBB, MBBI, NumBytes, false, TII);
11321132 }
1133
11341133 // Move SP to start of integer callee save spill area 2.
11351134 movePastCSLoadStoreOps(MBB, MBBI, ARM::FLDD, 3, STI);
11361135 emitSPUpdate(MBB, MBBI, AFI->getDPRCalleeSavedAreaSize(), false, TII);
0 ; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm &&
11 ; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-linux | grep mov | wc -l | grep 1 &&
2 ; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-apple-darwin | grep mov | wc -l | grep 2
2 ; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-apple-darwin --disable-fp-elim | grep mov | wc -l | grep 2
33
44 %str = internal constant [12 x sbyte] c"Hello World\00"
55
0 ; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm -mattr=+v6 &&
1 ; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-apple-darwin -mattr=+v6 | grep mov | wc -l | grep 2
1 ; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-apple-darwin -mattr=+v6 --disable-fp-elim | grep mov | wc -l | grep 2
22
33 int %test(int %x) {
44 %tmp = cast int %x to short
0 ; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm &&
11 ; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep "ldmia" | wc -l | grep 2 &&
22 ; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep "ldmib" | wc -l | grep 1 &&
3 ; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-apple-darwin | grep "ldmfd sp\!" | wc -l | grep 3
3 ; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-apple-darwin --disable-fp-elim | grep "ldmfd sp\!" | wc -l | grep 3
44
55 %X = external global [0 x int]
66