@@ -676,7 +676,7 @@ static void LowerTlsAddr(MCStreamer &OutStreamer,
676676}
677677
678678static std::pair<StackMaps::Location, MachineInstr::const_mop_iterator>
679- parseMemoryOperand (StackMaps::Location::LocationType LocTy,
679+ parseMemoryOperand (StackMaps::Location::LocationType LocTy, unsigned Size,
680680 MachineInstr::const_mop_iterator MOI,
681681 MachineInstr::const_mop_iterator MOE) {
682682
@@ -701,12 +701,13 @@ parseMemoryOperand(StackMaps::Location::LocationType LocTy,
701701 (void )ZeroReg;
702702
703703 return std::make_pair (
704- Location (LocTy, Base.getReg (), Disp.getImm ()), ++MOI);
704+ Location (LocTy, Size , Base.getReg (), Disp.getImm ()), ++MOI);
705705}
706706
707707std::pair<StackMaps::Location, MachineInstr::const_mop_iterator>
708708X86AsmPrinter::stackmapOperandParser (MachineInstr::const_mop_iterator MOI,
709- MachineInstr::const_mop_iterator MOE) {
709+ MachineInstr::const_mop_iterator MOE,
710+ const TargetMachine &TM) {
710711
711712 typedef StackMaps::Location Location;
712713
@@ -717,26 +718,42 @@ X86AsmPrinter::stackmapOperandParser(MachineInstr::const_mop_iterator MOI,
717718 if (MOP.isImm ()) {
718719 switch (MOP.getImm ()) {
719720 default : llvm_unreachable (" Unrecognized operand type." );
720- case StackMaps::DirectMemRefOp:
721- return parseMemoryOperand (StackMaps::Location::Direct,
721+ case StackMaps::DirectMemRefOp: {
722+ unsigned Size = TM.getDataLayout ()->getPointerSizeInBits ();
723+ assert ((Size % 8 ) == 0 && " Need pointer size in bytes." );
724+ Size /= 8 ;
725+ return parseMemoryOperand (StackMaps::Location::Direct, Size,
722726 llvm::next (MOI), MOE);
723- case StackMaps::IndirectMemRefOp:
724- return parseMemoryOperand (StackMaps::Location::Indirect,
727+ }
728+ case StackMaps::IndirectMemRefOp: {
729+ ++MOI;
730+ int64_t Size = MOI->getImm ();
731+ assert (Size > 0 && " Need a valid size for indirect memory locations." );
732+ return parseMemoryOperand (StackMaps::Location::Indirect, Size,
725733 llvm::next (MOI), MOE);
734+ }
726735 case StackMaps::ConstantOp: {
727736 ++MOI;
728737 assert (MOI->isImm () && " Expected constant operand." );
729738 int64_t Imm = MOI->getImm ();
730- return std::make_pair (Location (Location::Constant, 0 , Imm), ++MOI);
739+ return std::make_pair (
740+ Location (Location::Constant, sizeof (int64_t ), 0 , Imm), ++MOI);
731741 }
732742 }
733743 }
734744
735- // Otherwise this is a reg operand.
745+ // Otherwise this is a reg operand. The physical register number will
746+ // ultimately be encoded as a DWARF regno. The stack map also records the size
747+ // of a spill slot that can hold the register content. (The runtime can
748+ // track the actual size of the data type if it needs to.)
736749 assert (MOP.isReg () && " Expected register operand here." );
737750 assert (TargetRegisterInfo::isPhysicalRegister (MOP.getReg ()) &&
738751 " Virtreg operands should have been rewritten before now." );
739- return std::make_pair (Location (Location::Register, MOP.getReg (), 0 ), ++MOI);
752+ const TargetRegisterClass *RC =
753+ TM.getRegisterInfo ()->getMinimalPhysRegClass (MOP.getReg ());
754+ assert (!MOP.getSubReg () && " Physical subreg still around." );
755+ return std::make_pair (
756+ Location (Location::Register, RC->getSize (), MOP.getReg (), 0 ), ++MOI);
740757}
741758
742759static MachineInstr::const_mop_iterator
0 commit comments