[llvm-dev] _ExtInt, LLVM integers and constant time

Adrien Guinet via llvm-dev llvm-dev at lists.llvm.org
Wed Apr 22 09:35:22 PDT 2020


On 4/22/20 6:13 PM, Chris Lattner wrote:>> On Apr 22, 2020, at 12:24 AM, Roman Lebedev via
llvm-dev <llvm-dev at lists.llvm.org>
>> wrote:
>> 
>> On Wed, Apr 22, 2020 at 9:35 AM Adrien Guinet via llvm-dev <llvm-dev at lists.llvm.org
>> <mailto:llvm-dev at lists.llvm.org>> wrote:
>>> 
>>> Hello everyone,
>>> 
>>> After reading the nice blog post about _ExtInt, I was wondering whether operations
>>> on i128/i256 and more generally on integer types in LLVM are guaranteed to be
>>> constant time or not.
>> I don't believe there's any such guarantee even for normal 8/16/32/64 -bit integers.
> 
> Right. I would expect this to be implementation / target dependent.  The maximum bit
> width of an integer may also be target specific.  For example, some targets may not
> provide a 1024 bit integer divide lib call, and may not want to open code it.
> 

Okay that makes sense!

If we would like, at some point, to introduce such guarantees, that would imply adding a
"constant time" flag to the arithmetic operations at the LLVM IR level, and have the
backends honor it (which already seems the case), or fail if not possible ? .

The only use case I have in mind that would benefit from this is cryptographic code, but
there might be others.


More information about the llvm-dev mailing list