From 3a3a8b5f7701109fc413f42692c4de5769870489 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 7 Dec 2022 12:02:30 -0800 Subject: Lower-to-ir no longer produce `Construct` inst. (#2553) Co-authored-by: Yong He --- source/slang/slang-ir-inline.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (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 f49b52975..36eea8c54 100644 --- a/source/slang/slang-ir-inline.cpp +++ b/source/slang/slang-ir-inline.cpp @@ -198,6 +198,9 @@ struct InliningPassBase // outCallSite.callee = calleeFunc; + if (callee->findDecoration()) + return true; + // At this point the `CallSiteInfo` is complete and // could be used for inlining, but we have additional // checks to make. @@ -239,6 +242,27 @@ struct InliningPassBase IRBuilder builder(sharedBuilder); builder.setInsertBefore(call); + // If callee is an intrinsic op, just issue that intrinsic and be done. + if (auto intrinsicOpDecor = callee->findDecoration()) + { + List args; + for (UInt i = 0; i < call->getArgCount(); i++) + args.add(call->getArg(i)); + auto op = intrinsicOpDecor->getIntrinsicOp(); + if (op == 0) + { + SLANG_RELEASE_ASSERT(call->getArgCount() >= 1); + call->replaceUsesWith(call->getArg(0)); + } + else + { + auto newCall = builder.emitIntrinsicInst(call->getFullType(), op, args.getCount(), args.getBuffer()); + call->replaceUsesWith(newCall); + } + call->removeAndDeallocate(); + return; + } + // If the callee is a generic function, then we will // need to include the substitution of generic parameters // with their argument values in our cloning. @@ -506,6 +530,8 @@ struct MandatoryEarlyInliningPass : InliningPassBase { if(info.callee->findDecoration()) return true; + if (info.callee->findDecoration()) + return true; return false; } }; @@ -618,7 +644,8 @@ struct ForceInliningPass : InliningPassBase bool shouldInline(CallSiteInfo const& info) { if (info.callee->findDecoration() || - info.callee->findDecoration()) + info.callee->findDecoration()|| + info.callee->findDecoration()) return true; return false; } -- cgit v1.2.3