This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel][IRTranslator] Use preferred alignment when creating frame indices.
AbandonedPublic

Authored by aemerson on May 12 2021, 11:04 PM.

Details

Reviewers
paquette
arsenm
Summary

By using the the preferred alignment when possible, this can allow local stack slot allocation to avoid materializing a base register for stack slots.

Diff Detail

Event Timeline

aemerson created this revision.May 12 2021, 11:04 PM
aemerson requested review of this revision.May 12 2021, 11:04 PM
arsenm added inline comments.May 13 2021, 6:22 AM
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
263

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)

aemerson updated this revision to Diff 345734.May 16 2021, 5:10 PM

Guard this with a TLI check. I think a separate pass to do this is overkill.

arsenm added inline comments.May 17 2021, 6:31 AM
llvm/include/llvm/CodeGen/TargetLowering.h
535

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?

aemerson added inline comments.May 17 2021, 10:54 AM
llvm/include/llvm/CodeGen/TargetLowering.h
535

in practice frontends emit them with 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.

aemerson abandoned this revision.Sep 20 2021, 5:22 PM