X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=lib%2FTarget%2FX86%2FX86MCInstLower.cpp;h=4e0d594238c2ef09bed5961876b489354e03e779;hp=85cf5144f0cc853e57604171785f34b17a619162;hb=68aeef61f4a1da7af53b6ddcdbb6eb75da7eb72d;hpb=cf84852133ec605252dd2f26aa2abcc976e4c215 diff --git a/lib/Target/X86/X86MCInstLower.cpp b/lib/Target/X86/X86MCInstLower.cpp index 85cf5144f0c..4e0d594238c 100644 --- a/lib/Target/X86/X86MCInstLower.cpp +++ b/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); }