[llvm] r242395 - [X86] Fix emitPrologue() to make less assumptions about pushes

Michael Kuperstein michael.m.kuperstein at intel.com
Thu Jul 16 05:28:00 PDT 2015


Author: mkuper
Date: Thu Jul 16 07:27:59 2015
New Revision: 242395

URL: http://llvm.org/viewvc/llvm-project?rev=242395&view=rev
Log:
[X86] Fix emitPrologue() to make less assumptions about pushes

When X86FrameLowering::emitPrologue() looks for where to insert the %esp subtraction
to allocate stack space for local allocations, it assumes that any sequence of push
instructions that starts at function entry consists purely of spills of callee-save
registers.
This may be false, since from some point forward, the pushes may pushing arguments
to a subsequent function call.

This caused a miscompile that was exposed by r240257, and is not easily testable
since r240257 was reverted. A test will be committed separately after r240257 is
reapplied.

Modified:
    llvm/trunk/lib/Target/X86/X86FrameLowering.cpp

Modified: llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FrameLowering.cpp?rev=242395&r1=242394&r2=242395&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FrameLowering.cpp Thu Jul 16 07:27:59 2015
@@ -794,6 +794,7 @@ void X86FrameLowering::emitPrologue(Mach
   int StackOffset = 2 * stackGrowth;
 
   while (MBBI != MBB.end() &&
+         MBBI->getFlag(MachineInstr::FrameSetup) &&
          (MBBI->getOpcode() == X86::PUSH32r ||
           MBBI->getOpcode() == X86::PUSH64r)) {
     PushedRegs = true;





More information about the llvm-commits mailing list