This is an archive of the discontinued LLVM Phabricator instance.

[SPARC] Fix stupid oversight in stack realignment support.
ClosedPublic

Authored by jyknight on Aug 25 2015, 6:41 PM.

Details

Summary

If you're going to realign %sp to get object alignment properly (which
the code does), and stack offsets and alignments are calculated going
down from %fp (which they are), then the total stack size had better
be a multiple of the alignment. LLVM did indeed ensure that.

And then, after aligning, the sparc frame code added 96 (for sparcv8)
to the frame size, making any requested alignment of 64-bytes or
higher *guaranteed* to be misaligned. The test case added with r245668
even tests this exact scenario, and asserted the incorrect behavior,
which I somehow failed to notice. D'oh.

This change fixes the frame lowering code to align the stack size
*after* adding the spill area, instead.

Diff Detail

Repository
rL LLVM

Event Timeline

jyknight updated this revision to Diff 33163.Aug 25 2015, 6:41 PM
jyknight retitled this revision from to [SPARC] Fix stupid oversight in stack realignment support..
jyknight updated this object.
jyknight added a reviewer: chandlerc.
jyknight added a subscriber: llvm-commits.
chandlerc accepted this revision.Aug 26 2015, 1:47 AM
chandlerc edited edge metadata.

Looks good with a comment update below.

lib/Target/Sparc/SparcFrameLowering.cpp
121–123 ↗(On Diff #33163)

I wouldn't reference the hook here. Instead, I would explain the why. Clearly (according to the spec of the API) to do this here your target has to set the hook correctly. But why does SPARC handle alignment this way.

This revision is now accepted and ready to land.Aug 26 2015, 1:47 AM
This revision was automatically updated to reflect the committed changes.