This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] Simplifying assertions in fromCOO
ClosedPublic

Authored by wrengr on Jan 15 2022, 2:41 PM.

Details

Summary

Hoisting invariant assertions to the top

Diff Detail

Event Timeline

wrengr created this revision.Jan 15 2022, 2:41 PM
wrengr requested review of this revision.Jan 15 2022, 2:41 PM

Unfortunately, the const in the method signature is required to be certain that the assertion in the while-loop is indeed entailed. We can safely remove it, but then the compiler wouldn't warn someone who tries to make a change that would break the entailment (i.e., by actually mutating hi).

Unfortunately, the const in the method signature is required to be certain that the assertion in the while-loop is indeed entailed. We can safely remove it, but then the compiler wouldn't warn someone who tries to make a change that would break the entailment (i.e., by actually mutating hi).

That makes sense, but I am not sure if our style guidelines allow the const on scalars. I would just remove it to be safe, although I agree with your reasoning (in fact, in former projects, we put const on pretty much everything that would allow it ;-)

aartbik accepted this revision.Jan 17 2022, 1:47 PM
This revision is now accepted and ready to land.Jan 17 2022, 1:47 PM
wrengr updated this revision to Diff 400932.Jan 18 2022, 11:40 AM

removing const

(in fact, in former projects, we put const on pretty much everything that would allow it ;-)

That would be nice. Much easier to reason about :)

aartbik accepted this revision.Jan 19 2022, 9:39 AM

Still LGTM

This revision was automatically updated to reflect the committed changes.