[flang-commits] [flang] [flang][cuda] Implicitly load cudadevice module in device/global subprogram (PR #92038)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon May 13 15:06:56 PDT 2024
================
@@ -3797,6 +3797,26 @@ bool SubprogramVisitor::Pre(const parser::PrefixSpec::Attributes &attrs) {
subp->set_cudaSubprogramAttrs(attr);
}
}
+ if (auto attrs{subp->cudaSubprogramAttrs()}) {
+ if (*attrs == common::CUDASubprogramAttrs::Global ||
+ *attrs == common::CUDASubprogramAttrs::Device) {
+ const Scope &scope{currScope()};
+ const Scope *mod{FindModuleContaining(scope)};
+ if (mod && mod->GetName().value() == "cudadevice") {
+ return false;
+ }
+ // Implicitly USE the cudadevice module by copying its symbols in the
+ // current scope.
+ const Scope &cudaDeviceScope{context().GetCUDADeviceScope()};
+ for (auto sym : cudaDeviceScope.GetSymbols()) {
+ if (!currScope().FindSymbol(sym->name())) {
+ auto &localSymbol{MakeSymbol(sym->name())};
----------------
klausler wrote:
I think that there's an overload for `MakeSymbol` that lets you pass the details as an argument.
https://github.com/llvm/llvm-project/pull/92038
More information about the flang-commits
mailing list