I start my porting for picoblaze,the soft cpu for fpga ,which is designed by XILINX from MSP430 porting . After some day's work , somethinig looks good , for it can generate for some simple C program: eg : int f1(int a) { return a+1; } but it failed with this : char f() { char a; a++; a++; a++; a++; a++; a++; a++; a++; a++; a++; a++; a++; a++; a++; a++; a++; a++; a++; a++; a++; a++; a++; return a; } I think something is wrong with PicoblazeInstrInfo::storeRegToStackSlot and PicoblazeInstrInfo::loadRegFromStackSlot ,since if I remove some a++ from the above c program, It can generate the right picoblaze asm code . below is my code , the whole porting with this error can by found at github : https://github.com/huangjielg/llvm-picoblaze/tree/a667350354ca1f8d23da5e76b598b8327ef239bc/lib/Target/Picoblaze /******************************/ void PicoblazeInstrInfo::storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIdx, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI ) const { PR_FUNCTION(); DebugLoc DL; if (MI != MBB.end()) DL = MI->getDebugLoc(); MachineFunction &MF = *MBB.getParent();MF.dump(); MachineFrameInfo &MFI = *MF.getFrameInfo(); unsigned Align = MFI.getObjectAlignment(MVT::i8); MachineMemOperand *MMO MF.getMachineMemOperand(MachinePointerInfo::getFixedStack(MVT::i8), MachineMemOperand::MOStore, MFI.getObjectSize(MVT::i8), Align); BuildMI(MBB, MI, DL, get(Picoblaze::STORETOSTACK ));//.addMemOperand(MMO); if (RC == &Picoblaze::GR8RegClass) { // BuildMI(MBB, MI, DL, get(Picoblaze::ADD8ri )) // .addReg(Picoblaze::BP) // .addImm(FrameIdx); BuildMI(MBB, MI, DL, get(Picoblaze::STORE_I)) .addImm(FrameIdx) .addReg(SrcReg,getKillRegState(isKill)) ; // .addMemOperand(MMO); ;//addReg(Picoblaze::BP); // BuildMI(MBB, MI, DL, get(Picoblaze::ADD8ri )) // .addReg(Picoblaze::BP) // .addImm(-FrameIdx); } else llvm_unreachable("Cannot store this register to stack slot!"); BuildMI(MBB, MI, DL, get(Picoblaze::REGXXSTACKEND ));//.addMemOperand(MMO); ; MF.dump(); } void PicoblazeInstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIdx, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const { PR_FUNCTION(); DebugLoc DL; if (MI != MBB.end()) DL = MI->getDebugLoc(); MachineFunction &MF = *MBB.getParent(); MF.dump(); MachineFrameInfo &MFI = *MF.getFrameInfo(); unsigned Align = MFI.getObjectAlignment(MVT::i8); MachineMemOperand *MMO MF.getMachineMemOperand(MachinePointerInfo::getFixedStack(MVT::i8), MachineMemOperand::MOLoad, MFI.getObjectSize(MVT::i8), Align); BuildMI(MBB, MI, DL, get(Picoblaze::LOADFROMSTACK ));//.addMemOperand(MMO); if (RC == &Picoblaze::GR8RegClass) { //BuildMI(MBB, MI, DL, get(Picoblaze::ADD8ri ),Picoblaze::BP) // .addReg(Picoblaze::BP) // .addImm(FrameIdx); //BuildMI(MBB, MI, DL, get(Picoblaze::FETCH_R), DestReg) // .addImm(FrameIdx); //.addReg(Picoblaze::BP); //BuildMI(MBB, MI, DL, get(Picoblaze::ADD8ri ),Picoblaze::BP) // .addImm(-FrameIdx); BuildMI(MBB, MI, DL, get(Picoblaze::FETCH_FRAMEI), DestReg) .addImm(FrameIdx) ;//.addMemOperand(MMO); } else llvm_unreachable("Cannot store this register to stack slot!"); BuildMI(MBB, MI, DL, get(Picoblaze::REGXXSTACKEND ));//.addMemOperand(MMO); MF.dump(); } /******************************/