summaryrefslogtreecommitdiffstats
path: root/source/slang/emit.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2018-02-19 19:53:45 -0500
committerYong He <yonghe@outlook.com>2018-02-19 19:53:45 -0500
commit5de62bbe4dddc64895ddb17c4eb3572c3c9be248 (patch)
treed12fd2a9bad9a632430e1262de8f7e7da388bffa /source/slang/emit.cpp
parentff8adf7b45121aada0b4f4403b0f45a6e2dfe475 (diff)
more to fixing memory leaks
1. reorder destruction order of several key classes to avoid using deleted IR objects when destroying Types 2. remove Session::canonicalTypes and make each Type own a RefPtr to the canonicalType, to allow types to be destroyed along with each IRModule it belongs to.
Diffstat (limited to 'source/slang/emit.cpp')
-rw-r--r--source/slang/emit.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index b8fbc350e..46c0b20a9 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -8084,17 +8084,17 @@ String emitEntryPoint(
EmitVisitor visitor(&context);
+ // We are going to create a fresh IR module that we will use to
+ // clone any code needed by the user's entry point.
+ IRSpecializationState* irSpecializationState = createIRSpecializationState(
+ entryPoint,
+ programLayout,
+ target,
+ targetRequest);
{
TypeLegalizationContext typeLegalizationContext;
typeLegalizationContext.session = entryPoint->compileRequest->mSession;
- // We are going to create a fresh IR module that we will use to
- // clone any code needed by the user's entry point.
- IRSpecializationState* irSpecializationState = createIRSpecializationState(
- entryPoint,
- programLayout,
- target,
- targetRequest);
IRModule* irModule = getIRModule(irSpecializationState);
typeLegalizationContext.irModule = irModule;
@@ -8158,8 +8158,8 @@ String emitEntryPoint(
// TODO: do we want to emit directly from IR, or translate the
// IR back into AST for emission?
visitor.emitIRModule(&context, irModule);
- destroyIRSpecializationState(irSpecializationState);
}
+ destroyIRSpecializationState(irSpecializationState);
String code = sharedContext.sb.ProduceString();
sharedContext.sb.Clear();