File tree Expand file tree Collapse file tree 4 files changed +17
-26
lines changed Expand file tree Collapse file tree 4 files changed +17
-26
lines changed Original file line number Diff line number Diff line change @@ -2358,15 +2358,11 @@ class SILBuilder {
2358
2358
}
2359
2359
2360
2360
void insertImpl (SILInstruction *TheInst) {
2361
- if (BB == 0 )
2362
- return ;
2363
-
2361
+ assert (hasValidInsertionPoint ());
2364
2362
BB->insert (InsertPt, TheInst);
2365
2363
2366
2364
C.notifyInserted (TheInst);
2367
2365
2368
- // TODO: We really shouldn't be creating instructions unless we are going to
2369
- // insert them into a block... This failed in SimplifyCFG.
2370
2366
#ifndef NDEBUG
2371
2367
TheInst->verifyOperandOwnership ();
2372
2368
#endif
Original file line number Diff line number Diff line change @@ -1149,11 +1149,14 @@ namespace {
1149
1149
friend class SILCloner <TrivialCloner>;
1150
1150
friend class SILInstructionVisitor <TrivialCloner>;
1151
1151
SILInstruction *Result = nullptr ;
1152
- TrivialCloner (SILFunction *F) : SILCloner(*F) {}
1152
+ TrivialCloner (SILFunction *F, SILInstruction *InsertPt) : SILCloner(*F) {
1153
+ Builder.setInsertionPoint (InsertPt);
1154
+ }
1155
+
1153
1156
public:
1154
1157
1155
- static SILInstruction *doIt (SILInstruction *I) {
1156
- TrivialCloner TC (I->getFunction ());
1158
+ static SILInstruction *doIt (SILInstruction *I, SILInstruction *InsertPt ) {
1159
+ TrivialCloner TC (I->getFunction (), InsertPt );
1157
1160
TC.visit (I);
1158
1161
return TC.Result ;
1159
1162
}
@@ -1204,10 +1207,7 @@ bool SILInstruction::isDeallocatingStack() const {
1204
1207
// / then the new instruction is inserted before the specified point, otherwise
1205
1208
// / the new instruction is returned without a parent.
1206
1209
SILInstruction *SILInstruction::clone (SILInstruction *InsertPt) {
1207
- SILInstruction *NewInst = TrivialCloner::doIt (this );
1208
-
1209
- if (NewInst && InsertPt)
1210
- InsertPt->getParent ()->insert (InsertPt, NewInst);
1210
+ SILInstruction *NewInst = TrivialCloner::doIt (this , InsertPt);
1211
1211
return NewInst;
1212
1212
}
1213
1213
Original file line number Diff line number Diff line change @@ -96,8 +96,10 @@ class InstructionVisitor : public SILCloner<InstructionVisitor> {
96
96
SILInstruction *result = nullptr ;
97
97
98
98
public:
99
- InstructionVisitor (SILFunction *F, CrossModuleSerializationSetup &CMS) :
100
- SILCloner (*F), CMS(CMS) {}
99
+ InstructionVisitor (SILInstruction *I, CrossModuleSerializationSetup &CMS) :
100
+ SILCloner (*I->getFunction ()), CMS(CMS) {
101
+ Builder.setInsertionPoint (I);
102
+ }
101
103
102
104
SILType remapType (SILType Ty) {
103
105
CMS.makeTypeUsableFromInline (Ty.getASTType ());
@@ -124,11 +126,9 @@ class InstructionVisitor : public SILCloner<InstructionVisitor> {
124
126
SILBasicBlock *remapBasicBlock (SILBasicBlock *BB) { return BB; }
125
127
126
128
static void visitInst (SILInstruction *I, CrossModuleSerializationSetup &CMS) {
127
- InstructionVisitor visitor (I-> getFunction () , CMS);
129
+ InstructionVisitor visitor (I, CMS);
128
130
visitor.visit (I);
129
-
130
- SILInstruction::destroy (visitor.result );
131
- CMS.M .deallocateInst (visitor.result );
131
+ visitor.result ->eraseFromParent ();
132
132
}
133
133
};
134
134
Original file line number Diff line number Diff line change @@ -190,11 +190,12 @@ class InitSequenceCloner : public SILClonerWithScopes<InitSequenceCloner> {
190
190
friend class SILCloner <InitSequenceCloner>;
191
191
192
192
const InitSequence &Init;
193
- SILInstruction *DestIP;
194
193
195
194
public:
196
195
InitSequenceCloner (const InitSequence &init, SILInstruction *destIP)
197
- : SILClonerWithScopes(*destIP->getFunction ()), Init(init), DestIP(destIP) {}
196
+ : SILClonerWithScopes(*destIP->getFunction ()), Init(init) {
197
+ Builder.setInsertionPoint (destIP);
198
+ }
198
199
199
200
void process (SILInstruction *I) { visit (I); }
200
201
@@ -204,12 +205,6 @@ class InitSequenceCloner : public SILClonerWithScopes<InitSequenceCloner> {
204
205
return SILCloner<InitSequenceCloner>::getMappedValue (Value);
205
206
}
206
207
207
- void postProcess (SILInstruction *orig, SILInstruction *cloned) {
208
- DestIP->getParent ()->push_front (cloned);
209
- cloned->moveBefore (DestIP);
210
- SILClonerWithScopes<InitSequenceCloner>::postProcess (orig, cloned);
211
- }
212
-
213
208
// / Clone all the instructions from Insns into the destination function,
214
209
// / immediately before the destination block, and return the value of
215
210
// / the result.
You can’t perform that action at this time.
0 commit comments