This is an archive of the discontinued LLVM Phabricator instance.

[ConstraintElimination] Add Decomposition class (NFCI)
ClosedPublic

Authored by nikic on Nov 11 2022, 8:30 AM.

Details

Summary

Replace the vector of DecompEntry with a class that stores the constant offset separately. I think this is cleaner than giving the first element special handling.

This probably also fixes some potential ubsan errors by more consistently using addWithOverflow/multiplyWithOverflow.

Depends on D137847.

Diff Detail

Event Timeline

nikic created this revision.Nov 11 2022, 8:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 11 2022, 8:30 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
nikic requested review of this revision.Nov 11 2022, 8:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 11 2022, 8:30 AM
fhahn added inline comments.Nov 11 2022, 4:03 PM
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
196

Could this be a class instead of a struct to ensure the offsets are only adjusted using the safe methods?

nikic added inline comments.Nov 12 2022, 12:40 AM
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
196

What would we do with the code in ConstraintInfo::getConstraint, which actually uses the decomposition in that case? Read-only getters?

fhahn accepted this revision.Nov 13 2022, 2:43 PM
fhahn added reviewers: fcloutier, zjaffal.

LGTM, thanks! This is a nice improvement, we can iterate over making it a class as follow-up. It might be good to update title/description to say struct instead of class.

llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
196

Yeah that would be an option, but there might be a better API. I can play around a bit once this lands as struct.

This revision is now accepted and ready to land.Nov 13 2022, 2:43 PM