“When I saw that in memoriam, I was like, ‘Man, that could’ve been me,’” Foxx said onstage