[PATCH] D33003: Add callee-saved registers as implicit uses in return instructions

Krzysztof Parzyszek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 9 11:48:34 PDT 2017


kparzysz added a comment.

In https://reviews.llvm.org/D33003#749994, @MatzeB wrote:

> - I still have to dive into the patches details, at a first glance I am surprised this needs the new `getSavedRegisters()`/`getRestoredRegisters()` callbacks. Seems like there is some exception handling magic going on, why do we need to special case it?


Magic #1: ARM saves LR, but restores the value directly into PC, and in general there is no way of telling that LR does not need to be restored.  The general assumption is that the registers that are saved in the save blocks are the same that are later restored, and also the same registers that are live-out from the function (i.e. consumed by the return instructions).  Without this, LR would have ended up as imp-use on return instructions, and caused "use of undefined register" errors.

Magic #2: X86 on Windows has some concept of funclets, whose entry points are treated as save blocks, but which do not save all of the registers in CSI.  The exception handling runtime saves a few of them, and those ones are excluded from saving/restoring.  I think it actually happens to save/restore all of them (based on my reading of the code).  In this case, again we have to keep track which saves actually reached a given return instruction if we are to add the implicit uses correctly.

I don't like these hooks that much either.


Repository:
  rL LLVM

https://reviews.llvm.org/D33003





More information about the llvm-commits mailing list