Open Quuxplusone opened 9 years ago
Bugzilla Link | PR22288 |
Status | NEW |
Importance | P normal |
Reported by | Reid Kleckner (rnk@google.com) |
Reported on | 2015-01-21 17:33:31 -0800 |
Last modified on | 2018-04-04 17:40:31 -0700 |
Version | trunk |
Hardware | PC Windows NT |
CC | codeman.consulting@gmail.com, david.majnemer@gmail.com, echristo@gmail.com, llvm-bugs@lists.llvm.org, peter@pcc.me.uk |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
I might like to take a shot at this one, it's been a while since I wrote any pass code and I understand the construction methods for that type of structure well. Should I just assign myself the bug?
Go for it. :) If you need help, I'm on IRC and others may be able to help.
Apologies for the AFK, had the nasty flu that's been going around, holidays, etc. I'll be looking into this more if it hasn't been resolved in the meantime.
There was some recent progress on inlining variadic functions that don't call va_start. It's almost what we need, we just need to treat "thunks" specially.
Here's an alternative way to phrase the missed optimization with less pointer-y
code:
define i32 @call_thunk(i32 %x, i32 %y) {
%r = call i32 (i32, i32) bitcast (void (i32, ...)* @inc_first_arg_thunk to i32 (i32, i32)*)(i32 %x, i32 %y)
ret i32 %r
}
define internal void @inc_first_arg_thunk(i32 %arg1, ...) #0 {
entry:
%inc = add i32 1, %arg1
musttail call void (i32, ...) bitcast (i32 (i32,i32)* @plus to void (i32, ...)*)(i32 %inc, ...)
ret void
}
define internal i32 @plus(i32 %x, i32 %y) {
%r = add i32 %x, %y
ret i32 %r
}
attributes #0 = { "thunk" }
Inlining should produce:
define i32 @call_thunk(i32 %x, i32 %y) {
%x1 = add i32 %x, 1
%r = add i32 %x1, %y
ret i32 %r
}