diff options
| author | Yong He <yonghe@outlook.com> | 2018-02-20 23:55:51 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-20 23:55:51 -0500 |
| commit | 01c4134d33cea3a4f98fad9248584278fd4bc452 (patch) | |
| tree | 8ca6b0f7e844fbf56cb1991284aff3ebbcc8aa89 /source/slang/emit.cpp | |
| parent | 51cdcad24b5271ac8c0f816174c6a760e264ed9e (diff) | |
| parent | 4cf46e5c8b2af8a4ea4db15cd402aae4145a614c (diff) | |
Merge pull request #417 from csyonghe/leakfix
Fix IR memory leaks.
Diffstat (limited to 'source/slang/emit.cpp')
| -rw-r--r-- | source/slang/emit.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 672798359..d2ed1c7c3 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,7 +8158,12 @@ String emitEntryPoint( // TODO: do we want to emit directly from IR, or translate the // IR back into AST for emission? visitor.emitIRModule(&context, irModule); + + // retain the specialized ir module, because the current + // GlobalGenericParamSubstitution implementation may reference ir objects + targetRequest->compileRequest->compiledModules.Add(irModule); } + destroyIRSpecializationState(irSpecializationState); String code = sharedContext.sb.ProduceString(); sharedContext.sb.Clear(); @@ -8166,8 +8171,6 @@ String emitEntryPoint( // Now that we've emitted the code for all the declaratiosn in the file, // it is time to stich together the final output. - - // There may be global-scope modifiers that we should emit now visitor.emitGLSLPreprocessorDirectives(translationUnitSyntax); String prefix = sharedContext.sb.ProduceString(); @@ -8189,7 +8192,7 @@ String emitEntryPoint( finalResultBuilder << code; String finalResult = finalResultBuilder.ProduceString(); - + return finalResult; } |
