Index: llvm/lib/Transforms/Coroutines/CoroFrame.cpp =================================================================== --- llvm/lib/Transforms/Coroutines/CoroFrame.cpp +++ llvm/lib/Transforms/Coroutines/CoroFrame.cpp @@ -2521,6 +2521,7 @@ bool SkipOutermostLoad = !isa(DVI); Value *Storage = DVI->getVariableLocationOp(0); Value *OriginalStorage = Storage; + while (auto *Inst = dyn_cast_or_null(Storage)) { if (auto *LdInst = dyn_cast(Inst)) { Storage = LdInst->getOperand(0); @@ -2576,8 +2577,7 @@ // expression, we need to add a DW_OP_deref at the *start* of the // expression to first load the contents of the alloca before // adjusting it with the expression. - if (Expr && Expr->isComplex()) - Expr = DIExpression::prepend(Expr, DIExpression::DerefBefore); + Expr = DIExpression::prepend(Expr, DIExpression::DerefBefore); } DVI->replaceVariableLocationOp(OriginalStorage, Storage); Index: llvm/test/Transforms/Coroutines/coro-debug-coro-frame.ll =================================================================== --- llvm/test/Transforms/Coroutines/coro-debug-coro-frame.ll +++ llvm/test/Transforms/Coroutines/coro-debug-coro-frame.ll @@ -10,7 +10,7 @@ ; ; CHECK: define internal fastcc void @f.resume( ; CHECK: entry.resume: -; CHECK: call void @llvm.dbg.declare(metadata %f.Frame** %[[FramePtr_RESUME:.*]], metadata ![[CORO_FRAME_IN_RESUME:[0-9]+]], metadata !DIExpression() +; CHECK: call void @llvm.dbg.declare(metadata %f.Frame** %[[FramePtr_RESUME:.*]], metadata ![[CORO_FRAME_IN_RESUME:[0-9]+]], metadata !DIExpression(DW_OP_deref) ; ; CHECK-DAG: ![[FILE:[0-9]+]] = !DIFile(filename: "coro-debug.cpp" ; CHECK-DAG: ![[RAMP:[0-9]+]] = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov",