This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAGBuilder] Stop setting alignment to one for hidden sret values
ClosedPublic

Authored by arichardson on Apr 28 2020, 6:17 AM.

Details

Summary

We allocated a suitably aligned frame index so we know that all the values
have ABI alignment.
For MIPS this avoids using pair of lwl + lwr instructions instead of a
single lw. I found this when compiling CHERI pure capability code where
we can't use the lwl/lwr unaligned loads/stores and and were to falling
back to a byte load + shift + or sequence.

This should save a few instructions for MIPS and possibly other backends
that don't have fast unaligned loads/stores.
It also improves code generation for CodeGen/X86/pr34653.ll since it can
now use aligned loads.

Depends on D78998.

Diff Detail

Event Timeline

arichardson created this revision.Apr 28 2020, 6:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2020, 6:17 AM
arichardson requested review of this revision.Apr 28 2020, 6:19 AM
efriedma added inline comments.Apr 28 2020, 3:29 PM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
1836

The alignment of the stack slot is computed using Align Alignment = DL.getPrefTypeAlign(CLI.RetTy);, Is there some reason to do something different here?

9287

You don't need to use min() here. The "alignment" argument of getLoad is actually the alignment of the object referred to by the MachinePointerInfo, excluding the offset.

  • address review feedback. Also appears to improve codegen in one wasm test
arichardson marked 2 inline comments as done.Apr 29 2020, 1:48 AM
efriedma accepted this revision.Apr 29 2020, 1:19 PM

LGTM with one minor comment.

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
1849

commonAlignment(BaseAlign, Offsets[i])

This revision is now accepted and ready to land.Apr 29 2020, 1:19 PM
This revision was automatically updated to reflect the committed changes.