The Chemical Composition of Red Giants, AGB Stars and Planetary Nebulae