[llvm] 07bef02 - [OpenMPOpt] Initialize OpenMPIRBuilderConfig::IsGPU flag (#104456)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 5 04:30:23 PDT 2024


Author: Sergio Afonso
Date: 2024-09-05T12:30:20+01:00
New Revision: 07bef02831836748f46ddd285520f351fe18cfe9

URL: https://github.com/llvm/llvm-project/commit/07bef02831836748f46ddd285520f351fe18cfe9
DIFF: https://github.com/llvm/llvm-project/commit/07bef02831836748f46ddd285520f351fe18cfe9.diff

LOG: [OpenMPOpt] Initialize OpenMPIRBuilderConfig::IsGPU flag (#104456)

This patch ensures the `IsGPU` flag is set by the OpenMPOpt pass, so
that it can be relied upon by `OpenMPIRBuilder` methods when called by
that pass as well.

Since currently there are very limited callers for the
`OpenMPIRBuilder::isGPU()` method, no assertions are being triggered by
the lack of initialization of this flag. However, when more
offloading-related features are implemented, it will eventually start
happening.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 7c1489f37049f0..cd94661bbe07f7 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -286,6 +286,19 @@ struct OMPInformationCache : public InformationCache {
         OpenMPPostLink(OpenMPPostLink) {
 
     OMPBuilder.Config.IsTargetDevice = isOpenMPDevice(OMPBuilder.M);
+    const Triple T(OMPBuilder.M.getTargetTriple());
+    switch (T.getArch()) {
+    case llvm::Triple::nvptx:
+    case llvm::Triple::nvptx64:
+    case llvm::Triple::amdgcn:
+      assert(OMPBuilder.Config.IsTargetDevice &&
+             "OpenMP AMDGPU/NVPTX is only prepared to deal with device code.");
+      OMPBuilder.Config.IsGPU = true;
+      break;
+    default:
+      OMPBuilder.Config.IsGPU = false;
+      break;
+    }
     OMPBuilder.initialize();
     initializeRuntimeFunctions(M);
     initializeInternalControlVars();


        


More information about the llvm-commits mailing list