[llvm-dev] Why LR is saved before calling a 'noreturn' function ?
Tim Northover via llvm-dev
llvm-dev at lists.llvm.org
Thu May 12 07:00:39 PDT 2016
On 12 May 2016 at 06:26, HEITZMANN Frédéric 218168
<llvm-dev at lists.llvm.org> wrote:
> I don't get how llvm handles functions with __attribute__((noreturn)).
> It seems that LR register is backed up on the stack whilst it will never be used to return from a 'noreturn' function.
In your case, Clang is producing a proper frame record. r11 is set to
the address of a struct roughly this form:
This is necessary for producing a coherent backtraces and other
It could be dropped with -fomit-frame-pointer, but we don't seem to
take that opportunity. The code inserting that prologue is very late
(and very fragile anyway) and it just happens not to bother with that
The main place noreturn is used is for larger-scale optimizations
earlier on (eliminating code after a noreturn call as dead, for
> I have this problem with a home-made backend but it seems that ARM flavour of clang has same behaviour.
To fix it, you'll want to look into XYZFrameLowering.cpp (and possibly
code that ends up marking your LR as callee-saved in
> By the way, SP is also saved, I don't understand why.
This is the frame pointer.
More information about the llvm-dev