[PATCH] D97970: [RISCV] Make the hasStdExtM() check in RISCVInstrInfo::getVLENFactoredAmount a fatal error rather than an assert.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 4 11:43:49 PST 2021
craig.topper created this revision.
craig.topper added reviewers: evandro, HsiangKai, frasercrmck, khchen, arcbbb.
Herald added subscribers: StephenFan, vkmr, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: LLVM.
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 fatal_error we ensure we'll stop the compiler even
in release builds. The error presented to the user won't be the
prettiest, but we won't generate invalid code.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97970
Files:
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
Index: llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -1196,8 +1196,9 @@
BuildMI(MBB, II, DL, TII->get(RISCV::ADDI), VN)
.addReg(RISCV::X0)
.addImm(NumOfVReg);
- assert(MF.getSubtarget<RISCVSubtarget>().hasStdExtM() &&
- "M-extension must be enabled to calculate the vscaled size/offset.");
+ if (!MF.getSubtarget<RISCVSubtarget>().hasStdExtM())
+ report_fatal_error("M-extension must be enabled to calculate the vscaled "
+ "size/offset.");
BuildMI(MBB, II, DL, TII->get(RISCV::MUL), FactorRegister)
.addReg(SizeOfVector, RegState::Kill)
.addReg(VN, RegState::Kill);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97970.328262.patch
Type: text/x-patch
Size: 814 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210304/23b6f0ef/attachment.bin>
More information about the llvm-commits
mailing list