1
Fork 0

Rollup merge of #112791 - WaffleLapkin:wag_the_llvm, r=cuviper

llvm ffi: Expose `CallInst->setTailCallKind`

This is needed for the explicit tail calls experiment.
This commit is contained in:
fee1-dead 2023-07-06 09:20:31 +08:00 committed by GitHub
commit e461502e06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

View file

@ -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,