As @rsmith find in https://bugs.llvm.org/show_bug.cgi?id=45130 that musttail attribute is not added to some of the resume intrinsics. These are some optimizations need to do here:
- We only check llvm.coro.subfn.addr for now, however, the intrinsic can be replaced in CoroElide pass. Furthermore, we can support other function calls as long as they obey rules of musttail.
- in simplifyTerminatorLeadingToRet, we only check switch and unconditional branch instructions while suspend switch instruction can be reduced as conditional branch. This also break the optimization.
This patch implements part 1, all of the rules in shouldBeMustTail are same as verifyMustTailCall
TestPlan: check-llvm