[all-commits] [llvm/llvm-project] f20556: Reland "[llvm][AArch64] Copy all operands when exp...

David Spickett via All-commits all-commits at lists.llvm.org
Tue Jan 23 00:45:59 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f20556678c70f89f96ed01b2c6092c5f7d6efedd
      https://github.com/llvm/llvm-project/commit/f20556678c70f89f96ed01b2c6092c5f7d6efedd
  Author: David Spickett <david.spickett at linaro.org>
  Date:   2024-01-23 (Tue, 23 Jan 2024)

  Changed paths:
    M llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
    A llvm/test/CodeGen/AArch64/blr-bti-preserves-operands.mir
    R llvm/test/CodeGen/AArch64/blr-bti-preserves-regmask.mir

  Log Message:
  -----------
  Reland "[llvm][AArch64] Copy all operands when expanding BLR_BTI bundle (#78267)" (#78719)

This reverts commit 955417ade2648c2b1a4e5f0be697f61570590a88.

The problem with the previous version was that the bundle instruction
had arguments like "target arg1 arg2". When it's expanded we produced a
BL or BLR which can only accept one argument, the target of the branch.

Now I realise why expandCALL_RVMARKER has to copy them in mutiple steps.
The operands for the called function need to be changed to implicit
arguments of the branch instruction.

* Copy the branch target.
* Copy all register operands, marking them as implicit.
* Copy any other operands without modifying them.

Prior to any attempt to fix #77915:
BL @_setjmp, csr_aarch64_aapcs, implicit-def $lr, implicit $sp,
implicit-def dead $lr, implicit $sp, implicit-def $sp

Which is dropping the use of the arguments for the called function.

My first fix attempt produced:
BL @_setjmp, $x0, $w1, <regmask $fp ...>, implicit-def $lr, implicit
$sp, implicit-def dead $lr, implicit $sp, implicit-def $sp

It copied the arguments but as explicit arguments to the BL which only
expects 1, failing verification.

With this new change we produce:
BL @_setjmp, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit
$x0, implicit $w1, implicit-def dead $lr, implicit $sp, implicit-def $sp

Note specifically the added "implicit $x0, implicit $w1". So BL only has
1 explicit argument, but the arguments to the function are still used.




More information about the All-commits mailing list