[llvm] [RemoveDIs][DebugInfo] Verifier and printing fixes for DPLabel (PR #83242)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 04:38:24 PST 2024


================
@@ -6187,6 +6195,34 @@ static DISubprogram *getSubprogram(Metadata *LocalScope) {
   return nullptr;
 }
 
+void Verifier::visit(DPLabel &DPL) {
+  CheckDI(isa<DILabel>(DPL.getRawLabel()),
+          "invalid #dbg_label intrinsic variable", &DPL, DPL.getRawLabel());
+
+  // Ignore broken !dbg attachments; they're checked elsewhere.
+  if (MDNode *N = DPL.getDebugLoc().getAsMDNode())
+    if (!isa<DILocation>(N))
+      return;
+
+  BasicBlock *BB = DPL.getParent();
+  Function *F = BB ? BB->getParent() : nullptr;
+
+  // The scopes for variables and !dbg attachments must agree.
+  DILabel *Label = DPL.getLabel();
+  DILocation *Loc = DPL.getDebugLoc();
+  Check(Loc, "#dbg_label record requires a !dbg attachment", &DPL, BB, F);
----------------
jmorse wrote:

Any reason why this is `Check` and not `CheckDI`?

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


More information about the llvm-commits mailing list