[PATCH] D107420: [sema] Disallow __builtin_mul_overflow under special condition.

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 5 10:37:02 PDT 2021


erichkeane added a comment.

In D107420#2929115 <https://reviews.llvm.org/D107420#2929115>, @craig.topper wrote:

> In D107420#2929039 <https://reviews.llvm.org/D107420#2929039>, @aaron.ballman wrote:
>
>> In D107420#2928975 <https://reviews.llvm.org/D107420#2928975>, @craig.topper wrote:
>>
>>> I put up a patch for a simple fix for this in the backend. https://reviews.llvm.org/D107581  The generated code is not optimal, but maybe better than frontend workarounds.
>>
>> Thanks for putting up the backend fix! That's much better than frontend workarounds.
>
> Looks like I may have opened a small can of worms. In 32-bit mode, a __builtin_mul_overflow of _ExtInt(128) producing a signed result generates a call to _muloti4 which neither compiler-rt or libgcc implement in 32-bit mode. In 64-bit mode only compiler-rt implements _muloti4 for x86-64.

We also lack a proper codegen implementation of 'div' in cases of ints larger than 128.  Since `_ExtInt`is now part of the C23 standard (spelled as `_BitInt`), we should probably be supporting these as much as we can.  I would think we'd have to compose the `_muloti` and `_divoti` calls somehow for those.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107420/new/

https://reviews.llvm.org/D107420



More information about the cfe-commits mailing list