[llvm] af602ed - [RISCV] Make RISCVISAInfo::toFeatureVector ignore unsupported extensions
Alex Bradbury via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 26 07:52:17 PDT 2023
Author: Alex Bradbury
Date: 2023-03-26T15:51:38+01:00
New Revision: af602edf0ecb4e1d7de4ccce8ebe1be8bb53443d
URL: https://github.com/llvm/llvm-project/commit/af602edf0ecb4e1d7de4ccce8ebe1be8bb53443d
DIFF: https://github.com/llvm/llvm-project/commit/af602edf0ecb4e1d7de4ccce8ebe1be8bb53443d.diff
LOG: [RISCV] Make RISCVISAInfo::toFeatureVector ignore unsupported extensions
parseNormalizedArchString adds a code path that creates a RISCVISAInfo
including extensions that may not be supported by LLVM (rather than
erroring or just ignoring them). Therefore, toFeatureVector needs to
check the extension is supported in order to avoid creating unrecognised
feature strings.
This change shouldn't impact any code paths used outside of test code,
but this will be relied upon by the next patch which moves llvm-objdump
and related tools over to using parseNormalizedArchString.
Differential Revision: https://reviews.llvm.org/D146113
Added:
Modified:
llvm/lib/Support/RISCVISAInfo.cpp
llvm/unittests/Support/RISCVISAInfoTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp
index 2ad5a3cd5a565..994fba36b13c6 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -1101,6 +1101,8 @@ std::vector<std::string> RISCVISAInfo::toFeatureVector() const {
std::string ExtName = Ext.first;
if (ExtName == "i") // i is not recognized in clang -cc1
continue;
+ if (!isSupportedExtension(ExtName))
+ continue;
std::string Feature = isExperimentalExtension(ExtName)
? "+experimental-" + ExtName
: "+" + ExtName;
diff --git a/llvm/unittests/Support/RISCVISAInfoTest.cpp b/llvm/unittests/Support/RISCVISAInfoTest.cpp
index 05997d2d2d2c4..27b00709f2bb5 100644
--- a/llvm/unittests/Support/RISCVISAInfoTest.cpp
+++ b/llvm/unittests/Support/RISCVISAInfoTest.cpp
@@ -446,3 +446,10 @@ TEST(ToFeatureVector, IIsDroppedAndExperimentalExtensionsArePrefixed) {
EXPECT_THAT((*MaybeISAInfo2)->toFeatureVector(),
ElementsAre("+e", "+experimental-zihintntl", "+xventanacondops"));
}
+
+TEST(ToFeatureVector, UnsupportedExtensionsAreDropped) {
+ auto MaybeISAInfo =
+ RISCVISAInfo::parseNormalizedArchString("rv64i2p0_m2p0_xmadeup1p0");
+ ASSERT_THAT_EXPECTED(MaybeISAInfo, Succeeded());
+ EXPECT_THAT((*MaybeISAInfo)->toFeatureVector(), ElementsAre("+m"));
+}
More information about the llvm-commits
mailing list