[llvm] [RemoveDIs] Enable DPLabels conversion [3b/3] (PR #82639)

Stephen Tozer via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 04:09:33 PST 2024


================
@@ -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);
----------------
SLTozer wrote:

Could we make `createDebugIntrinsic` a dispatch method that covers all debug records?

https://github.com/llvm/llvm-project/pull/82639


More information about the llvm-commits mailing list