[flang-commits] [flang] [flang] Lower function/subroutine attribute to func op (PR #95468)

via flang-commits flang-commits at lists.llvm.org
Fri Jun 14 00:20:13 PDT 2024


================
@@ -5025,6 +5025,20 @@ class FirConverter : public Fortran::lower::AbstractConverter {
         new fir::FirOpBuilder(func, bridge.getKindMap(), &mlirSymbolTable);
     assert(builder && "FirOpBuilder did not instantiate");
     builder->setFastMathFlags(bridge.getLoweringOptions().getMathOptions());
+    // Set procedure attributes to the func op.
+    if (!funit.isMainProgram()) {
+      const Fortran::semantics::Symbol &funcSym = funit.getSubprogramSymbol();
+      if (IsPureProcedure(funcSym))
+        func.getOperation()->setAttr(fir::getFuncPureAttrName(),
+                                     builder->getUnitAttr());
+      if (IsElementalProcedure(funcSym))
+        func.getOperation()->setAttr(fir::getFuncElementAttrName(),
+                                     builder->getUnitAttr());
+      if (funcSym.attrs().test(Fortran::semantics::Attr::RECURSIVE))
+        func.getOperation()->setAttr(fir::getFuncRecursiveAttrName(),
+                                     builder->getUnitAttr());
+    }
+
----------------
jeanPerier wrote:

Can you move the logic to `addSymbolAttribute` https://github.com/llvm/llvm-project/blob/c4a1440c149d3ea03f14fd6858b6be3a2faf9af6/flang/lib/Lower/CallInterface.cpp#L582C13-L582C31 ?

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


More information about the flang-commits mailing list