It's a tough one, they trade blows at each other each beating the other one by a few FPS depending on the game you are playing and at what settings.

Here the GTX 580 just beats it by 1.5FPS,Not noticeable at all though.

Here the 7870 pulls ahead, beating the GTX 580 by 2FPS, although, again not noticeable difference,

Now here is the decider really, The GTX580 pulls ahead, and this may be noticeable at different points in the game as 20-30 FPS is where you may see lag.
Of course this is just battlefield 3, Here is the other benchmarks...
http://www.tomshardware.com/reviews/radeon-hd-7870-review-benchmark,3148-5.html
Just flick through the benchmarks...
It would also be worth mentioning the power consumption, the 7870
has significantly less power consumption
The GTX580 manages to use 40 more watts than the 7870, And imo that is a major deciding factor. It also means you can overclock higher with the 7870 than the 580
Hope I helped!