[PATCH] D14986: Fix Thumb1 epilogue generation

A. Skrobov via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 25 05:58:02 PST 2015


tyomitch added inline comments.

================
Comment at: lib/Target/ARM/Thumb1FrameLowering.cpp:413
@@ -412,3 +414,1 @@
-      IsV4PopReturn = true;
-  return IsV4PopReturn && STI.hasV4TOps() && !STI.hasV5TOps();
 }
----------------
This must have been a leftover from some ARM lowering code: `hasV4TOps()` and `hasV5TOps()` have no relevance to Thumb1 epilogue generation, but this code used to prevent the "pop special fix-up" when it was necessary.

================
Comment at: lib/Target/ARM/Thumb1FrameLowering.cpp:434
@@ -434,1 +433,3 @@
+       MBBI->getOpcode() == ARM::tPOP_RET)) {
+    if (!DoIt || MBBI->getOpcode() == ARM::tPOP_RET)
       return true;
----------------
`tPOP_RET` is a return instruction, too; but it doesn't need a conversion to `tPOP_RET`, so we can return early.

================
Comment at: lib/Target/ARM/Thumb1FrameLowering.cpp:462
@@ -461,3 +462,1 @@
     auto InstUpToMBBI = MBB.end();
-    // The post-decrement is on purpose here.
-    // We want to have the liveness right before MBBI.
----------------
If MBBI is the first instruction in the BB, then the last iteration of the `while` decrements `InstUpToMBBI` past the first instruction, crashing with an assertion failure.

================
Comment at: test/CodeGen/Thumb/thumb-shrink-wrapping.ll:42
@@ -41,3 +41,4 @@
 ; ENABLE-NEXT: add sp, #8
-; ENABLE-NEXT: pop {r7, lr}
 ;
----------------
`pop lr` is illegal in Thumb1; in fact, `llc -filetype=obj` emitted `pop r7` instead of this instruction, obviously unbalancing the stack.


http://reviews.llvm.org/D14986





More information about the llvm-commits mailing list