summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2014-10-27 22:38:45 +0000
committerPete Cooper <peter_cooper@apple.com>2014-10-27 22:38:45 +0000
commit7c801dc90b0dfda7ec74738cdf15c009fa92efeb (patch)
treebfc36e5ee7db95f479f5612cd7915bd35baab79b /llvm/lib
parent992bdf1b45bdb71871975729583e193ffbd67d13 (diff)
downloadbcm5719-llvm-7c801dc90b0dfda7ec74738cdf15c009fa92efeb.tar.gz
bcm5719-llvm-7c801dc90b0dfda7ec74738cdf15c009fa92efeb.zip
Fix a stackmap bug introduced in r220710.
For a call to not return in to the stackmap shadow, the shadow must end with the call. To do this, we must insert any required nops *before* the call, and not after it. llvm-svn: 220728
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/X86MCInstLower.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/llvm/lib/Target/X86/X86MCInstLower.cpp b/llvm/lib/Target/X86/X86MCInstLower.cpp
index 85cf5144f0c..4e0d594238c 100644
--- a/llvm/lib/Target/X86/X86MCInstLower.cpp
+++ b/llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1209,11 +1209,21 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCInst TmpInst;
MCInstLowering.Lower(MI, TmpInst);
- EmitAndCountInstruction(TmpInst);
// Stackmap shadows cannot include branch targets, so we can count the bytes
- // in a call towards the shadow, but must flush the shadow immediately after
- // to account for the return from the call.
- if (MI->isCall())
+ // in a call towards the shadow, but must ensure that the no thread returns
+ // in to the stackmap shadow. The only way to achieve this is if the call
+ // is at the end of the shadow.
+ if (MI->isCall()) {
+ // Count then size of the call towards the shadow
+ SMShadowTracker.count(TmpInst, getSubtargetInfo());
+ // Then flush the shadow so that we fill with nops before the call, not
+ // after it.
SMShadowTracker.emitShadowPadding(OutStreamer, getSubtargetInfo());
+ // Then emit the call
+ OutStreamer.EmitInstruction(TmpInst, getSubtargetInfo());
+ return;
+ }
+
+ EmitAndCountInstruction(TmpInst);
}
OpenPOWER on IntegriCloud