[llvm-bugs] [Bug 33868] New: Shrink wrapping not firing on seemingly basic cases? (maybe i misunderstand how it works)

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 20 18:07:29 PDT 2017


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

            Bug ID: 33868
           Summary: Shrink wrapping not firing on seemingly basic cases?
                    (maybe i misunderstand how it works)
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: chandlerc at gmail.com
                CC: llvm-bugs at lists.llvm.org

I was digging into sadly unrelated performance issues and noticed a surprising
lack of shrink wrapping for functions with obvious, trivial early-exits.

Here is one example I was able to quickly reproduce:

% cat shrink_wrap.cpp
struct S { long a, b; };

struct C {
  S doit() { return {1, 2}; }
};

S compute() {
  static C* c = new C();
  return c->doit();
}

% ./dev/bin/clang++ -std=c++11 -fno-rtti -fno-exceptions -c -S -o -
shrink_wrap.cpp -O3
        .text
        .file   "shrink_wrap.cpp"
        .globl  _Z7computev             # -- Begin function _Z7computev
        .p2align        4, 0x90
        .type   _Z7computev, at function
_Z7computev:                            # @_Z7computev
        .cfi_startproc
# BB#0:                                 # %entry
        pushq   %rax
.Lcfi0:
        .cfi_def_cfa_offset 16
        movb    _ZGVZ7computevE1c(%rip), %al
        testb   %al, %al
        jne     .LBB0_3
# BB#1:                                 # %init.check
        movl    $_ZGVZ7computevE1c, %edi
        callq   __cxa_guard_acquire
        testl   %eax, %eax
        je      .LBB0_3
# BB#2:                                 # %init
        movl    $1, %edi
        callq   _Znwm
        movq    %rax, _ZZ7computevE1c(%rip)
        movl    $_ZGVZ7computevE1c, %edi
        callq   __cxa_guard_release
.LBB0_3:                                # %init.end
        movl    $1, %eax
        movl    $2, %edx
        popq    %rcx
        retq
.Lfunc_end0:


Why do we need to pushq %rax and popq %rcx in the fast path?

-- 
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/20170721/a962d94d/attachment.html>


More information about the llvm-bugs mailing list