[llvm-bugs] [Bug 50042] New: X86: Tail calls with function pointer indirection not folded when more than 1 parameter is passed

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 20 10:59:10 PDT 2021


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

            Bug ID: 50042
           Summary: X86: Tail calls with function pointer indirection not
                    folded when more than 1 parameter is passed
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: mejedi at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, pengfei.wang at intel.com,
                    spatel+llvm at rotateright.com

Created attachment 24774
  --> https://bugs.llvm.org/attachment.cgi?id=24774&action=edit
reproducer

The following snippet produces the assembly with function pointer table
indexing folded into JMP:


typedef void (*FnTy3) (void *);

void dispatch15(FnTy3 *tab, intptr_t i) {
  tab[i](tab);
}


_dispatch15:                            ## @dispatch15
## %bb.0:                               ## %entry
        jmpq    *(%rdi,%rsi,8)                  ## TAILCALL


If the called function takes at least 2 parameters, indexing isn't folded.


typedef void (*FnTy2) (void *, intptr_t);

void dispatch1(FnTy2 *tab, intptr_t i) {
  tab[i](tab, i);
}


_dispatch1:                             ## @dispatch1
## %bb.0:                               ## %entry
        movq    (%rdi,%rsi,8), %rax
        jmpq    *%rax                           ## TAILCALL

-- 
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/20210420/fec4d56d/attachment-0001.html>


More information about the llvm-bugs mailing list