[llvm-bugs] [Bug 48712] New: [coroutines] Merging frame variables drops alignment information
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jan 11 04:50:26 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=48712
Bug ID: 48712
Summary: [coroutines] Merging frame variables drops alignment
information
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: jeremy.morse.llvm at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk,
yedeng.yd at linux.alibaba.com
A recent patch to merge non-overlapping allocas in coroutine frames [0] appears
to drop alignment information from one of the merged allocas. I have a fairly
complicated C++ reproducer that manages to crash as a result of this, however I
think it's best illustrated by one of the frame-reuse tests [1]. In that file,
%a and %b are merged into a single frame element:
%a.Frame = type {
void (%a.Frame*)*,
void (%a.Frame*)*,
%"struct.task::promise_type",
%struct.big_structure,
i1 }
Where the big_structure and big_structure.2 allocas have been merged into
big_structure. If I change %a to have 64 byte alignment:
%a = alloca %struct.big_structure, align 64
Then the frame is reshaped accordingly:
%a.Frame = type {
void (%a.Frame*)*,
void (%a.Frame*)*,
%"struct.task::promise_type",
i1,
[46 x i8],
%struct.big_structure }
With padding place before the big_structure type. If I add alignment to %b
instead of %a:
%b = alloca %struct.big_structure.2, align 64
Then the field in the frame doesn't get aligned:
%a.Frame = type {
void (%a.Frame*)*,
void (%a.Frame*)*,
%"struct.task::promise_type",
%struct.big_structure,
i1 }
The subsequent use of that unaligned field for %b's pointer:
%a.reload.addr = getelementptr inbounds %a.Frame, %a.Frame* %FramePtr, i32 0,
i32 3
%b.reload.addr = bitcast %struct.big_structure* %a.reload.addr to
%struct.big_structure.2*
Produces a pointer for %b that was supposed to be aligned to 64 bytes before
being split into a coroutine; and afterwards will not be aligned to 64 bytes.
I'm still hunting for why this causes my reproducer to crash later on, but I
believe this loss of alignment is a bug.
[0] https://reviews.llvm.org/rGb3a722e66b75
[1]
https://github.com/llvm/llvm-project/blob/a6db7cf1ce7f3523adb132819c1697a572bdcfde/llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-02.ll
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210111/78a66717/attachment-0001.html>
More information about the llvm-bugs
mailing list