[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:10:07 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:
You said that you only support string annotations for now, but that there might be others, right? If that's correct, this will cause crashes if we hit such cases in the import.
It might be sensible to use `dyn_cast` and skip this part when we aren't dealing with `llvm::MDString`?
Same for the number of operands, there is probably no verifier in LLVM, so we need to check this here to avoid indexing out of range.
https://github.com/llvm/llvm-project/pull/110946
More information about the flang-commits
mailing list