-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[BOLT][AArch64] Add tests for unsupported conditional tailcalls #139565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Tests cover: cbz, cbnz, tbz, tbnz, b.eq, and b.ne
Thanks for adding the test case! Looks good to me. Once the support is added, I think it will be simpler to have just once compilation, i.e. no need for macros. |
Thanks – that's exactly the plan! I used multiple macros in this reproducer commit to cover all 6 crash cases. |
Hey @maksfb , Sharing my thoughts to be sure we are aligned before I proceed with the below proposal. The B or BL cases were simple because there was a 1-1 mapping between relocation types and instructions. We only needed a hardcoded opcode and the immediate value to patch (see BL example here). Supporting conditional branches is slightly more involved. A single relocation type covers instructions that use the same number of bits for the immediate to be patched. So, My plan is to read the original instruction encoding from the BinarySection Contents during relocation flushing, and pass it as an extra parameter to What do you think? I can post a draft patch if it's unclear. (cc: @yota9) |
Hi Paschalis, your suggestion makes complete sense to me. I'll add "basic" support for these instructions, so we don't crash when we encounter them in light mode. Which will be skipping the relocations and relying on target function entry point patching/stub functionality. |
I've created #140669 that adds a temporary support for CTC in lite mode. Reading ARM manual, all conditional branches have the following statement in their description " provides a hint that this is not a subroutine call or return". Not sure what are the consequences if any when the instruction is used as a tail call. Regular branch |
Hey Maksim, I don't think there are any consequences. Any branch that doesn't link to LR isn't primarily intended for calls. All BR, B, B.cond, CBZ/CBNZ, and TBZ/TBNZ include this hint. BLR wording is slightly stricter. I've raised this internally to see if we need to improve consistency there. EDIT: Just to clarify for completeness (in case someone isn't following our context): If instructions are misused, features like our upcoming BRBE work, or PAC-BTI can be affected, in addition to performance implications. |
Tests cover: cbz, cbnz, tbz, tbnz, b.eq, and b.ne