1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

[Target][XCOFF] Correctly halt when mixing AIX or XCOFF with ppc64le

The code to prevent using `PPCXCOFFMCAsmInfo` with little-endian targets
used an incorrect check. Also, there does not appear to be sufficient
earlier checking to prevent failing this check, so the check here is
upgraded to be a `report_fatal_error`.

`PPCAIXAsmPrinter` was also missing a check against use with
little-endian targets. This patch adds such a check in.
This commit is contained in:
Hubert Tong 2020-05-08 16:40:28 -04:00
parent 72251fb9b9
commit bc72f56aea
3 changed files with 20 additions and 2 deletions

View File

@ -56,6 +56,7 @@ PPCELFMCAsmInfo::PPCELFMCAsmInfo(bool is64Bit, const Triple& T) {
void PPCXCOFFMCAsmInfo::anchor() {}
PPCXCOFFMCAsmInfo::PPCXCOFFMCAsmInfo(bool Is64Bit, const Triple &T) {
assert(!IsLittleEndian && "Little-endian XCOFF not supported.");
if (T.getArch() == Triple::ppc64le)
report_fatal_error("XCOFF is not supported for little-endian targets");
CodePointerSize = CalleeSaveStackSlotSize = Is64Bit ? 8 : 4;
}

View File

@ -151,7 +151,11 @@ private:
public:
PPCAIXAsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
: PPCAsmPrinter(TM, std::move(Streamer)) {}
: PPCAsmPrinter(TM, std::move(Streamer)) {
if (MAI->isLittleEndian())
report_fatal_error(
"cannot create AIX PPC Assembly Printer for a little-endian target");
}
StringRef getPassName() const override { return "AIX PPC Assembly Printer"; }

View File

@ -0,0 +1,13 @@
; Check that use of the AIX/XCOFF related classes with ppc64le would
; cause llc to die with an appropriate message instead of proceeding
; with an invalid state.
; RUN: not --crash llc < %s -mtriple powerpc64le--aix-xcoff 2>&1 \
; RUN: | FileCheck --check-prefix=AIXXCOFF %s
; AIXXCOFF: ERROR: XCOFF is not supported for little-endian
; RUN: not --crash llc < %s -mtriple powerpc64le--aix-macho 2>&1 \
; RUN: | FileCheck --check-prefix=AIXMACHO %s
; AIXMACHO: ERROR: cannot create AIX PPC Assembly Printer for a little-endian target
define i32 @a() { ret i32 0 }