diff options
| -rw-r--r-- | llvm/lib/Target/AArch64/AArch64FrameLowering.cpp | 6 | ||||
| -rw-r--r-- | llvm/test/CodeGen/AArch64/machine-outliner-noredzone.ll | 40 |
2 files changed, 40 insertions, 6 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp index b01a1ae5798..8575e59cd59 100644 --- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp @@ -527,6 +527,11 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF, bool needsFrameMoves = MMI.hasDebugInfo() || F.needsUnwindTableEntry(); bool HasFP = hasFP(MF); + // At this point, we're going to decide whether or not the function uses a + // redzone. In most cases, the function doesn't have a redzone so let's + // assume that's false and set it to true in the case that there's a redzone. + AFI->setHasRedZone(false); + // Debug location must be unknown since the first debug location is used // to determine the end of the prologue. DebugLoc DL; @@ -551,7 +556,6 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF, AFI->setHasRedZone(true); ++NumRedZoneFunctions; } else { - AFI->setHasRedZone(false); emitFrameOffset(MBB, MBBI, DL, AArch64::SP, AArch64::SP, -NumBytes, TII, MachineInstr::FrameSetup); diff --git a/llvm/test/CodeGen/AArch64/machine-outliner-noredzone.ll b/llvm/test/CodeGen/AArch64/machine-outliner-noredzone.ll index 504f8a8802b..f0246057f65 100644 --- a/llvm/test/CodeGen/AArch64/machine-outliner-noredzone.ll +++ b/llvm/test/CodeGen/AArch64/machine-outliner-noredzone.ll @@ -1,14 +1,44 @@ ; RUN: llc -enable-machine-outliner %s -o - | FileCheck %s -; CHECK: OUTLINED_FUNCTION ; RUN: llc -enable-machine-outliner -aarch64-redzone %s -o - | FileCheck %s -check-prefix=REDZONE -; REDZONE-NOT: OUTLINED_FUNCTION +; Ensure that the MachineOutliner does not fire on functions which use a +; redzone. We don't care about what's actually outlined here. We just want to +; force behaviour in the outliner to make sure that it never acts on anything +; that might have a redzone. target triple = "arm64----" -; Ensure that the MachineOutliner does not fire on functions which use a -; redzone. foo() should have a redzone when compiled with -aarch64-redzone, and -; no redzone otherwise. +@x = common global i32 0, align 4 +declare void @baz() #0 + +; In AArch64FrameLowering, there are a couple special early exit cases where we +; *know* we don't use a redzone. The GHC calling convention is one of these +; cases. Make sure that we know we don't have a redzone even in these cases. +define cc 10 void @bar() #0 { + ; CHECK-LABEL: bar + ; CHECK: bl OUTLINED_FUNCTION + ; REDZONE-LABEL: bar + ; REDZONE: bl OUTLINED_FUNCTION + %1 = load i32, i32* @x, align 4 + %2 = add nsw i32 %1, 1 + store i32 %2, i32* @x, align 4 + call void @baz() + %3 = load i32, i32* @x, align 4 + %4 = add nsw i32 %3, 1 + store i32 %4, i32* @x, align 4 + call void @baz() + %5 = load i32, i32* @x, align 4 + %6 = add nsw i32 %5, 1 + store i32 %6, i32* @x, align 4 + ret void +} + +; foo() should have a redzone when compiled with -aarch64-redzone, and no +; redzone otherwise. define void @foo() #0 { + ; CHECK-LABEL: foo + ; CHECK: bl OUTLINED_FUNCTION + ; REDZONE-LABEL: foo + ; REDZONE-NOT: bl OUTLINED_FUNCTION %1 = alloca i32, align 4 %2 = alloca i32, align 4 %3 = alloca i32, align 4 |

