Barilla started racing in 1975 and won the Italian 100cc karting title in 1976. In 1980 he entered Formula Fiat Abarth, and moved up to Formula 3 in 1981, where he won some races and finished third in the Italian Championship. Barilla then entered Formula 2 in 1982 with Minardi, but between 1983 and 1988 he concentrated in Sports car racing, winning 24 Hours of Le Mans by a three lap margin in 1985, among other victories, in the Joest Racing Porsche 956, co-driven at times with Klaus Ludwig, Paul Belmondo, Marc Duez, and Louis Krages (also known at the time as John Winter).