-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Flang]: Fix to bind(C) procs inside BLOCK construct #82483
Conversation
@llvm/pr-subscribers-flang-fir-hlfir Author: None (harishch4) ChangesName mangling is invoked for a bind(C) procedure contained in a block in a context that does not have access to block ID mapping. Relaxing an assert to account for this. Fixes #79408 Full diff: https://github.com/llvm/llvm-project/pull/82483.diff 2 Files Affected:
diff --git a/flang/lib/Lower/Mangler.cpp b/flang/lib/Lower/Mangler.cpp
index 24abbce01c059e..9a33be318a27d8 100644
--- a/flang/lib/Lower/Mangler.cpp
+++ b/flang/lib/Lower/Mangler.cpp
@@ -182,7 +182,8 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
bool underscoring) {
assert((symbol.owner().kind() !=
Fortran::semantics::Scope::Kind::BlockConstruct ||
- symbol.has<Fortran::semantics::SubprogramDetails>()) &&
+ symbol.has<Fortran::semantics::SubprogramDetails>() ||
+ Fortran::semantics::IsBindCProcedure(symbol)) &&
"block object mangling must specify a scopeBlockIdMap");
ScopeBlockIdMap scopeBlockIdMap;
return mangleName(symbol, scopeBlockIdMap, keepExternalInScope, underscoring);
diff --git a/flang/test/Lower/HLFIR/block_bindc_pocs.f90 b/flang/test/Lower/HLFIR/block_bindc_pocs.f90
new file mode 100644
index 00000000000000..cfec45cfcd8545
--- /dev/null
+++ b/flang/test/Lower/HLFIR/block_bindc_pocs.f90
@@ -0,0 +1,20 @@
+! This test checks bind(c) procs inside BLOCK construct.
+
+!RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
+
+module m
+ interface
+ subroutine test_proc() bind(C)
+ end subroutine test_proc
+ end interface
+end module m
+!CHECK-DAG: %[[S0:.*]] = fir.call @llvm.stacksave.p0() fastmath<contract> : () -> !fir.ref<i8>
+!CHECK-DAG: fir.call @test_proc() fastmath<contract> : () -> ()
+!CHECK-DAG: fir.call @llvm.stackrestore.p0(%[[S0]]) fastmath<contract> : (!fir.ref<i8>) -> ()
+!CHECK-DAG: func.func private @test_proc() attributes {fir.bindc_name = "test_proc"}
+subroutine test
+ BLOCK
+ use m
+ call test_proc
+ END BLOCK
+end subroutine test
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG.
Since this is not an OpenMP issue, please remove the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok to me; thanks for the fix
Name mangling is invoked for a bind(C) procedure contained in a block in a context that does not have access to block ID mapping. Relaxing an assert to account for this.
Fixes #79408