This is an archive of the discontinued LLVM Phabricator instance.

[builtins] Fix signed shift overflows in absvti2.c and negvti2.c
ClosedPublic

Authored by Ka-Ka on Aug 24 2023, 11:03 PM.

Details

Summary

When compiling the builtins with the undefined behavior sanitizer and running testcases you end up with the following warning:

UBSan: negvti2.c:22:32: left shift of 1 by 127 places cannot be represented in type 'ti_int' (aka 'int128')
UBSan: absvti2.c:23:23: left shift of 1 by 127 places cannot be represented in type 'ti_int' (aka '
int128')

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

This is the same kind of fixes that already was done in commit
854686f0794b9d0695d5a0a85ea1e7e71ba8edfd

This was found in an out of tree target.

Diff Detail

Event Timeline

Ka-Ka created this revision.Aug 24 2023, 11:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2023, 11:03 PM
Herald added a subscriber: Enna1. · View Herald Transcript
Ka-Ka requested review of this revision.Aug 24 2023, 11:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2023, 11:03 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
MaskRay accepted this revision.Aug 25 2023, 12:18 PM
This revision is now accepted and ready to land.Aug 25 2023, 12:18 PM