This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Make the hasStdExtM() check in RISCVInstrInfo::getVLENFactoredAmount emit a diagnostic rather than an assert.
ClosedPublic

Authored by craig.topper on Mar 4 2021, 11:43 AM.

Details

Summary

As far as I know we're not enforcing the StdExtM must be enabled
to use the V extension. If we use an assert here and hit this
code in a release build we'll silently emit an invalid instruction.

By using a diagnostic we report the error to the user in release
builds. I think there may still be a later fatal error from
the code emitter though.

Diff Detail

Event Timeline

craig.topper created this revision.Mar 4 2021, 11:43 AM
craig.topper requested review of this revision.Mar 4 2021, 11:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 4 2021, 11:43 AM
Herald added a subscriber: MaskRay. · View Herald Transcript
jrtc27 added inline comments.Mar 4 2021, 11:51 AM
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
1200
MF.getFunction().getContext().diagnose(DiagnosticInfoUnsupported{
    MF.getFunction(),
    "M-extension must ..."});

perhaps, if you want a friendlier experience?

Use a diagnostic instead. I don't this stops the build immediately, but that should be fine.

craig.topper retitled this revision from [RISCV] Make the hasStdExtM() check in RISCVInstrInfo::getVLENFactoredAmount a fatal error rather than an assert. to [RISCV] Make the hasStdExtM() check in RISCVInstrInfo::getVLENFactoredAmount emit a diagnostic rather than an assert..Mar 4 2021, 12:36 PM
craig.topper edited the summary of this revision. (Show Details)

This is better than an assert, but do we absolutely require M? Couldn't we fall back to compiler-rt, for instance?

This is better than an assert, but do we absolutely require M? Couldn't we fall back to compiler-rt, for instance?

Maybe. I'm not sure if I we're able to inject a call at the point in the compiler where this is used.

frasercrmck accepted this revision.Mar 9 2021, 1:57 AM

Maybe. I'm not sure if I we're able to inject a call at the point in the compiler where this is used.

Yeah, I thought that might be case. Perhaps we'd have to lower it differently/earlier without M. Since that code would be elsewhere, this diagnostic is still an improvement so I'm happy for it to go in. We can always come back to this issue if/when it's important.

This revision is now accepted and ready to land.Mar 9 2021, 1:57 AM