@@ -195,65 +195,68 @@ static SILValue extractSubElement(SILValue Val, unsigned SubElementNumber,
195
195
// ===----------------------------------------------------------------------===//
196
196
197
197
namespace {
198
- // / AllocOptimize - This performs load promotion and deletes synthesized
199
- // / allocations if all loads can be removed.
200
- class AllocOptimize {
201
- SILModule &Module;
202
-
203
- // / TheMemory - This is either an alloc_box or alloc_stack instruction.
204
- AllocationInst *TheMemory;
205
-
206
- // / This is the SILType of the memory object.
207
- SILType MemoryType;
208
-
209
- // / The number of primitive subelements across all elements of this memory
210
- // / value.
211
- unsigned NumMemorySubElements;
212
-
213
- SmallVectorImpl<DIMemoryUse> &Uses;
214
- SmallVectorImpl<SILInstruction*> &Releases;
215
-
216
- llvm::SmallPtrSet<SILBasicBlock*, 32 > HasLocalDefinition;
217
-
218
- // / This is a map of uses that are not loads (i.e., they are Stores,
219
- // / InOutUses, and Escapes), to their entry in Uses.
220
- llvm::SmallDenseMap<SILInstruction*, unsigned , 16 > NonLoadUses;
221
-
222
- // / Does this value escape anywhere in the function.
223
- bool HasAnyEscape = false ;
224
-
225
- public:
226
- AllocOptimize (AllocationInst *TheMemory,
227
- SmallVectorImpl<DIMemoryUse> &Uses,
228
- SmallVectorImpl<SILInstruction*> &Releases);
229
-
230
- bool doIt ();
231
-
232
- private:
233
-
234
- bool promoteLoad (SILInstruction *Inst);
235
- bool promoteDestroyAddr (DestroyAddrInst *DAI);
236
-
237
- // Load promotion.
238
- bool hasEscapedAt (SILInstruction *I);
239
- void updateAvailableValues (SILInstruction *Inst,
240
- llvm::SmallBitVector &RequiredElts,
241
- SmallVectorImpl<std::pair<SILValue, unsigned >> &Result,
242
- llvm::SmallBitVector &ConflictingValues);
243
- void computeAvailableValues (SILInstruction *StartingFrom,
244
- llvm::SmallBitVector &RequiredElts,
245
- SmallVectorImpl<std::pair<SILValue, unsigned >> &Result);
246
- void computeAvailableValuesFrom (SILBasicBlock::iterator StartingFrom,
247
- SILBasicBlock *BB,
248
- llvm::SmallBitVector &RequiredElts,
198
+
199
+ // / This performs load promotion and deletes synthesized allocations if all
200
+ // / loads can be removed.
201
+ class AllocOptimize {
202
+
203
+ SILModule &Module;
204
+
205
+ // / This is either an alloc_box or alloc_stack instruction.
206
+ AllocationInst *TheMemory;
207
+
208
+ // / This is the SILType of the memory object.
209
+ SILType MemoryType;
210
+
211
+ // / The number of primitive subelements across all elements of this memory
212
+ // / value.
213
+ unsigned NumMemorySubElements;
214
+
215
+ SmallVectorImpl<DIMemoryUse> &Uses;
216
+ SmallVectorImpl<SILInstruction *> &Releases;
217
+
218
+ llvm::SmallPtrSet<SILBasicBlock *, 32 > HasLocalDefinition;
219
+
220
+ // / This is a map of uses that are not loads (i.e., they are Stores,
221
+ // / InOutUses, and Escapes), to their entry in Uses.
222
+ llvm::SmallDenseMap<SILInstruction *, unsigned , 16 > NonLoadUses;
223
+
224
+ // / Does this value escape anywhere in the function.
225
+ bool HasAnyEscape = false ;
226
+
227
+ public:
228
+ AllocOptimize (AllocationInst *TheMemory, SmallVectorImpl<DIMemoryUse> &Uses,
229
+ SmallVectorImpl<SILInstruction *> &Releases);
230
+
231
+ bool doIt ();
232
+
233
+ private:
234
+ bool promoteLoad (SILInstruction *Inst);
235
+ bool promoteDestroyAddr (DestroyAddrInst *DAI);
236
+
237
+ // Load promotion.
238
+ bool hasEscapedAt (SILInstruction *I);
239
+ void
240
+ updateAvailableValues (SILInstruction *Inst,
241
+ llvm::SmallBitVector &RequiredElts,
249
242
SmallVectorImpl<std::pair<SILValue, unsigned >> &Result,
250
- llvm::SmallDenseMap<SILBasicBlock*, llvm::SmallBitVector, 32 > &VisitedBlocks,
251
- llvm::SmallBitVector &ConflictingValues);
252
-
253
- void explodeCopyAddr (CopyAddrInst *CAI);
254
-
255
- bool tryToRemoveDeadAllocation ();
256
- };
243
+ llvm::SmallBitVector &ConflictingValues);
244
+ void computeAvailableValues (
245
+ SILInstruction *StartingFrom, llvm::SmallBitVector &RequiredElts,
246
+ SmallVectorImpl<std::pair<SILValue, unsigned >> &Result);
247
+ void computeAvailableValuesFrom (
248
+ SILBasicBlock::iterator StartingFrom, SILBasicBlock *BB,
249
+ llvm::SmallBitVector &RequiredElts,
250
+ SmallVectorImpl<std::pair<SILValue, unsigned >> &Result,
251
+ llvm::SmallDenseMap<SILBasicBlock *, llvm::SmallBitVector, 32 >
252
+ &VisitedBlocks,
253
+ llvm::SmallBitVector &ConflictingValues);
254
+
255
+ void explodeCopyAddr (CopyAddrInst *CAI);
256
+
257
+ bool tryToRemoveDeadAllocation ();
258
+ };
259
+
257
260
} // end anonymous namespace
258
261
259
262
0 commit comments