Previously, we were legalizing new instructions in the order they were created (using the MIRBuilder). My previous patch to add a clean up combiner ended up chaining the order of how we process the instructions (in the worklist) from top down to bottom up.
While this shouldn't be an issue (legalization should only look at one instruction), there's some out of tree code that looks at other instructions as well, and this is breaking the legalization for that instruction.
This patch reverts the legalization processing order of newly created insts to how they were before the clean up combiner - but still cleans up artifacts.
I don't think I've seen the naming convention of ending type names with "Type" in the LLVM code base - but I also by far haven't looked at all the LLVM code.
Maybe "struct WorkList" would be better.
I find it unfortunate that we would need to create a custom container here for this single specific use case. Is there really not a pre-existing container that is good enough? My guess is that this WorkListType's advantage over a deque is only that it can check quickly if an element is present in the container. Is that really such a frequent operation that that must be fast, but removing that element if present doesn't have to be faster than deque.erase?