[Coroutines] Do not add alloca to the frame if the size is 0
authorXun Li <lxfind@gmail.com>
Tue, 4 May 2021 18:11:43 +0000 (11:11 -0700)
committerXun Li <lxfind@gmail.com>
Tue, 4 May 2021 19:55:40 +0000 (12:55 -0700)
commitdef86413d4c7bd088c3dbf445480a3eb2074da66
tree781c53095d2e4126c6da3f1cb28403e4c327ad85
parent6c3a10760da3707186d5204bd9283e99344fa90f
[Coroutines] Do not add alloca to the frame if the size is 0

This patch is to address https://bugs.llvm.org/show_bug.cgi?id=49916.
When the size of an alloca is 0, it will trigger an assertion in OptimizedStructLayout when being added to the frame.
Fix it by not adding it at all. We return index 0 (beginning of the frame) for all 0-sized allocas.

Differential Revision: https://reviews.llvm.org/D101841
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
llvm/test/Transforms/Coroutines/coro-zero-alloca.ll [new file with mode: 0644]