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? firstname.lastname@example.org
Working with your best friend, romantic or business partner will be productive. You're good at handling the small details, while your other half stays focused on the big picture. A publicity campaign will attract lots of loyal customers. Don't be afraid to put money into advertising. Once the word gets out, you'll see a dramatic increase in profits. You'll also meet lots of interesting people; some may even become lifelong friends. You love rubbing elbows with rebels who won't play by the rules.More