From 0ef482ef02cd230f456b051d832920554fe623e5 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Tue, 12 Nov 2013 22:58:39 +0000 Subject: Cleanup the stackmap operand folding code and fix a corner case. I still don't know how to refer to the fixed operands symbolically. I plan to look into it. llvm-svn: 194529 --- llvm/lib/Target/X86/X86InstrInfo.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'llvm/lib/Target/X86/X86InstrInfo.cpp') diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp index 75c6c2a7553..2351cffdaad 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.cpp +++ b/llvm/lib/Target/X86/X86InstrInfo.cpp @@ -4206,12 +4206,18 @@ static MachineInstr* foldPatchpoint(MachineFunction &MF, MF.CreateMachineInstr(TII.get(MI->getOpcode()), MI->getDebugLoc(), true); MachineInstrBuilder MIB(MF, NewMI); - bool isPatchPoint = MI->getOpcode() == TargetOpcode::PATCHPOINT; - // For PatchPoint, the call args are not foldable. - unsigned NumCallArgs = MI->getOperand(StartIdx+3).getImm(); - StartIdx = isPatchPoint ? - StartIdx + NumCallArgs + 5 : - StartIdx + 2; + switch (MI->getOpcode()) { + case TargetOpcode::STACKMAP: + StartIdx += 2; // Skip ID, nShadowBytes. + break; + case TargetOpcode::PATCHPOINT: + // Skip ID, numBytes, Target, numArgs. + // For PatchPoint, the call args are not foldable. + StartIdx += MI->getOperand(StartIdx+3).getImm() + 4; + break; + default: + llvm_unreachable("unexpected stackmap opcode"); + } // Return false if any operands requested for folding are not foldable (not // part of the stackmap's live values). -- cgit v1.2.3