[PATCH] D59385: [ARM] Don't try to create "push {r12, lr}" in Thumb1 at -Oz.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 14 13:17:57 PDT 2019


efriedma created this revision.
efriedma added a reviewer: t.p.northover.
Herald added subscribers: kristof.beyls, javed.absar.
Herald added a project: LLVM.

It's a little tricky to make this issue show up because prologue/epilogue emission normally likes to push at least two registers... but it doesn't when lr is force-spilled due to function length.  Not sure if that really makes sense, but I decided not to touch it for now.


Repository:
  rL LLVM

https://reviews.llvm.org/D59385

Files:
  lib/Target/ARM/ARMBaseInstrInfo.cpp
  test/CodeGen/ARM/fold-stack-adjust.ll


Index: test/CodeGen/ARM/fold-stack-adjust.ll
===================================================================
--- test/CodeGen/ARM/fold-stack-adjust.ll
+++ test/CodeGen/ARM/fold-stack-adjust.ll
@@ -2,6 +2,7 @@
 ; exerce the path for PR18136.
 ; RUN: llc -mtriple=thumbv7-apple-none-macho < %s -enable-shrink-wrap=false | FileCheck %s
 ; RUN: llc -mtriple=thumbv6m-apple-none-macho -frame-pointer=all < %s | FileCheck %s --check-prefix=CHECK-T1
+; RUN: llc -mtriple=thumbv6m-apple-none-macho < %s | FileCheck %s --check-prefix=CHECK-T1-NOFP
 ; RUN: llc -mtriple=thumbv7-apple-darwin-ios -frame-pointer=all < %s | FileCheck %s --check-prefix=CHECK-IOS
 ; RUN: llc -mtriple=thumbv7--linux-gnueabi -frame-pointer=all < %s | FileCheck %s --check-prefix=CHECK-LINUX
 
@@ -232,4 +233,13 @@
   ret void
 }
 
+define void @test_long_fn() minsize nounwind optsize {
+; CHECK-T1-NOFP-LABEL: test_long_fn:
+; CHECK-T1-NOFP: push {r7, lr}
+entry:
+  %z = alloca i32, align 4
+  call void asm sideeffect ".space 3000", "r"(i32* nonnull %z)
+  ret void
+}
+
 declare void @llvm.va_start(i8*) nounwind
Index: lib/Target/ARM/ARMBaseInstrInfo.cpp
===================================================================
--- lib/Target/ARM/ARMBaseInstrInfo.cpp
+++ lib/Target/ARM/ARMBaseInstrInfo.cpp
@@ -2331,6 +2331,8 @@
   for (int CurRegEnc = FirstRegEnc - 1; CurRegEnc >= 0 && RegsNeeded;
        --CurRegEnc) {
     unsigned CurReg = RegClass->getRegister(CurRegEnc);
+    if (IsT1PushPop && CurReg > ARM::R7)
+      continue;
     if (!IsPop) {
       // Pushing any register is completely harmless, mark the register involved
       // as undef since we don't care about its value and must not restore it


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59385.190713.patch
Type: text/x-patch
Size: 1692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190314/0431b78d/attachment.bin>


More information about the llvm-commits mailing list