[PATCH] D18541: [CodeGen] Consider register modified if it's used to pass landing pad parameters.

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Mon May 2 18:27:59 PDT 2016


MatzeB added subscribers: rnk, majnemer.
MatzeB added a comment.



In http://reviews.llvm.org/D18541#419066, @koriakin wrote:

> In http://reviews.llvm.org/D18541#418973, @MatzeB wrote:
>
> > I think you should rather change the TargetFrameLowering::determineCalleeSaves() callback of the target to mark the registers as callee saved.
> >
> > If this really makes sense for all targets then it could also be done in the PrologEpilogueInsertion code before/after determineCalleeSaves(), but I am not convinced yet this applies universally (though I'm no expert in exception handling code).
>
>
> Well, this applies to any target whose exception pointer/selector registers are callee-save.  I'm not sure if there's any target other than SystemZ where that applies for the default calling convention.  However, it can apply to other targets as well if you have a landing pad in a function with eg. preserve_mostcc calling convention - is that supposed to work?


So I've been thinking about this a bit more. We actually have a similar concept already in MachineBasicBlock::getBeginClobberMask() and MachineBasicBlock::getEndClobberMask() that gives you the set of registers clobbered between basic blocks which is exactly used to describe the clobbering effects of the personality function.

My first intuition would be that we just need to provide the proper clobber mask for all personality functions to get your desired behavior. However currently this would not help because these extra clobber masks are not passed to MachineRegisterInfo::addPhysRegsUsedFromRegMask() in the VirtRegRewriter and thus are not considered for prologue epilogue insertion.

Do we actually generate a proper epilogue when we leave the function via an exception? Maybe that is not the case for WinEH which would already be an example against these clobbers needing to be unconditionally spilled/restored...

+CC Reid, David who may have more insight into exception handling ABIs...


Repository:
  rL LLVM

http://reviews.llvm.org/D18541





More information about the llvm-commits mailing list