[llvm-dev] libcalls vs. size of int

Björn Pettersson A via llvm-dev llvm-dev at lists.llvm.org
Wed Mar 24 06:14:02 PDT 2021


Hi again.

I noticed that __builtin_powi/__builtin_powif/__builtin_powil doesn't work very well either
unless "int" is 32-bits. The builtins are defined as taking an int argument, but when
CGBuiltin.cpp is emitting code for the builtin it hits an assertion since there is a type
mismatch when emitting a call to Intrinsic::powi (that is hard-coded to use i32).

So either one has to sext/trunc the argument to match the type used in the intrinsic,
or maybe Intrinsic::powi should be overloaded on the second arguments type as well?

The problematic part with changing the type is that if we need to go back to a smaller
type when emitting the libcall, then one need to know if it simply is legal to truncate
the argument (or what should the result be if trying to pass a value that is out-of-bounds).

/Björn


More information about the llvm-dev mailing list