Fix crash in OSLogOptimization

A metatype need not always come from a metatype instruction. It can come from
a SILArgument. Fix the invalid cast operation in OSLogOptimization.

Fixes rdar://146160325
This commit is contained in:
Meghana Gupta
2025-04-21 11:48:47 -07:00
parent 7d77c615b3
commit d295bf96c0
2 changed files with 31 additions and 3 deletions

View File

@@ -163,9 +163,9 @@ public:
this->stringInitIntrinsic = callee;
MetatypeInst *stringMetatypeInst =
dyn_cast<MetatypeInst>(inst->getOperand(4)->getDefiningInstruction());
this->stringMetatype = stringMetatypeInst->getType();
auto stringMetatype = inst->getOperand(4)->getType();
assert(stringMetatype.isMetatype());
this->stringMetatype = stringMetatype;
}
bool isInitialized() { return stringInitIntrinsic != nullptr; }