From 3c505c22673701339d35eb2151f01c16eb3c78c3 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 14 Sep 2018 14:16:28 -0400 Subject: Improvements around IR representation and memory usage (#635) * * Remove dispose from IRInst * Use MemoryArena instead of MemoryPool * Make all IRInst not require Dtor - by having ref counted array store ptrs that need freeing * Increase block size - typically compilation is 2Mb of IR space(!) * Fix issues around StringRepresentation::equal because null has special meaning. * Don't bother to construct as String to compare StringRepresentation, just used UnownedStringSlice. * Added fromLiteral support to UnownedStringSlice and use instead of strlen version. * Use more conventional way to test StringRepresentation against a String. * Fix gcc/clang template problem with cast. --- source/slang/lower-to-ir.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'source/slang/lower-to-ir.cpp') diff --git a/source/slang/lower-to-ir.cpp b/source/slang/lower-to-ir.cpp index 280b89fb8..d57872fc9 100644 --- a/source/slang/lower-to-ir.cpp +++ b/source/slang/lower-to-ir.cpp @@ -4549,19 +4549,21 @@ struct DeclLoweringVisitor : DeclVisitor IRInst* irInst, Decl* decl) { + auto builder = getBuilder(); + for (auto targetMod : decl->GetModifiersOfType()) { - auto decoration = getBuilder()->addDecoration(irInst); - decoration->targetName = targetMod->targetToken.Content; - + auto decoration = builder->addDecoration(irInst); + decoration->targetName = builder->addStringToFree(targetMod->targetToken.Content); + auto definitionToken = targetMod->definitionToken; if (definitionToken.type == TokenType::StringLiteral) { - decoration->definition = getStringLiteralTokenValue(definitionToken); + decoration->definition = builder->addStringToFree(getStringLiteralTokenValue(definitionToken)); } else { - decoration->definition = definitionToken.Content; + decoration->definition = builder->addStringToFree(definitionToken.Content); } } } @@ -4900,7 +4902,7 @@ struct DeclLoweringVisitor : DeclVisitor // target, and we need to reflect that at the IR level. auto decoration = getBuilder()->addDecoration(irFunc); - decoration->targetName = targetMod->targetToken.Content; + decoration->targetName = getBuilder()->addStringToFree(targetMod->targetToken.Content); } // If this declaration was marked as having a target-specific lowering -- cgit v1.2.3