[flang-commits] [flang] [mlir] [mlir][debuginfo] Add support for subprogram annotations (PR #110946)
Walter Erquinigo via flang-commits
flang-commits at lists.llvm.org
Mon Oct 7 12:42:41 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));
----------------
walter-erquinigo wrote:
Yeah, that makes sense. The current code would only crash if the name of the annotation is not a string. All other conditions are now flexible.
https://github.com/llvm/llvm-project/pull/110946
More information about the flang-commits
mailing list