Skip to content

Commit 9d9628e

Browse files
Merge pull request llvm#245 from DominikAdamski/revert_bindc_omp_routines
Revert "[flang] Consider bind(c) when lowering calls to intrinsic module procedures (llvm#70386)" This revert patch needs to be removed when upstream is fixed.
2 parents e777f95 + 5919156 commit 9d9628e

File tree

3 files changed

+11
-36
lines changed

3 files changed

+11
-36
lines changed

flang/lib/Lower/ConvertCall.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2122,12 +2122,7 @@ genProcedureRef(CallContext &callContext) {
21222122
mlir::Location loc = callContext.loc;
21232123
if (auto *intrinsic = callContext.procRef.proc().GetSpecificIntrinsic())
21242124
return genIntrinsicRef(intrinsic, callContext);
2125-
// If it is an intrinsic module procedure reference - then treat as
2126-
// intrinsic unless it is bind(c) (since implementation is external from
2127-
// module).
2128-
if (Fortran::lower::isIntrinsicModuleProcRef(callContext.procRef) &&
2129-
!Fortran::semantics::IsBindCProcedure(
2130-
*callContext.procRef.proc().GetSymbol()))
2125+
if (Fortran::lower::isIntrinsicModuleProcRef(callContext.procRef))
21312126
return genIntrinsicRef(nullptr, callContext);
21322127

21332128
if (callContext.isStatementFunctionCall())
@@ -2232,7 +2227,8 @@ bool Fortran::lower::isIntrinsicModuleProcRef(
22322227
return false;
22332228
const Fortran::semantics::Symbol *module =
22342229
symbol->GetUltimate().owner().GetSymbol();
2235-
return module && module->attrs().test(Fortran::semantics::Attr::INTRINSIC);
2230+
return module && module->attrs().test(Fortran::semantics::Attr::INTRINSIC) &&
2231+
module->name().ToString().find("omp_lib") == std::string::npos;
22362232
}
22372233

22382234
std::optional<hlfir::EntityWithAttributes> Fortran::lower::convertCallToHLFIR(

flang/module/omp_lib.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
omp_atv_blocked = 17, &
9191
omp_atv_interleaved = 18
9292

93-
type, bind(c) :: omp_alloctrait
93+
type :: omp_alloctrait
9494
integer(kind=omp_alloctrait_key_kind) :: key, value
9595
end type omp_alloctrait
9696

@@ -264,23 +264,23 @@
264264
integer(kind=omp_integer_kind), intent(out) :: place_nums(*)
265265
end subroutine omp_get_partition_place_nums
266266

267-
subroutine omp_set_affinity_format(format) bind(c)
267+
subroutine omp_set_affinity_format(format)
268268
import
269269
character(len=*), intent(in) :: format
270270
end subroutine omp_set_affinity_format
271271

272-
function omp_get_affinity_format(buffer) bind(c)
272+
function omp_get_affinity_format(buffer)
273273
import
274274
character(len=*), intent(out) :: buffer
275275
integer(kind=omp_integer_kind) :: omp_get_affinity_format
276276
end function omp_get_affinity_format
277277

278-
subroutine omp_display_affinity(format) bind(c)
278+
subroutine omp_display_affinity(format)
279279
import
280280
character(len=*), intent(in) :: format
281281
end subroutine omp_display_affinity
282282

283-
function omp_capture_affinity(buffer, format) bind(c)
283+
function omp_capture_affinity(buffer, format)
284284
import
285285
character(len=*), intent(out) :: buffer
286286
character(len=*), intent(in) :: format
@@ -339,7 +339,7 @@
339339
integer(kind=omp_integer_kind) :: omp_pause_resource
340340
end function omp_pause_resource
341341

342-
function omp_pause_resource_all(kind) bind(c)
342+
function omp_pause_resource_all(kind)
343343
import
344344
integer(kind=omp_pause_resource_kind), value :: kind
345345
integer(kind=omp_integer_kind) :: omp_pause_resource_all
@@ -428,7 +428,7 @@
428428
! Device Memory Routines
429429

430430
! Memory Management Routines
431-
function omp_init_allocator(memspace, ntraits, traits) bind(c)
431+
function omp_init_allocator(memspace, ntraits, traits)
432432
import
433433
integer(kind=omp_memspace_handle_kind), value :: memspace
434434
integer, value :: ntraits
@@ -446,7 +446,7 @@
446446
integer(kind=omp_allocator_handle_kind), value :: allocator
447447
end subroutine omp_set_default_allocator
448448

449-
function omp_get_default_allocator() bind(c)
449+
function omp_get_default_allocator()
450450
import
451451
integer(kind=omp_allocator_handle_kind) :: omp_get_default_allocator
452452
end function omp_get_default_allocator

flang/test/Lower/OpenMP/omp-lib-num-threads.f90

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)