General Motors has said it would spend US$2.7bn at two Brazilian factories over the next five years, sparing them from closure.