MSL: Handle variable access in OpSelect.

CFG analysis needs to know if we need to take address of variable.
This commit is contained in:
Hans-Kristian Arntzen 2021-04-20 13:19:04 +02:00
parent 3cb8e7c223
commit 90c70e6605

View File

@ -3220,6 +3220,29 @@ bool Compiler::AnalyzeVariableScopeAccessHandler::handle(spv::Op op, const uint3
break; break;
} }
case OpSelect:
{
// In case of variable pointers, we might access a variable here.
// We cannot prove anything about these accesses however.
for (uint32_t i = 1; i < length; i++)
{
if (i >= 3)
{
auto *var = compiler.maybe_get_backing_variable(args[i]);
if (var)
{
accessed_variables_to_block[var->self].insert(current_block->self);
// Assume we can get partial writes to this variable.
partial_write_variables_to_block[var->self].insert(current_block->self);
}
}
// Might try to copy a Phi variable here.
notify_variable_access(args[i], current_block->self);
}
break;
}
case OpExtInst: case OpExtInst:
{ {
for (uint32_t i = 4; i < length; i++) for (uint32_t i = 4; i < length; i++)