Is there a source for the notion that someone who is killed "Al Kiddush Hashem" is not held accountable for his sins and goes straight to Gan Eden? Does this apply only when dying willingly?
Apart from Danny Schoemann's answer, there's another source that talks about this (Pesachim 50a), attributed to Rav Yosef the son of Rabbi Yehoshua son of Levi, who recovered from a coma in which he apparently had some visions of heaven.
ושמעתי שהיו אומרים הרוגי מלכות אין אדם יכול לעמוד במחיצתן (ומאן) [מסורת הש"ס: מאן] נינהו אילימא ר"ע וחביריו משום הרוגי מלכות ותו לא אלא הרוגי לוד
"And I heard they were saying (in heaven), 'No one can stand where those killed by the government are.'"
The Talmud proceeds to clarify that this doesn't refer to Rabbi Akiva and his friends (presumably the עשרה הרוגי מלכות, "ten killed by the government"), but rather to ordinary people killed by the government.
Who are they? If you say Rabbi Akiva and his friends, because of being killed by the government and nothing else? (Rashi: They didn't do anything else to deserve it?) Rather, those killed in Lud. (Rashi: Two brothers who admitted to a murder they didn't commit to save others who were incorrectly blamed for the murder.)
The source is a Gemara in Sanhedrin 47a where it seems to imply that anybody who was killed (as opposed to dying a natural death) gains atonement.
The parameters of this are discussed in the Gemara
(and I hope to fill them in when I have more time, if nobody does it for me.)
Then we find various Midrashim who explicitly talk about those killed Al Kiddush Hashem being considered righteous. Here are a few, which shall be translated as soon as I have time.
Source: ספר של הרב יחיאל מיכל שטרן שעוסק בקברים