Page MenuHomePhabricator

[MLIR][Presburger] Factor out space information to PresburgerSpace
ClosedPublic

Authored by Groverkss on Feb 8 2022, 1:28 PM.

Details

Summary

This patch factors out space information from IntegerPolyhedron, PresburgerSet
and PWMAFunction to PresburgerSpace and its extension with local variables,
PresburgerLocalSpace.

Generally any new data structure additions in Presburger library will require
space information. This patch removes the need to duplicate the space
information.

Diff Detail

Event Timeline

Groverkss created this revision.Feb 8 2022, 1:28 PM
Groverkss requested review of this revision.Feb 8 2022, 1:28 PM
arjunp added inline comments.Feb 8 2022, 2:02 PM
mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h
96

Why is this removed?

mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h
37

Can we avoid the duplication between the two classes by just putting numLocals in PresburgerSpace and setting it to zero in the constructor?

64

This can just be called insertId right?

67

This can just be called removeIdRange right?

71

I think it should be IDs immediately before the split become symbols or IDs immediately after become dims. Talk about leading/trailing sounds like the first or last IDs in the space, which is not what happens I think

mlir/lib/Analysis/Presburger/PresburgerSpace.cpp
105

You can factor out this repeated part into a free function

Groverkss updated this revision to Diff 407283.Feb 9 2022, 1:40 PM
Groverkss marked 6 inline comments as done.
  • Address Arjun's comments
Groverkss added inline comments.Feb 9 2022, 1:43 PM
mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h
96

Only the base class destructor needs to be virtual right?

arjunp added inline comments.Feb 9 2022, 2:33 PM
mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h
96

AFAIU, this will cause undefined behaviour if we ever have e.g. a unique_ptr<IntegerPolyhedron>

https://stackoverflow.com/questions/461203/when-to-use-virtual-destructors

Groverkss added inline comments.Feb 9 2022, 11:32 PM
mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h
96

"Inheriting from a base class using virtual destructor makes the destructor of the inheriting class automatically virtual, too (so you do not have to retype 'virtual' in the inheriting class destructor declaration)."

PresburgerSpace already has a virtual destructor. I can't find anything there that says derived classes also need to specify destructors as virtual.

arjunp accepted this revision.Feb 10 2022, 3:04 AM
arjunp added inline comments.
mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h
54

You can remove this line

96

Yeah, true. I think PresburgerSpace technically doesn't have to be virtual in this patch, but we need it to be later anyway so it's fine.

This revision is now accepted and ready to land.Feb 10 2022, 3:04 AM
Groverkss updated this revision to Diff 407479.Feb 10 2022, 4:53 AM
Groverkss marked 3 inline comments as done.
  • Fix doc comment for IntegerPolyhedron
This revision was landed with ongoing or failed builds.Feb 10 2022, 4:59 AM
This revision was automatically updated to reflect the committed changes.