Answer by taking a quote from the following article:

Legion (David Charles Haller) is a fictional superhero appearing in American comic books published by Marvel Comics. He is the mutant son of Professor Charles Xavier and Gabrielle Haller. Legion takes the role of an antihero who has a severe mental illness including a form of dissociative identity disorder, in which each of his alternate personas controls one of his many superpowers. The television series Legion premiered on FX network in 2017.

When Mystique tracked down David years later to get revenge for "his" murder of Destiny, he awakened with his fractured mind healed. David had a new goal, to help his father realize his dream of human-mutant coexistence by killing Magneto, Xavier's greatest opponent, before he had a chance to amass power. He traveled twenty years into the past, when Xavier and Magneto were orderlies at the mental hospital. In the process, he loses his memory. Magneto then accidentally triggers his memory, causing David to go on a rampage, attacking Magneto and revealing the existence of mutants to the public decades too early. Several X-Men who were pulled back in time with him were unable to prevent him from attacking Magneto. Xavier, however, leaped into the path of the psi-knife (the focused totality of Legion's psionic powers) and was killed in Magneto's place, causing the formation of the Age of Apocalypse timeline.  Due to being trapped in the past by David's actions, Bishop enlisted the aid of the new reality's X-Men to travel back in time to confront Legion again. Bishop seized Legion's psi-blade and drove it into his own chest, allowing Legion to see the future that he caused. In his last moments, David apologized for what he did. David's mother, Gabrielle Haller, described having a "maternal loss" afterward, implying she miscarried before giving birth to David.  While David was considered deceased, some of his alternate personalities remained trapped between life and death, manifesting as spirits. When the spirits started terrorizing Israel, Excalibur was called to stop them. After learning that the spirits were refusing death, Meggan used her empathy to calm their rage, convincing them to go "towards the light."

What was the result of his attempt to kill Magneto?
the Age of Apocalypse timeline.