Skip to content

Commit 2d78a98

Browse files
committed
Move small constructor inline. NFC.
1 parent addf7f0 commit 2d78a98

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

lib/SILOptimizer/Mandatory/PredictableMemOpt.cpp

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,18 @@ bool AvailableValueDataflowContext::hasEscapedAt(SILInstruction *I) {
983983
// Allocation Optimization
984984
//===----------------------------------------------------------------------===//
985985

986+
static SILType getMemoryType(AllocationInst *memory) {
987+
// Compute the type of the memory object.
988+
if (auto *abi = dyn_cast<AllocBoxInst>(memory)) {
989+
assert(abi->getBoxType()->getLayout()->getFields().size() == 1 &&
990+
"optimizing multi-field boxes not implemented");
991+
return abi->getBoxType()->getFieldType(abi->getModule(), 0);
992+
}
993+
994+
assert(isa<AllocStackInst>(memory));
995+
return cast<AllocStackInst>(memory)->getElementType();
996+
}
997+
986998
namespace {
987999

9881000
/// This performs load promotion and deletes synthesized allocations if all
@@ -1008,8 +1020,13 @@ class AllocOptimize {
10081020
AvailableValueDataflowContext DataflowContext;
10091021

10101022
public:
1011-
AllocOptimize(AllocationInst *TheMemory, SmallVectorImpl<PMOMemoryUse> &Uses,
1012-
SmallVectorImpl<SILInstruction *> &Releases);
1023+
AllocOptimize(AllocationInst *memory, SmallVectorImpl<PMOMemoryUse> &uses,
1024+
SmallVectorImpl<SILInstruction *> &releases)
1025+
: Module(memory->getModule()), TheMemory(memory),
1026+
MemoryType(getMemoryType(memory)),
1027+
NumMemorySubElements(getNumSubElements(MemoryType, Module)), Uses(uses),
1028+
Releases(releases),
1029+
DataflowContext(TheMemory, NumMemorySubElements, uses) {}
10131030

10141031
bool doIt();
10151032

@@ -1025,26 +1042,6 @@ class AllocOptimize {
10251042

10261043
} // end anonymous namespace
10271044

1028-
static SILType getMemoryType(AllocationInst *TheMemory) {
1029-
// Compute the type of the memory object.
1030-
if (auto *ABI = dyn_cast<AllocBoxInst>(TheMemory)) {
1031-
assert(ABI->getBoxType()->getLayout()->getFields().size() == 1 &&
1032-
"optimizing multi-field boxes not implemented");
1033-
return ABI->getBoxType()->getFieldType(ABI->getModule(), 0);
1034-
} else {
1035-
assert(isa<AllocStackInst>(TheMemory));
1036-
return cast<AllocStackInst>(TheMemory)->getElementType();
1037-
}
1038-
}
1039-
1040-
AllocOptimize::AllocOptimize(AllocationInst *InputMemory,
1041-
SmallVectorImpl<PMOMemoryUse> &InputUses,
1042-
SmallVectorImpl<SILInstruction *> &InputReleases)
1043-
: Module(InputMemory->getModule()), TheMemory(InputMemory),
1044-
MemoryType(getMemoryType(TheMemory)),
1045-
NumMemorySubElements(getNumSubElements(MemoryType, Module)),
1046-
Uses(InputUses), Releases(InputReleases),
1047-
DataflowContext(TheMemory, NumMemorySubElements, Uses) {}
10481045

10491046
/// If we are able to optimize \p Inst, return the source address that
10501047
/// instruction is loading from. If we can not optimize \p Inst, then just

0 commit comments

Comments
 (0)