mirror of
https://gitee.com/openharmony/third_party_spirv-tools
synced 2024-11-23 07:20:28 +00:00
Update access control lists. (#3433)
This CL updates the access control lists used in SPIRV-Tools to the more descriptive allow/deny naming.
This commit is contained in:
parent
30bf46dbe0
commit
52a5f074e9
@ -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;
|
||||
|
@ -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<const char*>(&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",
|
||||
|
@ -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<Instruction*> to_kill_;
|
||||
|
||||
// Extensions supported by this pass.
|
||||
std::unordered_set<std::string> extensions_whitelist_;
|
||||
std::unordered_set<std::string> extensions_allowlist_;
|
||||
};
|
||||
|
||||
} // namespace opt
|
||||
|
@ -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<const char*>(&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",
|
||||
|
@ -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<uint32_t> supported_ref_ptrs_;
|
||||
|
||||
// Extensions supported by this pass.
|
||||
std::unordered_set<std::string> extensions_whitelist_;
|
||||
std::unordered_set<std::string> extensions_allowlist_;
|
||||
};
|
||||
|
||||
} // namespace opt
|
||||
|
@ -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<const char*>(&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",
|
||||
|
@ -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<uint32_t> pinned_vars_;
|
||||
|
||||
// Extensions supported by this pass.
|
||||
std::unordered_set<std::string> extensions_whitelist_;
|
||||
std::unordered_set<std::string> extensions_allowlist_;
|
||||
|
||||
// Variables that are only referenced by supported operations for this
|
||||
// pass ie. loads and stores.
|
||||
|
@ -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<const char*>(&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",
|
||||
|
@ -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<Instruction*>& uses);
|
||||
|
||||
// Extensions supported by this pass.
|
||||
std::unordered_set<std::string> extensions_whitelist_;
|
||||
std::unordered_set<std::string> extensions_allowlist_;
|
||||
};
|
||||
|
||||
} // namespace opt
|
||||
|
@ -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;
|
||||
|
@ -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"(
|
||||
|
@ -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(
|
||||
|
@ -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, "
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user