The patch "Fix assertion failure when value is not added to solver" removed code which made the pass specialize in cases we were not intending before. The test function-specialization-constant-expression.ll explicitely mentions that in a comment. When I rebase my patch https://reviews.llvm.org/D126455 on top of main I get the same assertion error when compiling this test file. Adding back the removed code fixes the problem.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
60,070 ms | x64 debian > Clang.Driver::emit-reproducer.c | |
60,380 ms | x64 debian > Clang.Driver::fsanitize.c |
Event Timeline
The reason why test cases crash at Solver.getLatticeValueFor is that SCCPSolver does not track the lattice value of a callbase argument. However, it is doable for SCCPSolver to track the lattice value of a ConstantExpr, and that is why I think skipping ConstantExpr is not an sound solution.
So, the potential problem with D126455 is that the argument of a callbase is changed before FS, and SCCPSolver is not updated. Can you have a check on that?
Ping. I wanted to implement the idea discussed on https://discourse.llvm.org/t/rfc-should-we-enable-function-specialization/61518 in incremental steps, not in one go. The problem @sinan mentions is fixed in later patches. Does it make sense to land this patch first and once the fix is in place to revert the change in getPossibleConstants() and adapt the test to reflect that we actually intend to specialize?
Sounds fine. I tend to accept this patch since it is a stepping stone for the patch series, and we can revisit the constant expression case later after all patches merged.