This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Fix signed integer overflow in int_mulo_impl.inc
ClosedPublic

Authored by Ka-Ka on Mar 22 2023, 4:47 AM.

Details

Summary

When compiling compiler-rt with -fsanitize=undefined and running testcases you
end up with the following warning:

UBSan:/repo/uabkaka/llvm-project/compiler-rt/lib/builtins/int_mulo_impl.inc:24:23: signed integer overflow: -1 * -2147483648 cannot be represented in type 'si_int' (aka 'long')

This can be avoided by doing the multiplication in a matching unsigned variant
of the type.

This was found in an out of tree target.

Diff Detail

Event Timeline

Ka-Ka created this revision.Mar 22 2023, 4:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2023, 4:47 AM
Herald added subscribers: Enna1, dberris. · View Herald Transcript
Ka-Ka requested review of this revision.Mar 22 2023, 4:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2023, 4:47 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
phosek accepted this revision.Mar 24 2023, 12:31 AM

LGTM

This revision is now accepted and ready to land.Mar 24 2023, 12:31 AM