[PATCH] D152273: [RISCV] Don't persist invalid feature state on .option arch error
Jessica Clarke via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 6 07:34:19 PDT 2023
jrtc27 created this revision.
jrtc27 added reviewers: asb, craig.topper, luismarques, StephenFan.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
jrtc27 requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.
Otherwise subsequent .option arch, +foo directives (but not -, since
those have their own separate validation) fail the parseFeatureBits
check, leading to cascading errors.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152273
Files:
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/test/MC/RISCV/option-invalid.s
Index: llvm/test/MC/RISCV/option-invalid.s
===================================================================
--- llvm/test/MC/RISCV/option-invalid.s
+++ llvm/test/MC/RISCV/option-invalid.s
@@ -47,6 +47,10 @@
# CHECK: :[[#@LINE+1]]:20: error: 'f' and 'zfinx' extensions are incompatible
.option arch, +f, +zfinx
+## Make sure the above error isn't sticky
+# CHECK-NOT: :[[#@LINE+1]]:
+.option arch, +f
+
# CHECK: :[[#@LINE+1]]:13: error: expected newline
.option rvc foo
Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===================================================================
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2758,9 +2758,14 @@
Args.emplace_back(Type, Ext->Key);
if (Type == RISCVOptionArchArgType::Plus) {
+ FeatureBitset OldFeatureBits = STI->getFeatureBits();
+
setFeatureBits(Ext->Value, Ext->Key);
auto ParseResult = RISCVFeatures::parseFeatureBits(isRV64(), STI->getFeatureBits());
if (!ParseResult) {
+ copySTI().setFeatureBits(OldFeatureBits);
+ setAvailableFeatures(ComputeAvailableFeatures(OldFeatureBits));
+
std::string Buffer;
raw_string_ostream OutputErrMsg(Buffer);
handleAllErrors(ParseResult.takeError(), [&](llvm::StringError &ErrMsg) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152273.528859.patch
Type: text/x-patch
Size: 1367 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230606/045af1ec/attachment.bin>
More information about the llvm-commits
mailing list