Rory McIlroy was relieved to produce a strong finish after two poor holes almost derailed his US Open campaign on the second day at Pebble Beach.