Skip to content

Commit 88ddfd2

Browse files
authored
Ignore unknown SPIR-V extensions in --spirv-ext= flag (#632)
Relax the check since targets may support non-standard SPIR-V extensions. (cherry picked from commit 76e55fd)
1 parent b447a7b commit 88ddfd2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

options_compile.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ static int parseSPVExtOption(
8585
llvm::SmallVector<llvm::StringRef, 32> SPVExtList;
8686
llvm::SplitString(SPVExt, SPVExtList, ",");
8787

88-
if (SPVExtList.empty())
89-
return 0; // Nothing to do
88+
if (SPVExtList.empty()) {
89+
llvm::errs() << "Invalid value of --spirv-ext, expected format is:\n"
90+
<< "\t--spirv-ext=+EXT_NAME,-EXT_NAME\n";
91+
return -1;
92+
}
9093

9194
for (unsigned i = 0; i < SPVExtList.size(); ++i) {
9295
llvm::StringRef ExtString = SPVExtList[i];
@@ -111,14 +114,11 @@ static int parseSPVExtOption(
111114
for (const auto &It : ExtensionNamesMap)
112115
ExtensionsStatus[It.second] = ExtStatus;
113116
} else {
114-
// Reject unknown extensions
117+
// Ignore unknown extensions, as targets may support non-standard SPIR-V
118+
// extensions. Do not reject them; this approach is more tolerant.
115119
const auto &It = ExtensionNamesMap.find(ExtName);
116-
if (ExtensionNamesMap.end() == It) {
117-
llvm::errs() << "Unknown extension '" << ExtName
118-
<< "' was specified via "
119-
<< "--spirv-ext option\n";
120-
return -1;
121-
}
120+
if (ExtensionNamesMap.end() == It)
121+
continue;
122122

123123
ExtensionsStatus[It->second] = ExtStatus;
124124
}

0 commit comments

Comments
 (0)