[PATCH] D11243: [ARM] Force LR spill in thumb2 noreturn functions

Bruno Cardoso Lopes bruno.cardoso at gmail.com
Wed Jul 15 14:59:13 PDT 2015


bruno created this revision.
bruno added reviewers: t.p.northover, MatzeB.
bruno added a subscriber: llvm-commits.
bruno set the repository for this revision to rL LLVM.
Herald added subscribers: rengolin, aemerson.

    In ARM mode we do an opt in noreturn functions that uses branch
    instead of calls and explicitly save the pc (r151645):
    
      mov lr, pc
      b _bar
    
    This isn't possible in thumb2 mode because the mode bit doesnt get set
    (r167657). However, we currently emit a branch and link but do not save
    the LR, which leads to bad backtraces coming from noreturn functions.
    
    Example:
    
    define void @a() noreturn nounwind ssp {
      tail call void @b()
      unreachable
    }
    define void @b() noreturn nounwind ssp {
      tail call void @abort() noreturn nounwind
      unreachable
    }
    declare void @abort() noreturn
    
    Currently generates:
    
    _a:
            bl      _b
    _b:
            push    {r7, lr}
            mov     r7, sp
            blx     _abort
    
    Leading to bad backtraces. This patch generates instead:
    
    _a:
            push    {r7, lr}
            mov     r7, sp
            bl      _b
    _b:
            push    {r7, lr}
            mov     r7, sp
            blx     _abort

Repository:
  rL LLVM

http://reviews.llvm.org/D11243

Files:
  lib/Target/ARM/ARMFrameLowering.cpp
  lib/Target/ARM/ARMISelLowering.cpp
  lib/Target/ARM/ARMMachineFunctionInfo.h
  test/CodeGen/Thumb2/call-noret-direct.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11243.29837.patch
Type: text/x-patch
Size: 4272 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150715/6e7c8d59/attachment.bin>


More information about the llvm-commits mailing list