提交 6c0a4693 编写于 作者: B bors

auto merge of #6649 : brson/rust/atomic-load-align, r=graydon

......@@ -1571,13 +1571,15 @@ pub unsafe fn LLVMBuildPtrDiff(B: BuilderRef,
pub unsafe fn LLVMBuildAtomicLoad(B: BuilderRef,
PointerVal: ValueRef,
Name: *c_char,
Order: AtomicOrdering)
Order: AtomicOrdering,
Alignment: c_uint)
-> ValueRef;
pub unsafe fn LLVMBuildAtomicStore(B: BuilderRef,
Val: ValueRef,
Ptr: ValueRef,
Order: AtomicOrdering)
Order: AtomicOrdering,
Alignment: c_uint)
-> ValueRef;
pub unsafe fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
......
......@@ -14,6 +14,7 @@
use lib::llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef, ModuleRef};
use lib;
use middle::trans::common::*;
use middle::trans::machine::llalign_of_min;
use syntax::codemap::span;
use core::hashmap::HashMap;
......@@ -544,7 +545,8 @@ pub fn AtomicLoad(cx: block, PointerVal: ValueRef, order: AtomicOrdering) -> Val
return llvm::LLVMGetUndef(ccx.int_type);
}
count_insn(cx, "load.atomic");
return llvm::LLVMBuildAtomicLoad(B(cx), PointerVal, noname(), order);
let align = llalign_of_min(*ccx, ccx.int_type);
return llvm::LLVMBuildAtomicLoad(B(cx), PointerVal, noname(), order, align as c_uint);
}
}
......@@ -558,7 +560,6 @@ pub fn LoadRangeAssert(cx: block, PointerVal: ValueRef, lo: c_ulonglong,
let min = llvm::LLVMConstInt(t, lo, signed);
let max = llvm::LLVMConstInt(t, hi, signed);
do vec::as_imm_buf([min, max]) |ptr, len| {
llvm::LLVMSetMetadata(value, lib::llvm::MD_range as c_uint,
llvm::LLVMMDNode(ptr, len as c_uint));
......@@ -586,7 +587,8 @@ pub fn AtomicStore(cx: block, Val: ValueRef, Ptr: ValueRef, order: AtomicOrderin
val_str(cx.ccx().tn, Val),
val_str(cx.ccx().tn, Ptr));
count_insn(cx, "store.atomic");
llvm::LLVMBuildAtomicStore(B(cx), Val, Ptr, order);
let align = llalign_of_min(cx.ccx(), cx.ccx().int_type);
llvm::LLVMBuildAtomicStore(B(cx), Val, Ptr, order, align as c_uint);
}
}
......
......@@ -548,22 +548,24 @@ extern "C" LLVMTypeRef LLVMMetadataType(void) {
extern "C" LLVMValueRef LLVMBuildAtomicLoad(LLVMBuilderRef B,
LLVMValueRef source,
const char* Name,
AtomicOrdering order) {
AtomicOrdering order,
unsigned alignment) {
LoadInst* li = new LoadInst(unwrap(source),0);
li->setVolatile(true);
li->setAtomic(order);
li->setAlignment(sizeof(intptr_t));
li->setAlignment(alignment);
return wrap(unwrap(B)->Insert(li, Name));
}
extern "C" LLVMValueRef LLVMBuildAtomicStore(LLVMBuilderRef B,
LLVMValueRef val,
LLVMValueRef target,
AtomicOrdering order) {
LLVMValueRef val,
LLVMValueRef target,
AtomicOrdering order,
unsigned alignment) {
StoreInst* si = new StoreInst(unwrap(val),unwrap(target));
si->setVolatile(true);
si->setAtomic(order);
si->setAlignment(sizeof(intptr_t));
si->setAlignment(alignment);
return wrap(unwrap(B)->Insert(si));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册