This is an archive of the discontinued LLVM Phabricator instance.

[FuncSpec] Partially revert rG8b360c69e9e3.
AbandonedPublic

Authored by labrinea on Jun 29 2022, 7:26 AM.

Details

Summary

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.

Diff Detail

Event Timeline

labrinea created this revision.Jun 29 2022, 7:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2022, 7:26 AM
labrinea requested review of this revision.Jun 29 2022, 7:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2022, 7:26 AM
labrinea edited the summary of this revision. (Show Details)Jun 29 2022, 7:27 AM

LGTM basically. @sinan would you like to take a look?

sinan added a comment.EditedJul 11 2022, 10:53 PM

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?

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?

Hi, thanks for the input. D126455 is part of a patch series. Indeed if the users of a replaced value are visited then the crash doesn't happen. I am already doing this on D128825 and D126456.

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?

sinan accepted this revision.Aug 2 2022, 12:20 AM

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.

This revision is now accepted and ready to land.Aug 2 2022, 12:20 AM
labrinea abandoned this revision.Dec 5 2022, 5:15 AM

Abandoning in favor of D126455.