Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Cross.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Kristian Arntzen <post@arntzen-software.no>2021-07-29 16:24:28 +0300
committerHans-Kristian Arntzen <post@arntzen-software.no>2021-07-29 16:27:52 +0300
commitcb613eb675c673c638ce1a0f1ef1a47b4eac72e7 (patch)
tree726f949b43af307dd9bd759ad7948cedd9f82a68 /spirv_cross.cpp
parent1964799fba06abcbad2ff684cba360f0067c34a2 (diff)
Handle value access in terminators.
Fixes case where value is created inside loop body and consumed by a return outside it.
Diffstat (limited to 'spirv_cross.cpp')
-rw-r--r--spirv_cross.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/spirv_cross.cpp b/spirv_cross.cpp
index 4fcd969a..d053aac8 100644
--- a/spirv_cross.cpp
+++ b/spirv_cross.cpp
@@ -1659,6 +1659,9 @@ bool Compiler::traverse_all_reachable_opcodes(const SPIRBlock &block, OpcodeHand
}
}
+ if (!handler.handle_terminator(block))
+ return false;
+
return true;
}
@@ -3055,6 +3058,27 @@ bool Compiler::AnalyzeVariableScopeAccessHandler::id_is_potential_temporary(uint
return compiler.ir.ids[id].empty() || (compiler.ir.ids[id].get_type() == TypeExpression);
}
+bool Compiler::AnalyzeVariableScopeAccessHandler::handle_terminator(const SPIRBlock &block)
+{
+ switch (block.terminator)
+ {
+ case SPIRBlock::Return:
+ if (block.return_value)
+ notify_variable_access(block.return_value, block.self);
+ break;
+
+ case SPIRBlock::Select:
+ case SPIRBlock::MultiSelect:
+ notify_variable_access(block.condition, block.self);
+ break;
+
+ default:
+ break;
+ }
+
+ return true;
+}
+
bool Compiler::AnalyzeVariableScopeAccessHandler::handle(spv::Op op, const uint32_t *args, uint32_t length)
{
// Keep track of the types of temporaries, so we can hoist them out as necessary.