<div dir="ltr">Thanks Mark. You are right, the following assertion fails<div><br></div><div><div>require(!DS || DS->getParentFunction() == I->getFunction(),</div><div> "debug scope of instruction belongs to a different function");</div></div><div><br></div><div>I am not sure if we need such a check. </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 15, 2018 at 4:16 PM, 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"><div style="word-wrap:break-word;line-break:after-white-space"><br><div><span class=""><br><blockquote type="cite"><div>On Jan 15, 2018, at 12:54 PM, Raj Barik <<a href="mailto:rkbarik@gmail.com" target="_blank">rkbarik@gmail.com</a>> wrote:</div><br class="m_3833984575572660261Apple-interchange-newline"><div><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></div></blockquote><div><br></div></span><div>The assert you originally hit appears to indicate that the parentFunction of the debug scope for an instruction should be the same as the function the instruction is in. I am not very familiar with the requirements of our debug information and debug scopes, but this seems like a reasonable expectation.</div><div><br></div><div>I suggested looking at SILCloner because it is the primary way by which we clone functions, and clearly has to deal with debug scopes when it does so.</div><div><br></div><div>I’m not sure how much more help I can be on this matter, but perhaps someone more knowledgable can chime in.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Mark</div></font></span><div><div class="h5"><div><br></div><div><br></div><div><br></div><br><blockquote type="cite"><div><div dir="ltr"><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="m_3833984575572660261h5"><br>
> On Jan 15, 2018, at 9:24 AM, Raj Barik via swift-dev <<a href="mailto:swift-dev@swift.org" target="_blank">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.setOpenedArchetypesT<wbr>racker(&OpenedArchetypesTracke<wbr>rNF);<br>
> NFBuilder.setCurrentDebugScope<wbr>(NFBody->getParent()-><wbr>getDebugScope());<br>
> ...<br>
> for (auto &param : params) { /* Assume all are generic types */<br>
> auto GenericsSILType = ....<br>
> auto NewArg = NFBody->createFunctionArgument<wbr>(GenericSILType);<br>
> auto Conformances = Mod->lookupConformance(...);<br>
> auto *InitRef = NFBuilder.createInitExistentia<wbr>lRef( Loc, ArgDesc.Arg->getType(), NewArg->getType().getSwiftRVal<wbr>ueType()->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" target="_blank">swift-dev@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-dev" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-dev</a><br>
<br>
</blockquote></div><br></div>
</div></blockquote></div></div></div><br></div></blockquote></div><br></div>