[PATCH] D106760: Fix Local Deallocation for Homogeneous Prolog/Epilog

Kyungwoo Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 24 15:39:24 PDT 2021


kyulee created this revision.
Herald added a subscriber: hiraditya.
kyulee requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The stack adjustment for local deallocation was incorrectly ported.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106760

Files:
  llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
  llvm/test/CodeGen/AArch64/arm64-homogeneous-prolog-epilog-local.ll


Index: llvm/test/CodeGen/AArch64/arm64-homogeneous-prolog-epilog-local.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AArch64/arm64-homogeneous-prolog-epilog-local.ll
@@ -0,0 +1,35 @@
+; RUN: llc < %s -mtriple=arm64-apple-ios7.0  -homogeneous-prolog-epilog | FileCheck %s
+; RUN: llc < %s -mtriple=aarch64-unknown-linux-gnu  -homogeneous-prolog-epilog | FileCheck %s --check-prefixes=CHECK-LINUX
+
+; CHECK-LABEL: _foo:
+; CHECK:        stp	x29, x30, [sp, #-16]!
+; CHECK-NEXT:   bl	_OUTLINED_FUNCTION_PROLOG_FRAME16_x30x29x19x20
+; CHECK-NEXT:   sub     sp, sp, #16
+; CHECK:        bl      _goo
+; CHECK:        add     sp, sp, #16
+; CHECK-NEXT:   b	_OUTLINED_FUNCTION_EPILOG_TAIL_x30x29x19x20
+
+; CHECK-LINUX-LABEL: foo:
+; CHECK-LINUX:        stp	x29, x30, [sp, #-32]!
+; CHECK-LINUX-NEXT:   bl	OUTLINED_FUNCTION_PROLOG_FRAME0_x19x20x30x29
+; CHECK-LINUX-NEXT:   sub	sp, sp, #16
+; CHECK-LINUX:        bl      goo
+; CHECK-LINUX:        add	sp, sp, #16
+; CHECK-LINUX-NEXT:   b	OUTLINED_FUNCTION_EPILOG_TAIL_x19x20x30x29
+
+define i32 @foo(i32 %c) nounwind ssp minsize "frame-pointer"="non-leaf" {
+entry:
+  %buffer = alloca [1 x i32], align 4
+  %0 = bitcast [1 x i32]* %buffer to i8*
+  call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %0)
+  %arraydecay = getelementptr inbounds [1 x i32], [1 x i32]* %buffer, i64 0, i64 0
+  %call = call i32 @goo(i32* nonnull %arraydecay)
+  %sub = sub nsw i32 %c, %call
+  call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %0)
+
+  ret i32 %sub
+}
+
+declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)
+declare i32 @goo(i32*)
+declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)
Index: llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
@@ -1738,7 +1738,7 @@
 
     // Adjust local stack
     emitFrameOffset(MBB, LastPopI, DL, AArch64::SP, AArch64::SP,
-                    StackOffset::getFixed(-AFI->getLocalStackSize()), TII,
+                    StackOffset::getFixed(AFI->getLocalStackSize()), TII,
                     MachineInstr::FrameDestroy, false, NeedsWinCFI);
 
     // SP has been already adjusted while restoring callee save regs.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106760.361482.patch
Type: text/x-patch
Size: 2362 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210724/970ba541/attachment.bin>


More information about the llvm-commits mailing list