From c787c4b82ba76f87069911f203eb192060b5264f Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 28 Aug 2023 21:24:49 -0700 Subject: Add `target_switch` and `intrinsic_asm` statement. (#3154) * Add `target_switch` and `__intrinsic_asm` statement. * Cleanup. * WaveGetActiveMask, WaveGetActiveMask, WaveCountBits. * WaveIsFirstLane. * More wave intrinsics. * wave intrinsics. * merge fix. * Fix. * Fix. * Update test. * update test. * Fix. --------- Co-authored-by: Yong He --- source/slang/slang-ir-inline.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-ir-inline.cpp') diff --git a/source/slang/slang-ir-inline.cpp b/source/slang/slang-ir-inline.cpp index df245f555..f3fa213da 100644 --- a/source/slang/slang-ir-inline.cpp +++ b/source/slang/slang-ir-inline.cpp @@ -654,6 +654,19 @@ struct InliningPassBase }; +static bool hasGenericAsmInst(IRInst* func) +{ + auto f = as(getResolvedInstForDecorations(func)); + if (!f) + return false; + for (auto b : f->getBlocks()) + { + if (as(b->getTerminator())) + return true; + } + return false; +} + /// An inlining pass that inlines calls to `[unsafeForceInlineEarly]` functions struct MandatoryEarlyInliningPass : InliningPassBase { @@ -665,10 +678,15 @@ struct MandatoryEarlyInliningPass : InliningPassBase bool shouldInline(CallSiteInfo const& info) { - if(info.callee->findDecoration()) - return true; if (info.callee->findDecoration()) return true; + + // Never inline a callee that has genericASM instruction. + if (hasGenericAsmInst(info.callee)) + return false; + + if(info.callee->findDecoration()) + return true; return false; } }; @@ -782,6 +800,10 @@ struct ForceInliningPass : InliningPassBase bool shouldInline(CallSiteInfo const& info) { + // Never inline a callee that has genericASM instruction. + if (hasGenericAsmInst(info.callee)) + return false; + if (info.callee->findDecoration() || info.callee->findDecoration()|| info.callee->findDecoration()) -- cgit v1.2.3