Skip to content

Commit

Permalink
[OpenMP][Plugin] Update the global address calculation
Browse files Browse the repository at this point in the history
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.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D155886
  • Loading branch information
shiltian committed Jul 23, 2023
1 parent 5da317a commit 763fdb1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
16 changes: 0 additions & 16 deletions openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
Expand Up @@ -2583,22 +2583,6 @@ struct AMDGPUGlobalHandlerTy final : public GenericGlobalHandlerTy {
// Store the symbol address on the device global metadata.
DeviceGlobal.setPtr(reinterpret_cast<void *>(SymbolAddr));

return Plugin::success();
}

private:
/// Extract the global's information from the ELF image, section, and symbol.
Error getGlobalMetadataFromELF(const DeviceImageTy &Image,
const ELF64LE::Sym &Symbol,
const ELF64LE::Shdr &Section,
GlobalTy &ImageGlobal) override {
// The global's address in AMDGPU is computed as the image begin + the ELF
// symbol value. Notice we do not add the ELF section offset.
ImageGlobal.setPtr(advanceVoidPtr(Image.getStart(), Symbol.st_value));

// Set the global's size.
ImageGlobal.setSize(Symbol.st_size);

return Plugin::success();
}
};
Expand Down
Expand Up @@ -53,8 +53,8 @@ Error GenericGlobalHandlerTy::getGlobalMetadataFromELF(

// 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);
Expand Down

0 comments on commit 763fdb1

Please sign in to comment.