From e8a4a9b97eb66d66e10637790245730e588bb8aa Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Wed, 24 Jan 2024 12:23:54 +0000 Subject: [PATCH] Fix opt test --- llvm/lib/Transforms/IPO/OpenMPOpt.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp index 783f6df2da2901..b8e15a2895daa3 100644 --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -287,6 +287,20 @@ 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();