This patch changes the legalization order from top down to bottom up.
Also, this deletes trivially dead instructions while legalizing.
Additionally, the LegalizationCombiner tries to clean up artifacts before legalizeInstrStep. This lets the combiner clean up redundant extends/truncs before letting the target deal with them. This simplifies the legalization loop a little - where we don't need to have a separate list to track new legalization artifacts for combines - as we can try to clean up every artifact (vs just new ones).
I have updated AArch backend with this patch.
Can you add some comments explaining why this is needed/what it's trying to achieve.