This is an archive of the discontinued LLVM Phabricator instance.

[IRCE] Implement runtime overflow check for computed range's end
ClosedPublic

Authored by aleksandr.popov on Jun 30 2023, 12:12 AM.

Details

Summary

Here is activated check elimination which was parsed previously in
https://reviews.llvm.org/D154069

  • Added runtime check that computed range's boundary doesn't overflow in

terms of range type.

  • From the statement INT_MIN <= END <= INT_MAX is inferred check:

isNonNegative(INT_MAX - END) * isNonNegative(END - INT_MIN).

  • If overflow happens, check will return 0 and the safe interval will be

empty.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJun 30 2023, 12:12 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
aleksandr.popov requested review of this revision.Jun 30 2023, 12:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 30 2023, 12:12 AM
aleksandr.popov edited the summary of this revision. (Show Details)

Rebased

skatkov accepted this revision.Jul 7 2023, 3:18 AM
skatkov added inline comments.
llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
1741

bool NeedEndOverlowRuntimeCheck = EndType->getBitWidth() > RCType->getBitWidth();
if (NeedEndOverlowRuntimeCheck)

?

This revision is now accepted and ready to land.Jul 7 2023, 3:18 AM