[flang-commits] [flang] [flang][cuda] Implicitly load cudadevice module in device/global subprogram (PR #91668)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Thu May 9 15:46:27 PDT 2024


================
@@ -3797,6 +3797,17 @@ 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) {
+        // Implicitly USE the cudadevice module by copying its symbol in the
+        // current scope.
----------------
clementval wrote:

So according to the reference compiler we should not overwrite what is already in scope so I updated the copy of symbol and added a test.
For what is declared after, in device or global procedure, we will have an error msg. I added a test also for this case. 

https://github.com/llvm/llvm-project/pull/91668


More information about the flang-commits mailing list