1
Fork 0

Auto merge of #77885 - erikdesjardins:probeasm, r=cuviper

Use probe-stack=inline-asm in LLVM 11+

Fixes (?) #74405, related to #43241

r? `@cuviper`
This commit is contained in:
bors 2021-01-16 03:10:52 +00:00
commit 635ccfe01c
7 changed files with 63 additions and 11 deletions

View file

@ -127,13 +127,18 @@ fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
return;
}
// Flag our internal `__rust_probestack` function as the stack probe symbol.
// This is defined in the `compiler-builtins` crate for each architecture.
llvm::AddFunctionAttrStringValue(
llfn,
llvm::AttributePlace::Function,
const_cstr!("probe-stack"),
const_cstr!("__rust_probestack"),
if llvm_util::get_version() < (11, 0, 1) {
// Flag our internal `__rust_probestack` function as the stack probe symbol.
// This is defined in the `compiler-builtins` crate for each architecture.
const_cstr!("__rust_probestack")
} else {
// On LLVM 11+, emit inline asm for stack probes instead of a function call.
const_cstr!("inline-asm")
},
);
}

View file

@ -114,7 +114,7 @@ pub unsafe fn create_module(
let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx);
let mut target_data_layout = sess.target.data_layout.clone();
if llvm_util::get_major_version() < 10
if llvm_util::get_version() < (10, 0, 0)
&& (sess.target.arch == "x86" || sess.target.arch == "x86_64")
{
target_data_layout = strip_x86_address_spaces(target_data_layout);

View file

@ -1811,6 +1811,7 @@ extern "C" {
pub fn LLVMRustDebugMetadataVersion() -> u32;
pub fn LLVMRustVersionMajor() -> u32;
pub fn LLVMRustVersionMinor() -> u32;
pub fn LLVMRustVersionPatch() -> u32;
pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32);

View file

@ -171,14 +171,15 @@ pub fn target_features(sess: &Session) -> Vec<Symbol> {
}
pub fn print_version() {
// Can be called without initializing LLVM
unsafe {
println!("LLVM version: {}.{}", llvm::LLVMRustVersionMajor(), llvm::LLVMRustVersionMinor());
}
let (major, minor, patch) = get_version();
println!("LLVM version: {}.{}.{}", major, minor, patch);
}
pub fn get_major_version() -> u32 {
unsafe { llvm::LLVMRustVersionMajor() }
pub fn get_version() -> (u32, u32, u32) {
// Can be called without initializing LLVM
unsafe {
(llvm::LLVMRustVersionMajor(), llvm::LLVMRustVersionMinor(), llvm::LLVMRustVersionPatch())
}
}
pub fn print_passes() {