[PassManager][Coroutine] Run passes under -O0 conditionally and run GlobalDCE
authorArthur Eubanks <aeubanks@google.com>
Tue, 22 Mar 2022 23:51:36 +0000 (16:51 -0700)
committerArthur Eubanks <aeubanks@google.com>
Wed, 23 Mar 2022 18:03:26 +0000 (11:03 -0700)
commit9bd66b312c3e0e539ac6c85c1bacd17bdc731614
tree9f82bd05f97d10dccba24dfefb5bbc2ec950ec16
parente6ead19b774718113007ecb1a4449d7af0cbcfeb
[PassManager][Coroutine] Run passes under -O0 conditionally and run GlobalDCE

CoroSplit lowers various coroutine intrinsics. It's a CGSCC pass and
CGSCC passes don't run on unreachable functions. Normally GlobalDCE will
come along and delete unreachable functions, but we don't run GlobalDCE
under -O0, so an unreachable function with coroutine intrinsics may
never have CoroSplit run on it.

This patch adds GlobalDCE when coroutines intrinsics are present. It
also now runs all coroutine passes conditional when coroutine intrinsics
are present. This should also solve the -O0 regression reported in
D105877 due to LazyCallGraph construction.

Fixes https://github.com/llvm/llvm-project/issues/54117

Reviewed By: ChuanqiXu

Differential Revision: https://reviews.llvm.org/D122275
12 files changed:
clang/test/CodeGen/lto-newpm-pipeline.c
llvm/include/llvm/Transforms/Coroutines/CoroConditionalWrapper.h [new file with mode: 0644]
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/lib/Transforms/Coroutines/CMakeLists.txt
llvm/lib/Transforms/Coroutines/CoroConditionalWrapper.cpp [new file with mode: 0644]
llvm/lib/Transforms/Coroutines/CoroInternal.h
llvm/lib/Transforms/Coroutines/Coroutines.cpp
llvm/test/Other/new-pm-O0-defaults.ll
llvm/test/Transforms/Coroutines/coro-internal-O0.ll [new file with mode: 0644]
llvm/test/Transforms/Coroutines/coro-retcon-once-private.ll
llvm/test/Transforms/Coroutines/smoketest.ll
llvm/utils/gn/secondary/llvm/lib/Transforms/Coroutines/BUILD.gn