[swift-dev] High-level SIL Optimization: How do I get a FuncRef from the stdlib?
rlevenstein at apple.com
Tue Nov 15 19:27:22 CST 2016
> On Nov 15, 2016, at 5:17 PM, Ben Ng via swift-dev <swift-dev at swift.org> wrote:
> Good evening, folks.
> I’ve been working on a high-level SIL optimization pass that replaces an application of the `+=` function with an application of `Array.concat(A: Element)`. I’m blocked because I can’t figure out how to get a FuncRef to `Array.append` from the SILTransform.
You could use SILModule::hasFunction(FunctionName, SILLinkage::PublicExternal) to get the SILFunction. The FunctionName should be a mangled name of your Array.concat(A:Element) function.
> I’ve tried getting the stdlib module from the ASTContext, and looking through the visible decls, but the function that I want isn’t there. The next thing I was going to try was recursively looking through the imports, but I thought I’d stop to do a sanity check with the mailing list.
> It seems like even if I did succeed in getting a FuncRef to the generic `Array.append`, I’d still need to figure out how to get the specialized version, and add the appropriate declaration to the SIL. It also feels wrong that I’m depending on stuff in the AST from a SILTransform.
You can just create the invocation of the generic version of Array.concat SILFunction (with a proper set of substitutions) and let the generic specializer produce a specialization for you.
> swift-dev mailing list
> swift-dev at swift.org
More information about the swift-dev