http://llvm.org/bugs/show_bug.cgi?id=22288
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: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
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
this:
define double @f(i8* %a, i32 %b, i32 %c) {
entry:
%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 {
entry:
%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) {
entry:
%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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs