[llvm] [Coroutines] Drop dead instructions more aggressively in addMustTailToCoroResumes() (PR #85271)
Chuanqi Xu via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 18 06:14:23 PDT 2024
================
@@ -1203,10 +1203,6 @@ static bool simplifyTerminatorLeadingToRet(Instruction *InitialInst) {
if (isa<BitCastInst>(I) || I->isDebugOrPseudoInst() ||
I->isLifetimeStartOrEnd())
I = I->getNextNode();
- else if (isInstructionTriviallyDead(I))
- // Duing we are in the middle of the transformation, we need to erase
- // the dead instruction manually.
- I = &*I->eraseFromParent();
----------------
ChuanqiXu9 wrote:
> So perhaps CoroCloner is the one who should clean up these instructions.
Generally this is not something we'd like to do for the middle end passes. However, this is (was) a defect in the clang/llvm coroutines implementations. Since the symmetric transfer is semantics about C++ and according to our design for modules, we have to make it in the middle end. So this is the why we have this... But probably we can never get rid of this if we (Clang/LLVM) don't want to be conforming to C++ anymore.
> Yes, maybe it's too big a hammer. On the other hand, the ad-hoc dce and constant folding in simplifyTerminatorLeadingToRet() makes me a little nervous.
So my line is, if the problem comes from a particular C++ programs and the corresponding LLVM passes applied, yes we need to solve it. However, if it comes from a manual constructed IR only, then possibly we shouldn't do that.
https://github.com/llvm/llvm-project/pull/85271
More information about the llvm-commits
mailing list