When subtracting b \ c, when there are divisions in c, these division
constraints get added to b. b must be restored to its original state
when returning, but these added divisions constraints were not removed in
one of the return paths. This patch fixes this and deduplicates the
restoration logic by encapuslating it in a lambda restoreState. The patch
also includes a regression test for the bug fix.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Analysis/PresburgerSet.cpp | ||
---|---|---|
208–209 | Could you maybe remove the last x added divisions instead? The problem with this is, in case mergeLocalIds removes any duplicate inequalities (I plan to do that sometime), it will cause problems here. Removing the last x seems better to me. | |
mlir/unittests/Analysis/PresburgerSetTest.cpp | ||
664 | Could you maybe add a test case where division merging also takes place? Something that has maybe more divisions: A: [x/5] [y/2] [x/5] I think this will be useful in the future. Not exactly sure what kind of test, but something that tests merging and has some duplicate divisions. (It's fine if they are two test cases checking duplicate and merging separately). |
mlir/lib/Analysis/PresburgerSet.cpp | ||
---|---|---|
208–209 | Well, then we have to manually keep track of how many constraints we have added which is error-prone. What exactly do you mean by removing duplicate inequalities? | |
mlir/unittests/Analysis/PresburgerSetTest.cpp | ||
664 | Sure, we should definitely add such tests. But I suppose that would be a separate patch, since it's not really related to the bug of forgetting to rollback added constraints? |
mlir/lib/Analysis/PresburgerSet.cpp | ||
---|---|---|
204 | this feels like you want an RAII llvm::scope_exit to handle all the branches for you automatically. |
mlir/lib/Analysis/PresburgerSet.cpp | ||
---|---|---|
204 | Whoops, nice catch. This is an outdated comment. I eventually decided against it because only one of the return paths actually needs to restore at scope exit, the other one already restores earlier. |
this feels like you want an RAII llvm::scope_exit to handle all the branches for you automatically.