Realty Income has agreed to acquire Spirit Realty Capital in an all-stock deal valued at about $9.3 billion.