Skip to content

Commit 7b65ac4

Browse files
committed
adding test
1 parent 1b6da29 commit 7b65ac4

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

flang/include/flang/Semantics/symbol.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ class OpenACCRoutineDeviceTypeInfo {
142142
const std::string *bindName() const {
143143
return bindName_ ? &*bindName_ : nullptr;
144144
}
145-
void set_bindName(std::string &&name) { bindName_ = std::move(name); }
145+
bool bindNameIsInternal() const {return bindNameIsInternal_;}
146+
void set_bindName(std::string &&name, bool isInternal=false) {
147+
bindName_ = std::move(name);
148+
bindNameIsInternal_ = isInternal;
149+
}
146150

147151
Fortran::common::OpenACCDeviceType dType() const { return deviceType_; }
148152

@@ -153,6 +157,7 @@ class OpenACCRoutineDeviceTypeInfo {
153157
bool isGang_{false};
154158
unsigned gangDim_{0};
155159
std::optional<std::string> bindName_;
160+
bool bindNameIsInternal_{false};
156161
Fortran::common::OpenACCDeviceType deviceType_{
157162
Fortran::common::OpenACCDeviceType::None};
158163
};

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,10 +1077,12 @@ void AccAttributeVisitor::AddRoutineInfoToSymbol(
10771077
} else if (const auto *bindClause =
10781078
std::get_if<Fortran::parser::AccClause::Bind>(&clause.u)) {
10791079
std::string bindName = "";
1080+
bool isInternal = false;
10801081
if (const auto *name =
10811082
std::get_if<Fortran::parser::Name>(&bindClause->v.u)) {
10821083
if (Symbol *sym = ResolveFctName(*name)) {
10831084
bindName = sym->name().ToString();
1085+
isInternal = true;
10841086
} else {
10851087
context_.Say((*name).source,
10861088
"No function or subroutine declared for '%s'"_err_en_US,
@@ -1100,12 +1102,14 @@ void AccAttributeVisitor::AddRoutineInfoToSymbol(
11001102
if (!bindName.empty()) {
11011103
// Fixme: do we need to ensure there there is only one device?
11021104
for (auto &device : currentDevices) {
1103-
device->set_bindName(std::string(bindName));
1105+
device->set_bindName(std::string(bindName), isInternal);
11041106
}
11051107
}
11061108
}
11071109
}
11081110
symbol.get<SubprogramDetails>().add_openACCRoutineInfo(info);
1111+
} else {
1112+
llvm::errs() << "Couldnot add routine info to symbol: " << symbol.name() << "\n";
11091113
}
11101114
}
11111115

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
! RUN: rm -fr %t && mkdir -p %t && cd %t
2+
! RUN: bbc -fopenacc -emit-fir %s
3+
! RUN: cat mod1.mod | FileCheck %s
4+
5+
!CHECK-LABEL: module mod1
6+
module mod1
7+
contains
8+
!CHECK subroutine callee(aa)
9+
subroutine callee(aa)
10+
!CHECK: !$acc routine seq
11+
!$acc routine seq
12+
integer :: aa
13+
aa = 1
14+
end subroutine
15+
!CHECK: end
16+
!CHECK: end
17+
end module
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
! RUN: rm -fr %t && mkdir -p %t && cd %t
2+
! RUN: bbc -emit-fir %S/acc-module-definition.f90
3+
! RUN: bbc -emit-fir %s -o - | FileCheck %s
4+
5+
! This test module is based off of flang/test/Lower/use_module.f90
6+
! The first runs ensures the module file is generated.
7+
8+
module use_mod1
9+
use mod1
10+
contains
11+
!CHECK: func.func @_QMuse_mod1Pcaller
12+
!CHECK-SAME {
13+
subroutine caller(aa)
14+
integer :: aa
15+
!$acc serial
16+
!CHECK: fir.call @_QMmod1Pcallee
17+
call callee(aa)
18+
!$acc end serial
19+
end subroutine
20+
!CHECK: }
21+
!CHECK: acc.routine @acc_routine_0 func(@_QMmod1Pcallee) seq
22+
!CHECK: func.func private @_QMmod1Pcallee(!fir.ref<i32>) attributes {acc.routine_info = #acc.routine_info<[@acc_routine_0]>}
23+
end module

0 commit comments

Comments
 (0)