From f647e32659b58dbb63b8aa1e5efab40a4b3ff253 Mon Sep 17 00:00:00 2001 From: Polona Caserman Date: Mon, 16 Jan 2017 09:44:40 +0100 Subject: [PATCH] Add vars declared in the main to the functions --- spirv_msl.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/spirv_msl.cpp b/spirv_msl.cpp index 0ab34600..fa2dfbcf 100644 --- a/spirv_msl.cpp +++ b/spirv_msl.cpp @@ -137,8 +137,7 @@ void CompilerMSL::localize_global_variables() if (gbl_var.storage == StorageClassPrivate) { entry_func.add_local_variable(gv_id); - //iter = global_variables.erase(iter); - iter++; + iter = global_variables.erase(iter); } else iter++; @@ -164,6 +163,17 @@ void CompilerMSL::extract_global_variables_from_functions() } } } + + // Local vars that are declared in the main function and accessed directy by a function + auto &entry_func = get(entry_point); + auto iter = entry_func.local_variables.begin(); + while (iter != entry_func.local_variables.end()) + { + uint32_t gv_id = *iter; + auto &gbl_var = get(gv_id); + global_var_ids.insert(gbl_var.self); + iter++; + } std::unordered_set added_arg_ids; std::unordered_set processed_func_ids;