[clang] [llvm] [Offload] Change ELF machine type for SPIR-V OpenMP image (PR #159623)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 18 14:02:39 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Nick Sarnie (sarnex)

<details>
<summary>Changes</summary>

This needs to match the runtime plugin (currently in PR [here](https://github.com/llvm/llvm-project/pull/158900)), and the plugin uses `8086` which I think is better.

---
Full diff: https://github.com/llvm/llvm-project/pull/159623.diff


2 Files Affected:

- (modified) clang/test/Tooling/clang-linker-wrapper-spirv-elf.cpp (+3) 
- (modified) llvm/lib/Frontend/Offloading/Utility.cpp (+4-3) 


``````````diff
diff --git a/clang/test/Tooling/clang-linker-wrapper-spirv-elf.cpp b/clang/test/Tooling/clang-linker-wrapper-spirv-elf.cpp
index af98904677283..1bf4572ee566c 100644
--- a/clang/test/Tooling/clang-linker-wrapper-spirv-elf.cpp
+++ b/clang/test/Tooling/clang-linker-wrapper-spirv-elf.cpp
@@ -7,9 +7,12 @@
 // RUN: %clangxx -fopenmp -fopenmp-targets=spirv64-intel -nogpulib -c -o %t_clang-linker-wrapper-spirv-elf.o %s
 // RUN: not clang-linker-wrapper -o a.out %t_clang-linker-wrapper-spirv-elf.o --save-temps --linker-path=ld
 // RUN: clang-offload-packager --image=triple=spirv64-intel,kind=openmp,file=%t.elf  %t_tmp/a.out.openmp.image.wrapper.o
+// RUN: llvm-readelf -h %t.elf | FileCheck -check-prefix=CHECK-MACHINE %s
 // RUN: llvm-readelf -t %t.elf | FileCheck -check-prefix=CHECK-SECTION %s
 // RUN: llvm-readelf -n %t.elf | FileCheck -check-prefix=CHECK-NOTES %s
 
+// CHECK-MACHINE: Machine: 8086
+
 // CHECK-SECTION: .note.inteloneompoffload
 // CHECK-SECTION: __openmp_offload_spirv_0
 
diff --git a/llvm/lib/Frontend/Offloading/Utility.cpp b/llvm/lib/Frontend/Offloading/Utility.cpp
index 5dcc16d23004c..7cb83987f36d2 100644
--- a/llvm/lib/Frontend/Offloading/Utility.cpp
+++ b/llvm/lib/Frontend/Offloading/Utility.cpp
@@ -423,9 +423,10 @@ Error offloading::intel::containerizeOpenMPSPIRVImage(
   Header.Class = ELF::ELFCLASS64;
   Header.Data = ELF::ELFDATA2LSB;
   Header.Type = ELF::ET_DYN;
-  // Use an existing Intel machine type as there is not one specifically for
-  // Intel GPUs.
-  Header.Machine = ELF::EM_IA_64;
+  // Use a fake machine type as there is not one specifically for
+  // Intel GPUs, the associated runtime plugin is looking for
+  // this value.
+  Header.Machine = 0x8086;
 
   // Create a section with notes.
   ELFYAML::NoteSection Section{};

``````````

</details>


https://github.com/llvm/llvm-project/pull/159623


More information about the llvm-commits mailing list