This is an archive of the discontinued LLVM Phabricator instance.

[Thumb2] support `movs pc, lr` alias for `subs pc, lr, #0`/`eret`

Authored by nickdesaulniers on Feb 8 2021, 5:13 PM.



This is used by the Linux kernel built with CONFIG_THUMB2_KERNEL.

Because different operands are not permitted to movs, the diagnostics now provide multiple suggestions along the lines of using a non-pc destination operand or lr source operand.

Forked from D95586.

Signed-off-by: Nick Desaulniers <>

Diff Detail

Event Timeline

nickdesaulniers created this revision.Feb 8 2021, 5:13 PM
nickdesaulniers requested review of this revision.Feb 8 2021, 5:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 8 2021, 5:13 PM
nickdesaulniers edited the summary of this revision. (Show Details)Feb 8 2021, 5:16 PM

(I should probably add the new notes, so reviewers can see how the diagnostics are changed. Will do so tomorrow.)

  • add CHECKs for note: diagnostics to tests.
DavidSpickett accepted this revision.Feb 10 2021, 3:22 AM

LGTM with the one comment added.


Here please cite the armarmv7:

B9.3.19 SUBS PC, LR (Thumb)
In the Thumb instruction set, MOVS{<c>}{<q>} PC, LR is a pseudo-instruction for SUBS{<c>}{<q>} PC, LR, #0.
This revision is now accepted and ready to land.Feb 10 2021, 3:22 AM
nickdesaulniers marked an inline comment as done.Feb 10 2021, 10:44 AM
This revision was landed with ongoing or failed builds.Feb 10 2021, 11:01 AM
This revision was automatically updated to reflect the committed changes.