[flang-commits] [PATCH] D154127: [flang] Block containing an interface
vdonaldson via Phabricator via flang-commits
flang-commits at lists.llvm.org
Thu Jun 29 11:15:27 PDT 2023
vdonaldson created this revision.
vdonaldson added a project: Flang.
Herald added subscribers: sunshaoce, mehdi_amini, jdoerfert.
Herald added a project: All.
vdonaldson requested review of this revision.
Name mangling may be invoked for an interface procedure contained in
a block in a context that does not have access to block ID mapping.
Procedures can't be defined inside a block, so name mangling doesn't
need a block map. Relax an assert to account for this.
block
interface
subroutine ss(n) bind(c)
integer :: n
end subroutine
end interface
call ss(5)
end
https://reviews.llvm.org/D154127
Files:
flang/lib/Lower/Mangler.cpp
flang/test/Lower/block.f90
Index: flang/test/Lower/block.f90
===================================================================
--- flang/test/Lower/block.f90
+++ flang/test/Lower/block.f90
@@ -2,6 +2,7 @@
! CHECK-LABEL: func @_QQmain
program bb ! block stack management and exits
+ ! CHECK: %[[V_0:[0-9]+]] = fir.alloca i32 {adapt.valuebyref}
! CHECK: %[[V_1:[0-9]+]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFEi"}
integer :: i, j
! CHECK: fir.store %c0{{.*}} to %[[V_1]] : !fir.ref<i32>
@@ -61,7 +62,6 @@
! CHECK: fir.call @llvm.stackrestore(%[[V_3]])
! CHECK: br ^bb19
! CHECK: ^bb19: // 2 preds: ^bb13, ^bb18
- ! CHECK: return
block
i = i + 1 ! 1 increment
do j = 1, 5
@@ -78,4 +78,21 @@
i = i + 1 ! 0 increments
12 end block
100 print*, i ! expect 21
+
+ ! CHECK: %[[V_51:[0-9]+]] = fir.call @llvm.stacksave() fastmath<contract> : () -> !fir.ref<i8>
+ ! CHECK: fir.store %c5{{.*}} to %[[V_0]] : !fir.ref<i32>
+ ! CHECK: fir.call @ss(%[[V_0]]) fastmath<contract> : (!fir.ref<i32>) -> ()
+ ! CHECK: fir.call @llvm.stackrestore(%[[V_51]]) fastmath<contract> : (!fir.ref<i8>) -> ()
+ block
+ interface
+ subroutine ss(n) bind(c)
+ integer :: n
+ end subroutine
+ end interface
+ call ss(5)
+ end block
end
+
+subroutine ss(n) bind(c)
+ print*, n
+end subroutine
Index: flang/lib/Lower/Mangler.cpp
===================================================================
--- flang/lib/Lower/Mangler.cpp
+++ flang/lib/Lower/Mangler.cpp
@@ -188,8 +188,9 @@
std::string
Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
bool keepExternalInScope) {
- assert(symbol.owner().kind() !=
- Fortran::semantics::Scope::Kind::BlockConstruct &&
+ assert((symbol.owner().kind() !=
+ Fortran::semantics::Scope::Kind::BlockConstruct ||
+ symbol.has<Fortran::semantics::SubprogramDetails>()) &&
"block object mangling must specify a scopeBlockIdMap");
ScopeBlockIdMap scopeBlockIdMap;
return mangleName(symbol, scopeBlockIdMap, keepExternalInScope);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154127.535923.patch
Type: text/x-patch
Size: 2171 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230629/3cfd2960/attachment-0001.bin>
More information about the flang-commits
mailing list