You will get the miles of the originally-purchased fare, but may have to chase them after the fact to give you the "B" miles (as "O" is non-earning, and the system will most likely first think you flew in "O").
http://www.flyertalk.com/forum/air-f...pgraded-s.html
(by the way - this thread is supposed to be about operational upgrades, i.e. upgrades where you paid neither miles nor cash)