<div dir="ltr">Mark,<div><br></div><div>Thanks a lot for quick reply.</div><div> </div><div>Is there any reason this interface in SILInstruction should be private?</div><div>void setDebugScope(SILBuilder &B, const SILDebugScope *DS);<br></div><div><br></div><div>In my case, I am splicing the old F into the new function NF. While splicing retains the debug scope, the new instruction (InitRef) that I am adding to NF is being created in some random scope (not F) even though I explicitly make Builder's debug scope point to F's. </div><div><br></div><div>Best,</div><div>Raj</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 15, 2018 at 9:52 AM, Mark Lacey <span dir="ltr"><<a href="mailto:mark.lacey@apple.com" target="_blank">mark.lacey@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I’d suggest looking at SILCloner.h as well as ScopeCloner in SILBasicBlock.cpp to see how they are dealing with debug scopes.<br>
<br>
Mark<br>
<div><div class="h5"><br>
> On Jan 15, 2018, at 9:24 AM, Raj Barik via swift-dev <<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I am running into a debug scope SIL Verifier error when creating a new function (NF) from an existing one (F). Can someone point me where I am going wrong?<br>
><br>
> NF = M.createFunction(...., F->getDebugScope());<br>
> SILBasicBlock *NFBody = NF->createBasicBlock();<br>
> SILBuilder NFBuilder(NFBody);<br>
> SILOpenedArchetypesTracker OpenedArchetypesTrackerNF(NF);<br>
> NFBuilder.<wbr>setOpenedArchetypesTracker(&<wbr>OpenedArchetypesTrackerNF);<br>
> NFBuilder.<wbr>setCurrentDebugScope(NFBody-><wbr>getParent()->getDebugScope());<br>
> ...<br>
> for (auto &param : params) { /* Assume all are generic types */<br>
> auto GenericsSILType = ....<br>
> auto NewArg = NFBody-><wbr>createFunctionArgument(<wbr>GenericSILType);<br>
> auto Conformances = Mod->lookupConformance(...);<br>
> auto *InitRef = NFBuilder.<wbr>createInitExistentialRef( Loc, ArgDesc.Arg->getType(), NewArg->getType().<wbr>getSwiftRValueType()-><wbr>getCanonicalType(), NewArg, Conformances);<br>
> ...<br>
> }<br>
><br>
> The InitRef instruction created above runs into SIL verifier error:<br>
><br>
> SIL verification failed: debug scope of instruction belongs to a different function: !DS || DS->getParentFunction() == I->getFunction()<br>
> Verifying instruction:<br>
> %0 = argument of bb0 : $τ_0_0 // user: %1<br>
> -> %1 = init_existential_ref %0 : $τ_0_0 : $τ_0_0, $SomeProtocol // user: %2<br>
><br>
> The SIL looks correct to me though.<br>
><br>
> --Raj<br>
</div></div>> ______________________________<wbr>_________________<br>
> swift-dev mailing list<br>
> <a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-dev" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-dev</a><br>
<br>
</blockquote></div><br></div>