From 478af4479ab65b90a4c7bd6460ff685d8e95d625 Mon Sep 17 00:00:00 2001 From: Hubert Tong Date: Tue, 31 Mar 2020 17:24:22 -0400 Subject: [PATCH] [Object] Update ObjectFile::makeTriple for XCOFF Summary: When we encounter an XCOFF file, reflect that in the triple information. In addition to knowing the object file format, we know that the associated OS is AIX. This means that we can expect that there is no output difference in the processing of an XCOFF32 input file between cases where the triple is left unspecified by the user and cases where the user specifies `--triple powerpc-ibm-aix` explicitly. Reviewers: jhenderson, sfertile, jasonliu, daltenty Reviewed By: jasonliu Subscribers: wuzish, nemanjai, hiraditya, MaskRay, rupprecht, steven.zhang, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77025 --- llvm/lib/Object/ObjectFile.cpp | 11 +++++++---- llvm/test/CodeGen/PowerPC/aix-return55.ll | 2 +- llvm/test/tools/llvm-objdump/XCOFF/disassemble-all.test | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Object/ObjectFile.cpp b/llvm/lib/Object/ObjectFile.cpp index 098b3d8..7879e2e 100644 --- a/llvm/lib/Object/ObjectFile.cpp +++ b/llvm/lib/Object/ObjectFile.cpp @@ -108,14 +108,17 @@ Triple ObjectFile::makeTriple() const { setARMSubArch(TheTriple); // TheTriple defaults to ELF, and COFF doesn't have an environment: - // the best we can do here is indicate that it is mach-o. - if (isMachO()) + // something we can do here is indicate that it is mach-o. + if (isMachO()) { TheTriple.setObjectFormat(Triple::MachO); - - if (isCOFF()) { + } else if (isCOFF()) { const auto COFFObj = cast(this); if (COFFObj->getArch() == Triple::thumb) TheTriple.setTriple("thumbv7-windows"); + } else if (isXCOFF()) { + // XCOFF implies AIX. + TheTriple.setOS(Triple::AIX); + TheTriple.setObjectFormat(Triple::XCOFF); } return TheTriple; diff --git a/llvm/test/CodeGen/PowerPC/aix-return55.ll b/llvm/test/CodeGen/PowerPC/aix-return55.ll index a098571..0aa49e6 100644 --- a/llvm/test/CodeGen/PowerPC/aix-return55.ll +++ b/llvm/test/CodeGen/PowerPC/aix-return55.ll @@ -31,7 +31,7 @@ entry: ;CHECKOBJ-NEXT: 18: 00 01 23 45 ;CHECKOBJ-NEXT: 1c: 67 8a bc de oris 10, 28, 48350{{[[:space:]] *}} ;CHECKOBJ-NEXT: 00000020 : -;CHECKOBJ-NEXT: 20: 40 14 00 00 bdnzf 20, .+0 +;CHECKOBJ-NEXT: 20: 40 14 00 00 bdnzf 20, $+0 ;CHECKOBJ-NEXT: 24: 00 00 00 00 {{[[:space:]] *}} ;CHECKOBJ-NEXT: 00000028 : ;CHECKOBJ-NEXT: 28: 00 00 00 00 diff --git a/llvm/test/tools/llvm-objdump/XCOFF/disassemble-all.test b/llvm/test/tools/llvm-objdump/XCOFF/disassemble-all.test index 5a229ca..556a8e1 100644 --- a/llvm/test/tools/llvm-objdump/XCOFF/disassemble-all.test +++ b/llvm/test/tools/llvm-objdump/XCOFF/disassemble-all.test @@ -55,7 +55,7 @@ CHECK: 000000a4 : CHECK-NEXT: ... CHECK: Disassembly of section .tdata: CHECK: 00000000 : -CHECK-NEXT: 0: 40 09 21 f9 bdnzfl 9, .+8696 +CHECK-NEXT: 0: 40 09 21 f9 bdnzfl 9, $+8696 CHECK-NEXT: 4: f0 1b 86 6e CHECK: Disassembly of section .tbss: CHECK: 00000008 : -- 2.7.4