Skip to content

[RISCV] error: duplicated standard user-level extension 'zifencei' since LLVM 19 #136803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wangpc-pp opened this issue Apr 23, 2025 · 6 comments · Fixed by #136842
Closed

[RISCV] error: duplicated standard user-level extension 'zifencei' since LLVM 19 #136803

wangpc-pp opened this issue Apr 23, 2025 · 6 comments · Fixed by #136842

Comments

@wangpc-pp
Copy link
Contributor

See: https://godbolt.org/z/cnan5zh41

Before LLVM 19, we can compile successfully with -march=rv64gc_zifencei. But since LLVM 19, it complains:

error: invalid arch name 'rv64gc_zifencei', duplicated standard user-level extension 'zifencei'

The behavior is not compatible.

Is there something I missed? I know there are issues with zifencei implication, did we decide to not accept standalone zifencei? But I don't see it in release notes...

@llvmbot
Copy link
Member

llvmbot commented Apr 23, 2025

@llvm/issue-subscribers-backend-risc-v

Author: Pengcheng Wang (wangpc-pp)

See: https://godbolt.org/z/cnan5zh41

Before LLVM 19, we can compile successfully with -march=rv64gc_zifencei. But since LLVM 19, it complains:

error: invalid arch name 'rv64gc_zifencei', duplicated standard user-level extension 'zifencei'

The behavior is not compatible.

Is there something I missed? I know there are issues with zifencei implication, did we decide to not accept standalone zifencei? But I don't see it in release notes...

@topperc
Copy link
Collaborator

topperc commented Apr 23, 2025

Probably an unintentional break from dc90af5.

@wangpc-pp
Copy link
Contributor Author

wangpc-pp commented Apr 23, 2025

I see, only LLVM 17/18 can accept -march=rv64gc_zifencei. Both zicsr and zifencei have this problem.

@topperc
Copy link
Collaborator

topperc commented Apr 23, 2025

Possible fix.

diff --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp
index ff0174210f87..e23e161eecfd 100644
--- a/llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -46,7 +46,11 @@ struct RISCVProfile {
 } // end anonymous namespace
 
 static const char *RISCVGImplications[] = {
-  "i", "m", "a", "f", "d", "zicsr", "zifencei"
+  "i", "m", "a", "f", "d"
+};
+
+static const char *RISCVGImplicationsZi[] = {
+  "zicsr", "zifencei"
 };
 
 #define GET_SUPPORTED_EXTENSIONS
@@ -717,6 +721,14 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
     } while (!Ext.empty());
   }
 
+  if (Baseline == 'g') {
+    for (const char *Ext : RISCVGImplicationsZi) {
+      auto Version = findDefaultVersion(Ext);
+      assert(Version && "Default extension version not found?");
+      ISAInfo->Exts[std::string(Ext)] = {Version->Major, Version->Minor};
+    }
+  }
+
   return RISCVISAInfo::postProcessAndChecking(std::move(ISAInfo));
 }
 

@wangpc-pp
Copy link
Contributor Author

@topperc Thanks for the fix! I was hesitating to support this but I checked that GCC can accept specifying zicsr/zifencei with g all the time, so I think Clang should accept it too. The problem is we accidentally supported it in LLVM 17/18 but removed it since LLVM 19. We can cherry-pick the fix to LLVM 20 since we are still in the release cycle, but is it the same process for previous release LLVM 19? cc @asb @kito-cheng

wangpc-pp added a commit to wangpc-pp/llvm-project that referenced this issue Apr 23, 2025
This matches GCC and we supported it in LLVM 17/18.

Fixes llvm#136803
wangpc-pp added a commit to wangpc-pp/llvm-project that referenced this issue Apr 23, 2025
This matches GCC and we supported it in LLVM 17/18.

Fixes llvm#136803
@asb
Copy link
Contributor

asb commented Apr 24, 2025

@topperc Thanks for the fix! I was hesitating to support this but I checked that GCC can accept specifying zicsr/zifencei with g all the time, so I think Clang should accept it too. The problem is we accidentally supported it in LLVM 17/18 but removed it since LLVM 19. We can cherry-pick the fix to LLVM 20 since we are still in the release cycle, but is it the same process for previous release LLVM 19? cc @asb @kito-cheng

I think the answer is basically that there won't be further LLVM 19 releases so this won't get backported to LLVM 19. If there are distros packaging LLVM 19 and supporting it long term, we can file bugs on their issue trackers to suggest they cherry-pick the patch in their downstream package.

jyli0116 pushed a commit to jyli0116/llvm-project that referenced this issue Apr 28, 2025
This matches GCC and we supported it in LLVM 17/18.

Fixes llvm#136803
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
This matches GCC and we supported it in LLVM 17/18.

Fixes llvm#136803
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
This matches GCC and we supported it in LLVM 17/18.

Fixes llvm#136803
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
This matches GCC and we supported it in LLVM 17/18.

Fixes llvm#136803
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this issue May 9, 2025
This matches GCC and we supported it in LLVM 17/18.

Fixes llvm#136803
swift-ci pushed a commit to swiftlang/llvm-project that referenced this issue May 13, 2025
This matches GCC and we supported it in LLVM 17/18.

Fixes llvm#136803

(cherry picked from commit 6c33735)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants