  Recent studies proposed that cosmic rays (CR) are a key ingredient in setting
the conditions for star formation, thanks to their ability to alter the thermal
and chemical state of dense gas in the UV-shielded cores of molecular clouds.
In this paper, we explore their role as regulators of the stellar initial mass
function (IMF) variations, using the semi-analytic model for GAlaxy Evolution
and Assembly (GAEA). The new model confirms our previous results obtained using
the integrated galaxy-wide IMF (IGIMF) theory: both variable IMF models
reproduce the observed increase of $\alpha$-enhancement as a function of
stellar mass and the measured $z=0$ excess of dynamical mass-to-light ratios
with respect to photometric estimates assuming a universal IMF. We focus here
on the mismatch between the photometrically-derived ($M^{\rm app}_{\star}$) and
intrinsic ($M_{\star}$) stellar masses, by analysing in detail the evolution of
model galaxies with different values of $M_{\star}/M^{\rm app}_{\star}$. We
find that galaxies with small deviations (i.e. formally consistent with a
universal IMF hypothesis) are characterized by more extended star formation
histories and live in less massive haloes with respect to the bulk of the
galaxy population. While the IGIMF theory does not change significantly the
mean evolution of model galaxies with respect to the reference model, a
CR-regulated IMF implies shorter star formation histories and higher peaks of
star formation for objects more massive than $10^{10.5} M_\odot$. However, we
also show that it is difficult to unveil this behaviour from observations, as
the key physical quantities are typically derived assuming a universal IMF.
