From 216689ace71dee579c0e42f67978beb25f5f7df0 Mon Sep 17 00:00:00 2001 From: Jun Ma Date: Wed, 2 Dec 2020 14:45:15 +0800 Subject: [PATCH] [Coroutines] Add DW_OP_deref for transformed dbg.value intrinsic. Differential Revision: https://reviews.llvm.org/D92462 --- llvm/lib/Transforms/Coroutines/CoroFrame.cpp | 4 +++- .../Transforms/Coroutines/coro-debug-frame-variable.ll | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp index 1a000c1913c6..48d52ff1d8df 100644 --- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp +++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp @@ -1289,7 +1289,9 @@ static Instruction *insertSpills(const FrameDataInfo &FrameData, // that control flow can be later changed by other passes. auto *DI = cast(FirstDbgDecl); BasicBlock *CurrentBlock = I->getParent(); - DIB.insertDbgValueIntrinsic(G, DI->getVariable(), DI->getExpression(), + auto *DerefExpr = + DIExpression::append(DI->getExpression(), dwarf::DW_OP_deref); + DIB.insertDbgValueIntrinsic(G, DI->getVariable(), DerefExpr, DI->getDebugLoc(), &*CurrentBlock->getFirstInsertionPt()); SeenDbgBBs.insert(CurrentBlock); diff --git a/llvm/test/Transforms/Coroutines/coro-debug-frame-variable.ll b/llvm/test/Transforms/Coroutines/coro-debug-frame-variable.ll index 00a77cb790dc..68d496c880ff 100644 --- a/llvm/test/Transforms/Coroutines/coro-debug-frame-variable.ll +++ b/llvm/test/Transforms/Coroutines/coro-debug-frame-variable.ll @@ -37,8 +37,8 @@ ; CHECK: call void @llvm.dbg.declare(metadata i32* [[IGEP]], metadata ![[IVAR:[0-9]+]], metadata !DIExpression()), !dbg ![[IDBGLOC:[0-9]+]] ; CHECK: call void @llvm.dbg.declare(metadata [10 x i32]* [[XGEP]], metadata ![[XVAR:[0-9]+]], metadata !DIExpression()), !dbg ![[IDBGLOC]] ; CHECK: await.ready: -; CHECK: call void @llvm.dbg.value(metadata [10 x i32]* [[XGEP]], metadata ![[XVAR]], metadata !DIExpression()), !dbg ![[IDBGLOC]] -; CHECK: call void @llvm.dbg.value(metadata i32* [[IGEP]], metadata ![[IVAR]], metadata !DIExpression()), !dbg ![[IDBGLOC]] +; CHECK: call void @llvm.dbg.value(metadata [10 x i32]* [[XGEP]], metadata ![[XVAR]], metadata !DIExpression(DW_OP_deref)), !dbg ![[IDBGLOC]] +; CHECK: call void @llvm.dbg.value(metadata i32* [[IGEP]], metadata ![[IVAR]], metadata !DIExpression(DW_OP_deref)), !dbg ![[IDBGLOC]] ; CHECK: call void @llvm.dbg.declare(metadata i32* %j, metadata ![[JVAR:[0-9]+]], metadata !DIExpression()), !dbg ![[JDBGLOC:[0-9]+]] ; ; CHECK-LABEL: define internal fastcc void @f.resume({{.*}}) { @@ -50,8 +50,8 @@ ; CHECK: call void @llvm.dbg.declare(metadata i32* [[IGEP_RESUME]], metadata ![[IVAR_RESUME:[0-9]+]], metadata !DIExpression()), !dbg ![[IDBGLOC_RESUME:[0-9]+]] ; CHECK: call void @llvm.dbg.declare(metadata [10 x i32]* [[XGEP_RESUME]], metadata ![[XVAR_RESUME:[0-9]+]], metadata !DIExpression()), !dbg ![[IDBGLOC_RESUME]] ; CHECK: await.ready: -; CHECK: call void @llvm.dbg.value(metadata [10 x i32]* [[XGEP_RESUME]], metadata ![[XVAR_RESUME]], metadata !DIExpression()), !dbg ![[IDBGLOC_RESUME]] -; CHECK: call void @llvm.dbg.value(metadata i32* [[IGEP_RESUME]], metadata ![[IVAR_RESUME]], metadata !DIExpression()), !dbg ![[IDBGLOC_RESUME]] +; CHECK: call void @llvm.dbg.value(metadata [10 x i32]* [[XGEP_RESUME]], metadata ![[XVAR_RESUME]], metadata !DIExpression(DW_OP_deref)), !dbg ![[IDBGLOC_RESUME]] +; CHECK: call void @llvm.dbg.value(metadata i32* [[IGEP_RESUME]], metadata ![[IVAR_RESUME]], metadata !DIExpression(DW_OP_deref)), !dbg ![[IDBGLOC_RESUME]] ; CHECK: call void @llvm.dbg.declare(metadata i32* %j, metadata ![[JVAR_RESUME:[0-9]+]], metadata !DIExpression()), !dbg ![[JDBGLOC_RESUME:[0-9]+]] ; ; CHECK: ![[IVAR]] = !DILocalVariable(name: "i" @@ -247,4 +247,4 @@ declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg) !19 = !DILocation(line: 42, column: 8, scope: !7) !20 = !DILocation(line: 43, column: 3, scope: !7) !21 = !DILocation(line: 43, column: 8, scope: !7) -!22 = distinct !DILexicalBlock(scope: !8, file: !1, line: 23, column: 12) \ No newline at end of file +!22 = distinct !DILexicalBlock(scope: !8, file: !1, line: 23, column: 12)