error when ABI does not support guaranteed tail calls #148878
+259
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some ABIs cannot support guaranteed tail calls. There isn't really an exhaustive list, so this is a best effort. Conveniently, we already disallow calling most of these directly anyway. The only exception that I was able to trigger an LLVM assertion with so far was
cmse-nonsecure-entry.For that calling convention, LLVM specifically notes that (guaranteed) tail calls cannot be supported:
https://github.com/llvm/llvm-project/blob/28dbbba6c3a4e026e085c48cc022cb97b5d8bc6d/llvm/lib/Target/ARM/ARMISelLowering.cpp#L2331-L2335
I have some doubts about the implementation here though. I think it would be nicer to use
CanonAbi, and move thebecomeABI check intorustc_hir_typeck, similar tocheck_call_abi:rust/compiler/rustc_hir_typeck/src/callee.rs
Lines 157 to 194 in d6deffe
Both the check for whether an ABI is callable and whether it supports guaranteed tail calls can then be methods (containing exhaustive matches) on
CanonAbi. I'm however not surecallexpression incheck_expr_become, it looks like currently the check that the "argument" tobecomeis a function call also only occurs later during MIR constructionAre there issues with validating the ABI earlier in
rustc_hir_typeckthat I'm overlooking? I believe that we should already know the call's ABI and whether it is c-variadic at that point.cc @workingjubilee for
CanonAbi, @davidtwco for cmser? @WaffleLapkin