[llvm] r256226 - [MC] Don't use the architecture to govern which object file format to use
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 22 14:02:23 PST 2015
awesome. Thanks!
On 21 December 2015 at 20:39, David Majnemer via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: majnemer
> Date: Mon Dec 21 19:39:04 2015
> New Revision: 256226
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256226&view=rev
> Log:
> [MC] Don't use the architecture to govern which object file format to use
>
> InitMCObjectFileInfo was trying to override the triple in awkward ways.
> For example, a triple specifying COFF but not Windows was forced as ELF.
> This makes it easy for internal invariants to get violated, such as
> those which triggered PR25912.
>
> This fixes PR25912.
>
> Added:
> llvm/trunk/test/MC/ELF/ARM/directive-type-diagnostics.s
> Removed:
> llvm/trunk/test/MC/COFF/ARM/directive-type-diagnostics.s
> Modified:
> llvm/trunk/lib/MC/MCObjectFileInfo.cpp
> llvm/trunk/lib/Support/Triple.cpp
> llvm/trunk/test/CodeGen/X86/statepoint-stackmap-format.ll
>
> Modified: llvm/trunk/lib/MC/MCObjectFileInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=256226&r1=256225&r2=256226&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCObjectFileInfo.cpp (original)
> +++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp Mon Dec 21 19:39:04 2015
> @@ -606,7 +606,6 @@ void MCObjectFileInfo::initCOFFMCObjectF
> // though it contains relocatable pointers. In PIC mode, this is probably a
> // big runtime hit for C++ apps. Either the contents of the LSDA need to be
> // adjusted or this should be a data section.
> - assert(T.isOSWindows() && "Windows is the only supported COFF target");
> if (T.getArch() == Triple::x86_64) {
> // On Windows 64 with SEH, the LSDA is emitted into the .xdata section
> LSDASection = nullptr;
> @@ -810,25 +809,26 @@ void MCObjectFileInfo::InitMCObjectFileI
>
> TT = TheTriple;
>
> - Triple::ArchType Arch = TT.getArch();
> - // FIXME: Checking for Arch here to filter out bogus triples such as
> - // cellspu-apple-darwin. Perhaps we should fix in Triple?
> - if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
> - Arch == Triple::arm || Arch == Triple::thumb ||
> - Arch == Triple::aarch64 ||
> - Arch == Triple::ppc || Arch == Triple::ppc64 ||
> - Arch == Triple::UnknownArch) &&
> - TT.isOSBinFormatMachO()) {
> + switch (TT.getObjectFormat()) {
> + case Triple::MachO:
> Env = IsMachO;
> initMachOMCObjectFileInfo(TT);
> - } else if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
> - Arch == Triple::arm || Arch == Triple::thumb) &&
> - (TT.isOSWindows() && TT.getObjectFormat() == Triple::COFF)) {
> + break;
> + case Triple::COFF:
> + if (!TT.isOSWindows())
> + report_fatal_error(
> + "Cannot initialize MC for non-Windows COFF object files.");
> +
> Env = IsCOFF;
> initCOFFMCObjectFileInfo(TT);
> - } else {
> + break;
> + case Triple::ELF:
> Env = IsELF;
> initELFMCObjectFileInfo(TT);
> + break;
> + case Triple::UnknownObjectFormat:
> + report_fatal_error("Cannot initialize MC for unknown object file format.");
> + break;
> }
> }
>
>
> Modified: llvm/trunk/lib/Support/Triple.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=256226&r1=256225&r2=256226&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/Triple.cpp (original)
> +++ llvm/trunk/lib/Support/Triple.cpp Mon Dec 21 19:39:04 2015
> @@ -538,22 +538,53 @@ static const char *getObjectFormatTypeNa
>
> static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
> switch (T.getArch()) {
> - default:
> - break;
> + case Triple::UnknownArch:
> + case Triple::aarch64:
> + case Triple::arm:
> + case Triple::thumb:
> + case Triple::x86:
> + case Triple::x86_64:
> + if (T.isOSDarwin())
> + return Triple::MachO;
> + else if (T.isOSWindows())
> + return Triple::COFF;
> + return Triple::ELF;
> +
> + case Triple::aarch64_be:
> + case Triple::amdgcn:
> + case Triple::amdil:
> + case Triple::amdil64:
> + case Triple::armeb:
> + case Triple::avr:
> + case Triple::bpfeb:
> + case Triple::bpfel:
> case Triple::hexagon:
> + case Triple::hsail:
> + case Triple::hsail64:
> + case Triple::kalimba:
> + case Triple::le32:
> + case Triple::le64:
> case Triple::mips:
> - case Triple::mipsel:
> case Triple::mips64:
> case Triple::mips64el:
> + case Triple::mipsel:
> + case Triple::msp430:
> + case Triple::nvptx:
> + case Triple::nvptx64:
> + case Triple::ppc64le:
> case Triple::r600:
> - case Triple::amdgcn:
> + case Triple::shave:
> case Triple::sparc:
> + case Triple::sparcel:
> case Triple::sparcv9:
> + case Triple::spir:
> + case Triple::spir64:
> case Triple::systemz:
> + case Triple::tce:
> + case Triple::thumbeb:
> case Triple::wasm32:
> case Triple::wasm64:
> case Triple::xcore:
> - case Triple::ppc64le:
> return Triple::ELF;
>
> case Triple::ppc:
> @@ -562,12 +593,7 @@ static Triple::ObjectFormatType getDefau
> return Triple::MachO;
> return Triple::ELF;
> }
> -
> - if (T.isOSDarwin())
> - return Triple::MachO;
> - else if (T.isOSWindows())
> - return Triple::COFF;
> - return Triple::ELF;
> + llvm_unreachable("unknown architecture");
> }
>
> /// \brief Construct a triple from the string representation provided.
>
> Modified: llvm/trunk/test/CodeGen/X86/statepoint-stackmap-format.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/statepoint-stackmap-format.ll?rev=256226&r1=256225&r2=256226&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/statepoint-stackmap-format.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/statepoint-stackmap-format.ll Mon Dec 21 19:39:04 2015
> @@ -1,5 +1,5 @@
> ; RUN: llc < %s -mtriple="x86_64-pc-linux-gnu" | FileCheck %s
> -; RUN: llc < %s -mtriple="x86_64-pc-win64-coff" | FileCheck %s
> +; RUN: llc < %s -mtriple="x86_64-pc-unknown-elf" | FileCheck %s
>
> ; This test is a sanity check to ensure statepoints are generating StackMap
> ; sections correctly. This is not intended to be a rigorous test of the
>
> Removed: llvm/trunk/test/MC/COFF/ARM/directive-type-diagnostics.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/ARM/directive-type-diagnostics.s?rev=256225&view=auto
> ==============================================================================
> --- llvm/trunk/test/MC/COFF/ARM/directive-type-diagnostics.s (original)
> +++ llvm/trunk/test/MC/COFF/ARM/directive-type-diagnostics.s (removed)
> @@ -1,10 +0,0 @@
> -// RUN: not llvm-mc -triple arm-coff -filetype asm -o /dev/null %s 2>&1 | FileCheck %s
> -// RUN: not llvm-mc -triple armeb-coff -filetype asm -o /dev/null %s 2>&1 | FileCheck %s
> -// RUN: not llvm-mc -triple thumb-coff -filetype asm -o /dev/null %s 2>&1 | FileCheck %s
> -// RUN: not llvm-mc -triple thumbeb-coff -filetype asm -o /dev/null %s 2>&1 | FileCheck %s
> -
> - .type symbol 32
> -// CHECK: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '%<type>' or "<type>"
> -// CHECK: .type symbol 32
> -// CHECK: ^
> -
>
> Added: llvm/trunk/test/MC/ELF/ARM/directive-type-diagnostics.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/ARM/directive-type-diagnostics.s?rev=256226&view=auto
> ==============================================================================
> --- llvm/trunk/test/MC/ELF/ARM/directive-type-diagnostics.s (added)
> +++ llvm/trunk/test/MC/ELF/ARM/directive-type-diagnostics.s Mon Dec 21 19:39:04 2015
> @@ -0,0 +1,10 @@
> +// RUN: not llvm-mc -triple arm-elf -filetype asm -o /dev/null %s 2>&1 | FileCheck %s
> +// RUN: not llvm-mc -triple armeb-elf -filetype asm -o /dev/null %s 2>&1 | FileCheck %s
> +// RUN: not llvm-mc -triple thumb-elf -filetype asm -o /dev/null %s 2>&1 | FileCheck %s
> +// RUN: not llvm-mc -triple thumbeb-elf -filetype asm -o /dev/null %s 2>&1 | FileCheck %s
> +
> + .type symbol 32
> +// CHECK: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '%<type>' or "<type>"
> +// CHECK: .type symbol 32
> +// CHECK: ^
> +
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list