[flang-commits] [flang] dc477a8 - [flang] Remove obsolete TODO

Daniil Dudkin via flang-commits flang-commits at lists.llvm.org
Fri Aug 26 03:01:46 PDT 2022


Author: Daniil Dudkin
Date: 2022-08-26T13:00:39+03:00
New Revision: dc477a8161984dc5b8e245800e1166eb81394df6

URL: https://github.com/llvm/llvm-project/commit/dc477a8161984dc5b8e245800e1166eb81394df6
DIFF: https://github.com/llvm/llvm-project/commit/dc477a8161984dc5b8e245800e1166eb81394df6.diff

LOG: [flang] Remove obsolete TODO

As the comment tells, the TODO was added because
there was no conversion for abstract results in function types inside GlobalOps.
Since the conversion was added, this TODO is obsolete, so it is removed.

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D130369

Added: 
    flang/test/Fir/non-trivial-procedure-binding-description.f90

Modified: 
    flang/lib/Lower/ConvertExpr.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index 6fb1ca2432692..b50670e1e4419 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -917,13 +917,6 @@ class ScalarExprLowering {
       std::string name = converter.mangleName(*symbol);
       mlir::func::FuncOp func =
           Fortran::lower::getOrDeclareFunction(name, proc, converter);
-      // Abstract results require later rewrite of the function type.
-      // This currently does not happen inside GloalOps, causing LLVM
-      // IR verification failure. This helper is only here to catch these
-      // cases and emit a TODOs for now.
-      if (inInitializer && fir::hasAbstractResult(func.getFunctionType()))
-        TODO(converter.genLocation(symbol->name()),
-             "static description of non trivial procedure bindings");
       funcPtr = builder.create<fir::AddrOfOp>(loc, func.getFunctionType(),
                                               builder.getSymbolRefAttr(name));
     }

diff  --git a/flang/test/Fir/non-trivial-procedure-binding-description.f90 b/flang/test/Fir/non-trivial-procedure-binding-description.f90
new file mode 100644
index 0000000000000..695d7fdfe232d
--- /dev/null
+++ b/flang/test/Fir/non-trivial-procedure-binding-description.f90
@@ -0,0 +1,30 @@
+! RUN: %flang_fc1 -emit-mlir %s -o - | FileCheck %s --check-prefix=BEFORE
+! RUN: %flang_fc1 -emit-mlir %s -o - | fir-opt --abstract-result-on-global-opt | FileCheck %s --check-prefix=AFTER
+module a
+  type f
+  contains
+! BEFORE: fir.address_of(@_QMaPfoo) : (!fir.ref<!fir.type<_QMaTf>>) -> !fir.box<!fir.heap<!fir.char<1,?>>>
+! AFTER: [[ADDRESS:%.*]] = fir.address_of(@_QMaPfoo) : (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>, !fir.ref<!fir.type<_QMaTf>>) -> ()
+! AFTER: fir.convert [[ADDRESS]] : ((!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>, !fir.ref<!fir.type<_QMaTf>>) -> ()) -> ((!fir.ref<!fir.type<_QMaTf>>) -> !fir.box<!fir.heap<!fir.char<1,?>>>)
+! AFTER-NOT: fir.address_of(@_QMaPfoo) : (!fir.ref<!fir.type<_QMaTf>>) -> !fir.box<!fir.heap<!fir.char<1,?>>>
+    procedure, nopass :: foo
+  end type f
+contains
+  function foo(obj) result(bar)
+    type(f) :: obj
+    character(len=:), allocatable :: bar
+
+    if (.TRUE.) then
+      bar = "true"
+    else
+      bar = "false"
+    endif
+  end function foo
+end module a
+
+program main
+  use a
+
+  type(f) :: obj 
+  print *, obj%foo(obj)
+end program


        


More information about the flang-commits mailing list