diff options
| author | Joel Wejdenstål <joel.wejdenstal@gmail.com> | 2025-07-25 21:21:42 +0200 |
|---|---|---|
| committer | Joel Wejdenstål <joel.wejdenstal@gmail.com> | 2025-07-26 01:02:29 +0200 |
| commit | a448837045326d7c33059dc3aa2d1d87529dcf3d (patch) | |
| tree | 8b14dc9670550379eb0fe6cfdcc31aeeae73f27b /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | 430d6eddfc6a455ca4a0137c0822a982cccd3b2b (diff) | |
| download | rust-a448837045326d7c33059dc3aa2d1d87529dcf3d.tar.gz rust-a448837045326d7c33059dc3aa2d1d87529dcf3d.zip | |
Implement support for explicit tail calls in the MIR block builders and the LLVM codegen backend.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
| -rw-r--r-- | compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 82568ed4ae1..8e1c18eb56b 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -1986,3 +1986,29 @@ extern "C" void LLVMRustSetNoSanitizeHWAddress(LLVMValueRef Global) { MD.NoHWAddress = true; GV.setSanitizerMetadata(MD); } + +enum class LLVMRustTailCallKind { + None = 0, + Tail = 1, + MustTail = 2, + NoTail = 3 +}; + +extern "C" void LLVMRustSetTailCallKind(LLVMValueRef Call, + LLVMRustTailCallKind Kind) { + CallInst *CI = unwrap<CallInst>(Call); + switch (Kind) { + case LLVMRustTailCallKind::None: + CI->setTailCallKind(CallInst::TCK_None); + break; + case LLVMRustTailCallKind::Tail: + CI->setTailCallKind(CallInst::TCK_Tail); + break; + case LLVMRustTailCallKind::MustTail: + CI->setTailCallKind(CallInst::TCK_MustTail); + break; + case LLVMRustTailCallKind::NoTail: + CI->setTailCallKind(CallInst::TCK_NoTail); + break; + } +} |
