[clang] [RISCV][FMV] Support target_version (PR #99040)

Piyou Chen via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 22 23:08:56 PDT 2024


================
@@ -3056,6 +3056,45 @@ bool Sema::checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D,
   enum SecondParam { None };
   enum ThirdParam { Target, TargetClones, TargetVersion };
   llvm::SmallVector<StringRef, 8> Features;
+  if (Context.getTargetInfo().getTriple().isRISCV()) {
+
+    llvm::SmallVector<StringRef, 8> AttrStrs;
+    AttrStr.split(AttrStrs, ';');
+
+    bool IsPriority = false;
+    bool IsDefault = false;
+    for (auto &AttrStr : AttrStrs) {
+      // Only support arch=+ext,... syntax.
----------------
BeMg wrote:

The `target_version("arch=rv64gc;default;")` attribute will raise an error with the message: `"unsupported '' in the 'target_version' attribute string; 'target_version' attribute ignored"`. This occurs due to an empty `AttrStr` appearing in the attribute.

However, `target_version("arch=rv64gc;default")` will not raise an error and will now treat the version as default. To address this situation, I have added a `HasArch` guard.



https://github.com/llvm/llvm-project/pull/99040


More information about the cfe-commits mailing list