[llvm] [RemoveDIs] Enable DPLabels conversion [3b/3] (PR #82639)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 22 07:48:08 PST 2024
https://github.com/OCHyams created https://github.com/llvm/llvm-project/pull/82639
Enables conversion between llvm.dbg.label and DPLabel.
>From 86fc290155d804629764dccefabbc7d3859a8dbc Mon Sep 17 00:00:00 2001
From: OCHyams <orlando.hyams at sony.com>
Date: Tue, 16 Jan 2024 11:16:03 +0000
Subject: [PATCH] enable conversion
---
llvm/lib/IR/BasicBlock.cpp | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 0680754444f17f..8a5bfdb0506854 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -81,6 +81,12 @@ void BasicBlock::convertToNewDbgValues() {
continue;
}
+ if (DbgLabelInst *DLI = dyn_cast<DbgLabelInst>(&I)) {
+ DPVals.push_back(new DPLabel(DLI->getLabel(), DLI->getDebugLoc()));
+ DLI->eraseFromParent();
+ continue;
+ }
+
if (DPVals.empty())
continue;
@@ -108,15 +114,26 @@ void BasicBlock::convertFromNewDbgValues() {
DPMarker &Marker = *Inst.DbgMarker;
for (DbgRecord &DR : Marker.getDbgValueRange()) {
- if (auto *DPV = dyn_cast<DPValue>(&DR))
+ if (auto *DPV = dyn_cast<DPValue>(&DR)) {
InstList.insert(Inst.getIterator(),
DPV->createDebugIntrinsic(getModule(), nullptr));
- else
+ } else if (auto *DPL = dyn_cast<DPLabel>(&DR)) {
+ auto *LabelFn =
+ Intrinsic::getDeclaration(getModule(), Intrinsic::dbg_label);
+ Value *Args[] = {
+ MetadataAsValue::get(getModule()->getContext(), DPL->getLabel())};
+ DbgLabelInst *DbgLabel = cast<DbgLabelInst>(
+ CallInst::Create(LabelFn->getFunctionType(), LabelFn, Args));
+ DbgLabel->setTailCall();
+ DbgLabel->setDebugLoc(DPL->getDebugLoc());
+ InstList.insert(Inst.getIterator(), DbgLabel);
+ } else {
llvm_unreachable("unsupported DbgRecord kind");
+ }
}
Marker.eraseFromParent();
- };
+ }
// Assume no trailing DPValues: we could technically create them at the end
// of the block, after a terminator, but this would be non-cannonical and
More information about the llvm-commits
mailing list