[PATCH] D45221: [coroutines] Respect alloca alignment requirements when building coroutine frame

Gor Nishanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 3 11:45:17 PDT 2018


GorNishanov created this revision.
GorNishanov added reviewers: rnk, lewissbaker, modocache.
Herald added a subscriber: EricWF.

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 }


https://reviews.llvm.org/D45221

Files:
  lib/Transforms/Coroutines/CoroFrame.cpp
  lib/Transforms/Coroutines/CoroInternal.h
  test/Transforms/Coroutines/coro-padding.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45221.140839.patch
Type: text/x-patch
Size: 8386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180403/c71b62b7/attachment.bin>


More information about the llvm-commits mailing list