@@ -39,24 +39,21 @@ static unsigned getElementCountRec(SILModule &Module, SILType T) {
39
39
return 1 ;
40
40
}
41
41
42
- PMOMemoryObjectInfo::PMOMemoryObjectInfo (SingleValueInstruction *MI) {
43
- auto &Module = MI->getModule ();
42
+ PMOMemoryObjectInfo::PMOMemoryObjectInfo (AllocationInst *allocation)
43
+ : MemoryInst(allocation) {
44
+ auto &module = MemoryInst->getModule ();
44
45
45
- MemoryInst = MI;
46
46
// Compute the type of the memory object.
47
- if (auto *ABI = dyn_cast<AllocBoxInst>(MemoryInst)) {
48
- assert (ABI ->getBoxType ()->getLayout ()->getFields ().size () == 1 &&
47
+ if (auto *abi = dyn_cast<AllocBoxInst>(MemoryInst)) {
48
+ assert (abi ->getBoxType ()->getLayout ()->getFields ().size () == 1 &&
49
49
" analyzing multi-field boxes not implemented" );
50
- MemorySILType = ABI->getBoxType ()->getFieldType (Module, 0 );
51
- } else if (auto *ASI = dyn_cast<AllocStackInst>(MemoryInst)) {
52
- MemorySILType = ASI->getElementType ();
50
+ MemorySILType = abi->getBoxType ()->getFieldType (module , 0 );
53
51
} else {
54
- llvm_unreachable (
55
- " Predictable Mem Opts should only be analyzing alloc_box/alloc_stack" );
52
+ MemorySILType = cast<AllocStackInst>(MemoryInst)->getElementType ();
56
53
}
57
54
58
55
// Break down the initializer.
59
- NumElements = getElementCountRec (Module , MemorySILType);
56
+ NumElements = getElementCountRec (module , MemorySILType);
60
57
}
61
58
62
59
SILInstruction *PMOMemoryObjectInfo::getFunctionEntryPoint () const {
0 commit comments