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
Working in isolation doesn't suit you. You're a social creature who gets your best ideas when collaborating with others. Unfortunately, that's not possible right now. Resign yourself to this difficult situation. If you do a good job, you'll pave the way for bigger and better assignments. Part of the problem is you lack experience. The only way to get the training you need is to do some volunteer work. Making a temporary sacrifice will eventually pay off. Be patient.More