This is an archive of the discontinued LLVM Phabricator instance.

Correct CreateAlignmentAssumption to check sign and power-of-2 (Clang Part)
AbandonedPublic

Authored by lebedev.ri on Nov 16 2018, 2:58 PM.

Details

Summary

CreateAlignmentAssumption with a run-time alignment value doesn't
correctly condition based on signedness, which can cause some odd
behaviors on large unsigneds. Additionally, only powers-of-two
are valid here, add that check to the assumption to prevent UB.

Diff Detail

Event Timeline

erichkeane created this revision.Nov 16 2018, 2:58 PM
This comment was removed by erichkeane.
lebedev.ri accepted this revision.Nov 16 2018, 3:15 PM

LG.
I hope that extra is-power-of-two won't confuse the optimizer.

This revision is now accepted and ready to land.Nov 16 2018, 3:15 PM

As discussed on IRC, check sign/power of 2 correctly for the alignment assumptions.

"As discussed on IRC" is not appropriate for a commit message. The rationale must be documented here.

I hope that extra is-power-of-two won't confuse the optimizer.

Probably would unless it gets constant folded.

erichkeane edited the summary of this revision. (Show Details)Nov 19 2018, 6:53 AM
lebedev.ri commandeered this revision.Jan 24 2019, 6:04 AM
lebedev.ri edited reviewers, added: erichkeane; removed: lebedev.ri.
This revision now requires review to proceed.Jan 24 2019, 6:04 AM
lebedev.ri abandoned this revision.Jan 24 2019, 9:53 AM

As disscussed in D54653 (https://reviews.llvm.org/D54653#1318964),
this differential will be simply unneeded, that review will address the issue too, so abandoning.