[flang-commits] [flang] [mlir] [mlir][debuginfo] Add support for subprogram annotations (PR #110946)

Christian Ulmann via flang-commits flang-commits at lists.llvm.org
Mon Oct 7 12:39:24 PDT 2024


================
@@ -245,12 +245,24 @@ DISubprogramAttr DebugImporter::translateImpl(llvm::DISubprogram *node) {
   if (llvm::is_contained(retainedNodes, nullptr))
     retainedNodes.clear();
 
+  SmallVector<DINodeAttr> annotations;
+  if (llvm::DINodeArray rawAnns = node->getAnnotations(); rawAnns) {
+    for (size_t i = 0, e = rawAnns->getNumOperands(); i < e; ++i) {
+      const llvm::MDTuple *tuple = cast<llvm::MDTuple>(rawAnns->getOperand(i));
+      const auto name = StringAttr::get(
+          context, cast<llvm::MDString>(tuple->getOperand(0))->getString());
+      const auto value = StringAttr::get(
+          context, cast<llvm::MDString>(tuple->getOperand(1))->getString());
+      annotations.push_back(DIAnnotationAttr::get(context, name, value));
----------------
Dinistro wrote:

Only supporting strings is fine, but crashing on legal LLVM IR is not. This should just be resilient to arbitary legal inputs and not randomly crash or segfault.


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


More information about the flang-commits mailing list