summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2013-11-12 22:58:39 +0000
committerAndrew Trick <atrick@apple.com>2013-11-12 22:58:39 +0000
commit7107aded170612748f46380f21ec6b71dfaf4910 (patch)
tree6960660e3e5b1489f31a8f32015a066e26c9a71e
parent430b6eb4191579651c630ef2922db22578df9710 (diff)
downloadllvm-7107aded170612748f46380f21ec6b71dfaf4910.tar.gz
llvm-7107aded170612748f46380f21ec6b71dfaf4910.tar.bz2
llvm-7107aded170612748f46380f21ec6b71dfaf4910.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194529 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/X86/X86InstrInfo.cpp18
-rw-r--r--test/CodeGen/X86/stackmap.ll22
2 files changed, 33 insertions, 7 deletions
diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp
index 75c6c2a755..2351cffdaa 100644
--- a/lib/Target/X86/X86InstrInfo.cpp
+++ b/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).
diff --git a/test/CodeGen/X86/stackmap.ll b/test/CodeGen/X86/stackmap.ll
index 335aaf0db4..71bb72e58c 100644
--- a/test/CodeGen/X86/stackmap.ll
+++ b/test/CodeGen/X86/stackmap.ll
@@ -9,7 +9,7 @@
; CHECK-NEXT: .long 1
; CHECK-NEXT: .quad 4294967296
; Num Callsites
-; CHECK-NEXT: .long 8
+; CHECK-NEXT: .long 9
; Constant arguments
;
@@ -195,6 +195,26 @@ entry:
ret void
}
+; Spilled stack map values.
+;
+; Verify 17 stack map entries.
+;
+; CHECK: .long 12
+; CHECK-LABEL: .long L{{.*}}-_spilledStackMapValue
+; CHECK-NEXT: .short 0
+; CHECK-NEXT: .short 17
+;
+; Check that at least one is a spilled entry from RBP.
+; Location: Indirect RBP + ...
+; CHECK: .byte 3
+; CHECK: .byte 0
+; CHECK: .short 6
+define webkit_jscc void @spilledStackMapValue(i64 %l0, i64 %l1, i64 %l2, i64 %l3, i64 %l4, i64 %l5, i64 %l6, i64 %l7, i64 %l8, i64 %l9, i64 %l10, i64 %l11, i64 %l12, i64 %l13, i64 %l14, i64 %l15, i64 %l16) {
+entry:
+ call void (i32, i32, ...)* @llvm.experimental.stackmap(i32 12, i32 15, i64 %l0, i64 %l1, i64 %l2, i64 %l3, i64 %l4, i64 %l5, i64 %l6, i64 %l7, i64 %l8, i64 %l9, i64 %l10, i64 %l11, i64 %l12, i64 %l13, i64 %l14, i64 %l15, i64 %l16)
+ ret void
+}
+
declare void @llvm.experimental.stackmap(i32, i32, ...)
declare void @llvm.experimental.patchpoint.void(i32, i32, i8*, i32, ...)
declare i64 @llvm.experimental.patchpoint.i64(i32, i32, i8*, i32, ...)