[Openmp-commits] [PATCH] D106579: [libomptarget][amdgpu][nfc] Replace use of gelf.h with libelf.h

Jon Chesterfield via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Jul 22 11:41:42 PDT 2021


JonChesterfield created this revision.
JonChesterfield added reviewers: jdoerfert, tianshilei1992, pdhaliwal, ronlieb.
Herald added subscribers: kerbowa, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl.
JonChesterfield requested review of this revision.
Herald added subscribers: openmp-commits, wdng.
Herald added a project: OpenMP.

AMDGPU can assume Elf64 so doesn't need to abstract over Elf32

Drop a few unused std headers at the same time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106579

Files:
  openmp/libomptarget/plugins/amdgpu/impl/system.cpp
  openmp/libomptarget/plugins/amdgpu/src/rtl.cpp


Index: openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
===================================================================
--- openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -15,10 +15,7 @@
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
-#include <elf.h>
-#include <fstream>
 #include <functional>
-#include <iostream>
 #include <libelf.h>
 #include <list>
 #include <memory>
Index: openmp/libomptarget/plugins/amdgpu/impl/system.cpp
===================================================================
--- openmp/libomptarget/plugins/amdgpu/impl/system.cpp
+++ openmp/libomptarget/plugins/amdgpu/impl/system.cpp
@@ -3,13 +3,9 @@
  *
  * This file is distributed under the MIT License. See LICENSE.txt for details.
  *===------------------------------------------------------------------------*/
-#include <gelf.h>
 #include <libelf.h>
 
 #include <cassert>
-#include <fstream>
-#include <iomanip>
-#include <set>
 #include <sstream>
 #include <string>
 
@@ -465,11 +461,10 @@
     return failure;
   }
 
+  Elf64_Phdr *pHdrs = elf64_getphdr(e);
   for (size_t i = 0; i < numpHdrs; ++i) {
-    GElf_Phdr pHdr;
-    if (gelf_getphdr(e, i, &pHdr) != &pHdr) {
-      continue;
-    }
+    Elf64_Phdr pHdr = pHdrs[i];
+
     // Look for the runtime metadata note
     if (pHdr.p_type == PT_NOTE && pHdr.p_align >= sizeof(int)) {
       // Iterate over the notes in this segment


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106579.360910.patch
Type: text/x-patch
Size: 1438 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210722/12ea7200/attachment.bin>


More information about the Openmp-commits mailing list