summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-04 12:11:40 -0800
committerGitHub <noreply@github.com>2024-03-04 12:11:40 -0800
commit16342f4a6baa2e50d390c8835879fc056497aa4c (patch)
tree79eecd2bdc216c773b406c10542de07f268ba03b /source
parentf8c54056048f38369ac93b5da5b823a6f758e227 (diff)
Fix lowering logic around imported modules. (#3668)
* Fix lowering logic around imported modules. * Use actual source loc when emitting SPIRV.
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-lower-to-ir.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp
index 89fc00087..5e35bf165 100644
--- a/source/slang/slang-lower-to-ir.cpp
+++ b/source/slang/slang-lower-to-ir.cpp
@@ -656,6 +656,16 @@ bool isFromStdLib(Decl* decl)
return false;
}
+bool isDeclInDifferentModule(IRGenContext* context, Decl* decl)
+{
+ return getModuleDecl(decl) != context->getMainModuleDecl();
+}
+
+bool isForceInlineEarly(Decl* decl)
+{
+ return decl->hasModifier<UnsafeForceInlineEarlyAttribute>();
+}
+
bool isImportedDecl(IRGenContext* context, Decl* decl, bool& outIsExplicitExtern)
{
// If the declaration has the extern attribute then it must be imported
@@ -6295,7 +6305,10 @@ void maybeEmitDebugLine(IRGenContext* context, StmtLoweringVisitor& visitor, Stm
IRInst* debugSourceInst = nullptr;
if (context->shared->mapSourceFileToDebugSourceInst.tryGetValue(source, debugSourceInst))
{
- auto humaneLoc = context->getLinkage()->getSourceManager()->getHumaneLoc(stmt->loc, SourceLocType::Emit);
+ // When working with RenderDoc, we need to use actual source loc instead of the nominal one,
+ // since RenderDoc has the builtin support to split a source file into multiple files based on
+ // line directives in the file.
+ auto humaneLoc = context->getLinkage()->getSourceManager()->getHumaneLoc(stmt->loc, SourceLocType::Actual);
visitor.startBlockIfNeeded(stmt);
context->irBuilder->emitDebugLine(debugSourceInst, humaneLoc.line, humaneLoc.line, humaneLoc.column, humaneLoc.column + 1);
}
@@ -9132,6 +9145,10 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
// (although we might have to give in eventually), so
// this case should really only occur for builtin declarations.
}
+ else if (isDeclInDifferentModule(context, decl) && !isForceInlineEarly(decl))
+ {
+
+ }
else if (emitBody)
{
// This is a function definition, so we need to actually