[PATCH] D15707: [Thumb] Fix assembler error 'cannot honor width suffix pop {lr}'

Ana Pazos via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 23 14:41:39 PST 2015


apazos added a comment.

Artyom,

These additional changes solve my problem. See if you agree with them.

- a/lib/Target/ARM/Thumb1FrameLowering.cpp

+++ b/lib/Target/ARM/Thumb1FrameLowering.cpp
@@ -433,18 +433,23 @@ bool Thumb1FrameLowering::emitPopSpecialFixUp(MachineBasicBlock &MBB,

  auto MBBI = MBB.getFirstTerminator();
  bool CanRestoreDirectly = STI.hasV5TOps() && !ArgRegsSaveSize;
  if (CanRestoreDirectly) {

- if (MBBI != MBB.end() && MBBI->getOpcode() != ARM::tB)

+    if (MBBI != MBB.end() && MBBI->getOpcode() != ARM::tB &&
+      MBBI->getOpcode() != ARM::tBcc)

    CanRestoreDirectly = (MBBI->getOpcode() == ARM::tBX_RET ||
                          MBBI->getOpcode() == ARM::tPOP_RET);
  else {
    auto MBBI_prev = MBBI;
    MBBI_prev--;
    assert(MBBI_prev->getOpcode() == ARM::tPOP);

- assert(MBB.succ_size() == 1);
- if ((*MBB.succ_begin())->begin()->getOpcode() == ARM::tBX_RET)
- MBBI = MBBI_prev; // Replace the final tPOP with a tPOP_RET.
- else
- CanRestoreDirectly = false;

+      if (MBB.succ_size() > 1)
+         CanRestoreDirectly = false;
+      else {
+        assert(MBB.succ_size() == 1);
+        if ((*MBB.succ_begin())->begin()->getOpcode() == ARM::tBX_RET)
+          MBBI = MBBI_prev; // Replace the final tPOP with a tPOP_RET.
+        else
+          CanRestoreDirectly = false;
+      }

    }
  }

@@ -531,7 +536,8 @@ bool Thumb1FrameLowering::emitPopSpecialFixUp(MachineBasicBlock &MBB,

                       .addReg(PopReg, RegState::Kill));
  }

- if (MBBI == MBB.end() || MBBI->getOpcode() == ARM::tB) {

+  if (MBBI == MBB.end() || MBBI->getOpcode() == ARM::tB ||
+    MBBI->getOpcode() == ARM::tBcc) {

  auto Pop = MBBI;
  Pop--;
  assert(Pop->getOpcode() == ARM::tPOP);


http://reviews.llvm.org/D15707





More information about the llvm-commits mailing list