diff options
| author | bors <bors@rust-lang.org> | 2023-07-07 07:06:53 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-07-07 07:06:53 +0000 |
| commit | fa6cf3f0f92e8536da894941881c953cb2284105 (patch) | |
| tree | 90e85fd048dde3c6d999ff957244308e5f8a3a0d /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | c8b3992da82d973031ed56630765f947fe7fe394 (diff) | |
| parent | 536c9108b1b4c26c4ec4f319cb4356568f280cba (diff) | |
| download | rust-fa6cf3f0f92e8536da894941881c953cb2284105.tar.gz rust-fa6cf3f0f92e8536da894941881c953cb2284105.zip | |
Auto merge of #2970 - rust-lang:rustup2023-07-07, r=oli-obk
Automatic sync from rustc
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 553fe6cf087..bb7510b3a53 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -121,6 +121,32 @@ extern "C" LLVMValueRef LLVMRustGetNamedValue(LLVMModuleRef M, const char *Name, return wrap(unwrap(M)->getNamedValue(StringRef(Name, NameLen))); } +enum class LLVMRustTailCallKind { + None, + Tail, + MustTail, + NoTail, +}; + +static CallInst::TailCallKind fromRust(LLVMRustTailCallKind Kind) { + switch (Kind) { + case LLVMRustTailCallKind::None: + return CallInst::TailCallKind::TCK_None; + case LLVMRustTailCallKind::Tail: + return CallInst::TailCallKind::TCK_Tail; + case LLVMRustTailCallKind::MustTail: + return CallInst::TailCallKind::TCK_MustTail; + case LLVMRustTailCallKind::NoTail: + return CallInst::TailCallKind::TCK_NoTail; + default: + report_fatal_error("bad CallInst::TailCallKind."); + } +} + +extern "C" void LLVMRustSetTailCallKind(LLVMValueRef Call, LLVMRustTailCallKind TCK) { + unwrap<CallInst>(Call)->setTailCallKind(fromRust(TCK)); +} + extern "C" LLVMValueRef LLVMRustGetOrInsertFunction(LLVMModuleRef M, const char *Name, size_t NameLen, |
