diff options
| author | bors <bors@rust-lang.org> | 2021-01-16 03:10:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-16 03:10:52 +0000 |
| commit | 635ccfe01c0be19d9fb0a99facbd9e06290f0ab1 (patch) | |
| tree | 278f5200156f523b626bea00183518235a0b9074 /compiler/rustc_codegen_llvm/src | |
| parent | 6c869d34ae2d87d21db9892d4dc088639bcbe041 (diff) | |
| parent | cd2580722375671fa2967661f65b7b33570547ec (diff) | |
| download | rust-635ccfe01c0be19d9fb0a99facbd9e06290f0ab1.tar.gz rust-635ccfe01c0be19d9fb0a99facbd9e06290f0ab1.zip | |
Auto merge of #77885 - erikdesjardins:probeasm, r=cuviper
Use probe-stack=inline-asm in LLVM 11+ Fixes (?) #74405, related to #43241 r? `@cuviper`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/attributes.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/context.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm_util.rs | 11 |
4 files changed, 16 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 97c38e04bc1..700f32e15b9 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -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") + }, ); } diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 8dd40308075..6acd26bd415 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -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); diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index eb4f36266db..d9f42efebab 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -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); diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index a9d57ea8b8a..6c2a871e520 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -171,16 +171,17 @@ pub fn target_features(sess: &Session) -> Vec<Symbol> { } pub fn print_version() { + let (major, minor, patch) = get_version(); + println!("LLVM version: {}.{}.{}", major, minor, patch); +} + +pub fn get_version() -> (u32, u32, u32) { // Can be called without initializing LLVM unsafe { - println!("LLVM version: {}.{}", llvm::LLVMRustVersionMajor(), llvm::LLVMRustVersionMinor()); + (llvm::LLVMRustVersionMajor(), llvm::LLVMRustVersionMinor(), llvm::LLVMRustVersionPatch()) } } -pub fn get_major_version() -> u32 { - unsafe { llvm::LLVMRustVersionMajor() } -} - pub fn print_passes() { // Can be called without initializing LLVM unsafe { |
