Skip to content

Commit 331d83e

Browse files
authored
Ignore unknown SPIR-V extensions in --spirv-ext= flag (#636)
Relax the check since targets may support non-standard SPIR-V extensions. (cherry picked from commit 76e55fd)
1 parent 096af8a commit 331d83e

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
@@ -84,8 +84,11 @@ static int parseSPVExtOption(
8484
llvm::SmallVector<llvm::StringRef, 32> SPVExtList;
8585
llvm::SplitString(SPVExt, SPVExtList, ",");
8686

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

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

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

0 commit comments

Comments
 (0)