[llvm] r329922 - [AArch64] Move AFI->setRedZone(false) to top of emitPrologue

Jessica Paquette via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 12 09:16:18 PDT 2018


Author: paquette
Date: Thu Apr 12 09:16:18 2018
New Revision: 329922

URL: http://llvm.org/viewvc/llvm-project?rev=329922&view=rev
Log:
[AArch64] Move AFI->setRedZone(false) to top of emitPrologue

AFI->setRedZone(false) was put in the wrong place before, and so it only fired
on functions that didn't have stack frames. This moves that to the top of
emitPrologue to make sure that every function without a redzone has it set
correctly.

This also adds a function representing one of the early exit cases (GHC calling
convention) to the MachineOutliner noredzone test to ensure that we can outline
from functions like these, where we never use a redzone.


Modified:
    llvm/trunk/lib/Target/AArch64/AArch64FrameLowering.cpp
    llvm/trunk/test/CodeGen/AArch64/machine-outliner-noredzone.ll

Modified: llvm/trunk/lib/Target/AArch64/AArch64FrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64FrameLowering.cpp?rev=329922&r1=329921&r2=329922&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64FrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64FrameLowering.cpp Thu Apr 12 09:16:18 2018
@@ -527,6 +527,11 @@ void AArch64FrameLowering::emitPrologue(
   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(
       AFI->setHasRedZone(true);
       ++NumRedZoneFunctions;
     } else {
-      AFI->setHasRedZone(false);
       emitFrameOffset(MBB, MBBI, DL, AArch64::SP, AArch64::SP, -NumBytes, TII,
                       MachineInstr::FrameSetup);
 

Modified: llvm/trunk/test/CodeGen/AArch64/machine-outliner-noredzone.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/machine-outliner-noredzone.ll?rev=329922&r1=329921&r2=329922&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/machine-outliner-noredzone.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/machine-outliner-noredzone.ll Thu Apr 12 09:16:18 2018
@@ -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.
+ at 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




More information about the llvm-commits mailing list