This is an archive of the discontinued LLVM Phabricator instance.

[FuncSpec] Don't crash and specialise on poison or constexpr values
ClosedPublic

Authored by SjoerdMeijer on Sep 27 2021, 3:23 AM.

Details

Summary

Function specialization was crashing at i) poison values and 2) constexpr values.

The problem is that these values are not added to the solver, so when a lookup is performed the crash happens. This fixes that by not specialising on these values. For poison that is obvious, but for constexpr this is a change in behaviour. Thus, in one way this is a bit of a stopgap, but specialising on constexpr values wasn't done very intentionally, and need some more work and tests if we wanted to support this, which is why not allowing constexprs seems fine to me.

This fixes: https://bugs.llvm.org/show_bug.cgi?id=51600

Diff Detail

Event Timeline

SjoerdMeijer created this revision.Sep 27 2021, 3:23 AM
SjoerdMeijer requested review of this revision.Sep 27 2021, 3:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 27 2021, 3:23 AM

I met the problem about ConstantExpr before: https://reviews.llvm.org/D107067. So it looks good to me basically. But I am wondering if it is better to fix the solver to solve these kind of problem fundamentally?

I met the problem about ConstantExpr before: https://reviews.llvm.org/D107067. So it looks good to me basically. But I am wondering if it is better to fix the solver to solve these kind of problem fundamentally?

Yep, agreed. That's why I called this change to function specialisation a stopgap, but I think this makes sense because I don't think we want to support constexprs at this point.

In addition, we would indeed need to fix the solver (or how it is used), which I think is a separate issue. I don't know if the solver should exit more gracefully and returns a "don't know", and/or really support these constexprs. That needs some looking into...

ChuanqiXu accepted this revision.Sep 27 2021, 3:55 AM

I met the problem about ConstantExpr before: https://reviews.llvm.org/D107067. So it looks good to me basically. But I am wondering if it is better to fix the solver to solve these kind of problem fundamentally?

Yep, agreed. That's why I called this change to function specialisation a stopgap, but I think this makes sense because I don't think we want to support constexprs at this point.

In addition, we would indeed need to fix the solver (or how it is used), which I think is a separate issue. I don't know if the solver should exit more gracefully and returns a "don't know", and/or really support these constexprs. That needs some looking into...

Agreed. I think we should add corresponding TODO or FIXME in SCCPSolver.cpp in this patch or in another NFC patch.

This revision is now accepted and ready to land.Sep 27 2021, 3:55 AM
SjoerdMeijer added a comment.EditedSep 27 2021, 5:53 AM

Agreed. I think we should add corresponding TODO or FIXME in SCCPSolver.cpp in this patch or in another NFC patch.

Ok, thanks, I will commit this first. Then I will have a look later this week at the solver and when I understand better where things happen, leave a comment somewhere (or propose a fix).

This revision was landed with ongoing or failed builds.Sep 27 2021, 6:59 AM
This revision was automatically updated to reflect the committed changes.