This patch fixes a bug in instruction scheduling backtracking code.
https://llvm.org/bugs/show_bug.cgi?id=22304
It can happen (by line CurSU->isPending = true; // This SU is not in AvailableQueue right now.) that a SUnit is mark as available but is not in the AvailableQueue. For SUnit being selected for scheduling both conditions must be met.
This patch mainly defensively protects from invalid removing a node from a queue. For noob like be this isAvailable flag and being in the AvailableQueue decoherence is annoying but maybe I don't have a full picture. I tried to synchronize that but it breaks the whole scheduling algorithm.