diff options
author | Derek Schuff <dschuff@google.com> | 2015-12-11 18:55:34 +0000 |
---|---|---|
committer | Derek Schuff <dschuff@google.com> | 2015-12-11 18:55:34 +0000 |
commit | 5a143063237a3c9ae050f377f8f0d02192dc9b2c (patch) | |
tree | 636abe8716be7a2d96740d5fbe13baa07c80c532 | |
parent | a6763e838602ca3ebc7b44013297303b59f2867f (diff) | |
download | bcm5719-llvm-5a143063237a3c9ae050f377f8f0d02192dc9b2c.tar.gz bcm5719-llvm-5a143063237a3c9ae050f377f8f0d02192dc9b2c.zip |
[WebAssembly] Fix ADJCALLSTACKDOWN/UP use/defs
Summary:
ADJCALLSTACK{DOWN,UP} (aka CALLSEQ_{START,END}) MIs are supposed to use
and def the stack pointer. Since they do not, all the nodes are being
eliminated by DeadMachineInstructionElim, so they aren't in the IR when
PrologEpilogInserter/eliminateCallFramePseudo needs them.
This change fixes that, but since RegStackify will not stackify across
them (and it runs early, before PEI), change LowerCall to only emit them
when the call frame size is > 0. That makes the current code work the
same way and makes code handled by D15344 also work the same way. We can
expand the condition beyond NumBytes > 0 in the future if needed.
Reviewers: sunfish, jfb
Subscribers: jfb, dschuff, llvm-commits
Differential Revision: http://reviews.llvm.org/D15459
llvm-svn: 255356
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp index 4ef0846d311..76df63b5407 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp @@ -359,8 +359,11 @@ WebAssemblyTargetLowering::LowerCall(CallLoweringInfo &CLI, unsigned NumBytes = CCInfo.getAlignedCallFrameSize(); - auto NB = DAG.getConstant(NumBytes, DL, PtrVT, true); - Chain = DAG.getCALLSEQ_START(Chain, NB, DL); + SDValue NB; + if (NumBytes) { + NB = DAG.getConstant(NumBytes, DL, PtrVT, true); + Chain = DAG.getCALLSEQ_START(Chain, NB, DL); + } if (IsVarArg) { // For non-fixed arguments, next emit stores to store the argument values @@ -420,8 +423,10 @@ WebAssemblyTargetLowering::LowerCall(CallLoweringInfo &CLI, Chain = Res.getValue(1); } - SDValue Unused = DAG.getUNDEF(PtrVT); - Chain = DAG.getCALLSEQ_END(Chain, NB, Unused, SDValue(), DL); + if (NumBytes) { + SDValue Unused = DAG.getUNDEF(PtrVT); + Chain = DAG.getCALLSEQ_END(Chain, NB, Unused, SDValue(), DL); + } return Chain; } diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td index 0587c0b6613..6ea8cec7397 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td @@ -18,7 +18,7 @@ let Defs = [ARGUMENTS] in { // Call sequence markers. These have an immediate which represents the amount of // stack space to allocate or free, which is used for varargs lowering. -let isCodeGenOnly = 1 in { +let Uses = [SP32, SP64], Defs = [SP32, SP64], isCodeGenOnly = 1 in { def ADJCALLSTACKDOWN : I<(outs), (ins i32imm:$amt), [(WebAssemblycallseq_start timm:$amt)]>; def ADJCALLSTACKUP : I<(outs), (ins i32imm:$amt), |