Skip to content

Commit c1336c9

Browse files
davemgreentru
authored andcommitted
[GlobalISel] Bail out early for big-endian (#103310)
If we continue through the function we can currently hit crashes. We can bail out early and fall back to SDAG. Fixes #103032 (cherry picked from commit 05d17a1)
1 parent 263965e commit c1336c9

File tree

6 files changed

+35
-2
lines changed

6 files changed

+35
-2
lines changed

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3889,6 +3889,7 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &CurMF) {
38893889
F.getSubprogram(), &F.getEntryBlock());
38903890
R << "unable to translate in big endian mode";
38913891
reportTranslationError(*MF, *TPC, *ORE, R);
3892+
return false;
38923893
}
38933894

38943895
// Release the per-function state when we return, whether we succeeded or not.

llvm/lib/Target/ARM/ARMCallLowering.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@
5050

5151
using namespace llvm;
5252

53+
// Whether Big-endian GISel is enabled, defaults to off, can be enabled for
54+
// testing.
55+
static cl::opt<bool>
56+
EnableGISelBigEndian("enable-arm-gisel-bigendian", cl::Hidden,
57+
cl::init(false),
58+
cl::desc("Enable Global-ISel Big Endian Lowering"));
59+
5360
ARMCallLowering::ARMCallLowering(const ARMTargetLowering &TLI)
5461
: CallLowering(&TLI) {}
5562

@@ -539,3 +546,5 @@ bool ARMCallLowering::lowerCall(MachineIRBuilder &MIRBuilder, CallLoweringInfo &
539546

540547
return true;
541548
}
549+
550+
bool ARMCallLowering::enableBigEndian() const { return EnableGISelBigEndian; }

llvm/lib/Target/ARM/ARMCallLowering.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class ARMCallLowering : public CallLowering {
4242
bool lowerCall(MachineIRBuilder &MIRBuilder,
4343
CallLoweringInfo &Info) const override;
4444

45+
bool enableBigEndian() const override;
46+
4547
private:
4648
bool lowerReturnVal(MachineIRBuilder &MIRBuilder, const Value *Val,
4749
ArrayRef<Register> VRegs,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple aarch64-unknown-linux-musl -O0 -global-isel-abort=2 < %s 2>&1 | FileCheck %s --check-prefix=CHECK-LE
3+
; RUN: llc -mtriple aarch64_be-unknown-linux-musl -O0 -global-isel-abort=2 < %s 2>&1 | FileCheck %s --check-prefix=CHECK-BE
4+
5+
; Make sure we fall-back to SDAG for BE targets.
6+
7+
; CHECK-LE-NOT: warning: Instruction selection used fallback path for foo
8+
; CHECK-BE: warning: Instruction selection used fallback path for foo
9+
10+
define <4 x i6> @foo(float %0, <4 x i6> %1) {
11+
; CHECK-LE-LABEL: foo:
12+
; CHECK-LE: // %bb.0:
13+
; CHECK-LE-NEXT: fmov d0, d1
14+
; CHECK-LE-NEXT: ret
15+
;
16+
; CHECK-BE-LABEL: foo:
17+
; CHECK-BE: // %bb.0:
18+
; CHECK-BE-NEXT: fmov d0, d1
19+
; CHECK-BE-NEXT: ret
20+
ret <4 x i6> %1
21+
}

llvm/test/CodeGen/ARM/GlobalISel/arm-irtranslator.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; RUN: llc -mtriple arm-unknown -mattr=+vfp2,+v4t -global-isel -stop-after=irtranslator -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=LITTLE
2-
; RUN: llc -mtriple armeb-unknown -mattr=+vfp2,+v4t -global-isel -global-isel-abort=0 -stop-after=irtranslator -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=BIG
2+
; RUN: llc -mtriple armeb-unknown -mattr=+vfp2,+v4t -global-isel -global-isel-abort=0 -enable-arm-gisel-bigendian -stop-after=irtranslator -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=BIG
33

44
define void @test_void_return() {
55
; CHECK-LABEL: name: test_void_return

llvm/test/CodeGen/ARM/GlobalISel/arm-param-lowering.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; RUN: llc -O0 -mtriple arm-unknown -mattr=+vfp2,+v4t -global-isel -stop-after=irtranslator -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=ARM -check-prefix=LITTLE
2-
; RUN: llc -O0 -mtriple armeb-unknown -mattr=+vfp2,+v4t -global-isel -global-isel-abort=0 -stop-after=irtranslator -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=ARM -check-prefix=BIG
2+
; RUN: llc -O0 -mtriple armeb-unknown -mattr=+vfp2,+v4t -global-isel -global-isel-abort=0 -enable-arm-gisel-bigendian -stop-after=irtranslator -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=ARM -check-prefix=BIG
33
; RUN: llc -O0 -mtriple thumb-unknown -mattr=+vfp2,+v6t2 -global-isel -stop-after=irtranslator -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=LITTLE -check-prefix=THUMB
44

55
declare arm_aapcscc ptr @simple_reg_params_target(i32, ptr)

0 commit comments

Comments
 (0)