summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2018-05-10 20:28:39 -0700
committerTim Foley <tfoley@nvidia.com>2018-05-10 20:28:39 -0700
commit4e07e22f5d6b62481108f620d28c24e480dfff7a (patch)
treed8cd92fb4727955f01e945701998b4d480dca507 /source
parent140e51e8f9f3b966372efef112f00aa931dd0ca5 (diff)
Workaround for cases where we emit illegal-but-unused types
This is a quick workaround to deal with cases where we try to emit an unreferenced IR type that contains references to pre-legalization types (which might have been removed from the IR even thought they are still referenced). The basic fix is to *not* add types to our global order of instructions to emit by default, and only add them on demand as they are referenced by other instructions. This is not a real fix for the underlying issue, which is that type legalization is only being applied to a subset of global instructions instead of all of them. A more detailed fix for that problem will need to be devised next. This fix also doesn't address the question of why an unreferenced `struct` type came to be present in the IR code passed to the back-end in the first place. It would be good to understand how this scenario is arising.
Diffstat (limited to 'source')
-rw-r--r--source/slang/emit.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index 9874e3ef3..bf7fceb0e 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -5701,6 +5701,12 @@ struct EmitVisitor
for(auto inst : module->getGlobalInsts())
{
+ if( as<IRType>(inst) )
+ {
+ // Don't emit a type unless it is actually used.
+ continue;
+ }
+
ensureGlobalInst(&ctx, inst, EmitAction::Level::Definition);
}
}