summaryrefslogtreecommitdiff
path: root/source/slang/lower-to-ir.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2018-09-14 14:16:28 -0400
committerGitHub <noreply@github.com>2018-09-14 14:16:28 -0400
commit3c505c22673701339d35eb2151f01c16eb3c78c3 (patch)
treeff21543fcc846c693cbb6aba43a4e8ae9918f600 /source/slang/lower-to-ir.cpp
parente1c934972509f4bbd2c05affe565f91e7a1e6c16 (diff)
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.
Diffstat (limited to 'source/slang/lower-to-ir.cpp')
-rw-r--r--source/slang/lower-to-ir.cpp14
1 files changed, 8 insertions, 6 deletions
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<DeclLoweringVisitor, LoweredValInfo>
IRInst* irInst,
Decl* decl)
{
+ auto builder = getBuilder();
+
for (auto targetMod : decl->GetModifiersOfType<TargetIntrinsicModifier>())
{
- auto decoration = getBuilder()->addDecoration<IRTargetIntrinsicDecoration>(irInst);
- decoration->targetName = targetMod->targetToken.Content;
-
+ auto decoration = builder->addDecoration<IRTargetIntrinsicDecoration>(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<DeclLoweringVisitor, LoweredValInfo>
// target, and we need to reflect that at the IR level.
auto decoration = getBuilder()->addDecoration<IRTargetDecoration>(irFunc);
- decoration->targetName = targetMod->targetToken.Content;
+ decoration->targetName = getBuilder()->addStringToFree(targetMod->targetToken.Content);
}
// If this declaration was marked as having a target-specific lowering