US stocks rallied to the brink of a record overnight after more companies reported bigger profits than expected.