[swift-dev] DebugScope Verification Error

Raj Barik rkbarik at gmail.com
Mon Jan 15 14:54:47 CST 2018


Mark,

Thanks a lot for quick reply.

Is there any reason this interface in SILInstruction should be private?
void setDebugScope(SILBuilder &B, const SILDebugScope *DS);

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.

Best,
Raj



On Mon, Jan 15, 2018 at 9:52 AM, Mark Lacey <mark.lacey at apple.com> wrote:

> I’d suggest looking at SILCloner.h as well as ScopeCloner in
> SILBasicBlock.cpp to see how they are dealing with debug scopes.
>
> Mark
>
> > On Jan 15, 2018, at 9:24 AM, Raj Barik via swift-dev <
> swift-dev at swift.org> wrote:
> >
> > Hi,
> >
> > 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?
> >
> > NF = M.createFunction(...., F->getDebugScope());
> > SILBasicBlock *NFBody = NF->createBasicBlock();
> > SILBuilder NFBuilder(NFBody);
> > SILOpenedArchetypesTracker OpenedArchetypesTrackerNF(NF);
> > NFBuilder.setOpenedArchetypesTracker(&OpenedArchetypesTrackerNF);
> > NFBuilder.setCurrentDebugScope(NFBody->getParent()->getDebugScope());
> > ...
> > for (auto &param : params) { /* Assume all are generic types */
> >   auto GenericsSILType = ....
> >   auto NewArg = NFBody->createFunctionArgument(GenericSILType);
> >   auto Conformances = Mod->lookupConformance(...);
> >   auto *InitRef = NFBuilder.createInitExistentialRef( Loc,
> ArgDesc.Arg->getType(), NewArg->getType().getSwiftRValueType()->getCanonicalType(),
> NewArg, Conformances);
> >   ...
> > }
> >
> > The InitRef instruction created above runs into SIL verifier error:
> >
> > SIL verification failed: debug scope of instruction belongs to a
> different function: !DS || DS->getParentFunction() == I->getFunction()
> > Verifying instruction:
> >    %0 = argument of bb0 : $τ_0_0                 // user: %1
> > ->   %1 = init_existential_ref %0 : $τ_0_0 : $τ_0_0, $SomeProtocol //
> user: %2
> >
> > The SIL looks correct to me though.
> >
> > --Raj
> > _______________________________________________
> > swift-dev mailing list
> > swift-dev at swift.org
> > https://lists.swift.org/mailman/listinfo/swift-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20180115/820a1607/attachment.html>


More information about the swift-dev mailing list