-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RemoveDIs] Enable DPLabels conversion [3b/3] #82639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-debuginfo @llvm/pr-subscribers-llvm-ir Author: Orlando Cazalet-Hyams (OCHyams) ChangesEnables conversion between llvm.dbg.label and DPLabel. Full diff: https://github.com/llvm/llvm-project/pull/82639.diff 1 Files Affected:
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
|
Patch 2 of 3 to add llvm.dbg.label support to the RemoveDIs project. The patch stack adds the DPLabel class, which is the RemoveDIs llvm.dbg.label equivalent. 1. Add DbgRecord base class for DPValue and the not-yet-added DPLabel class. 2. Add the DPLabel class. -> 3. Add support to passes. The next patch, #82639, will enable conversion between dbg.labels and DPLabels. AssignemntTrackingAnalysis support could have gone two ways: 1. Have the analysis store a DPLabel representation in its results - SelectionDAGBuilder reads the analysis results and ignores all DbgRecord kinds. 2. Ignore DPLabels in the analysis - SelectionDAGBuilder reads the analysis results but still needs to iterate over DPLabels from the IR. I went with option 2 because it's less work and is no less correct than 1. It's worth noting that causes labels to sink to the bottom of packs of debug records. e.g., [value, label, value] becomes [value, value, label]. This shouldn't be a problem because labels and variable locations don't have an ordering requirement. The ordering between variable locations is maintained and the label movement is deterministic
86fc290
to
f4ebc40
Compare
llvm/lib/IR/BasicBlock.cpp
Outdated
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make createDebugIntrinsic
a dispatch method that covers all debug records?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM - done
Enables conversion between llvm.dbg.label and DPLabel.
Enables conversion between llvm.dbg.label and DPLabel.