[clang] [Clang][OpenMP] Clang adding the addrSpace according to DataLayout fix (PR #65483)

Aaron Jarmusch via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 6 07:09:04 PDT 2023


https://github.com/ajarmusch created https://github.com/llvm/llvm-project/pull/65483:

Fix for an issue where clang was not adding the address space according to the data layout, instead was using the default which resulted in a crash at times. The fix includes changes to the cases of LargeCapMemAlloc and CGroupMemAlloc where we are setting the AddrSpace according to the DataLayout. 

>From 5a56cffb1e53e8c7415bf468a7edfb464fbc08a0 Mon Sep 17 00:00:00 2001
From: Aaron Jarmusch <jarmusch at udel.edu>
Date: Wed, 6 Sep 2023 13:56:16 +0000
Subject: [PATCH] [Clang][OpenMP] Clang adding the addrSpace according to
 DataLayout fix

---
 clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 1ec9bb3d5234714..927cc5215d9a1e5 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -3362,6 +3362,8 @@ Address CGOpenMPRuntimeGPU::getAddressOfLocalVariable(CodeGenFunction &CGF,
       break;
     case OMPAllocateDeclAttr::OMPLargeCapMemAlloc:
     case OMPAllocateDeclAttr::OMPCGroupMemAlloc:
+      if (VD->hasGlobalStorage()) 
+        AS = getLangASFromTargetAS(CGF.CGM.getModule().getDataLayout().getDefaultGlobalsAddressSpace());
       break;
     }
     llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());



More information about the cfe-commits mailing list