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: unassignedb...@nondot.org
          Reporter: mej...@gmail.com
                CC: craig.top...@gmail.com, llvm-bugs@lists.llvm.org,
                    llvm-...@redking.me.uk, pengfei.w...@intel.com,
                    spatel+l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to