[LLVMbugs] [Bug 22288] New: Add support for inlining through musttail thunks

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jan 21 15:33:31 PST 2015


            Bug ID: 22288
           Summary: Add support for inlining through musttail thunks
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: rnk at google.com
          Reporter: rnk at google.com
                CC: david.majnemer at gmail.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Missing optimization request extracted from
http://llvm.org/bugs/show_bug.cgi?id=20944#c10 :

In the future, we should teach the inliner how to inline through thunks like

define double @f(i8* %a, i32 %b, i32 %c) {
  %call = call x86_thiscallcc double bitcast (void (i8*, ...)* @thunk to double
(i8*, i32, i32)*)(i8* %a, i32 %b, i32 %c)
  ret double %call
define linkonce_odr x86_thiscallcc void @thunk(i8* %this, ...) #0  {
  %0 = bitcast i8* %this to void (i8*, ...)**
  %1 = load void (i8*, ...)** %0
  musttail call x86_thiscallcc void (i8*, ...)* %1(i8* %this, ...)
  ret void
attributes #0 = { "thunk" }

--- New IR ---

define double @f(i8* %a, i32 %b, i32 %c) {
  %0 = bitcast i8* %a to void (i8*, ...)**
  %1 = load void (i8*, ...)** %0
  %2 = bitcast void (i8*, ...)* %1 to double (i8*, i32, i32)* ; new bitcast
  %3 = tail call double %2(i8* %a, i32 %b, i32 %c) ; fill in missing parameters
and use the result of the expected type
  ret double %3

Basically, push the bitcast on the function prototype through to the musttail
call sites. The musttail call site will always have a prototype matching the
thunk, so this shouldn't require instcombine-like bitcast insertion logic, it's
just a bitcast of the function prototype. Follow-on optimizations can clean up
the cast.

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/20150121/57f74838/attachment.html>

More information about the llvm-bugs mailing list