This is an archive of the discontinued LLVM Phabricator instance.

Left shifts of negative values are defined if -fwrapv is set
ClosedPublic

Authored by jmolloy on Aug 15 2016, 3:41 AM.

Details

Summary

This means we shouldn't emit ubsan detection code or warn.
Fixes PR25552.

Diff Detail

Event Timeline

jmolloy updated this revision to Diff 68009.Aug 15 2016, 3:41 AM
jmolloy retitled this revision from to Left shifts of negative values are defined if -fwrapv is set.
jmolloy updated this object.
jmolloy added reviewers: davide, aaron.ballman.
jmolloy added a subscriber: cfe-commits.
filcab added a subscriber: filcab.Aug 15 2016, 6:47 AM
filcab added inline comments.
test/CodeGen/wrapv-lshr-sanitize.c
2

Do you really need instnamer?

test/Sema/negative-shift-wrapv.c
10

It's a bit weird to have the test function be dead code, but I don't see a big problem anyway.

Do you need to do the whole WORD_BIT thing? I'd rather just shift -1 by 1 (which is already UB in non -fwrapv world, but defined in -fwrapv world).

jmolloy updated this revision to Diff 68033.Aug 15 2016, 6:55 AM

Hi Filipe,

Thanks for the review! SGTM on both counts.

Hi Filipe,

Did this look good to you after those changes?

Cheers,

James

davide edited edge metadata.Aug 16 2016, 2:23 AM

The Sema bits look fine to me. I'll let Filipe comment on the sanitizer part.

jmolloy accepted this revision.Aug 16 2016, 2:59 AM
jmolloy added a reviewer: jmolloy.

Thanks, r278786!

This revision is now accepted and ready to land.Aug 16 2016, 2:59 AM
jmolloy closed this revision.Aug 16 2016, 2:59 AM