[llvm] [ARM] Fix Machine Outliner crash when tBLXr uses non-tcGPR register (PR #200684)

Deepak Shirke via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 12:46:39 PDT 2026


================
@@ -5827,9 +5827,11 @@ ARMBaseInstrInfo::getOutliningCandidateInfo(
     SetCandidateCallInfo(MachineOutlinerTailCall, Costs.CallTailCall);
   } else if (LastInstrOpcode == ARM::BL || LastInstrOpcode == ARM::BLX ||
              LastInstrOpcode == ARM::BLX_noip || LastInstrOpcode == ARM::tBL ||
-             LastInstrOpcode == ARM::tBLXr ||
-             LastInstrOpcode == ARM::tBLXr_noip ||
-             LastInstrOpcode == ARM::tBLXi) {
+             LastInstrOpcode == ARM::tBLXi ||
+             ((LastInstrOpcode == ARM::tBLXr ||
+               LastInstrOpcode == ARM::tBLXr_noip) &&
+              ARM::tcGPRRegClass.contains(
+                  RepeatedSequenceLocs[0].back().getOperand(2).getReg()))) {
----------------
deepakshirkem wrote:

Hi @smithp35, For the $r12 + branch-protection case, here is the .mir reproducer: https://gist.github.com/deepakshirkem/ddec5b0eeb5f2d74f43f12e763f58b74/revisions

```
Run with:
llc -run-pass=machine-outliner -verify-machineinstrs \
    -mtriple=thumbv8.1m.main-arm-none-eabi \
    test-r12-pacbti.mir -o -
```

No crash was found. I also verified with GDB. I believe this code already handles the situation correctly:

https://github.com/llvm/llvm-project/pull/200684/changes#diff-df612ace1e3737add6ae74bebd7cb82b4be660994cbd8e406d376129a42222c7L5714-L5732

Could you please verify whether my test is correct?

https://github.com/llvm/llvm-project/pull/200684


More information about the llvm-commits mailing list