summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ir-inst-defs.h3
-rw-r--r--source/slang/slang-ir-insts.h1
-rw-r--r--source/slang/slang-ir-link.cpp16
-rw-r--r--source/slang/slang-lower-to-ir.cpp4
4 files changed, 23 insertions, 1 deletions
diff --git a/source/slang/slang-ir-inst-defs.h b/source/slang/slang-ir-inst-defs.h
index 85c489528..5a96fd8e8 100644
--- a/source/slang/slang-ir-inst-defs.h
+++ b/source/slang/slang-ir-inst-defs.h
@@ -474,7 +474,8 @@ INST(HighLevelDeclDecoration, highLevelDecl, 1, 0)
INST(VulkanCallablePayloadDecoration, vulkanCallablePayload, 0, 0)
INST(EarlyDepthStencilDecoration, earlyDepthStencil, 0, 0)
INST(GloballyCoherentDecoration, globallyCoherent, 0, 0)
- INST(PreciseDecoration, precise, 0, 0)
+ INST(PreciseDecoration, precise, 0, 0)
+ INST(PublicDecoration, public, 0, 0)
INST(PatchConstantFuncDecoration, patchConstantFunc, 1, 0)
INST(OutputControlPointsDecoration, outputControlPoints, 1, 0)
diff --git a/source/slang/slang-ir-insts.h b/source/slang/slang-ir-insts.h
index c74dfb4ea..159021412 100644
--- a/source/slang/slang-ir-insts.h
+++ b/source/slang/slang-ir-insts.h
@@ -220,6 +220,7 @@ IR_SIMPLE_DECORATION(ReadNoneDecoration)
IR_SIMPLE_DECORATION(EarlyDepthStencilDecoration)
IR_SIMPLE_DECORATION(GloballyCoherentDecoration)
IR_SIMPLE_DECORATION(PreciseDecoration)
+IR_SIMPLE_DECORATION(PublicDecoration)
struct IROutputControlPointsDecoration : IRDecoration
diff --git a/source/slang/slang-ir-link.cpp b/source/slang/slang-ir-link.cpp
index 7acdac40b..3935eab07 100644
--- a/source/slang/slang-ir-link.cpp
+++ b/source/slang/slang-ir-link.cpp
@@ -1479,6 +1479,22 @@ LinkedIR linkIR(
}
}
+ for (IRModule* irModule : irModules)
+ {
+ for (auto inst : irModule->getGlobalInsts())
+ {
+ auto hasPublic = inst->findDecoration<IRPublicDecoration>();
+ if (!hasPublic)
+ continue;
+
+ auto cloned = cloneValue(context, inst);
+ if (!cloned->findDecorationImpl(kIROp_KeepAliveDecoration))
+ {
+ context->builder->addKeepAliveDecoration(cloned);
+ }
+ }
+ }
+
// TODO: *technically* we should consider the case where
// we have global variables with initializers, since
// these should get run whether or not the entry point
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp
index d14fbfed5..1ba99dffb 100644
--- a/source/slang/slang-lower-to-ir.cpp
+++ b/source/slang/slang-lower-to-ir.cpp
@@ -6716,6 +6716,10 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
getBuilder()->addRequireCUDASMVersionDecoration(irFunc, versionMod->version);
}
+ if (decl->findModifier<PublicModifier>()) {
+ getBuilder()->addSimpleDecoration<IRPublicDecoration>(irFunc);
+ }
+
if (auto attr = decl->findModifier<InstanceAttribute>())
{
IRIntLit* intLit = _getIntLitFromAttribute(getBuilder(), attr);