Upgrade LLVM
This comes with a number of fixes to be compatible with upstream LLVM: * Previously all monomorphizations of "mem::size_of()" would receive the same symbol. In the past LLVM would silently rename duplicated symbols, but it appears to now be dropping the duplicate symbols and functions now. The symbol names of monomorphized functions are now no longer solely based on the type of the function, but rather the type and the unique hash for the monomorphization. * Split stacks are no longer a global feature controlled by a flag in LLVM. Instead, they are opt-in on a per-function basis through a function attribute. The rust #[no_split_stack] attribute will disable this, otherwise all functions have #[split_stack] attached to them. * The compare and swap instruction now takes two atomic orderings, one for the successful case and one for the failure case. LLVM internally has an implementation of calculating the appropriate failure ordering given a particular success ordering (previously only a success ordering was specified), and I copied that into the intrinsic translation so the failure ordering isn't supplied on a source level for now. * Minor tweaks to LLVM's API in terms of debuginfo, naming, c++11 conventions, etc.
This commit is contained in:
parent
903fbd2635
commit
30ff17f809
13 changed files with 89 additions and 35 deletions
|
|
@ -1261,7 +1261,8 @@ pub mod llvm {
|
|||
LHS: ValueRef,
|
||||
CMP: ValueRef,
|
||||
RHS: ValueRef,
|
||||
Order: AtomicOrdering)
|
||||
Order: AtomicOrdering,
|
||||
FailureOrder: AtomicOrdering)
|
||||
-> ValueRef;
|
||||
pub fn LLVMBuildAtomicRMW(B: BuilderRef,
|
||||
Op: AtomicBinOp,
|
||||
|
|
@ -1586,7 +1587,8 @@ pub mod llvm {
|
|||
Scope: DIDescriptor,
|
||||
File: DIFile,
|
||||
Line: c_uint,
|
||||
Col: c_uint)
|
||||
Col: c_uint,
|
||||
Discriminator: c_uint)
|
||||
-> DILexicalBlock;
|
||||
|
||||
pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
|
||||
|
|
|
|||
|
|
@ -445,8 +445,8 @@ pub fn set_llvm_fn_attrs(attrs: &[ast::Attribute], llfn: ValueRef) {
|
|||
}
|
||||
|
||||
// Add the no-split-stack attribute if requested
|
||||
if contains_name(attrs, "no_split_stack") {
|
||||
set_no_split_stack(llfn);
|
||||
if !contains_name(attrs, "no_split_stack") {
|
||||
set_split_stack(llfn);
|
||||
}
|
||||
|
||||
if contains_name(attrs, "cold") {
|
||||
|
|
@ -458,8 +458,8 @@ pub fn set_always_inline(f: ValueRef) {
|
|||
lib::llvm::SetFunctionAttribute(f, lib::llvm::AlwaysInlineAttribute)
|
||||
}
|
||||
|
||||
pub fn set_no_split_stack(f: ValueRef) {
|
||||
"no-split-stack".with_c_str(|buf| {
|
||||
pub fn set_split_stack(f: ValueRef) {
|
||||
"split-stack".with_c_str(|buf| {
|
||||
unsafe { llvm::LLVMAddFunctionAttrString(f, buf); }
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -814,8 +814,9 @@ pub fn Resume(cx: &Block, exn: ValueRef) -> ValueRef {
|
|||
// Atomic Operations
|
||||
pub fn AtomicCmpXchg(cx: &Block, dst: ValueRef,
|
||||
cmp: ValueRef, src: ValueRef,
|
||||
order: AtomicOrdering) -> ValueRef {
|
||||
B(cx).atomic_cmpxchg(dst, cmp, src, order)
|
||||
order: AtomicOrdering,
|
||||
failure_order: AtomicOrdering) -> ValueRef {
|
||||
B(cx).atomic_cmpxchg(dst, cmp, src, order, failure_order)
|
||||
}
|
||||
pub fn AtomicRMW(cx: &Block, op: AtomicBinOp,
|
||||
dst: ValueRef, src: ValueRef,
|
||||
|
|
|
|||
|
|
@ -949,9 +949,11 @@ impl<'a> Builder<'a> {
|
|||
// Atomic Operations
|
||||
pub fn atomic_cmpxchg(&self, dst: ValueRef,
|
||||
cmp: ValueRef, src: ValueRef,
|
||||
order: AtomicOrdering) -> ValueRef {
|
||||
order: AtomicOrdering,
|
||||
failure_order: AtomicOrdering) -> ValueRef {
|
||||
unsafe {
|
||||
llvm::LLVMBuildAtomicCmpXchg(self.llbuilder, dst, cmp, src, order)
|
||||
llvm::LLVMBuildAtomicCmpXchg(self.llbuilder, dst, cmp, src,
|
||||
order, failure_order)
|
||||
}
|
||||
}
|
||||
pub fn atomic_rmw(&self, op: AtomicBinOp,
|
||||
|
|
|
|||
|
|
@ -2422,7 +2422,8 @@ fn populate_scope_map(cx: &CrateContext,
|
|||
parent_scope,
|
||||
file_metadata,
|
||||
loc.line as c_uint,
|
||||
loc.col.to_uint() as c_uint)
|
||||
loc.col.to_uint() as c_uint,
|
||||
0)
|
||||
};
|
||||
|
||||
scope_stack.push(ScopeStackEntry { scope_metadata: scope_metadata, ident: None });
|
||||
|
|
@ -2539,7 +2540,8 @@ fn populate_scope_map(cx: &CrateContext,
|
|||
parent_scope,
|
||||
file_metadata,
|
||||
loc.line as c_uint,
|
||||
loc.col.to_uint() as c_uint)
|
||||
loc.col.to_uint() as c_uint,
|
||||
0)
|
||||
};
|
||||
|
||||
scope_stack.push(ScopeStackEntry {
|
||||
|
|
|
|||
|
|
@ -223,10 +223,23 @@ pub fn trans_intrinsic(ccx: &CrateContext,
|
|||
|
||||
match *split.get(1) {
|
||||
"cxchg" => {
|
||||
// See include/llvm/IR/Instructions.h for their implementation
|
||||
// of this, I assume that it's good enough for us to use for
|
||||
// now.
|
||||
let strongest_failure_ordering = match order {
|
||||
lib::llvm::NotAtomic | lib::llvm::Unordered =>
|
||||
ccx.sess().fatal("cmpxchg must be atomic"),
|
||||
lib::llvm::Monotonic | lib::llvm::Release =>
|
||||
lib::llvm::Monotonic,
|
||||
lib::llvm::Acquire | lib::llvm::AcquireRelease =>
|
||||
lib::llvm::Acquire,
|
||||
lib::llvm::SequentiallyConsistent =>
|
||||
lib::llvm::SequentiallyConsistent,
|
||||
};
|
||||
let old = AtomicCmpXchg(bcx, get_param(decl, first_real_arg),
|
||||
get_param(decl, first_real_arg + 1u),
|
||||
get_param(decl, first_real_arg + 2u),
|
||||
order);
|
||||
order, strongest_failure_ordering);
|
||||
Ret(bcx, old);
|
||||
}
|
||||
"load" => {
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
use back::link::mangle_exported_name;
|
||||
use back::link::exported_name;
|
||||
use driver::session;
|
||||
use lib::llvm::ValueRef;
|
||||
use middle::trans::base::{set_llvm_fn_attrs, set_inline_hint};
|
||||
|
|
@ -27,6 +26,7 @@ use syntax::abi;
|
|||
use syntax::ast;
|
||||
use syntax::ast_map;
|
||||
use syntax::ast_util::local_def;
|
||||
use std::hash::sip;
|
||||
|
||||
pub fn monomorphic_fn(ccx: &CrateContext,
|
||||
fn_id: ast::DefId,
|
||||
|
|
@ -178,7 +178,8 @@ pub fn monomorphic_fn(ccx: &CrateContext,
|
|||
}
|
||||
|
||||
let s = ccx.tcx.map.with_path(fn_id.node, |path| {
|
||||
mangle_exported_name(ccx, path, mono_ty, fn_id.node)
|
||||
exported_name(path, format!("h{}", sip::hash(&(hash_id, mono_ty))),
|
||||
ccx.link_meta.crateid.version_or_default())
|
||||
});
|
||||
debug!("monomorphize_fn mangled to {}", s);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue