[PATCH] ArgumentPromotion: Don't hack on functions containing musttail calls

Reid Kleckner rnk at google.com
Sun Jul 6 22:49:22 PDT 2014


>>! In D4352#6, @nicholas wrote:
> Isn't this overly conservative?
> 
>   define internal void @aaa() {
>     %X = ...
>     %Y = ...
>     call void @bbb(i8 %X, i8 %Y)
>     ret void
>   }
>   
>   define internal void @bbb(i8 %X, i8 %Y) {
>     musttail call void @ccc(i8 %X, i8 %Y)
>     ret void
>   }
>   
>   define internal void @ccc(i8 %X, i8 %Y) {
>     call @use(i8 %X)
>     ret void
>   }
> 
> You can totally knock out %Y, right?

That would be deadargelim, not argument promotion, but that's besides the point.

Yes, if we could teach argument promotion to promote the entire call stack of musttail callers and callees at once, then we could do that transformation.

It might be worth it if we expect functional languages to use this construct widely.  For C++, musttail is used with thunks that will either be a) virtual, and therefore not promotable, or b) devirtualized, and more profitable to inline at the call site.

http://reviews.llvm.org/D4352






More information about the llvm-commits mailing list