Skip to content

Commit 2dd0652

Browse files
hubert-reinterpretcastarichardson
authored andcommitted
[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.
2 parents c916f32 + 601d5bd commit 2dd0652

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ PPCELFMCAsmInfo::PPCELFMCAsmInfo(bool is64Bit, const Triple& T) {
5656
void PPCXCOFFMCAsmInfo::anchor() {}
5757

5858
PPCXCOFFMCAsmInfo::PPCXCOFFMCAsmInfo(bool Is64Bit, const Triple &T) {
59-
assert(!IsLittleEndian && "Little-endian XCOFF not supported.");
59+
if (T.getArch() == Triple::ppc64le)
60+
report_fatal_error("XCOFF is not supported for little-endian targets");
6061
CodePointerSize = CalleeSaveStackSlotSize = Is64Bit ? 8 : 4;
6162
}

llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ class PPCAIXAsmPrinter : public PPCAsmPrinter {
151151

152152
public:
153153
PPCAIXAsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
154-
: PPCAsmPrinter(TM, std::move(Streamer)) {}
154+
: PPCAsmPrinter(TM, std::move(Streamer)) {
155+
if (MAI->isLittleEndian())
156+
report_fatal_error(
157+
"cannot create AIX PPC Assembly Printer for a little-endian target");
158+
}
155159

156160
StringRef getPassName() const override { return "AIX PPC Assembly Printer"; }
157161

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

0 commit comments

Comments
 (0)