Skip to content

Commit e145520

Browse files
authored
Merge pull request #21917 from gottesmm/pr-a9126f66b71672d1823ee198a41a780eda159569
Move small constructor inline. NFC.
2 parents e140015 + 2d78a98 commit e145520

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 optimizeMemoryAccesses();
10151032
bool tryToRemoveDeadAllocation();
@@ -1024,26 +1041,6 @@ class AllocOptimize {
10241041

10251042
} // end anonymous namespace
10261043

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

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

0 commit comments

Comments
 (0)