Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

using namespace llvm;

std::set<SPIRV::Extension::Extension> SPIRVExtensionsParser::DisabledExtensions;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need to be ordered? Would unordered_set be good enough?

@sarnex sarnex Feb 26, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same thought, but I just copied the type of the existing extensions map which is ordered. I can try changing them both to unordered if you're prefer (which makes more sense to me tbh) but I think the types should match at least

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind to change orderness later (assuming we have a github issue)

@sarnex sarnex Feb 26, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to change the order basically immediately after merging this PR, if approved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that works for me.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will do it now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


static const std::map<StringRef, SPIRV::Extension::Extension>
SPIRVExtensionMap = {
{"SPV_EXT_shader_atomic_float_add",
Expand Down Expand Up @@ -231,7 +233,7 @@ bool SPIRVExtensionsParser::parse(cl::Option &O, StringRef ArgName,
return O.error(
"Extension cannot be allowed and disallowed at the same time: " +
NameValuePair->first);

DisabledExtensions.insert(NameValuePair->second);
Vals.erase(NameValuePair->second);
}

Expand Down Expand Up @@ -270,7 +272,8 @@ SPIRVExtensionsParser::getValidExtensions(const Triple &TT) {
SPIRV::OperandCategory::OperandCategory::ExtensionOperand,
ExtensionEnum);

if (llvm::is_contained(AllowedEnv, CurrentEnvironment))
if (llvm::is_contained(AllowedEnv, CurrentEnvironment) &&
!llvm::is_contained(DisabledExtensions, ExtensionEnum))
R.insert(ExtensionEnum);
}

Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/Target/SPIRV/SPIRVCommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ struct SPIRVExtensionsParser
/// target environment (i.e., OpenCL or Vulkan).
static std::set<SPIRV::Extension::Extension>
getValidExtensions(const Triple &TT);

private:
static std::set<SPIRV::Extension::Extension> DisabledExtensions;
};

} // namespace llvm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=+SPV_EXT_relaxed_printf_string_address_space %s -o - | FileCheck %s
; RUN: llc -O0 -mtriple=spirv32-intel-unknown %s -o - | FileCheck %s
; RUN: not llc -O0 -mtriple=spirv32-unknown-unknown %s -o %t.spvt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
; RUN: not llc -O0 -mtriple=spirv32-intel-unknown --spirv-ext=-SPV_EXT_relaxed_printf_string_address_space %s -o %t.spvt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
; RUN: not llc -O0 -mtriple=spirv32-intel-unknown --spirv-ext=all,-SPV_EXT_relaxed_printf_string_address_space %s -o %t.spvt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
; RUN: not llc -O0 -mtriple=spirv32-intel-unknown --spirv-ext=-SPV_EXT_relaxed_printf_string_address_space,all %s -o %t.spvt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR

; CHECK: OpExtension "SPV_EXT_relaxed_printf_string_address_space"
; CHECK: %[[#ExtInstSetId:]] = OpExtInstImport "OpenCL.std"
Expand Down