[llvm-dev] Invalid instruction generated on armV4

Renato Golin via llvm-dev llvm-dev at lists.llvm.org
Thu Sep 17 05:13:53 PDT 2015


On 11 September 2015 at 15:07, Frédéric Richez
<frederic.richez at gmail.com> wrote:
> I’m sure it is not a solution but it could help to solve/understand the
> issue.

I think you've found the bug!

That line you just added back moves the lowering of the call away from
that code, but right now, it's following down and reaching the piece
of code:

+  if (!GV){
+    CallOpc = isThumb2 ? ARM::tBLXr : ARM::BLX;
+    CalleeReg = getRegForValue(Callee);
+    if (CalleeReg == 0) return false;
+  }

With the problem here being:

+    CallOpc = isThumb2 ? ARM::tBLXr : ARM::BLX;

If your variable is not global, and you're not in Thumb2 mode, it
selects ARM's BLX. This conditional is incomplete, as it should also
be enquiring about ARMv4 and using BX plus adding something akin "mov
lr, pc" before.

If keeping the patch helps you, then please keep it local until this
is properly fixed.

For now, I have created a bug
(https://llvm.org/bugs/show_bug.cgi?id=24858) and added Jonathan and
Tim, both folks that worked with ARMv4 and have a better knowledge of
FastISel than I do.

It'd be hard for me to test this, as I don't have access to a v4T
anymore and QEMU doesn't seem to emulate anything before v5. :( Maybe
someone else could have a look at it earlier than I can get my hands
in one.

cheers,
--renato


More information about the llvm-dev mailing list