From 52a5f074e9bb6712487653cf360771e98a1ebe97 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Mon, 15 Jun 2020 13:20:40 -0400 Subject: [PATCH] Update access control lists. (#3433) This CL updates the access control lists used in SPIRV-Tools to the more descriptive allow/deny naming. --- source/operand.cpp | 2 +- source/opt/aggressive_dead_code_elim_pass.cpp | 10 +++++----- source/opt/aggressive_dead_code_elim_pass.h | 4 ++-- source/opt/local_access_chain_convert_pass.cpp | 10 +++++----- source/opt/local_access_chain_convert_pass.h | 4 ++-- source/opt/local_single_block_elim_pass.cpp | 10 +++++----- source/opt/local_single_block_elim_pass.h | 4 ++-- source/opt/local_single_store_elim_pass.cpp | 10 +++++----- source/opt/local_single_store_elim_pass.h | 6 +++--- test/opt/aggressive_dead_code_elim_test.cpp | 4 ++-- test/val/val_builtins_test.cpp | 6 +++--- test/val/val_decoration_test.cpp | 2 +- test/val/val_modes_test.cpp | 8 ++++---- test/val/val_webgpu_test.cpp | 4 ++-- utils/check_symbol_exports.py | 6 +++--- 15 files changed, 45 insertions(+), 45 deletions(-) diff --git a/source/operand.cpp b/source/operand.cpp index 755ad6ac7..09105958e 100644 --- a/source/operand.cpp +++ b/source/operand.cpp @@ -455,7 +455,7 @@ bool spvIsInIdType(spv_operand_type_t type) { return false; } switch (type) { - // Blacklist non-input IDs. + // Deny non-input IDs. case SPV_OPERAND_TYPE_TYPE_ID: case SPV_OPERAND_TYPE_RESULT_ID: return false; diff --git a/source/opt/aggressive_dead_code_elim_pass.cpp b/source/opt/aggressive_dead_code_elim_pass.cpp index db2b67b92..760d8e843 100644 --- a/source/opt/aggressive_dead_code_elim_pass.cpp +++ b/source/opt/aggressive_dead_code_elim_pass.cpp @@ -131,11 +131,11 @@ void AggressiveDCEPass::AddStores(uint32_t ptrId) { } bool AggressiveDCEPass::AllExtensionsSupported() const { - // If any extension not in whitelist, return false + // If any extension not in allowlist, return false for (auto& ei : get_module()->extensions()) { const char* extName = reinterpret_cast(&ei.GetInOperand(0).words[0]); - if (extensions_whitelist_.find(extName) == extensions_whitelist_.end()) + if (extensions_allowlist_.find(extName) == extensions_allowlist_.end()) return false; } return true; @@ -882,14 +882,14 @@ bool AggressiveDCEPass::ProcessGlobalValues() { AggressiveDCEPass::AggressiveDCEPass() = default; Pass::Status AggressiveDCEPass::Process() { - // Initialize extensions whitelist + // Initialize extensions allowlist InitExtensions(); return ProcessImpl(); } void AggressiveDCEPass::InitExtensions() { - extensions_whitelist_.clear(); - extensions_whitelist_.insert({ + extensions_allowlist_.clear(); + extensions_allowlist_.insert({ "SPV_AMD_shader_explicit_vertex_parameter", "SPV_AMD_shader_trinary_minmax", "SPV_AMD_gcn_shader", diff --git a/source/opt/aggressive_dead_code_elim_pass.h b/source/opt/aggressive_dead_code_elim_pass.h index c043a96f4..131e33a26 100644 --- a/source/opt/aggressive_dead_code_elim_pass.h +++ b/source/opt/aggressive_dead_code_elim_pass.h @@ -87,7 +87,7 @@ class AggressiveDCEPass : public MemPass { // to the live instruction worklist. void AddStores(uint32_t ptrId); - // Initialize extensions whitelist + // Initialize extensions allowlist void InitExtensions(); // Return true if all extensions in this module are supported by this pass. @@ -191,7 +191,7 @@ class AggressiveDCEPass : public MemPass { std::vector to_kill_; // Extensions supported by this pass. - std::unordered_set extensions_whitelist_; + std::unordered_set extensions_allowlist_; }; } // namespace opt diff --git a/source/opt/local_access_chain_convert_pass.cpp b/source/opt/local_access_chain_convert_pass.cpp index 0afe79858..05704c148 100644 --- a/source/opt/local_access_chain_convert_pass.cpp +++ b/source/opt/local_access_chain_convert_pass.cpp @@ -281,7 +281,7 @@ void LocalAccessChainConvertPass::Initialize() { // Initialize collections supported_ref_ptrs_.clear(); - // Initialize extension whitelist + // Initialize extension allowlist InitExtensions(); } @@ -292,11 +292,11 @@ bool LocalAccessChainConvertPass::AllExtensionsSupported() const { if (context()->get_feature_mgr()->HasCapability( SpvCapabilityVariablePointers)) return false; - // If any extension not in whitelist, return false + // If any extension not in allowlist, return false for (auto& ei : get_module()->extensions()) { const char* extName = reinterpret_cast(&ei.GetInOperand(0).words[0]); - if (extensions_whitelist_.find(extName) == extensions_whitelist_.end()) + if (extensions_allowlist_.find(extName) == extensions_allowlist_.end()) return false; } return true; @@ -336,8 +336,8 @@ Pass::Status LocalAccessChainConvertPass::Process() { } void LocalAccessChainConvertPass::InitExtensions() { - extensions_whitelist_.clear(); - extensions_whitelist_.insert({ + extensions_allowlist_.clear(); + extensions_allowlist_.insert({ "SPV_AMD_shader_explicit_vertex_parameter", "SPV_AMD_shader_trinary_minmax", "SPV_AMD_gcn_shader", diff --git a/source/opt/local_access_chain_convert_pass.h b/source/opt/local_access_chain_convert_pass.h index e3592bf0c..552062e52 100644 --- a/source/opt/local_access_chain_convert_pass.h +++ b/source/opt/local_access_chain_convert_pass.h @@ -110,7 +110,7 @@ class LocalAccessChainConvertPass : public MemPass { // Returns a status to indicate success or failure, and change or no change. Status ConvertLocalAccessChains(Function* func); - // Initialize extensions whitelist + // Initialize extensions allowlist void InitExtensions(); // Return true if all extensions in this module are allowed by this pass. @@ -124,7 +124,7 @@ class LocalAccessChainConvertPass : public MemPass { std::unordered_set supported_ref_ptrs_; // Extensions supported by this pass. - std::unordered_set extensions_whitelist_; + std::unordered_set extensions_allowlist_; }; } // namespace opt diff --git a/source/opt/local_single_block_elim_pass.cpp b/source/opt/local_single_block_elim_pass.cpp index b5435bb7a..401dad8e3 100644 --- a/source/opt/local_single_block_elim_pass.cpp +++ b/source/opt/local_single_block_elim_pass.cpp @@ -168,16 +168,16 @@ void LocalSingleBlockLoadStoreElimPass::Initialize() { // Clear collections supported_ref_ptrs_.clear(); - // Initialize extensions whitelist + // Initialize extensions allowlist InitExtensions(); } bool LocalSingleBlockLoadStoreElimPass::AllExtensionsSupported() const { - // If any extension not in whitelist, return false + // If any extension not in allowlist, return false for (auto& ei : get_module()->extensions()) { const char* extName = reinterpret_cast(&ei.GetInOperand(0).words[0]); - if (extensions_whitelist_.find(extName) == extensions_whitelist_.end()) + if (extensions_allowlist_.find(extName) == extensions_allowlist_.end()) return false; } return true; @@ -214,8 +214,8 @@ Pass::Status LocalSingleBlockLoadStoreElimPass::Process() { } void LocalSingleBlockLoadStoreElimPass::InitExtensions() { - extensions_whitelist_.clear(); - extensions_whitelist_.insert({ + extensions_allowlist_.clear(); + extensions_allowlist_.insert({ "SPV_AMD_shader_explicit_vertex_parameter", "SPV_AMD_shader_trinary_minmax", "SPV_AMD_gcn_shader", diff --git a/source/opt/local_single_block_elim_pass.h b/source/opt/local_single_block_elim_pass.h index 0fe7732a8..ea72816a8 100644 --- a/source/opt/local_single_block_elim_pass.h +++ b/source/opt/local_single_block_elim_pass.h @@ -63,7 +63,7 @@ class LocalSingleBlockLoadStoreElimPass : public MemPass { // where possible. Assumes logical addressing. bool LocalSingleBlockLoadStoreElim(Function* func); - // Initialize extensions whitelist + // Initialize extensions allowlist void InitExtensions(); // Return true if all extensions in this module are supported by this pass. @@ -94,7 +94,7 @@ class LocalSingleBlockLoadStoreElimPass : public MemPass { std::unordered_set pinned_vars_; // Extensions supported by this pass. - std::unordered_set extensions_whitelist_; + std::unordered_set extensions_allowlist_; // Variables that are only referenced by supported operations for this // pass ie. loads and stores. diff --git a/source/opt/local_single_store_elim_pass.cpp b/source/opt/local_single_store_elim_pass.cpp index 4c71ce1ca..3f6185347 100644 --- a/source/opt/local_single_store_elim_pass.cpp +++ b/source/opt/local_single_store_elim_pass.cpp @@ -46,11 +46,11 @@ bool LocalSingleStoreElimPass::LocalSingleStoreElim(Function* func) { } bool LocalSingleStoreElimPass::AllExtensionsSupported() const { - // If any extension not in whitelist, return false + // If any extension not in allowlist, return false for (auto& ei : get_module()->extensions()) { const char* extName = reinterpret_cast(&ei.GetInOperand(0).words[0]); - if (extensions_whitelist_.find(extName) == extensions_whitelist_.end()) + if (extensions_allowlist_.find(extName) == extensions_allowlist_.end()) return false; } return true; @@ -74,12 +74,12 @@ Pass::Status LocalSingleStoreElimPass::ProcessImpl() { LocalSingleStoreElimPass::LocalSingleStoreElimPass() = default; Pass::Status LocalSingleStoreElimPass::Process() { - InitExtensionWhiteList(); + InitExtensionAllowList(); return ProcessImpl(); } -void LocalSingleStoreElimPass::InitExtensionWhiteList() { - extensions_whitelist_.insert({ +void LocalSingleStoreElimPass::InitExtensionAllowList() { + extensions_allowlist_.insert({ "SPV_AMD_shader_explicit_vertex_parameter", "SPV_AMD_shader_trinary_minmax", "SPV_AMD_gcn_shader", diff --git a/source/opt/local_single_store_elim_pass.h b/source/opt/local_single_store_elim_pass.h index 4cf8bbb86..a7cdd1920 100644 --- a/source/opt/local_single_store_elim_pass.h +++ b/source/opt/local_single_store_elim_pass.h @@ -57,8 +57,8 @@ class LocalSingleStoreElimPass : public Pass { // any resulting dead code. bool LocalSingleStoreElim(Function* func); - // Initialize extensions whitelist - void InitExtensionWhiteList(); + // Initialize extensions allowlist + void InitExtensionAllowList(); // Return true if all extensions in this module are allowed by this pass. bool AllExtensionsSupported() const; @@ -94,7 +94,7 @@ class LocalSingleStoreElimPass : public Pass { const std::vector& uses); // Extensions supported by this pass. - std::unordered_set extensions_whitelist_; + std::unordered_set extensions_allowlist_; }; } // namespace opt diff --git a/test/opt/aggressive_dead_code_elim_test.cpp b/test/opt/aggressive_dead_code_elim_test.cpp index e7303baab..a13ccbbbe 100644 --- a/test/opt/aggressive_dead_code_elim_test.cpp +++ b/test/opt/aggressive_dead_code_elim_test.cpp @@ -413,7 +413,7 @@ OpFunctionEnd predefs1 + names_after + predefs2 + func_after, true, true); } -TEST_F(AggressiveDCETest, OptWhitelistExtension) { +TEST_F(AggressiveDCETest, OptAllowListExtension) { // #version 140 // // in vec4 BaseColor; @@ -498,7 +498,7 @@ OpFunctionEnd predefs1 + names_after + predefs2 + func_after, true, true); } -TEST_F(AggressiveDCETest, NoOptBlacklistExtension) { +TEST_F(AggressiveDCETest, NoOptDenyListExtension) { // #version 140 // // in vec4 BaseColor; diff --git a/test/val/val_builtins_test.cpp b/test/val/val_builtins_test.cpp index 58593dcf9..730986ce5 100644 --- a/test/val/val_builtins_test.cpp +++ b/test/val/val_builtins_test.cpp @@ -1952,7 +1952,7 @@ INSTANTIATE_TEST_SUITE_P( "needs to be a 32-bit int", "is not an int")))); INSTANTIATE_TEST_SUITE_P( - WhitelistRejection, + AllowListRejection, ValidateWebGPUCombineBuiltInExecutionModelDataTypeResult, Combine(Values("PointSize", "ClipDistance", "CullDistance", "VertexId", "InstanceId", "PointCoord", "SampleMask", "HelperInvocation", @@ -2979,7 +2979,7 @@ OpMemberDecorate %input_type 0 BuiltIn InstanceId TEST_F(ValidateBuiltIns, ValidBuiltinsForMeshShader) { CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator(); generator.capabilities_ += R"( -OpCapability MeshShadingNV +OpCapability MeshShadingNV )"; generator.extensions_ = R"( @@ -3017,7 +3017,7 @@ OpDecorate %gl_ViewportIndex PerPrimitiveNV TEST_F(ValidateBuiltIns, InvalidBuiltinsForMeshShader) { CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator(); generator.capabilities_ += R"( -OpCapability MeshShadingNV +OpCapability MeshShadingNV )"; generator.extensions_ = R"( diff --git a/test/val/val_decoration_test.cpp b/test/val/val_decoration_test.cpp index 204f46853..b50c4adbb 100644 --- a/test/val/val_decoration_test.cpp +++ b/test/val/val_decoration_test.cpp @@ -6353,7 +6353,7 @@ INSTANTIATE_TEST_SUITE_P( "requires one of these capabilities")))); INSTANTIATE_TEST_SUITE_P( - DecorationWhitelistFailure, ValidateWebGPUCombineDecorationResult, + DecorationAllowListFailure, ValidateWebGPUCombineDecorationResult, Combine(Values("RelaxedPrecision", "BufferBlock", "GLSLShared", "GLSLPacked", "Invariant", "Volatile", "Coherent"), Values(TestResult( diff --git a/test/val/val_modes_test.cpp b/test/val/val_modes_test.cpp index 688f43399..0a1476ee4 100644 --- a/test/val/val_modes_test.cpp +++ b/test/val/val_modes_test.cpp @@ -714,14 +714,14 @@ INSTANTIATE_TEST_SUITE_P( "SubgroupsPerWorkgroup 1", "SubgroupsPerWorkgroupId %int1"), Values(SPV_ENV_UNIVERSAL_1_3))); -INSTANTIATE_TEST_SUITE_P(ValidateModeGLComputeWebGPUWhitelistGood, +INSTANTIATE_TEST_SUITE_P(ValidateModeGLComputeWebGPUAllowListGood, ValidateModeExecution, Combine(Values(SPV_SUCCESS), Values(""), Values("GLCompute"), Values("LocalSize 1 1 1"), Values(SPV_ENV_WEBGPU_0))); INSTANTIATE_TEST_SUITE_P( - ValidateModeGLComputeWebGPUWhitelistBad, ValidateModeExecution, + ValidateModeGLComputeWebGPUAllowListBad, ValidateModeExecution, Combine(Values(SPV_ERROR_INVALID_DATA), Values("Execution mode must be one of OriginUpperLeft, " "DepthReplacing, DepthGreater, DepthLess, DepthUnchanged, " @@ -730,14 +730,14 @@ INSTANTIATE_TEST_SUITE_P( Values(SPV_ENV_WEBGPU_0))); INSTANTIATE_TEST_SUITE_P( - ValidateModeFragmentWebGPUWhitelistGood, ValidateModeExecution, + ValidateModeFragmentWebGPUAllowListGood, ValidateModeExecution, Combine(Values(SPV_SUCCESS), Values(""), Values("Fragment"), Values("OriginUpperLeft", "DepthReplacing", "DepthGreater", "DepthLess", "DepthUnchanged"), Values(SPV_ENV_WEBGPU_0))); INSTANTIATE_TEST_SUITE_P( - ValidateModeFragmentWebGPUWhitelistBad, ValidateModeExecution, + ValidateModeFragmentWebGPUAllowListBad, ValidateModeExecution, Combine(Values(SPV_ERROR_INVALID_DATA), Values("Execution mode must be one of OriginUpperLeft, " "DepthReplacing, DepthGreater, DepthLess, DepthUnchanged, " diff --git a/test/val/val_webgpu_test.cpp b/test/val/val_webgpu_test.cpp index e81fc7ce3..bca156b17 100644 --- a/test/val/val_webgpu_test.cpp +++ b/test/val/val_webgpu_test.cpp @@ -254,7 +254,7 @@ TEST_F(ValidateWebGPU, NonVulkanKHRMemoryModelBad) { "environment.\n OpMemoryModel Logical GLSL450\n")); } -TEST_F(ValidateWebGPU, WhitelistedExtendedInstructionsImportGood) { +TEST_F(ValidateWebGPU, AllowListedExtendedInstructionsImportGood) { std::string spirv = R"( OpCapability Shader OpCapability VulkanMemoryModelKHR @@ -275,7 +275,7 @@ TEST_F(ValidateWebGPU, WhitelistedExtendedInstructionsImportGood) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_WEBGPU_0)); } -TEST_F(ValidateWebGPU, NonWhitelistedExtendedInstructionsImportBad) { +TEST_F(ValidateWebGPU, NonAllowListedExtendedInstructionsImportBad) { std::string spirv = R"( OpCapability Shader OpCapability VulkanMemoryModelKHR diff --git a/utils/check_symbol_exports.py b/utils/check_symbol_exports.py index e14c2eb89..bcd77da68 100755 --- a/utils/check_symbol_exports.py +++ b/utils/check_symbol_exports.py @@ -55,11 +55,11 @@ def check_library(library): # _Z[0-9]+spv[A-Z_] : C++ symbol starting with spv[A-Z_] symbol_ok_pattern = re.compile(r'^(spv[A-Z]|_ZN|_Z[0-9]+spv[A-Z_])') - # In addition, the following pattern whitelists global functions that are added + # In addition, the following pattern allowlists global functions that are added # by the protobuf compiler: # - AddDescriptors_spvtoolsfuzz_2eproto() # - InitDefaults_spvtoolsfuzz_2eproto() - symbol_whitelist_pattern = re.compile(r'_Z[0-9]+(InitDefaults|AddDescriptors)_spvtoolsfuzz_2eprotov') + symbol_allowlist_pattern = re.compile(r'_Z[0-9]+(InitDefaults|AddDescriptors)_spvtoolsfuzz_2eprotov') seen = set() result = 0 @@ -70,7 +70,7 @@ def check_library(library): if symbol not in seen: seen.add(symbol) #print("look at '{}'".format(symbol)) - if not (symbol_whitelist_pattern.match(symbol) or symbol_ok_pattern.match(symbol)): + if not (symbol_allowlist_pattern.match(symbol) or symbol_ok_pattern.match(symbol)): print('{}: error: Unescaped exported symbol: {}'.format(PROG, symbol)) result = 1 return result