This is an archive of the discontinued LLVM Phabricator instance.

FIx UB in APInt::ashr
ClosedPublic

Authored by jroelofs on Aug 10 2016, 11:08 AM.

Details

Reviewers
majnemer
hfinkel
Summary

i64 -1, whose sign bit is the 0th one, can't be left shifted without invoking UB.

Diff Detail

Event Timeline

jroelofs updated this revision to Diff 67556.Aug 10 2016, 11:08 AM
jroelofs retitled this revision from to FIx UB in APInt::ashr.
jroelofs updated this object.
jroelofs added reviewers: majnemer, hfinkel.
jroelofs added a subscriber: llvm-commits.
majnemer added inline comments.Aug 10 2016, 12:27 PM
lib/Support/APInt.cpp
1047–1048

Isn't this SignExtend64(Val, BitWidth) ?

jroelofs updated this revision to Diff 67578.Aug 10 2016, 12:46 PM

Use SignExtend64()

lib/Support/APInt.cpp
1047–1048

Why yes, it is.

majnemer accepted this revision.Aug 10 2016, 12:54 PM
majnemer edited edge metadata.

LGTM

This revision is now accepted and ready to land.Aug 10 2016, 12:54 PM