[PATCH] D47159: [InstCombine] Format String optimizations

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 21 15:00:19 PDT 2018


xbolva00 added a comment.

In https://reviews.llvm.org/D47159#1107120, @efriedma wrote:

> I'm not sure we can rewrite calls to varargs functions safely in general given the current state of the C ABI rules in LLVM.
>
> Sometimes clang does weird things to conform with the ABI rules, because the LLVM type system isn't the same as the C system.  For most functions, it's pretty easy to tell it happened: if the IR signature of the function doesn't match the expected signature, something weird happened, so we can just bail out.  But varargs functions don't specify a complete signature, so we can't tell if the clang ABI code was forced to do something weird, like split an argument into multiple values, or insert a padding value.  For example, for the target mips64-unknown-linux-gnu, a call like `printf("asdf%Lf", 1.0L);` gets lowered to the following:
>
>   %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i64 undef, fp128 0xL00000000000000003FFF000000000000) #2
>   


Ahh, so I should stop to work on this then?


https://reviews.llvm.org/D47159





More information about the llvm-commits mailing list