After https://reviews.llvm.org/D59990 submit several issues were discovered.
Changes in common code were preserved but AMDGPU specific part was reverted to keep the backend working correctly.
Discovered issues were addressed in the following commits:
- https://reviews.llvm.org/D67662
- https://reviews.llvm.org/D67101
- https://reviews.llvm.org/D63953
- https://reviews.llvm.org/D63731
This change brings back AMDGPU specific changes.
Can you split this into a function?