summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-inline.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-07-11 16:54:43 -0700
committerGitHub <noreply@github.com>2025-07-11 23:54:43 +0000
commit1e1a49ccf595dcc99bd9792a47199ec89d5b4370 (patch)
tree199dca9cc2c5f27466ebd8b6e9e6fcd8328db9fa /source/slang/slang-ir-inline.cpp
parentd8d0b8969f731990820f25812f3d90ee4dd1ee75 (diff)
Fixup address spaces after inlining. (#7731)
* Fixup address spaces after inlining. * add -O0
Diffstat (limited to 'source/slang/slang-ir-inline.cpp')
-rw-r--r--source/slang/slang-ir-inline.cpp31
1 files changed, 23 insertions, 8 deletions
diff --git a/source/slang/slang-ir-inline.cpp b/source/slang/slang-ir-inline.cpp
index 9e522081f..f0f940b12 100644
--- a/source/slang/slang-ir-inline.cpp
+++ b/source/slang/slang-ir-inline.cpp
@@ -2,6 +2,7 @@
#include "slang-ir-inline.h"
#include "../core/slang-performance-profiler.h"
+#include "slang-ir-specialize-address-space.h"
#include "slang-ir-ssa-simplification.h"
#include "slang-ir-util.h"
@@ -727,6 +728,16 @@ struct InliningPassBase
auto debugInlineInfo = emitCalleeDebugInlinedAt(call, callee, *builder);
+ // Collect all arguments that are pointers, so we can propagate their address
+ // spaces to the cloned instructions after inlining.
+ List<IRInst*> ptrArgList;
+ for (UInt i = 0; i < call->getArgCount(); i++)
+ {
+ auto arg = call->getArg(i);
+ if (as<IRPtrTypeBase>(arg->getDataType()))
+ ptrArgList.add(arg);
+ }
+
// If the callee consists of a single basic block *and* that block
// ends with a `return` instruction, then we can apply a simple approach
// to inlining that is compatible with any call site (including those
@@ -742,16 +753,20 @@ struct InliningPassBase
builder,
debugInlineInfo.newDebugInlinedAt,
debugInlineInfo.calleeDebugFunc);
- return;
+ }
+ else
+ {
+ // If the callee has multiple blocks, use the more complex inlining approach
+ inlineMultipleBlockFuncBody(
+ callSite,
+ env,
+ builder,
+ debugInlineInfo.newDebugInlinedAt,
+ debugInlineInfo.calleeDebugFunc);
}
- // If the callee has multiple blocks, use the more complex inlining approach
- inlineMultipleBlockFuncBody(
- callSite,
- env,
- builder,
- debugInlineInfo.newDebugInlinedAt,
- debugInlineInfo.calleeDebugFunc);
+ // Propagate the address space from the argument to the cloned instructions.
+ propagateAddressSpaceFromInsts(_Move(ptrArgList));
}
// Inline the body of the callee for `callSite`, for a callee that has multiple basic blocks.