This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] Fixes bug in VarSet ctor
ClosedPublic

Authored by wrengr on Jul 21 2023, 2:41 PM.

Details

Summary

Previously, the commented out code in the DimLvlMap ctor would result in VarSet::add raising an OOB error; which should be impossible because the ctor asserted DimLvlMap::isWF which ensures that all variables occuring in the map are within bounds for the ranks.

The root cause of that bug was the VarSet ctor using SmallBitVector::reserve which does not actually change the size of the bitvectors (hence the subsequent OOB). This is corrected by using any of SmallBitVector::resize, the move-ctor, or the copy-ctor. Since the default-initialized bitvectors being modified/overwritten have size zero, there shouldn't be any significant performance difference between these three implementations.

Diff Detail

Event Timeline

wrengr created this revision.Jul 21 2023, 2:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2023, 2:41 PM
wrengr requested review of this revision.Jul 21 2023, 2:41 PM
wrengr retitled this revision from [mlir][sparse] Fixing bug in VarSet ctor to [mlir][sparse] Fixes bug in VarSet ctor.Jul 21 2023, 2:42 PM
wrengr updated this revision to Diff 543132.Jul 21 2023, 6:49 PM

Removed fixme comment in VarSet::contains(Var). The potential logic-bug mentioned there is the same one in the VarSet ctor that this CL fixes. (I.e., if we were to assert against OOB in that method, then everything would still pass not that we've corrected the VarSet ctor)

Peiming accepted this revision.Jul 24 2023, 8:23 AM
This revision is now accepted and ready to land.Jul 24 2023, 8:23 AM
This revision was automatically updated to reflect the committed changes.