Gravitational effects on Yang-Mills topology