Merge "Calculating has_second_ref only once for single_ref context."