[PATCH] [X86] Use single add/sub for large stack offsets
rob.lougher at gmail.com
Wed Jan 28 10:29:07 PST 2015
Comment at: lib/Target/X86/X86FrameLowering.cpp:202
@@ +201,3 @@
+ unsigned Reg = isSub
+ ? (unsigned)(Is64BitTarget ? X86::RAX : X86::EAX)
+ : findDeadCallerSavedReg(MBB, MBBI, TRI, Is64BitTarget);
> rob.lougher wrote:
> > asl wrote:
> > > This clobbers rax/eax w/o checking whether it's a livein or not. This may be a problem for functions with inreg attributes. I believe the code should always use findDeadCallerSavedReg().
> > I copied that from the code that generates a push/pop (lines 223-225), so the existing code always uses rax/eax in the prologue for a push. If this is a problem for inreg attributes, this code will also need to be fixed.
> It's not a problem for push below, because we just need to put something on stack (we can use any register for this). For pop'ing stuff we need to find free register, since we're going to clobber it.
> Situation here is completely different, because the code in the patch materializes a constant in the register thus clobbering it always.
OK, point taken - in the push case it's pushing whatever value is in rax/eax (as it's just making space, the value doesn't matter). I tried changing the code to always use findDeadCallerSavedReg(), but it returns zero when used in the prologue, so we fall back to using multiple instructions (as before). I need to do some more investigation.
More information about the llvm-commits