[PATCH] D84395: [AArch64] Fix a machine verifier ICE when using __builtin_return_address with return address sign and authentication
Momchil Velikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 23 05:10:59 PDT 2020
chill created this revision.
chill added reviewers: MatzeB, t.p.northover.
Herald added subscribers: llvm-commits, hiraditya, kristof.beyls.
Herald added a project: LLVM.
When using PAuth instructions in the NOP-space, the compiler can emit an
`AUTIxSP` instruction in the function epilogue.
In a certain test case, using `__builtin_return_address`, the compiler causes
the machine verifier to exit with an error after turning
%0 = COPY LR
x0 = COPY killed %0
into
x0 = COPY killed LR
and the backend later emitting
x0 = COPY killed LR
AUTIASP implicit def LR, implicit LR
This is obviously incorrect since `LR` is live beyond the `COPY` instruction.
The issue is that lifetime of the return address is not tracked properly. The
backend relies on the callee-saved registers mechanism to ensure `LR` is
restored before used for return. For the return instruction that's handled with
a little hack to appease the verifier.
This patch employs the same hack for `AUTIxSP`, marking the implicit `LR`
operand as `undef`.
https://reviews.llvm.org/D84395
Files:
llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
llvm/test/CodeGen/AArch64/builtin-return-address-autisap.ll
llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-sp-mod.mir
llvm/test/CodeGen/MIR/AArch64/return-address-signing.mir
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84395.280075.patch
Type: text/x-patch
Size: 9218 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200723/7d58f83b/attachment.bin>
More information about the llvm-commits
mailing list