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@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 ¶m : 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@swift.org > https://lists.swift.org/mailman/listinfo/swift-dev _______________________________________________ swift-dev mailing list swift-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-dev