[Openmp-commits] [PATCH] D155886: [OpenMP][Plugin] Update the global address calculation

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Jul 20 14:28:48 PDT 2023


tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, jhuber6.
Herald added subscribers: sunshaoce, guansong, tpr, yaxunl.
Herald added a project: All.
tianshilei1992 requested review of this revision.
Herald added subscribers: openmp-commits, jplehr, sstefan1.
Herald added a project: OpenMP.

Current global address caculation doesn't work for AMDGPU in some cases (https://reviews.llvm.org/D142569#4506212).
The root cause is the `sh_addr` is not substracted when caculating the address.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155886

Files:
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/GlobalHandler.cpp


Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/GlobalHandler.cpp
===================================================================
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/GlobalHandler.cpp
+++ openmp/libomptarget/plugins-nextgen/common/PluginInterface/GlobalHandler.cpp
@@ -53,8 +53,8 @@
 
   // The global's address is computed as the image begin + the ELF section
   // offset + the ELF symbol value.
-  ImageGlobal.setPtr(
-      advanceVoidPtr(Image.getStart(), Section.sh_offset + Symbol.st_value));
+  ImageGlobal.setPtr(advanceVoidPtr(
+      Image.getStart(), Section.sh_offset - Section.sh_addr + Symbol.st_value));
 
   // Set the global's size.
   ImageGlobal.setSize(Symbol.st_size);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155886.542676.patch
Type: text/x-patch
Size: 740 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230720/c2add1f6/attachment.bin>


More information about the Openmp-commits mailing list