[flang-commits] [flang] [flang][debug] Set scope of internal functions correctly. (PR #99531)

Abid Qadeer via flang-commits flang-commits at lists.llvm.org
Wed Jul 24 04:48:44 PDT 2024


================
@@ -299,9 +299,29 @@ void AddDebugInfoPass::runOnOperation() {
           subprogramFlags | mlir::LLVM::DISubprogramFlags::Definition;
     }
     unsigned line = getLineFromLoc(l);
-    if (!result.second.modules.empty())
+    if (fir::isInternalProcedure(funcOp)) {
+      // For contained functions, the scope is the parent subroutine.
+      mlir::SymbolRefAttr sym = mlir::cast<mlir::SymbolRefAttr>(
+          funcOp->getAttr(fir::getHostSymbolAttrName()));
+      if (sym) {
+        if (auto func = symbolTable.lookup<mlir::func::FuncOp>(
+                sym.getLeafReference())) {
+          // FIXME: Can there be situation where we process contained function
----------------
abidh wrote:

Thanks for the review. I have moved the function processing in a separate function and now we can make sure that parent is processed before contained subroutine.

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


More information about the flang-commits mailing list