[clang-tools-extra] [llvm] [RISCV][MCA] Avoid deriving EMUL without SEW (PR #207981)
Zeyi Xu via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 7 05:04:52 PDT 2026
https://github.com/zeyi2 created https://github.com/llvm/llvm-project/pull/207981
None
>From 55ae34ff5176b42d229add6a6beaee0ab14b279b Mon Sep 17 00:00:00 2001
From: Zeyi Xu <mitchell.xu2 at gmail.com>
Date: Tue, 7 Jul 2026 12:46:01 +0800
Subject: [PATCH 1/3] [clang-tidy][docs] Update CERT links to current SEI URLs.
NFC.
---
.../docs/clang-tidy/checks/bugprone/command-processor.rst | 2 +-
.../docs/clang-tidy/checks/bugprone/float-loop-counter.rst | 2 +-
.../clang-tidy/checks/bugprone/std-namespace-modification.rst | 2 +-
.../checks/bugprone/throwing-static-initialization.rst | 2 +-
.../checks/bugprone/unchecked-string-to-number-conversion.rst | 2 +-
clang-tools-extra/docs/clang-tidy/checks/cert/dcl50-cpp.rst | 2 +-
clang-tools-extra/docs/clang-tidy/checks/cert/dcl58-cpp.rst | 2 +-
clang-tools-extra/docs/clang-tidy/checks/cert/env33-c.rst | 2 +-
clang-tools-extra/docs/clang-tidy/checks/cert/err52-cpp.rst | 2 +-
clang-tools-extra/docs/clang-tidy/checks/cert/err58-cpp.rst | 2 +-
clang-tools-extra/docs/clang-tidy/checks/cert/fio38-c.rst | 2 +-
clang-tools-extra/docs/clang-tidy/checks/cert/flp30-c.rst | 2 +-
.../docs/clang-tidy/checks/misc/new-delete-overloads.rst | 2 +-
.../docs/clang-tidy/checks/misc/non-copyable-objects.rst | 2 +-
.../docs/clang-tidy/checks/modernize/avoid-setjmp-longjmp.rst | 2 +-
.../clang-tidy/checks/modernize/avoid-variadic-functions.rst | 2 +-
.../checkers/bugprone/copy-constructor-mutates-argument.cpp | 2 +-
17 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/command-processor.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/command-processor.rst
index cbffe7dddae04..ff832af1e1ad1 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/command-processor.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/command-processor.rst
@@ -13,4 +13,4 @@ References
This check corresponds to the CERT C Coding Standard rule
`ENV33-C. Do not call system()
-<https://www.securecoding.cert.org/confluence/display/c/ENV33-C.+Do+not+call+system()>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/environment-env/env33-c/>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/float-loop-counter.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/float-loop-counter.rst
index e663b40ab5a5d..86d7d2ccebc9b 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/float-loop-counter.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/float-loop-counter.rst
@@ -10,4 +10,4 @@ References
This check corresponds to the CERT C Coding Standard rule
`FLP30-C. Do not use floating-point variables as loop counters
-<https://www.securecoding.cert.org/confluence/display/c/FLP30-C.+Do+not+use+floating-point+variables+as+loop+counters>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/floating-point-flp/flp30-c/>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/std-namespace-modification.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/std-namespace-modification.rst
index 56d2559be904e..29e128e3b1f20 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/std-namespace-modification.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/std-namespace-modification.rst
@@ -65,4 +65,4 @@ References
This check corresponds to the CERT C++ Coding Standard rule
`DCL58-CPP. Do not modify the standard namespaces
-<https://www.securecoding.cert.org/confluence/display/cplusplus/DCL58-CPP.+Do+not+modify+the+standard+namespaces>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-cpp-coding-standard/rules/declarations-and-initialization-dcl/dcl58-cpp/>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/throwing-static-initialization.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/throwing-static-initialization.rst
index 0bbae1e8571f1..23ffc29b4dc4f 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/throwing-static-initialization.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/throwing-static-initialization.rst
@@ -24,4 +24,4 @@ References
This check corresponds to the CERT C++ Coding Standard rule
`ERR58-CPP. Handle all exceptions thrown before main() begins executing
-<https://www.securecoding.cert.org/confluence/display/cplusplus/ERR58-CPP.+Handle+all+exceptions+thrown+before+main%28%29+begins+executing>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-cpp-coding-standard/rules/exceptions-and-error-handling-err/err58-cpp/>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-string-to-number-conversion.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-string-to-number-conversion.rst
index e38b29817f30a..31d3262acbeb2 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-string-to-number-conversion.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-string-to-number-conversion.rst
@@ -28,4 +28,4 @@ References
This check corresponds to the CERT C Coding Standard rule
`ERR34-C. Detect errors when converting a string to a number
-<https://www.securecoding.cert.org/confluence/display/c/ERR34-C.+Detect+errors+when+converting+a+string+to+a+number>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/error-handling-err/err34-c/>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/cert/dcl50-cpp.rst b/clang-tools-extra/docs/clang-tidy/checks/cert/dcl50-cpp.rst
index 5a9995d8ac2cc..12def084cfecb 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cert/dcl50-cpp.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cert/dcl50-cpp.rst
@@ -10,4 +10,4 @@ for more information.
This check corresponds to the CERT C++ Coding Standard rule
`DCL50-CPP. Do not define a C-style variadic function
-<https://www.securecoding.cert.org/confluence/display/cplusplus/DCL50-CPP.+Do+not+define+a+C-style+variadic+function>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-cpp-coding-standard/rules/declarations-and-initialization-dcl/dcl50-cpp/>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/cert/dcl58-cpp.rst b/clang-tools-extra/docs/clang-tidy/checks/cert/dcl58-cpp.rst
index f584e88413b13..e89f4ea21b007 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cert/dcl58-cpp.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cert/dcl58-cpp.rst
@@ -10,4 +10,4 @@ for more information.
This check corresponds to the CERT C++ Coding Standard rule
`DCL58-CPP. Do not modify the standard namespaces
-<https://www.securecoding.cert.org/confluence/display/cplusplus/DCL58-CPP.+Do+not+modify+the+standard+namespaces>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-cpp-coding-standard/rules/declarations-and-initialization-dcl/dcl58-cpp/>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/cert/env33-c.rst b/clang-tools-extra/docs/clang-tidy/checks/cert/env33-c.rst
index 33fa7f1c3dd57..c07b5761b570b 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cert/env33-c.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cert/env33-c.rst
@@ -9,4 +9,4 @@ for more information.
This check corresponds to the CERT C Coding Standard rule
`ENV33-C. Do not call system()
-<https://www.securecoding.cert.org/confluence/display/c/ENV33-C.+Do+not+call+system()>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/environment-env/env33-c/>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/cert/err52-cpp.rst b/clang-tools-extra/docs/clang-tidy/checks/cert/err52-cpp.rst
index 4b726d8115662..eeb05b42c3f38 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cert/err52-cpp.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cert/err52-cpp.rst
@@ -9,4 +9,4 @@ for more information.
This check corresponds to the CERT C++ Coding Standard rule
`ERR52-CPP. Do not use setjmp() or longjmp()
-<https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=1834>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-cpp-coding-standard/rules/exceptions-and-error-handling-err/err52-cpp/>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/cert/err58-cpp.rst b/clang-tools-extra/docs/clang-tidy/checks/cert/err58-cpp.rst
index f591334ab5be9..befc156ba9a33 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cert/err58-cpp.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cert/err58-cpp.rst
@@ -10,4 +10,4 @@ for more information.
This check corresponds to the CERT C++ Coding Standard rule
`ERR58-CPP. Handle all exceptions thrown before main() begins executing
-<https://www.securecoding.cert.org/confluence/display/cplusplus/ERR58-CPP.+Handle+all+exceptions+thrown+before+main%28%29+begins+executing>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-cpp-coding-standard/rules/exceptions-and-error-handling-err/err58-cpp/>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/cert/fio38-c.rst b/clang-tools-extra/docs/clang-tidy/checks/cert/fio38-c.rst
index f67c7a64e16e8..fd2f409e7928d 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cert/fio38-c.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cert/fio38-c.rst
@@ -8,4 +8,4 @@ The `cert-fio38-c` check is an alias, please see
information.
This check corresponds to CERT C++ Coding Standard rule `FIO38-C. Do not copy a FILE object
-<https://www.securecoding.cert.org/confluence/display/c/FIO38-C.+Do+not+copy+a+FILE+object>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/input-output-fio/fio38-c/>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/cert/flp30-c.rst b/clang-tools-extra/docs/clang-tidy/checks/cert/flp30-c.rst
index 8bd23f6cdd29d..36ad4eee53230 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cert/flp30-c.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cert/flp30-c.rst
@@ -9,4 +9,4 @@ for more information
This check corresponds to the CERT C Coding Standard rule
`FLP30-C. Do not use floating-point variables as loop counters
-<https://www.securecoding.cert.org/confluence/display/c/FLP30-C.+Do+not+use+floating-point+variables+as+loop+counters>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/floating-point-flp/flp30-c/>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/new-delete-overloads.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/new-delete-overloads.rst
index 727436d8464a4..b8555b5a42f26 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/misc/new-delete-overloads.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/misc/new-delete-overloads.rst
@@ -16,4 +16,4 @@ The check does not flag implicitly-defined operators, deleted or private
operators, or placement operators.
This check corresponds to CERT C++ Coding Standard rule `DCL54-CPP. Overload allocation and deallocation functions as a pair in the same scope
-<https://www.securecoding.cert.org/confluence/display/cplusplus/DCL54-CPP.+Overload+allocation+and+deallocation+functions+as+a+pair+in+the+same+scope>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-cpp-coding-standard/rules/declarations-and-initialization-dcl/dcl54-cpp/>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/non-copyable-objects.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/non-copyable-objects.rst
index d3190e1155f08..4c95d6d1f6e67 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/misc/non-copyable-objects.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/misc/non-copyable-objects.rst
@@ -13,4 +13,4 @@ References
----------
This check corresponds to CERT C++ Coding Standard rule `FIO38-C. Do not copy a FILE object
-<https://www.securecoding.cert.org/confluence/display/c/FIO38-C.+Do+not+copy+a+FILE+object>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/input-output-fio/fio38-c/>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-setjmp-longjmp.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-setjmp-longjmp.rst
index 744a12cc3fc6d..835d94b69f358 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-setjmp-longjmp.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-setjmp-longjmp.rst
@@ -13,4 +13,4 @@ References
This check corresponds to the CERT C++ Coding Standard rule
`ERR52-CPP. Do not use setjmp() or longjmp()
-<https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=88046492>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-cpp-coding-standard/rules/exceptions-and-error-handling-err/err52-cpp/>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-variadic-functions.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-variadic-functions.rst
index 5b1da418cf45d..7604c92c8dbac 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-variadic-functions.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-variadic-functions.rst
@@ -15,4 +15,4 @@ References
This check corresponds to the CERT C++ Coding Standard rule
`DCL50-CPP. Do not define a C-style variadic function
-<https://www.securecoding.cert.org/confluence/display/cplusplus/DCL50-CPP.+Do+not+define+a+C-style+variadic+function>`_.
+<https://cmu-sei.github.io/secure-coding-standards/sei-cert-cpp-coding-standard/rules/declarations-and-initialization-dcl/dcl50-cpp/>`_.
diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-mutates-argument.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-mutates-argument.cpp
index 9fdbb7af90f90..59d54d155b331 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-mutates-argument.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-mutates-argument.cpp
@@ -1,7 +1,7 @@
// RUN: %check_clang_tidy %s bugprone-copy-constructor-mutates-argument %t
// Example test cases from CERT rule
-// https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP58-CPP.+Copy+operations+must+not+mutate+the+source+object
+// https://cmu-sei.github.io/secure-coding-standards/sei-cert-cpp-coding-standard/rules/object-oriented-programming-oop/oop58-cpp/
namespace test_mutating_noncompliant_example {
class A {
mutable int m;
>From 5f0c88ead79c6f372d23f07cd74fb20e8e27a462 Mon Sep 17 00:00:00 2001
From: Zeyi Xu <mitchell.xu2 at gmail.com>
Date: Tue, 7 Jul 2026 13:02:49 +0800
Subject: [PATCH 2/3] ~
---
.../clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
index b331426d09c7b..1057fe21b7f05 100644
--- a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
@@ -85,9 +85,7 @@ void ThrowByValueCatchByReferenceCheck::diagnoseThrowLocations(
// If the throw statement does not throw by pointer then it throws by value
// which is ok.
// There are addition checks that emit diagnosis messages if the thrown value
- // is not an RValue. See:
- // https://www.securecoding.cert.org/confluence/display/cplusplus/ERR09-CPP.+Throw+anonymous+temporaries
- // This behavior can be influenced by an option.
+ // is not an RValue. This behavior can be influenced by an option.
// If we encounter a CXXThrowExpr, we move through all casts until you either
// encounter a DeclRefExpr or a CXXConstructExpr.
>From 8b292d3796667c64ee8afb5fbe138ed3b19b5862 Mon Sep 17 00:00:00 2001
From: Zeyi Xu <mitchell.xu2 at gmail.com>
Date: Tue, 7 Jul 2026 20:04:31 +0800
Subject: [PATCH 3/3] [RISCV][MCA] Avoid deriving EMUL without SEW
---
llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp | 6 ++++++
.../RISCV/SiFiveX280/needs-sew-but-only-lmul.s | 14 ++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp b/llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp
index 1270cdd8189d9..8f8af225ce686 100644
--- a/llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp
+++ b/llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp
@@ -265,6 +265,9 @@ unsigned RISCVInstrumentManager::getSchedClassID(
std::optional<unsigned> VPOpcode;
if (const auto *VXMO = RISCV::getVXMemOpInfo(Opcode)) {
+ if (!SEW)
+ return SchedClassID;
+
// Calculate the expected index EMUL. For indexed operations,
// the DataEEW and DataEMUL are equal to SEW and LMUL, respectively.
unsigned IndexEMUL = ((1 << VXMO->Log2IdxEEW) * LMUL) / SEW;
@@ -297,6 +300,9 @@ unsigned RISCVInstrumentManager::getSchedClassID(
}
}
} else if (opcodeHasEEWAndEMULInfo(Opcode)) {
+ if (!SEW)
+ return SchedClassID;
+
RISCVVType::VLMUL VLMUL = static_cast<RISCVVType::VLMUL>(LMUL);
auto [EEW, EMUL] = getEEWAndEMUL(Opcode, VLMUL, SEW);
if (const auto *RVV =
diff --git a/llvm/test/tools/llvm-mca/RISCV/SiFiveX280/needs-sew-but-only-lmul.s b/llvm/test/tools/llvm-mca/RISCV/SiFiveX280/needs-sew-but-only-lmul.s
index 747cfca51e4dc..9fec908e73a51 100644
--- a/llvm/test/tools/llvm-mca/RISCV/SiFiveX280/needs-sew-but-only-lmul.s
+++ b/llvm/test/tools/llvm-mca/RISCV/SiFiveX280/needs-sew-but-only-lmul.s
@@ -1,12 +1,26 @@
# NOTE: Assertions have been autogenerated by utils/update_mca_test_checks.py
# RUN: llvm-mca -mtriple=riscv64 -mcpu=sifive-x280 -timeline -iterations=1 < %s | FileCheck %s
+# LLVM-MCA-BEGIN memory
+# LLVM-MCA-RISCV-LMUL M1
+vle8.v v8, (a0)
+vluxei8.v v8, (a0), v0
+# LLVM-MCA-END
+
+# LLVM-MCA-BEGIN div
# Test LMUL but no SEW falls back to worst case.
vsetvli zero, a0, e8, m1, tu, mu
# LLVM-MCA-RISCV-LMUL M1
vdiv.vv v8, v8, v12
# LLVM-MCA-RISCV-SEW E8
vdiv.vv v8, v8, v12
+# LLVM-MCA-END
+
+# CHECK: Code Region - memory
+# CHECK: Iterations: 1
+# CHECK-NEXT: Instructions: 2
+# CHECK: vle8.v v8, (a0)
+# CHECK: vluxei8.v v8, (a0), v0
# CHECK: Iterations: 1
# CHECK-NEXT: Instructions: 3
More information about the cfe-commits
mailing list