30
30
using namespace swift ;
31
31
32
32
namespace {
33
+
33
34
// / Optimize the placement of global initializers.
34
35
// /
35
36
// / TODO:
@@ -53,31 +54,31 @@ class SILGlobalOpt {
53
54
// Map each global initializer to a list of call sites.
54
55
typedef SmallVector<ApplyInst *, 4 > GlobalInitCalls;
55
56
typedef SmallVector<LoadInst *, 4 > GlobalLoads;
56
- llvm::MapVector<SILFunction*, GlobalInitCalls> GlobalInitCallMap;
57
+ llvm::MapVector<SILFunction *, GlobalInitCalls> GlobalInitCallMap;
57
58
58
59
// The following mappings are used if this is a compilation
59
60
// in scripting mode and global variables are accessed without
60
61
// addressors.
61
62
62
63
// Map each global let variable to a set of loads from it.
63
- llvm::MapVector<SILGlobalVariable*, GlobalLoads> GlobalLoadMap;
64
+ llvm::MapVector<SILGlobalVariable *, GlobalLoads> GlobalLoadMap;
64
65
// Map each global let variable to the store instruction which initializes it.
65
- llvm::MapVector<SILGlobalVariable*, StoreInst *> GlobalVarStore;
66
+ llvm::MapVector<SILGlobalVariable *, StoreInst *> GlobalVarStore;
66
67
// Variables in this set should not be processed by this pass
67
68
// anymore.
68
- llvm::SmallPtrSet<SILGlobalVariable*, 16 > GlobalVarSkipProcessing;
69
+ llvm::SmallPtrSet<SILGlobalVariable *, 16 > GlobalVarSkipProcessing;
69
70
70
71
// Mark any block that this pass has determined to be inside a loop.
71
- llvm::DenseSet<SILBasicBlock*> LoopBlocks;
72
+ llvm::DenseSet<SILBasicBlock *> LoopBlocks;
72
73
// Mark any functions for which loops have been analyzed.
73
- llvm::DenseSet<SILFunction*> LoopCheckedFunctions;
74
+ llvm::DenseSet<SILFunction *> LoopCheckedFunctions;
74
75
// Keep track of cold blocks.
75
76
ColdBlockInfo ColdBlocks;
76
77
77
78
// Whether we see a "once" call to callees that we currently don't handle.
78
79
bool UnhandledOnceCallee = false ;
79
80
// Record number of times a globalinit_func is called by "once".
80
- llvm::DenseMap<SILFunction*, unsigned > InitializerCount;
81
+ llvm::DenseMap<SILFunction *, unsigned > InitializerCount;
81
82
public:
82
83
SILGlobalOpt (SILModule *M, DominanceAnalysis *DA)
83
84
: Module(M), DA(DA), ColdBlocks(DA) {}
@@ -92,7 +93,7 @@ class SILGlobalOpt {
92
93
93
94
SILGlobalVariable *getVariableOfGlobalInit (SILFunction *AddrF);
94
95
bool isInLoop (SILBasicBlock *CurBB);
95
- void placeInitializers (SILFunction *InitF, ArrayRef<ApplyInst*> Calls);
96
+ void placeInitializers (SILFunction *InitF, ArrayRef<ApplyInst *> Calls);
96
97
97
98
// Update UnhandledOnceCallee and InitializerCount by going through all "once"
98
99
// calls.
@@ -417,12 +418,12 @@ static bool isAvailabilityCheckOnDomPath(SILBasicBlock *From, SILBasicBlock *To,
417
418
// / The current heuristic hoists all initialization points within a function to
418
419
// / a single dominating call in the outer loop preheader.
419
420
void SILGlobalOpt::placeInitializers (SILFunction *InitF,
420
- ArrayRef<ApplyInst*> Calls) {
421
+ ArrayRef<ApplyInst *> Calls) {
421
422
DEBUG (llvm::dbgs () << " GlobalOpt: calls to "
422
423
<< Demangle::demangleSymbolAsString (InitF->getName ())
423
424
<< " : " << Calls.size () << " \n " );
424
425
// Map each initializer-containing function to its final initializer call.
425
- llvm::DenseMap<SILFunction*, ApplyInst*> ParentFuncs;
426
+ llvm::DenseMap<SILFunction *, ApplyInst *> ParentFuncs;
426
427
for (auto *AI : Calls) {
427
428
assert (AI->getNumArguments () == 0 && " ill-formed global init call" );
428
429
assert (cast<FunctionRefInst>(AI->getCallee ())->getReferencedFunction ()
0 commit comments