summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-emit.cpp')
-rw-r--r--source/slang/slang-emit.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp
index f724b1941..fbc99b0ce 100644
--- a/source/slang/slang-emit.cpp
+++ b/source/slang/slang-emit.cpp
@@ -78,6 +78,7 @@
#include "slang-ir-pytorch-cpp-binding.h"
#include "slang-ir-uniformity.h"
#include "slang-ir-vk-invert-y.h"
+#include "slang-ir-variable-scope-correction.h"
#include "slang-legalize-types.h"
#include "slang-lower-to-ir.h"
#include "slang-mangle.h"
@@ -1062,6 +1063,18 @@ Result linkAndOptimizeIR(
#endif
validateIRModuleIfEnabled(codeGenContext, irModule);
+ if ( (target != CodeGenTarget::SPIRV) && (target != CodeGenTarget::SPIRVAssembly) )
+ {
+ // We need to perform a final pass to ensure that all the
+ // variables in the IR module have their scopes set correctly.
+ //
+ // This is a separate pass because it needs to run after
+ // all the other optimization passes have been performed.
+
+ applyVariableScopeCorrection(irModule, targetRequest);
+ validateIRModuleIfEnabled(codeGenContext, irModule);
+ }
+
auto metadata = new ArtifactPostEmitMetadata;
outLinkedIR.metadata = metadata;