[llvm] 495f182 - [VFABI] Fix parsing of uniform parameters that shouldn't expect step or positional data.
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Wed May 27 09:14:10 PDT 2020
Author: Paul Walker
Date: 2020-05-27T16:07:45Z
New Revision: 495f18292b2bc90a162b79d187c6d14ecfbe98f9
URL: https://github.com/llvm/llvm-project/commit/495f18292b2bc90a162b79d187c6d14ecfbe98f9
DIFF: https://github.com/llvm/llvm-project/commit/495f18292b2bc90a162b79d187c6d14ecfbe98f9.diff
LOG: [VFABI] Fix parsing of uniform parameters that shouldn't expect step or positional data.
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D80575
Added:
Modified:
llvm/lib/Analysis/VFABIDemangling.cpp
llvm/unittests/Analysis/VectorFunctionABITest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/VFABIDemangling.cpp b/llvm/lib/Analysis/VFABIDemangling.cpp
index a975e0ff493a..0192a216b2f7 100644
--- a/llvm/lib/Analysis/VFABIDemangling.cpp
+++ b/llvm/lib/Analysis/VFABIDemangling.cpp
@@ -214,28 +214,6 @@ ParseRet tryParseLinearWithCompileTimeStep(StringRef &ParseString,
return ParseRet::None;
}
-/// The function looks for the following strings at the beginning of
-/// the input string `ParseString`:
-///
-/// "u" <number>
-///
-/// On success, it removes the parsed parameter from `ParseString`,
-/// sets `PKind` to the correspondent enum value, sets `Pos` to
-/// <number>, and return success. On a syntax error, it return a
-/// parsing error. If nothing is parsed, it returns None.
-ParseRet tryParseUniform(StringRef &ParseString, VFParamKind &PKind, int &Pos) {
- // "u" <Pos>
- const char *UniformToken = "u";
- if (ParseString.consume_front(UniformToken)) {
- PKind = VFABI::getVFParamKindFromString(UniformToken);
- if (ParseString.consumeInteger(10, Pos))
- return ParseRet::Error;
-
- return ParseRet::OK;
- }
- return ParseRet::None;
-}
-
/// Looks into the <parameters> part of the mangled name in search
/// for valid paramaters at the beginning of the string
/// `ParseString`.
@@ -252,6 +230,12 @@ ParseRet tryParseParameter(StringRef &ParseString, VFParamKind &PKind,
return ParseRet::OK;
}
+ if (ParseString.consume_front("u")) {
+ PKind = VFParamKind::OMP_Uniform;
+ StepOrPos = 0;
+ return ParseRet::OK;
+ }
+
const ParseRet HasLinearRuntime =
tryParseLinearWithRuntimeStep(ParseString, PKind, StepOrPos);
if (HasLinearRuntime != ParseRet::None)
@@ -262,10 +246,6 @@ ParseRet tryParseParameter(StringRef &ParseString, VFParamKind &PKind,
if (HasLinearCompileTime != ParseRet::None)
return HasLinearCompileTime;
- const ParseRet HasUniform = tryParseUniform(ParseString, PKind, StepOrPos);
- if (HasUniform != ParseRet::None)
- return HasUniform;
-
return ParseRet::None;
}
diff --git a/llvm/unittests/Analysis/VectorFunctionABITest.cpp b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
index cc6dbe84c09f..6668529f49e0 100644
--- a/llvm/unittests/Analysis/VectorFunctionABITest.cpp
+++ b/llvm/unittests/Analysis/VectorFunctionABITest.cpp
@@ -326,7 +326,7 @@ TEST_F(VFABIParserTest, Align) {
}
TEST_F(VFABIParserTest, ParseUniform) {
- EXPECT_TRUE(invokeParser("_ZGVnN2u0_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVnN2u_sin"));
EXPECT_EQ(VF, (unsigned)2);
EXPECT_FALSE(IsMasked());
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
@@ -334,10 +334,10 @@ TEST_F(VFABIParserTest, ParseUniform) {
EXPECT_EQ(Parameters.size(), (unsigned)1);
EXPECT_EQ(Parameters[0], VFParameter({0, VFParamKind::OMP_Uniform, 0}));
EXPECT_EQ(ScalarName, "sin");
- EXPECT_EQ(VectorName, "_ZGVnN2u0_sin");
+ EXPECT_EQ(VectorName, "_ZGVnN2u_sin");
- EXPECT_FALSE(invokeParser("_ZGVnN2u_sin"));
- EXPECT_FALSE(invokeParser("_ZGVnN2ul_sin"));
+ // Uniform doesn't expect extra data.
+ EXPECT_FALSE(invokeParser("_ZGVnN2u0_sin"));
}
TEST_F(VFABIParserTest, ISAIndependentMangling) {
@@ -353,7 +353,7 @@ TEST_F(VFABIParserTest, ISAIndependentMangling) {
VFParameter({6, VFParamKind::OMP_LinearVal, 10}),
VFParameter({7, VFParamKind::OMP_LinearUVal, 100}),
VFParameter({8, VFParamKind::OMP_LinearRef, 1000}),
- VFParameter({9, VFParamKind::OMP_Uniform, 2}),
+ VFParameter({9, VFParamKind::OMP_Uniform, 0}),
};
#define __COMMON_CHECKS \
@@ -367,54 +367,54 @@ TEST_F(VFABIParserTest, ISAIndependentMangling) {
} while (0)
// Advanced SIMD: <isa> = "n"
- EXPECT_TRUE(invokeParser("_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000u2_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000u_sin"));
EXPECT_EQ(ISA, VFISAKind::AdvancedSIMD);
__COMMON_CHECKS;
- EXPECT_EQ(VectorName, "_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000u2_sin");
+ EXPECT_EQ(VectorName, "_ZGVnN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// SVE: <isa> = "s"
- EXPECT_TRUE(invokeParser("_ZGVsN2vls2Ls27Us4Rs5l1L10U100R1000u2_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVsN2vls2Ls27Us4Rs5l1L10U100R1000u_sin"));
EXPECT_EQ(ISA, VFISAKind::SVE);
__COMMON_CHECKS;
- EXPECT_EQ(VectorName, "_ZGVsN2vls2Ls27Us4Rs5l1L10U100R1000u2_sin");
+ EXPECT_EQ(VectorName, "_ZGVsN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// SSE: <isa> = "b"
- EXPECT_TRUE(invokeParser("_ZGVbN2vls2Ls27Us4Rs5l1L10U100R1000u2_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVbN2vls2Ls27Us4Rs5l1L10U100R1000u_sin"));
EXPECT_EQ(ISA, VFISAKind::SSE);
__COMMON_CHECKS;
- EXPECT_EQ(VectorName, "_ZGVbN2vls2Ls27Us4Rs5l1L10U100R1000u2_sin");
+ EXPECT_EQ(VectorName, "_ZGVbN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// AVX: <isa> = "c"
- EXPECT_TRUE(invokeParser("_ZGVcN2vls2Ls27Us4Rs5l1L10U100R1000u2_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVcN2vls2Ls27Us4Rs5l1L10U100R1000u_sin"));
EXPECT_EQ(ISA, VFISAKind::AVX);
__COMMON_CHECKS;
- EXPECT_EQ(VectorName, "_ZGVcN2vls2Ls27Us4Rs5l1L10U100R1000u2_sin");
+ EXPECT_EQ(VectorName, "_ZGVcN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// AVX2: <isa> = "d"
- EXPECT_TRUE(invokeParser("_ZGVdN2vls2Ls27Us4Rs5l1L10U100R1000u2_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVdN2vls2Ls27Us4Rs5l1L10U100R1000u_sin"));
EXPECT_EQ(ISA, VFISAKind::AVX2);
__COMMON_CHECKS;
- EXPECT_EQ(VectorName, "_ZGVdN2vls2Ls27Us4Rs5l1L10U100R1000u2_sin");
+ EXPECT_EQ(VectorName, "_ZGVdN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// AVX512: <isa> = "e"
- EXPECT_TRUE(invokeParser("_ZGVeN2vls2Ls27Us4Rs5l1L10U100R1000u2_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVeN2vls2Ls27Us4Rs5l1L10U100R1000u_sin"));
EXPECT_EQ(ISA, VFISAKind::AVX512);
__COMMON_CHECKS;
- EXPECT_EQ(VectorName, "_ZGVeN2vls2Ls27Us4Rs5l1L10U100R1000u2_sin");
+ EXPECT_EQ(VectorName, "_ZGVeN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
// LLVM: <isa> = "_LLVM_" internal vector function.
EXPECT_TRUE(invokeParser(
- "_ZGV_LLVM_N2vls2Ls27Us4Rs5l1L10U100R1000u2_sin(vectorf)", "vectorf"));
+ "_ZGV_LLVM_N2vls2Ls27Us4Rs5l1L10U100R1000u_sin(vectorf)", "vectorf"));
EXPECT_EQ(ISA, VFISAKind::LLVM);
__COMMON_CHECKS;
EXPECT_EQ(VectorName, "vectorf");
// Unknown ISA (randomly using "q"). This test will need update if
// some targets decide to use "q" as their ISA token.
- EXPECT_TRUE(invokeParser("_ZGVqN2vls2Ls27Us4Rs5l1L10U100R1000u2_sin"));
+ EXPECT_TRUE(invokeParser("_ZGVqN2vls2Ls27Us4Rs5l1L10U100R1000u_sin"));
EXPECT_EQ(ISA, VFISAKind::Unknown);
__COMMON_CHECKS;
- EXPECT_EQ(VectorName, "_ZGVqN2vls2Ls27Us4Rs5l1L10U100R1000u2_sin");
+ EXPECT_EQ(VectorName, "_ZGVqN2vls2Ls27Us4Rs5l1L10U100R1000u_sin");
#undef __COMMON_CHECKS
}
More information about the llvm-commits
mailing list