[llvm-bugs] [Bug 46667] New: Missed optimization: AArch64 backend doesn’t elide function prologue/epilogue emission for noreturn+nounwind+!uwtable functions

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 9 19:00:01 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46667

            Bug ID: 46667
           Summary: Missed optimization: AArch64 backend doesn’t elide
                    function prologue/epilogue emission for
                    noreturn+nounwind+!uwtable functions
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: AArch64
          Assignee: unassignedbugs at nondot.org
          Reporter: vlad at tsyrklevich.net
                CC: arnaud.degrandmaison at arm.com,
                    llvm-bugs at lists.llvm.org, smithp352 at googlemail.com,
                    Ties.Stuij at arm.com

AArch64FrameLowering doesn’t implement enableCalleeSaveSkip() [1], so it gets
the default base class implementation that always returns false. Simply
implementing this method to return true would slightly slim down
noreturn+nounwind+!uwtable functions.

For example:
$ cat noret.c
int puts(const char *s);

__attribute__((noreturn)) __attribute__((nothrow))
void mytrap(void) {
  puts("In mytrap\n");
  __builtin_trap();
}
$ clang -arch arm64 -Oz -c -o noret.o noret.c -fomit-frame-pointer
-fno-unwind-tables -msign-return-address=non-leaf
$ objdump -d noret.o
…
0000000000000000 ltmp0:
       0: 3f 23 03 d5                   paciasp
       4: fd 7b bf a9                   stp     x29, x30, [sp, #-16]!
       8: 00 00 00 90                   adrp    x0, #0
       c: 00 00 00 91                   add     x0, x0, #0
      10: 00 00 00 94                   bl      #0 <ltmp0+0x10>
      14: 20 00 20 d4                   brk     #0x1

If enableCalleeSaveSkip() were to return true on AArch64, the paciasp and stp
would be elided.

[1] https://reviews.llvm.org/D42898

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200710/0adece0b/attachment.html>


More information about the llvm-bugs mailing list