static bool isSafeReadOnlyApply(SideEffectAnalysis *SEA, ApplyInst *AI) { FunctionSideEffects E; SEA->getCalleeEffects(E, AI); if (E.getGlobalEffects().mayRead()) { // If we have Global effects, // we don't know which memory is read in the callee. // Therefore we bail for safety return false; } auto MB = E.getMemBehavior(RetainObserveKind::ObserveRetains); return (MB <= SILInstruction::MemoryBehavior::MayRead); }