llvm.org GIT mirror llvm / eb62a01
[X86] Use fresh MemOps when emitting VAARG64 Previously it copied over MachineMemOperands verbatim which caused MOV32rm to have store flags set, and MOV32mr to have load flags set. This fixes some assertions being thrown with EXPENSIVE_CHECKS on. Committed on behalf of @luke (Luke Lau) Differential Revision: https://reviews.llvm.org/D62726 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363268 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Pilgrim 4 months ago
1 changed file(s) with 15 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
2872728727 unsigned ArgMode = MI.getOperand(7).getImm();
2872828728 unsigned Align = MI.getOperand(8).getImm();
2872928729
28730 MachineFunction *MF = MBB->getParent();
28731
2873028732 // Memory Reference
2873128733 assert(MI.hasOneMemOperand() && "Expected VAARG_64 to have one memoperand");
28732 SmallVector MMOs(MI.memoperands_begin(),
28733 MI.memoperands_end());
28734
28735 MachineMemOperand *OldMMO = MI.memoperands().front();
28736
28737 // Clone the MMO into two separate MMOs for loading and storing
28738 MachineMemOperand *LoadOnlyMMO = MF->getMachineMemOperand(
28739 OldMMO, OldMMO->getFlags() & ~MachineMemOperand::MOStore);
28740 MachineMemOperand *StoreOnlyMMO = MF->getMachineMemOperand(
28741 OldMMO, OldMMO->getFlags() & ~MachineMemOperand::MOLoad);
2873428742
2873528743 // Machine Information
2873628744 const TargetInstrInfo *TII = Subtarget.getInstrInfo();
2879528803 OverflowDestReg = MRI.createVirtualRegister(AddrRegClass);
2879628804
2879728805 const BasicBlock *LLVM_BB = MBB->getBasicBlock();
28798 MachineFunction *MF = MBB->getParent();
2879928806 overflowMBB = MF->CreateMachineBasicBlock(LLVM_BB);
2880028807 offsetMBB = MF->CreateMachineBasicBlock(LLVM_BB);
2880128808 endMBB = MF->CreateMachineBasicBlock(LLVM_BB);
2882828835 .add(Index)
2882928836 .addDisp(Disp, UseFPOffset ? 4 : 0)
2883028837 .add(Segment)
28831 .setMemRefs(MMOs);
28838 .setMemRefs(LoadOnlyMMO);
2883228839
2883328840 // Check if there is enough room left to pull this argument.
2883428841 BuildMI(thisMBB, DL, TII->get(X86::CMP32ri))
2885328860 .add(Index)
2885428861 .addDisp(Disp, 16)
2885528862 .add(Segment)
28856 .setMemRefs(MMOs);
28863 .setMemRefs(LoadOnlyMMO);
2885728864
2885828865 // Zero-extend the offset
2885928866 unsigned OffsetReg64 = MRI.createVirtualRegister(AddrRegClass);
2888128888 .addDisp(Disp, UseFPOffset ? 4 : 0)
2888228889 .add(Segment)
2888328890 .addReg(NextOffsetReg)
28884 .setMemRefs(MMOs);
28891 .setMemRefs(StoreOnlyMMO);
2888528892
2888628893 // Jump to endMBB
2888728894 BuildMI(offsetMBB, DL, TII->get(X86::JMP_1))
2890028907 .add(Index)
2890128908 .addDisp(Disp, 8)
2890228909 .add(Segment)
28903 .setMemRefs(MMOs);
28910 .setMemRefs(LoadOnlyMMO);
2890428911
2890528912 // If we need to align it, do so. Otherwise, just copy the address
2890628913 // to OverflowDestReg.
2893728944 .addDisp(Disp, 8)
2893828945 .add(Segment)
2893928946 .addReg(NextAddrReg)
28940 .setMemRefs(MMOs);
28947 .setMemRefs(StoreOnlyMMO);
2894128948
2894228949 // If we branched, emit the PHI to the front of endMBB.
2894328950 if (offsetMBB) {