mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #37328 from rjmccall/di-box-scaling
In DI, cache whether a memory object is a box
This commit is contained in:
@@ -93,13 +93,8 @@ static unsigned getElementCountRec(TypeExpansionContext context,
|
||||
}
|
||||
|
||||
static std::pair<SILType, bool>
|
||||
computeMemorySILType(MarkUninitializedInst *MemoryInst) {
|
||||
computeMemorySILType(MarkUninitializedInst *MUI, SILValue Address) {
|
||||
// Compute the type of the memory object.
|
||||
auto *MUI = MemoryInst;
|
||||
SILValue Address = MUI;
|
||||
if (auto *PBI = Address->getSingleUserOfType<ProjectBoxInst>()) {
|
||||
Address = PBI;
|
||||
}
|
||||
SILType MemorySILType = Address->getType().getObjectType();
|
||||
|
||||
// If this is a let variable we're initializing, remember this so we don't
|
||||
@@ -118,7 +113,13 @@ DIMemoryObjectInfo::DIMemoryObjectInfo(MarkUninitializedInst *MI)
|
||||
: MemoryInst(MI) {
|
||||
auto &Module = MI->getModule();
|
||||
|
||||
std::tie(MemorySILType, IsLet) = computeMemorySILType(MemoryInst);
|
||||
SILValue Address = MemoryInst;
|
||||
if (auto PBI = MemoryInst->getSingleUserOfType<ProjectBoxInst>()) {
|
||||
IsBox = true;
|
||||
Address = PBI;
|
||||
}
|
||||
|
||||
std::tie(MemorySILType, IsLet) = computeMemorySILType(MI, Address);
|
||||
|
||||
// Compute the number of elements to track in this memory object.
|
||||
// If this is a 'self' in a delegating initializer, we only track one bit:
|
||||
|
||||
@@ -72,6 +72,9 @@ class DIMemoryObjectInfo {
|
||||
/// non-empty.
|
||||
bool HasDummyElement = false;
|
||||
|
||||
/// True if this object has a single user of type ProjectBoxInst.
|
||||
bool IsBox = false;
|
||||
|
||||
public:
|
||||
DIMemoryObjectInfo(MarkUninitializedInst *MemoryInst);
|
||||
|
||||
@@ -98,8 +101,12 @@ public:
|
||||
/// instruction. For alloc_box though it returns the project_box associated
|
||||
/// with the memory info.
|
||||
SingleValueInstruction *getUninitializedValue() const {
|
||||
if (auto *pbi = MemoryInst->getSingleUserOfType<ProjectBoxInst>())
|
||||
if (IsBox) {
|
||||
// TODO: consider just storing the ProjectBoxInst in this case.
|
||||
auto *pbi = MemoryInst->getSingleUserOfType<ProjectBoxInst>();
|
||||
assert(pbi);
|
||||
return pbi;
|
||||
}
|
||||
return MemoryInst;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user