aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/ObjectFile.cpp
diff options
context:
space:
mode:
authorJoseph Huber <huberjn@outlook.com>2024-01-05 10:24:30 -0600
committerGitHub <noreply@github.com>2024-01-05 10:24:30 -0600
commit3b337bbc811002d088d3ae6fcae869a8d5682bc1 (patch)
tree260bc7345b8946d8dcec4337283d36cb87c744fa /llvm/lib/Object/ObjectFile.cpp
parent5352ce32fccd37c54aff2b3a2b0e3ca5115bb8a9 (diff)
downloadllvm-3b337bbc811002d088d3ae6fcae869a8d5682bc1.zip
llvm-3b337bbc811002d088d3ae6fcae869a8d5682bc1.tar.gz
llvm-3b337bbc811002d088d3ae6fcae869a8d5682bc1.tar.bz2
[ELF] Attempt to set the OS when using 'makeTriple()' (#76992)
Summary: This patch fixes up the `makeTriple()` interface to emit append the operating system information when it is readily avaialble from the ELF. The main motivation for this is so the GPU architectures can be easily identified correctly when given and ELF. E.g. we want `amdgpu-amd-amdhsa` as the output and not `amdgpu--`. This required adding support for the CUDA OS/ABI, which is easily found to be `0x33` when using `readelf`.
Diffstat (limited to 'llvm/lib/Object/ObjectFile.cpp')
-rw-r--r--llvm/lib/Object/ObjectFile.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Object/ObjectFile.cpp b/llvm/lib/Object/ObjectFile.cpp
index ca92183..c05eb0a 100644
--- a/llvm/lib/Object/ObjectFile.cpp
+++ b/llvm/lib/Object/ObjectFile.cpp
@@ -111,6 +111,10 @@ Triple ObjectFile::makeTriple() const {
auto Arch = getArch();
TheTriple.setArch(Triple::ArchType(Arch));
+ auto OS = getOS();
+ if (OS != Triple::UnknownOS)
+ TheTriple.setOS(OS);
+
// For ARM targets, try to use the build attributes to build determine
// the build target. Target features are also added, but later during
// disassembly.
@@ -129,10 +133,13 @@ Triple ObjectFile::makeTriple() const {
// XCOFF implies AIX.
TheTriple.setOS(Triple::AIX);
TheTriple.setObjectFormat(Triple::XCOFF);
- }
- else if (isGOFF()) {
+ } else if (isGOFF()) {
TheTriple.setOS(Triple::ZOS);
TheTriple.setObjectFormat(Triple::GOFF);
+ } else if (TheTriple.isAMDGPU()) {
+ TheTriple.setVendor(Triple::AMD);
+ } else if (TheTriple.isNVPTX()) {
+ TheTriple.setVendor(Triple::NVIDIA);
}
return TheTriple;