The pair worked together on new film Filth, which also stars Jim Broadbent and Jamie Bell, and is based on Welsh's "unfilmable" third book.
Welsh told the Radio Times that while making Filth, he discussed the subject of sexual abuse with X-Men star McAvoy, who apparently told him: "If you ever write a script about it, I'd love to play Jimmy Savile."
In Welsh's 1996 collection Ecstasy, one of the stories, Lorraine Goes to Livingston, concerns Freddy Royle, a fictional children's TV presenter described as the nation's "favourite caring, laconic uncle", who turns out to be a child molester and necrophiliac, raising millions for the hospital where he commits his crimes.
The story was written over 15 years before Savile's crimes became public.
Asked whether the similarities were based on inside knowledge, Welsh told the Radio Times: "I had nothing to do with the hospital services, or NHS trusts, or the BBC.
"So how come I knew this rumour about Jimmy Savile, this eccentric British institution? There must have been so much stuff on the grapevine. But there was a whole culture then of not addressing these issues."
Welsh said that he was groped by middle-aged women when, as a student in the late 70s, he worked in a bingo hall.
He said that he believed such abusive behaviour was "all about power".
COMMENT RULES: Comments that are judged to be defamatory, abusive or in bad taste are not acceptable and contributors who consistently fall below certain criteria will be permanently blacklisted. The moderator will not enter into debate with individual contributors and the moderator’s decision is final. It is Belfast Telegraph policy to close comments on court cases, tribunals and active legal investigations. We may also close comments on articles which are being targeted for abuse. Problems with commenting? email@example.com
An opportunity to expand your horizons is too good to ignore. Studying or travelling abroad will keep you far from home, but absence will make the heart grow fonder. If you have a beloved pet, make arrangements to travel with your companion. Don't let small inconveniences keep you from exploring new vistas. Have you been yearning to write a book? Begin now, while you have some stellar cosmic energy at your back. Great things can happen if you take a risk.More