We investigate the effects of a top-heavy stellar initial mass function on the reionization history of the intergalactic medium (IGM). We use cosmological simulations that include self-consistently the feedback from ionizing radiation, H-2 dissociating radiation and supernova (SN) explosions. We run a set of simulations to check the numerical convergence and the effect of mechanical energy input from SNe. In agreement with other studies, we find that it is difficult to reionize the IGM at z(rei)>0 with stellar sources even after making extreme assumptions. If star formation in 10(9) M-circle dot galaxies is not suppressed by SN explosions, the optical depth to Thomson scattering is tau(e)less than or similar to 0.13. If we allow for the normal energy input from SNe or if pair-instability SNe are dominant, we find tau(e)less than or similar to 0.09. Assuming normal yields for the first stars (Population III), the mean metallicity of the IGM is already Z/Z(circle dot)= 2x10(-3) (10(-3)<Z/Z(circle dot)<1 in overdense regions) when the IGM mean ionization fraction is less than 10 per cent. For these reasons, Population III stars cannot contribute significantly to reionization unless the mechanical energy input from SNe is greatly reduced and either the metal yield or the mixing efficiency is reduced by a factor of 10(3). Both problems have a solution if Population III stars collapse to black holes. This can happen if, having masses M-*<130 M-circle dot, they are characterized by heavy element fallback or if, having masses M-*>260 M-circle dot, they collapse directly on to black holes without exploding as SNe. If metal-poor stars are initially important and if collapse to black holes is the typical outcome, then the secondary emission of ionizing radiation from accretion on SN-induced seed black holes might be more important than the primary emission. We also develop a semi-analytic code to study how tau(e) is sensitive to cosmological parameters, finding essentially the same results. Neglecting feedback effects, we find simple relationships for tau(e) as a function of the power spectrum spectral index and the emission efficiency of ionizing radiation for cold dark matter and warm dark matter cosmologies. Surprisingly, we estimate that a warm dark matter scenario (with particle mass of 1.25 keV) reduces tau(e) by only approximately 10 per cent.