Sharapova outlasts Halep to reach semis