Skip to content

Commit 6de07bb

Browse files
authored
Ignore unknown SPIR-V extensions in --spirv-ext= flag (#629)
Relax the check since targets may support non-standard SPIR-V extensions. (cherry picked from commit 76e55fd)
1 parent 02dba07 commit 6de07bb

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
@@ -80,8 +80,11 @@ static int parseSPVExtOption(
8080
llvm::SmallVector<llvm::StringRef, 32> SPVExtList;
8181
llvm::SplitString(SPVExt, SPVExtList, ",");
8282

83-
if (SPVExtList.empty())
84-
return 0; // Nothing to do
83+
if (SPVExtList.empty()) {
84+
llvm::errs() << "Invalid value of --spirv-ext, expected format is:\n"
85+
<< "\t--spirv-ext=+EXT_NAME,-EXT_NAME\n";
86+
return -1;
87+
}
8588

8689
for (unsigned i = 0; i < SPVExtList.size(); ++i) {
8790
llvm::StringRef ExtString = SPVExtList[i];
@@ -106,14 +109,11 @@ static int parseSPVExtOption(
106109
for (const auto &It : ExtensionNamesMap)
107110
ExtensionsStatus[It.second] = ExtStatus;
108111
} else {
109-
// Reject unknown extensions
112+
// Ignore unknown extensions, as targets may support non-standard SPIR-V
113+
// extensions. Do not reject them; this approach is more tolerant.
110114
const auto &It = ExtensionNamesMap.find(ExtName);
111-
if (ExtensionNamesMap.end() == It) {
112-
llvm::errs() << "Unknown extension '" << ExtName
113-
<< "' was specified via "
114-
<< "--spirv-ext option\n";
115-
return -1;
116-
}
115+
if (ExtensionNamesMap.end() == It)
116+
continue;
117117

118118
ExtensionsStatus[It->second] = ExtStatus;
119119
}

0 commit comments

Comments
 (0)