By using the the preferred alignment when possible, this can allow local stack slot allocation to avoid materializing a base register for stack slots.
I think the answer is no. You could have a separate pass up-align allocas, and in practice frontends emit them with the preferred alignment to begin with.
For AMDGPU there is no benefit to aligning anything on the stack over 4, and anything more just wastes space. The ABI still requires the higher alignment though, so I would like to have a pass to under align allocas when the alignment isn't visible. I've also long wanted to allow the datalayout to specify a preferred alignment lower than the ABI, but this isn't allowed (D29810 partially addressed this but never went anywhere)
I really don't like this hook. We have way too many super specific hacky hooks like this. Is this really a concern? Why isn't the frontend setting the preferred alignment to begin with?
I can't find where this is happening. I'm too familiar with clang but if I grep for 'getPrefTypeAlign' I only see a few places where it's called there, which look specific to some cases, not general allocas.