Skip to content

release/19.x: [GlobalISel] Bail out early for big-endian (#103310) #104823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3889,6 +3889,7 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &CurMF) {
F.getSubprogram(), &F.getEntryBlock());
R << "unable to translate in big endian mode";
reportTranslationError(*MF, *TPC, *ORE, R);
return false;
}

// Release the per-function state when we return, whether we succeeded or not.
Expand Down
9 changes: 9 additions & 0 deletions llvm/lib/Target/ARM/ARMCallLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@

using namespace llvm;

// Whether Big-endian GISel is enabled, defaults to off, can be enabled for
// testing.
static cl::opt<bool>
EnableGISelBigEndian("enable-arm-gisel-bigendian", cl::Hidden,
cl::init(false),
cl::desc("Enable Global-ISel Big Endian Lowering"));

ARMCallLowering::ARMCallLowering(const ARMTargetLowering &TLI)
: CallLowering(&TLI) {}

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

return true;
}

bool ARMCallLowering::enableBigEndian() const { return EnableGISelBigEndian; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing end of line but I guess that's an upstream patch issue

2 changes: 2 additions & 0 deletions llvm/lib/Target/ARM/ARMCallLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class ARMCallLowering : public CallLowering {
bool lowerCall(MachineIRBuilder &MIRBuilder,
CallLoweringInfo &Info) const override;

bool enableBigEndian() const override;

private:
bool lowerReturnVal(MachineIRBuilder &MIRBuilder, const Value *Val,
ArrayRef<Register> VRegs,
Expand Down
21 changes: 21 additions & 0 deletions llvm/test/CodeGen/AArch64/GlobalISel/endian_fallback.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc -mtriple aarch64-unknown-linux-musl -O0 -global-isel-abort=2 < %s 2>&1 | FileCheck %s --check-prefix=CHECK-LE
; RUN: llc -mtriple aarch64_be-unknown-linux-musl -O0 -global-isel-abort=2 < %s 2>&1 | FileCheck %s --check-prefix=CHECK-BE

; Make sure we fall-back to SDAG for BE targets.

; CHECK-LE-NOT: warning: Instruction selection used fallback path for foo
; CHECK-BE: warning: Instruction selection used fallback path for foo

define <4 x i6> @foo(float %0, <4 x i6> %1) {
; CHECK-LE-LABEL: foo:
; CHECK-LE: // %bb.0:
; CHECK-LE-NEXT: fmov d0, d1
; CHECK-LE-NEXT: ret
;
; CHECK-BE-LABEL: foo:
; CHECK-BE: // %bb.0:
; CHECK-BE-NEXT: fmov d0, d1
; CHECK-BE-NEXT: ret
ret <4 x i6> %1
}
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/ARM/GlobalISel/arm-irtranslator.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; 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
; 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
; 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

define void @test_void_return() {
; CHECK-LABEL: name: test_void_return
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/ARM/GlobalISel/arm-param-lowering.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; 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
; 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
; 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
; 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

declare arm_aapcscc ptr @simple_reg_params_target(i32, ptr)
Expand Down
Loading