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).
In 1987 Barilla returned to single-seaters and raced in the Japanese Formula 3000 Championship, before returning to Minardi in 1989 for a test. This test gave him the chance to replace Pierluigi Martini at Suzuka that year and afterwards was signed to drive for the team in 1990. Barilla wasn't quick enough to qualify regularly and was replaced before the end of the year by Gianni Morbidelli.
Barilla was featured in the 2017 documentary about the restoration of a Ferrari 312B historic Formula 1 race car.