This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Fix signed shift overflows in absvdi2.c, absvsi2.c, negvdi2.c and negvsi2.c
ClosedPublic

Authored by Ka-Ka on Mar 26 2023, 11:23 PM.

Details

Summary

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

UBSan: absvdi2.c:21:23: left shift of 1 by 63 places cannot be represented in type 'di_int' (aka 'long long')
UBSan: absvsi2.c:21:23: left shift of 1 by 31 places cannot be represented in type 'si_int' (aka 'long')
UBSan: negvdi2.c:20:32: left shift of 1 by 63 places cannot be represented in type 'di_int' (aka 'long long')
UBSan: negvsi2.c:20:32: left shift of 1 by 31 places cannot be represented in type 'si_int' (aka 'long')

This can be avoided by doing the shift 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 26 2023, 11:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 26 2023, 11:23 PM
Herald added subscribers: Enna1, dberris. · View Herald Transcript
Ka-Ka requested review of this revision.Mar 26 2023, 11:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 26 2023, 11:23 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
Ka-Ka updated this revision to Diff 513436.Apr 13 2023, 10:21 PM

git-clang-format

MaskRay accepted this revision.Apr 13 2023, 10:38 PM
This revision is now accepted and ready to land.Apr 13 2023, 10:38 PM