[PATCH] D144353: [lld][RISCV] Avoid error when encountering unrecognised ISA extensions/versions in RISC-V attributes

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 22 16:46:11 PST 2023


MaskRay added inline comments.


================
Comment at: llvm/lib/Support/RISCVISAInfo.cpp:519
+    return createStringError(errc::invalid_argument,
+                             "string must be lowercase");
+  }
----------------
This is untested. You can test it with a test under llvm/unittest/Support


================
Comment at: llvm/lib/Support/RISCVISAInfo.cpp:545
+                               "extension lacks version in expected format");
+    unsigned long long MajorVersion, MinorVersion;
+    if (getAsUnsignedInteger(MinorVersionStr, 10, MinorVersion))
----------------
`getExtensionVersion` uses `unsigned` instead of `unsigned long long`.


================
Comment at: llvm/lib/Support/RISCVISAInfo.cpp:555
+    while (!ExtName.empty()) {
+      if (!isDigit(ExtName.back()))
+        break;
----------------
Merge this into the loop condition


================
Comment at: llvm/lib/Support/RISCVISAInfo.cpp:558
+      ExtName = ExtName.drop_back(1);
+      TrailingDigits++;
+    }
----------------
pre-increment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144353/new/

https://reviews.llvm.org/D144353



More information about the llvm-commits mailing list