@@ -70,7 +70,7 @@ static bool useCaptured(Operand *UI) {
70
70
71
71
// Is any successor of BB in the LiveIn set?
72
72
static bool successorHasLiveIn (SILBasicBlock *BB,
73
- llvm:: SmallPtrSetImpl<SILBasicBlock *> &LiveIn) {
73
+ SmallPtrSetImpl<SILBasicBlock *> &LiveIn) {
74
74
for (auto &Succ : BB->getSuccessors ())
75
75
if (LiveIn.count (Succ))
76
76
return true ;
@@ -80,11 +80,11 @@ static bool successorHasLiveIn(SILBasicBlock *BB,
80
80
81
81
// Propagate liveness backwards from an initial set of blocks in our
82
82
// LiveIn set.
83
- static void propagateLiveness (llvm:: SmallPtrSetImpl<SILBasicBlock*> &LiveIn,
83
+ static void propagateLiveness (SmallPtrSetImpl<SILBasicBlock *> &LiveIn,
84
84
SILBasicBlock *DefBB) {
85
85
86
86
// First populate a worklist of predecessors.
87
- llvm:: SmallVector<SILBasicBlock*, 64 > Worklist;
87
+ SmallVector<SILBasicBlock *, 64 > Worklist;
88
88
for (auto *BB : LiveIn)
89
89
for (auto Pred : BB->getPredecessorBlocks ())
90
90
Worklist.push_back (Pred);
@@ -106,7 +106,7 @@ static void propagateLiveness(llvm::SmallPtrSetImpl<SILBasicBlock*> &LiveIn,
106
106
// Walk backwards in BB looking for strong_release, destroy_value, or
107
107
// dealloc_box of the given value, and add it to releases.
108
108
static bool addLastRelease (SILValue V, SILBasicBlock *BB,
109
- llvm:: SmallVectorImpl<SILInstruction*> &Releases) {
109
+ SmallVectorImpl<SILInstruction *> &Releases) {
110
110
for (auto I = BB->rbegin (); I != BB->rend (); ++I) {
111
111
if (isa<StrongReleaseInst>(*I) || isa<DeallocBoxInst>(*I) ||
112
112
isa<DestroyValueInst>(*I)) {
@@ -124,11 +124,10 @@ static bool addLastRelease(SILValue V, SILBasicBlock *BB,
124
124
// Find the final releases of the alloc_box along any given path.
125
125
// These can include paths from a release back to the alloc_box in a
126
126
// loop.
127
- static bool
128
- getFinalReleases (SILValue Box,
129
- llvm::SmallVectorImpl<SILInstruction *> &Releases) {
130
- llvm::SmallPtrSet<SILBasicBlock*, 16 > LiveIn;
131
- llvm::SmallPtrSet<SILBasicBlock*, 16 > UseBlocks;
127
+ static bool getFinalReleases (SILValue Box,
128
+ SmallVectorImpl<SILInstruction *> &Releases) {
129
+ SmallPtrSet<SILBasicBlock *, 16 > LiveIn;
130
+ SmallPtrSet<SILBasicBlock *, 16 > UseBlocks;
132
131
133
132
auto *DefBB = Box->getParentBlock ();
134
133
@@ -138,7 +137,7 @@ getFinalReleases(SILValue Box,
138
137
// We'll treat this like a liveness problem where the alloc_box is
139
138
// the def. Each block that has a use of the owning pointer has the
140
139
// value live-in unless it is the block with the alloc_box.
141
- llvm:: SmallVector<Operand *, 32 > Worklist (Box->use_begin (), Box->use_end ());
140
+ SmallVector<Operand *, 32 > Worklist (Box->use_begin (), Box->use_end ());
142
141
while (!Worklist.empty ()) {
143
142
auto *Op = Worklist.pop_back_val ();
144
143
auto *User = Op->getUser ();
@@ -200,7 +199,7 @@ getFinalReleases(SILValue Box,
200
199
// / sorting, uniquing at the appropriate time. The reason why it makes sense to
201
200
// / just use a sorted vector with std::count is because generally functions do
202
201
// / not have that many arguments and even fewer promoted arguments.
203
- using ArgIndexList = llvm:: SmallVector<unsigned , 8 >;
202
+ using ArgIndexList = SmallVector<unsigned , 8 >;
204
203
205
204
static bool partialApplyEscapes (SILValue V, bool examineApply);
206
205
@@ -220,7 +219,7 @@ static bool applyArgumentEscapes(FullApplySite Apply, Operand *O) {
220
219
221
220
static bool partialApplyEscapes (SILValue V, bool examineApply) {
222
221
SILModuleConventions ModConv (*V->getModule ());
223
- llvm:: SmallVector<Operand *, 32 > Worklist (V->use_begin (), V->use_end ());
222
+ SmallVector<Operand *, 32 > Worklist (V->use_begin (), V->use_end ());
224
223
while (!Worklist.empty ()) {
225
224
Operand *Op = Worklist.pop_back_val ();
226
225
@@ -277,7 +276,7 @@ static bool partialApplyEscapes(SILValue V, bool examineApply) {
277
276
static SILInstruction *findUnexpectedBoxUse (SILValue Box,
278
277
bool examinePartialApply,
279
278
bool inAppliedFunction,
280
- llvm:: SmallVectorImpl<Operand *> &);
279
+ SmallVectorImpl<Operand *> &);
281
280
282
281
// / checkPartialApplyBody - Check the body of a partial apply to see
283
282
// / if the box pointer argument passed to it has uses that would
@@ -291,7 +290,7 @@ static bool checkPartialApplyBody(Operand *O) {
291
290
292
291
// We don't actually use these because we're not recursively
293
292
// rewriting the partial applies we find.
294
- llvm:: SmallVector<Operand *, 1 > PromotedOperands;
293
+ SmallVector<Operand *, 1 > PromotedOperands;
295
294
auto calleeArg = F->getArgument (ApplySite (O->getUser ()).getCalleeArgIndex (*O));
296
295
return !findUnexpectedBoxUse (calleeArg, /* examinePartialApply = */ false ,
297
296
/* inAppliedFunction = */ true ,
@@ -305,18 +304,18 @@ static bool checkPartialApplyBody(Operand *O) {
305
304
static SILInstruction *
306
305
findUnexpectedBoxUse (SILValue Box, bool examinePartialApply,
307
306
bool inAppliedFunction,
308
- llvm:: SmallVectorImpl<Operand *> &PromotedOperands) {
307
+ SmallVectorImpl<Operand *> &PromotedOperands) {
309
308
assert ((Box->getType ().is <SILBoxType>()
310
309
|| Box->getType ()
311
310
== SILType::getNativeObjectType (Box->getType ().getASTContext ()))
312
311
&& " Expected an object pointer!" );
313
312
314
- llvm:: SmallVector<Operand *, 4 > LocalPromotedOperands;
313
+ SmallVector<Operand *, 4 > LocalPromotedOperands;
315
314
316
315
// Scan all of the uses of the retain count value, collecting all
317
316
// the releases and validating that we don't have an unexpected
318
317
// user.
319
- llvm:: SmallVector<Operand *, 32 > Worklist (Box->use_begin (), Box->use_end ());
318
+ SmallVector<Operand *, 32 > Worklist (Box->use_begin (), Box->use_end ());
320
319
while (!Worklist.empty ()) {
321
320
auto *Op = Worklist.pop_back_val ();
322
321
auto *User = Op->getUser ();
@@ -357,7 +356,7 @@ findUnexpectedBoxUse(SILValue Box, bool examinePartialApply,
357
356
358
357
// / canPromoteAllocBox - Can we promote this alloc_box to an alloc_stack?
359
358
static bool canPromoteAllocBox (AllocBoxInst *ABI,
360
- llvm:: SmallVectorImpl<Operand *> &PromotedOperands){
359
+ SmallVectorImpl<Operand *> &PromotedOperands) {
361
360
// Scan all of the uses of the address of the box to see if any
362
361
// disqualifies the box from being promoted to the stack.
363
362
if (auto *User = findUnexpectedBoxUse (ABI,
@@ -387,16 +386,15 @@ struct AllocBoxToStackState {
387
386
SILFunctionTransform *T;
388
387
bool CFGChanged = false ;
389
388
390
- llvm:: SmallVector<AllocBoxInst *, 8 > Promotable;
391
- llvm:: SmallVector<Operand *, 8 > PromotedOperands;
389
+ SmallVector<AllocBoxInst *, 8 > Promotable;
390
+ SmallVector<Operand *, 8 > PromotedOperands;
392
391
393
392
AllocBoxToStackState (SILFunctionTransform *T) : T(T) {}
394
393
};
395
394
} // anonymous namespace
396
395
397
396
static void replaceProjectBoxUsers (SILValue HeapBox, SILValue StackBox) {
398
- llvm::SmallVector<Operand *, 8 > Worklist (HeapBox->use_begin (),
399
- HeapBox->use_end ());
397
+ SmallVector<Operand *, 8 > Worklist (HeapBox->use_begin (), HeapBox->use_end ());
400
398
while (!Worklist.empty ()) {
401
399
auto *Op = Worklist.pop_back_val ();
402
400
if (auto *PBI = dyn_cast<ProjectBoxInst>(Op->getUser ())) {
@@ -427,7 +425,7 @@ static bool rewriteAllocBoxAsAllocStack(AllocBoxInst *ABI) {
427
425
}
428
426
}
429
427
430
- llvm:: SmallVector<SILInstruction *, 4 > FinalReleases;
428
+ SmallVector<SILInstruction *, 4 > FinalReleases;
431
429
if (!getFinalReleases (HeapBox, FinalReleases))
432
430
return false ;
433
431
@@ -472,7 +470,7 @@ static bool rewriteAllocBoxAsAllocStack(AllocBoxInst *ABI) {
472
470
// Remove any retain and release instructions. Since all uses of project_box
473
471
// are gone, this only walks through uses of the box itself (the retain count
474
472
// pointer).
475
- llvm:: SmallVector<SILInstruction *, 8 > Worklist;
473
+ SmallVector<SILInstruction *, 8 > Worklist;
476
474
std::transform (ABI->use_begin (), ABI->use_end (), std::back_inserter (Worklist),
477
475
[](Operand *Op) -> SILInstruction * { return Op->getUser (); });
478
476
while (!Worklist.empty ()) {
@@ -514,12 +512,12 @@ class PromotedParamCloner : public SILClonerWithScopes<PromotedParamCloner> {
514
512
515
513
// The values in the original function that are promoted to stack
516
514
// references.
517
- llvm::SmallSet <SILValue, 4 > OrigPromotedParameters;
515
+ SmallPtrSet <SILValue, 4 > OrigPromotedParameters;
518
516
519
517
public:
520
- PromotedParamCloner (SILOptFunctionBuilder &FuncBuilder, SILFunction *Orig, IsSerialized_t Serialized,
521
- ArgIndexList &PromotedArgIndices ,
522
- llvm:: StringRef ClonedName);
518
+ PromotedParamCloner (SILOptFunctionBuilder &FuncBuilder, SILFunction *Orig,
519
+ IsSerialized_t Serialized ,
520
+ ArgIndexList &PromotedArgIndices, StringRef ClonedName);
523
521
524
522
void populateCloned ();
525
523
@@ -529,7 +527,7 @@ class PromotedParamCloner : public SILClonerWithScopes<PromotedParamCloner> {
529
527
static SILFunction *initCloned (SILOptFunctionBuilder &FuncBuilder,
530
528
SILFunction *Orig, IsSerialized_t Serialized,
531
529
ArgIndexList &PromotedArgIndices,
532
- llvm:: StringRef ClonedName);
530
+ StringRef ClonedName);
533
531
534
532
void visitStrongReleaseInst (StrongReleaseInst *Inst);
535
533
void visitDestroyValueInst (DestroyValueInst *Inst);
@@ -543,10 +541,9 @@ PromotedParamCloner::PromotedParamCloner(SILOptFunctionBuilder &FuncBuilder,
543
541
SILFunction *Orig,
544
542
IsSerialized_t Serialized,
545
543
ArgIndexList &PromotedArgIndices,
546
- llvm::StringRef ClonedName)
547
- : SILClonerWithScopes<PromotedParamCloner>(
548
- *initCloned (FuncBuilder, Orig, Serialized, PromotedArgIndices,
549
- ClonedName)),
544
+ StringRef ClonedName)
545
+ : SILClonerWithScopes<PromotedParamCloner>(*initCloned (
546
+ FuncBuilder, Orig, Serialized, PromotedArgIndices, ClonedName)),
550
547
Orig(Orig), PromotedArgIndices(PromotedArgIndices) {
551
548
NewPromotedArgs.reserve (PromotedArgIndices.size ());
552
549
assert (Orig->getDebugScope ()->getParentFunction () !=
@@ -566,10 +563,11 @@ static std::string getClonedName(SILFunction *F, IsSerialized_t Serialized,
566
563
// / Create the function corresponding to the clone of the
567
564
// / original closure with the signature modified to reflect promoted
568
565
// / parameters (which are specified by PromotedArgIndices).
569
- SILFunction *PromotedParamCloner::
570
- initCloned (SILOptFunctionBuilder &FuncBuilder, SILFunction *Orig,
571
- IsSerialized_t Serialized, ArgIndexList &PromotedArgIndices,
572
- llvm::StringRef ClonedName) {
566
+ SILFunction *PromotedParamCloner::initCloned (SILOptFunctionBuilder &FuncBuilder,
567
+ SILFunction *Orig,
568
+ IsSerialized_t Serialized,
569
+ ArgIndexList &PromotedArgIndices,
570
+ StringRef ClonedName) {
573
571
SILModule &M = Orig->getModule ();
574
572
575
573
SmallVector<SILParameterInfo, 4 > ClonedInterfaceArgTys;
@@ -776,7 +774,7 @@ specializePartialApply(SILOptFunctionBuilder &FuncBuilder,
776
774
}
777
775
778
776
// Now create the new partial_apply using the cloned function.
779
- llvm:: SmallVector<SILValue, 16 > Args;
777
+ SmallVector<SILValue, 16 > Args;
780
778
781
779
ValueLifetimeAnalysis::Frontier PAFrontier;
782
780
0 commit comments