File tree Expand file tree Collapse file tree 3 files changed +9
-1
lines changed
SwiftCompilerSources/Sources/SIL/Utilities Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,9 @@ public struct Cloner<Context: MutatingContext> {
6767 if let entryBlock = targetFunction. blocks. first {
6868 return entryBlock
6969 }
70- return targetFunction. appendNewBlock ( context)
70+ let entryBlock = targetFunction. appendNewBlock ( context)
71+ bridged. setInsertionBlockIfNotSet ( entryBlock. bridged)
72+ return entryBlock
7173 }
7274
7375 public func cloneFunctionBody( from originalFunction: Function , entryBlockArguments: [ Value ] ) {
Original file line number Diff line number Diff line change @@ -1549,6 +1549,7 @@ struct BridgedCloner {
15491549 void recordClonedInstruction (BridgedInstruction origInst, BridgedInstruction clonedInst) const ;
15501550 void recordFoldedValue (BridgedValue orig, BridgedValue mapped) const ;
15511551 BridgedInstruction clone (BridgedInstruction inst) const ;
1552+ void setInsertionBlockIfNotSet (BridgedBasicBlock block) const ;
15521553};
15531554
15541555struct BridgedTypeSubstCloner {
Original file line number Diff line number Diff line change @@ -699,6 +699,11 @@ BridgedInstruction BridgedCloner::clone(BridgedInstruction inst) const {
699699 return {cloner->cloneInst (inst.unbridged ())->asSILNode ()};
700700}
701701
702+ void BridgedCloner::setInsertionBlockIfNotSet (BridgedBasicBlock block) const {
703+ if (!cloner->getBuilder ().hasValidInsertionPoint ())
704+ cloner->getBuilder ().setInsertionPoint (block.unbridged ());
705+ }
706+
702707BridgedBasicBlock BridgedCloner::getClonedBasicBlock (BridgedBasicBlock originalBasicBlock) const {
703708 return { cloner->getOpBasicBlock (originalBasicBlock.unbridged ()) };
704709}
You can’t perform that action at this time.
0 commit comments