[PATCH] D107384: Simplify coro::salvageDebugInfo() (NFC-ish)
Adrian Prantl via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 3 11:53:45 PDT 2021
aprantl created this revision.
aprantl added reviewers: StephenTozer, ChuanqiXu, vsk.
aprantl added a project: debug-info.
Herald added subscribers: lxfind, hiraditya.
aprantl requested review of this revision.
Herald added a project: LLVM.
This patch removes the hand-rolled implementation of salvageDebugInfo for cast and GEPs and replaces it with a call into llvm::salvageDebugInfoImpl().
A side-effect of this is that additional redundant convert operations are introduced, but those don't have any negative effect on the resulting DWARF expression.
https://reviews.llvm.org/D107384
Files:
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
llvm/test/Transforms/Coroutines/coro-debug.ll
Index: llvm/test/Transforms/Coroutines/coro-debug.ll
===================================================================
--- llvm/test/Transforms/Coroutines/coro-debug.ll
+++ llvm/test/Transforms/Coroutines/coro-debug.ll
@@ -154,7 +154,7 @@
; CHECK: call void @llvm.dbg.declare(metadata %f.Frame** %[[DBG_PTR]], metadata ![[RESUME_DIRECT:[0-9]+]], metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, [[EXPR_TAIL]])
; CHECK: store %f.Frame* {{.*}}, %f.Frame** %[[DBG_PTR]]
; CHECK-NOT: alloca %struct.test*
-; CHECK: call void @llvm.dbg.declare(metadata i32 0, metadata ![[RESUME_CONST:[0-9]+]], metadata !DIExpression())
+; CHECK: call void @llvm.dbg.declare(metadata i8 0, metadata ![[RESUME_CONST:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_convert, 8, DW_ATE_signed, DW_OP_LLVM_convert, 32, DW_ATE_signed))
; Note that keeping the undef value here could be acceptable, too.
; CHECK-NOT: call void @llvm.dbg.declare(metadata i32* undef, metadata !{{[0-9]+}}, metadata !DIExpression())
; CHECK: call void @coro.devirt.trigger(i8* null)
Index: llvm/lib/Transforms/Coroutines/CoroFrame.cpp
===================================================================
--- llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -2527,22 +2527,21 @@
OutermostLoad = false;
} else if (auto *StInst = dyn_cast<StoreInst>(Storage)) {
Storage = StInst->getOperand(0);
- } else if (auto *GEPInst = dyn_cast<GetElementPtrInst>(Storage)) {
+ } else if (auto *Inst = dyn_cast<Instruction>(Storage)) {
SmallVector<uint64_t, 16> Ops;
SmallVector<Value *, 0> AdditionalValues;
- Storage = llvm::salvageDebugInfoImpl(
- *GEPInst, Expr ? Expr->getNumLocationOperands() : 0, Ops,
+ Value *Op = llvm::salvageDebugInfoImpl(
+ *Inst, Expr ? Expr->getNumLocationOperands() : 0, Ops,
AdditionalValues);
- if (!Storage)
+ if (!Op)
break;
// Debug declares cannot currently handle additional location
// operands.
if (!AdditionalValues.empty())
break;
+ Storage = Op;
Expr = DIExpression::appendOpsToArg(Expr, Ops, 0, /*StackValue*/false);
- } else if (auto *BCInst = dyn_cast<llvm::BitCastInst>(Storage))
- Storage = BCInst->getOperand(0);
- else
+ } else
break;
}
if (!Storage)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107384.363829.patch
Type: text/x-patch
Size: 2363 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210803/35e9fdab/attachment.bin>
More information about the llvm-commits
mailing list