Page MenuHomePhabricator

[coroutine] Respect alloca alignment requirements.
ClosedPublic

Authored by GorNishanov on Nov 20 2017, 4:17 PM.

Details

Reviewers
lewissbaker
Summary

If an alloca need to be stored in the coroutine frame and it has an alignment specified and the alignment does not match the natural alignment of the alloca type. Insert appropriate padding into the coroutine frame to make sure that it gets requested alignment.

For example for a packet type (which natural alignment is 1), but alloca alignment is 8, we may need to insert a padding field with required number of bytes to make sure it is properly aligned.

%PackedStruct = type <{ i64 }>
...
  %data = alloca %PackedStruct, align 8

If the previous field in the coroutine frame had alignment 2, we would have [6 x i8] inserted before %PackedStruct in the coroutine frame:

%f.Frame = type { ..., i16, [6 x i8], %PackedStruct }

Also, removed useless std::sort for spills that was not required and was causing needless non-determinism of builds since it was sorting based on addresses of the instruction that may result in different sorted order between the builds

Diff Detail

Event Timeline

GorNishanov created this revision.Nov 20 2017, 4:17 PM
GorNishanov edited the summary of this revision. (Show Details)Nov 20 2017, 4:27 PM
GorNishanov edited the summary of this revision. (Show Details)Nov 20 2017, 4:31 PM
lewissbaker accepted this revision.Dec 14 2017, 3:15 AM
lewissbaker added a subscriber: lewissbaker.

All looks fine to me.

This revision is now accepted and ready to land.Dec 14 2017, 3:15 AM
GorNishanov closed this revision.Apr 3 2018, 11:44 AM

Put out an updated version of this patch in

https://reviews.llvm.org/D45221