about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-07-06 02:34:11 +0000
committerbors <bors@rust-lang.org>2023-07-06 02:34:11 +0000
commit0d50ab77397d7278500abd22d34de0e10940b2ee (patch)
tree02a35487baaef052fd3f02c7b935276f4df24468 /compiler/rustc_llvm/llvm-wrapper
parentbd8aabef316bf8779193798eaf35b8749221a9b4 (diff)
parentc668eb086e27985043b060b82d913520fd24612b (diff)
downloadrust-0d50ab77397d7278500abd22d34de0e10940b2ee.tar.gz
rust-0d50ab77397d7278500abd22d34de0e10940b2ee.zip
Auto merge of #113391 - fee1-dead-contrib:rollup-9bqlw9z, r=fee1-dead
Rollup of 9 pull requests

Successful merges:

 - #111119 (style-guide: Add chapter about formatting for nightly-only syntax)
 - #112791 (llvm ffi: Expose `CallInst->setTailCallKind`)
 - #113145 (style-guide: Document newline rules for assignment operators)
 - #113163 (Add a regression test for #112895)
 - #113332 (resolve: Use `Interned` for some interned structures)
 - #113334 (Revert the lexing of `c"…"` string literals)
 - #113350 (Fix the issue of wrong diagnosis for extern pub fn)
 - #113371 (Fix submodule handling when the current branch is named after a tag)
 - #113384 (style-guide: Clarify grammar for small patterns (not a semantic change))

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper')
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp26
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,