Cherry pick b40e901333b903fd71f17c3314d3e40f8abde074 for llvm-project. (#8901)
Cherry pick b40e901333b903fd71f17c3314d3e40f8abde074 for llvm-project. (#8901)

This pulls in the changes needed for PR #8723.
iree-org/iree,google/iree,iree-org/iree,google/iree,iree-org/iree,google/iree,google/iree,iree-org/iree,iree-org/iree,iree-org/iree,google/iree,google/iree,google/iree,iree-org/iree