[eddyb/rebase cleanup] s/&self./self.
This commit is contained in:
parent
0a1c50955b
commit
484e07c231
4 changed files with 77 additions and 77 deletions
|
@ -761,7 +761,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
}).collect::<Vec<_>>();
|
}).collect::<Vec<_>>();
|
||||||
|
|
||||||
debug!("Asm Output Type: {:?}", output);
|
debug!("Asm Output Type: {:?}", output);
|
||||||
let fty = &self.cx().type_func(&argtys[..], output);
|
let fty = self.cx().type_func(&argtys[..], output);
|
||||||
unsafe {
|
unsafe {
|
||||||
// Ask LLVM to verify that the constraints are well-formed.
|
// Ask LLVM to verify that the constraints are well-formed.
|
||||||
let constraints_ok = llvm::LLVMRustInlineAsmVerify(fty, cons);
|
let constraints_ok = llvm::LLVMRustInlineAsmVerify(fty, cons);
|
||||||
|
@ -896,9 +896,9 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
fn vector_splat(&self, num_elts: usize, elt: &'ll Value) -> &'ll Value {
|
fn vector_splat(&self, num_elts: usize, elt: &'ll Value) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let elt_ty = self.cx.val_ty(elt);
|
let elt_ty = self.cx.val_ty(elt);
|
||||||
let undef = llvm::LLVMGetUndef(&self.cx().type_vector(elt_ty, num_elts as u64));
|
let undef = llvm::LLVMGetUndef(self.cx().type_vector(elt_ty, num_elts as u64));
|
||||||
let vec = self.insert_element(undef, elt, self.cx.const_i32(0));
|
let vec = self.insert_element(undef, elt, self.cx.const_i32(0));
|
||||||
let vec_i32_ty = &self.cx().type_vector(&self.cx().type_i32(), num_elts as u64);
|
let vec_i32_ty = self.cx().type_vector(self.cx().type_i32(), num_elts as u64);
|
||||||
self.shuffle_vector(vec, undef, self.cx().const_null(vec_i32_ty))
|
self.shuffle_vector(vec, undef, self.cx().const_null(vec_i32_ty))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1305,6 +1305,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cx(&self) -> &'a CodegenCx<'ll, 'tcx> {
|
fn cx(&self) -> &'a CodegenCx<'ll, 'tcx> {
|
||||||
&self.cx
|
self.cx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,19 +255,19 @@ impl<'ll, 'tcx: 'll> ConstMethods for CodegenCx<'ll, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_bool(&self, val: bool) -> &'ll Value {
|
fn const_bool(&self, val: bool) -> &'ll Value {
|
||||||
&self.const_uint(&self.type_i1(), val as u64)
|
self.const_uint(self.type_i1(), val as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_i32(&self, i: i32) -> &'ll Value {
|
fn const_i32(&self, i: i32) -> &'ll Value {
|
||||||
&self.const_int(&self.type_i32(), i as i64)
|
self.const_int(self.type_i32(), i as i64)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_u32(&self, i: u32) -> &'ll Value {
|
fn const_u32(&self, i: u32) -> &'ll Value {
|
||||||
&self.const_uint(&self.type_i32(), i as u64)
|
self.const_uint(self.type_i32(), i as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_u64(&self, i: u64) -> &'ll Value {
|
fn const_u64(&self, i: u64) -> &'ll Value {
|
||||||
&self.const_uint(&self.type_i64(), i)
|
self.const_uint(self.type_i64(), i)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_usize(&self, i: u64) -> &'ll Value {
|
fn const_usize(&self, i: u64) -> &'ll Value {
|
||||||
|
@ -277,11 +277,11 @@ impl<'ll, 'tcx: 'll> ConstMethods for CodegenCx<'ll, 'tcx> {
|
||||||
assert!(i < (1<<bit_size));
|
assert!(i < (1<<bit_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
&self.const_uint(&self.isize_ty, i)
|
self.const_uint(self.isize_ty, i)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_u8(&self, i: u8) -> &'ll Value {
|
fn const_u8(&self, i: u8) -> &'ll Value {
|
||||||
&self.const_uint(&self.type_i8(), i as u64)
|
self.const_uint(self.type_i8(), i as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -293,23 +293,23 @@ impl<'ll, 'tcx: 'll> ConstMethods for CodegenCx<'ll, 'tcx> {
|
||||||
null_terminated: bool,
|
null_terminated: bool,
|
||||||
) -> &'ll Value {
|
) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
if let Some(&llval) = &self.const_cstr_cache.borrow().get(&s) {
|
if let Some(&llval) = self.const_cstr_cache.borrow().get(&s) {
|
||||||
return llval;
|
return llval;
|
||||||
}
|
}
|
||||||
|
|
||||||
let sc = llvm::LLVMConstStringInContext(&self.llcx,
|
let sc = llvm::LLVMConstStringInContext(self.llcx,
|
||||||
s.as_ptr() as *const c_char,
|
s.as_ptr() as *const c_char,
|
||||||
s.len() as c_uint,
|
s.len() as c_uint,
|
||||||
!null_terminated as Bool);
|
!null_terminated as Bool);
|
||||||
let sym = &self.generate_local_symbol_name("str");
|
let sym = self.generate_local_symbol_name("str");
|
||||||
let g = declare::define_global(&self, &sym[..], &self.val_ty(sc)).unwrap_or_else(||{
|
let g = declare::define_global(&self, &sym[..], self.val_ty(sc)).unwrap_or_else(||{
|
||||||
bug!("symbol `{}` is already defined", sym);
|
bug!("symbol `{}` is already defined", sym);
|
||||||
});
|
});
|
||||||
llvm::LLVMSetInitializer(g, sc);
|
llvm::LLVMSetInitializer(g, sc);
|
||||||
llvm::LLVMSetGlobalConstant(g, True);
|
llvm::LLVMSetGlobalConstant(g, True);
|
||||||
llvm::LLVMRustSetLinkage(g, llvm::Linkage::InternalLinkage);
|
llvm::LLVMRustSetLinkage(g, llvm::Linkage::InternalLinkage);
|
||||||
|
|
||||||
&self.const_cstr_cache.borrow_mut().insert(s, g);
|
self.const_cstr_cache.borrow_mut().insert(s, g);
|
||||||
g
|
g
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,9 +318,9 @@ impl<'ll, 'tcx: 'll> ConstMethods for CodegenCx<'ll, 'tcx> {
|
||||||
// you will be kicked off fast isel. See issue #4352 for an example of this.
|
// you will be kicked off fast isel. See issue #4352 for an example of this.
|
||||||
fn const_str_slice(&self, s: LocalInternedString) -> &'ll Value {
|
fn const_str_slice(&self, s: LocalInternedString) -> &'ll Value {
|
||||||
let len = s.len();
|
let len = s.len();
|
||||||
let cs = consts::ptrcast(&self.const_cstr(s, false),
|
let cs = consts::ptrcast(self.const_cstr(s, false),
|
||||||
&self.type_ptr_to(&self.layout_of(&self.tcx.mk_str()).llvm_type(&self)));
|
self.type_ptr_to(self.layout_of(self.tcx.mk_str()).llvm_type(&self)));
|
||||||
&self.const_fat_ptr(cs, &self.const_usize(len as u64))
|
self.const_fat_ptr(cs, self.const_usize(len as u64))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_fat_ptr(
|
fn const_fat_ptr(
|
||||||
|
@ -330,7 +330,7 @@ impl<'ll, 'tcx: 'll> ConstMethods for CodegenCx<'ll, 'tcx> {
|
||||||
) -> &'ll Value {
|
) -> &'ll Value {
|
||||||
assert_eq!(abi::FAT_PTR_ADDR, 0);
|
assert_eq!(abi::FAT_PTR_ADDR, 0);
|
||||||
assert_eq!(abi::FAT_PTR_EXTRA, 1);
|
assert_eq!(abi::FAT_PTR_EXTRA, 1);
|
||||||
&self.const_struct(&[ptr, meta], false)
|
self.const_struct(&[ptr, meta], false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_struct(
|
fn const_struct(
|
||||||
|
@ -338,7 +338,7 @@ impl<'ll, 'tcx: 'll> ConstMethods for CodegenCx<'ll, 'tcx> {
|
||||||
elts: &[&'ll Value],
|
elts: &[&'ll Value],
|
||||||
packed: bool
|
packed: bool
|
||||||
) -> &'ll Value {
|
) -> &'ll Value {
|
||||||
struct_in_context(&self.llcx, elts, packed)
|
struct_in_context(self.llcx, elts, packed)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
|
fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
|
||||||
|
@ -354,7 +354,7 @@ impl<'ll, 'tcx: 'll> ConstMethods for CodegenCx<'ll, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_bytes(&self, bytes: &[u8]) -> &'ll Value {
|
fn const_bytes(&self, bytes: &[u8]) -> &'ll Value {
|
||||||
bytes_in_context(&self.llcx, bytes)
|
bytes_in_context(self.llcx, bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
|
fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
|
||||||
|
|
|
@ -137,16 +137,16 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
) -> &'ll Value {
|
) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let gv = match kind {
|
let gv = match kind {
|
||||||
Some(kind) if !&self.tcx.sess.fewer_names() => {
|
Some(kind) if !self.tcx.sess.fewer_names() => {
|
||||||
let name = &self.generate_local_symbol_name(kind);
|
let name = self.generate_local_symbol_name(kind);
|
||||||
let gv = declare::define_global(&self, &name[..],
|
let gv = declare::define_global(&self, &name[..],
|
||||||
&self.val_ty(cv)).unwrap_or_else(||{
|
self.val_ty(cv)).unwrap_or_else(||{
|
||||||
bug!("symbol `{}` is already defined", name);
|
bug!("symbol `{}` is already defined", name);
|
||||||
});
|
});
|
||||||
llvm::LLVMRustSetLinkage(gv, llvm::Linkage::PrivateLinkage);
|
llvm::LLVMRustSetLinkage(gv, llvm::Linkage::PrivateLinkage);
|
||||||
gv
|
gv
|
||||||
},
|
},
|
||||||
_ => declare::define_private_global(&self, &self.val_ty(cv)),
|
_ => declare::define_private_global(&self, self.val_ty(cv)),
|
||||||
};
|
};
|
||||||
llvm::LLVMSetInitializer(gv, cv);
|
llvm::LLVMSetInitializer(gv, cv);
|
||||||
set_global_alignment(&self, gv, align);
|
set_global_alignment(&self, gv, align);
|
||||||
|
@ -161,7 +161,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
align: Align,
|
align: Align,
|
||||||
kind: Option<&str>,
|
kind: Option<&str>,
|
||||||
) -> &'ll Value {
|
) -> &'ll Value {
|
||||||
if let Some(&gv) = &self.const_globals.borrow().get(&cv) {
|
if let Some(&gv) = self.const_globals.borrow().get(&cv) {
|
||||||
unsafe {
|
unsafe {
|
||||||
// Upgrade the alignment in cases where the same constant is used with different
|
// Upgrade the alignment in cases where the same constant is used with different
|
||||||
// alignment requirements
|
// alignment requirements
|
||||||
|
@ -172,21 +172,21 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
}
|
}
|
||||||
return gv;
|
return gv;
|
||||||
}
|
}
|
||||||
let gv = &self.static_addr_of_mut(cv, align, kind);
|
let gv = self.static_addr_of_mut(cv, align, kind);
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMSetGlobalConstant(gv, True);
|
llvm::LLVMSetGlobalConstant(gv, True);
|
||||||
}
|
}
|
||||||
&self.const_globals.borrow_mut().insert(cv, gv);
|
self.const_globals.borrow_mut().insert(cv, gv);
|
||||||
gv
|
gv
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_static(&self, def_id: DefId) -> &'ll Value {
|
fn get_static(&self, def_id: DefId) -> &'ll Value {
|
||||||
let instance = Instance::mono(self.tcx, def_id);
|
let instance = Instance::mono(self.tcx, def_id);
|
||||||
if let Some(&g) = &self.instances.borrow().get(&instance) {
|
if let Some(&g) = self.instances.borrow().get(&instance) {
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
let defined_in_current_codegen_unit = &self.codegen_unit
|
let defined_in_current_codegen_unit = self.codegen_unit
|
||||||
.items()
|
.items()
|
||||||
.contains_key(&MonoItem::Static(def_id));
|
.contains_key(&MonoItem::Static(def_id));
|
||||||
assert!(!defined_in_current_codegen_unit,
|
assert!(!defined_in_current_codegen_unit,
|
||||||
|
@ -201,8 +201,8 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
|
|
||||||
let g = if let Some(id) = self.tcx.hir.as_local_node_id(def_id) {
|
let g = if let Some(id) = self.tcx.hir.as_local_node_id(def_id) {
|
||||||
|
|
||||||
let llty = &self.layout_of(ty).llvm_type(&self);
|
let llty = self.layout_of(ty).llvm_type(&self);
|
||||||
let (g, attrs) = match &self.tcx.hir.get(id) {
|
let (g, attrs) = match self.tcx.hir.get(id) {
|
||||||
Node::Item(&hir::Item {
|
Node::Item(&hir::Item {
|
||||||
ref attrs, span, node: hir::ItemKind::Static(..), ..
|
ref attrs, span, node: hir::ItemKind::Static(..), ..
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -212,7 +212,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
|
|
||||||
let g = declare::define_global(&self, &sym[..], llty).unwrap();
|
let g = declare::define_global(&self, &sym[..], llty).unwrap();
|
||||||
|
|
||||||
if !&self.tcx.is_reachable_non_generic(def_id) {
|
if !self.tcx.is_reachable_non_generic(def_id) {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMRustSetVisibility(g, llvm::Visibility::Hidden);
|
llvm::LLVMRustSetVisibility(g, llvm::Visibility::Hidden);
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
Node::ForeignItem(&hir::ForeignItem {
|
Node::ForeignItem(&hir::ForeignItem {
|
||||||
ref attrs, span, node: hir::ForeignItemKind::Static(..), ..
|
ref attrs, span, node: hir::ForeignItemKind::Static(..), ..
|
||||||
}) => {
|
}) => {
|
||||||
let fn_attrs = &self.tcx.codegen_fn_attrs(def_id);
|
let fn_attrs = self.tcx.codegen_fn_attrs(def_id);
|
||||||
(check_and_apply_linkage(&self, &fn_attrs, ty, sym, Some(span)), attrs)
|
(check_and_apply_linkage(&self, &fn_attrs, ty, sym, Some(span)), attrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,9 +242,9 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
g
|
g
|
||||||
} else {
|
} else {
|
||||||
// FIXME(nagisa): perhaps the map of externs could be offloaded to llvm somehow?
|
// FIXME(nagisa): perhaps the map of externs could be offloaded to llvm somehow?
|
||||||
debug!("get_static: sym={} item_attr={:?}", sym, &self.tcx.item_attrs(def_id));
|
debug!("get_static: sym={} item_attr={:?}", sym, self.tcx.item_attrs(def_id));
|
||||||
|
|
||||||
let attrs = &self.tcx.codegen_fn_attrs(def_id);
|
let attrs = self.tcx.codegen_fn_attrs(def_id);
|
||||||
let g = check_and_apply_linkage(&self, &attrs, ty, sym, None);
|
let g = check_and_apply_linkage(&self, &attrs, ty, sym, None);
|
||||||
|
|
||||||
// Thread-local statics in some other crate need to *always* be linked
|
// Thread-local statics in some other crate need to *always* be linked
|
||||||
|
@ -258,11 +258,11 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let needs_dll_storage_attr =
|
let needs_dll_storage_attr =
|
||||||
self.use_dll_storage_attrs && !&self.tcx.is_foreign_item(def_id) &&
|
self.use_dll_storage_attrs && !self.tcx.is_foreign_item(def_id) &&
|
||||||
// ThinLTO can't handle this workaround in all cases, so we don't
|
// ThinLTO can't handle this workaround in all cases, so we don't
|
||||||
// emit the attrs. Instead we make them unnecessary by disallowing
|
// emit the attrs. Instead we make them unnecessary by disallowing
|
||||||
// dynamic linking when cross-language LTO is enabled.
|
// dynamic linking when cross-language LTO is enabled.
|
||||||
!&self.tcx.sess.opts.debugging_opts.cross_lang_lto.enabled();
|
!self.tcx.sess.opts.debugging_opts.cross_lang_lto.enabled();
|
||||||
|
|
||||||
// If this assertion triggers, there's something wrong with commandline
|
// If this assertion triggers, there's something wrong with commandline
|
||||||
// argument validation.
|
// argument validation.
|
||||||
|
@ -281,7 +281,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
// crates, so there are cases where a static with an upstream DefId
|
// crates, so there are cases where a static with an upstream DefId
|
||||||
// is actually present in the current crate. We can find out via the
|
// is actually present in the current crate. We can find out via the
|
||||||
// is_codegened_item query.
|
// is_codegened_item query.
|
||||||
if !&self.tcx.is_codegened_item(def_id) {
|
if !self.tcx.is_codegened_item(def_id) {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMSetDLLStorageClass(g, llvm::DLLStorageClass::DllImport);
|
llvm::LLVMSetDLLStorageClass(g, llvm::DLLStorageClass::DllImport);
|
||||||
}
|
}
|
||||||
|
@ -297,7 +297,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&self.instances.borrow_mut().insert(instance, g);
|
self.instances.borrow_mut().insert(instance, g);
|
||||||
g
|
g
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
is_mutable: bool,
|
is_mutable: bool,
|
||||||
) {
|
) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let attrs = &self.tcx.codegen_fn_attrs(def_id);
|
let attrs = self.tcx.codegen_fn_attrs(def_id);
|
||||||
|
|
||||||
let (v, alloc) = match ::mir::codegen_static_initializer(&self, def_id) {
|
let (v, alloc) = match ::mir::codegen_static_initializer(&self, def_id) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
|
@ -315,7 +315,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
Err(_) => return,
|
Err(_) => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
let g = &self.get_static(def_id);
|
let g = self.get_static(def_id);
|
||||||
|
|
||||||
// boolean SSA values are i1, but they have to be stored in i8 slots,
|
// boolean SSA values are i1, but they have to be stored in i8 slots,
|
||||||
// otherwise some LLVM optimization passes don't work as expected
|
// otherwise some LLVM optimization passes don't work as expected
|
||||||
|
@ -344,7 +344,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
let visibility = llvm::LLVMRustGetVisibility(g);
|
let visibility = llvm::LLVMRustGetVisibility(g);
|
||||||
|
|
||||||
let new_g = llvm::LLVMRustGetOrInsertGlobal(
|
let new_g = llvm::LLVMRustGetOrInsertGlobal(
|
||||||
&self.llmod, name_string.as_ptr(), val_llty);
|
self.llmod, name_string.as_ptr(), val_llty);
|
||||||
|
|
||||||
llvm::LLVMRustSetLinkage(new_g, linkage);
|
llvm::LLVMRustSetLinkage(new_g, linkage);
|
||||||
llvm::LLVMRustSetVisibility(new_g, visibility);
|
llvm::LLVMRustSetVisibility(new_g, visibility);
|
||||||
|
@ -352,7 +352,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
// To avoid breaking any invariants, we leave around the old
|
// To avoid breaking any invariants, we leave around the old
|
||||||
// global for the moment; we'll replace all references to it
|
// global for the moment; we'll replace all references to it
|
||||||
// with the new global later. (See base::codegen_backend.)
|
// with the new global later. (See base::codegen_backend.)
|
||||||
&self.statics_to_rauw.borrow_mut().push((g, new_g));
|
self.statics_to_rauw.borrow_mut().push((g, new_g));
|
||||||
new_g
|
new_g
|
||||||
};
|
};
|
||||||
set_global_alignment(&self, g, self.align_of(ty));
|
set_global_alignment(&self, g, self.align_of(ty));
|
||||||
|
@ -416,19 +416,19 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
if self.tcx.sess.opts.target_triple.triple().starts_with("wasm32") {
|
if self.tcx.sess.opts.target_triple.triple().starts_with("wasm32") {
|
||||||
if let Some(section) = attrs.link_section {
|
if let Some(section) = attrs.link_section {
|
||||||
let section = llvm::LLVMMDStringInContext(
|
let section = llvm::LLVMMDStringInContext(
|
||||||
&self.llcx,
|
self.llcx,
|
||||||
section.as_str().as_ptr() as *const _,
|
section.as_str().as_ptr() as *const _,
|
||||||
section.as_str().len() as c_uint,
|
section.as_str().len() as c_uint,
|
||||||
);
|
);
|
||||||
let alloc = llvm::LLVMMDStringInContext(
|
let alloc = llvm::LLVMMDStringInContext(
|
||||||
&self.llcx,
|
self.llcx,
|
||||||
alloc.bytes.as_ptr() as *const _,
|
alloc.bytes.as_ptr() as *const _,
|
||||||
alloc.bytes.len() as c_uint,
|
alloc.bytes.len() as c_uint,
|
||||||
);
|
);
|
||||||
let data = [section, alloc];
|
let data = [section, alloc];
|
||||||
let meta = llvm::LLVMMDNodeInContext(&self.llcx, data.as_ptr(), 2);
|
let meta = llvm::LLVMMDNodeInContext(self.llcx, data.as_ptr(), 2);
|
||||||
llvm::LLVMAddNamedMetadataOperand(
|
llvm::LLVMAddNamedMetadataOperand(
|
||||||
&self.llmod,
|
self.llmod,
|
||||||
"wasm.custom_sections\0".as_ptr() as *const _,
|
"wasm.custom_sections\0".as_ptr() as *const _,
|
||||||
meta,
|
meta,
|
||||||
);
|
);
|
||||||
|
@ -439,8 +439,8 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
|
|
||||||
if attrs.flags.contains(CodegenFnAttrFlags::USED) {
|
if attrs.flags.contains(CodegenFnAttrFlags::USED) {
|
||||||
// This static will be stored in the llvm.used variable which is an array of i8*
|
// This static will be stored in the llvm.used variable which is an array of i8*
|
||||||
let cast = llvm::LLVMConstPointerCast(g, &self.type_i8p());
|
let cast = llvm::LLVMConstPointerCast(g, self.type_i8p());
|
||||||
&self.used_statics.borrow_mut().push(cast);
|
self.used_statics.borrow_mut().push(cast);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,52 +339,52 @@ impl IntrinsicDeclarationMethods for CodegenCx<'b, 'tcx> {
|
||||||
macro_rules! ifn {
|
macro_rules! ifn {
|
||||||
($name:expr, fn() -> $ret:expr) => (
|
($name:expr, fn() -> $ret:expr) => (
|
||||||
if key == $name {
|
if key == $name {
|
||||||
let f = declare::declare_cfn(&self, $name, &self.type_func(&[], $ret));
|
let f = declare::declare_cfn(&self, $name, self.type_func(&[], $ret));
|
||||||
llvm::SetUnnamedAddr(f, false);
|
llvm::SetUnnamedAddr(f, false);
|
||||||
&self.intrinsics.borrow_mut().insert($name, f.clone());
|
self.intrinsics.borrow_mut().insert($name, f.clone());
|
||||||
return Some(f);
|
return Some(f);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
($name:expr, fn(...) -> $ret:expr) => (
|
($name:expr, fn(...) -> $ret:expr) => (
|
||||||
if key == $name {
|
if key == $name {
|
||||||
let f = declare::declare_cfn(&self, $name, &self.type_variadic_func(&[], $ret));
|
let f = declare::declare_cfn(&self, $name, self.type_variadic_func(&[], $ret));
|
||||||
llvm::SetUnnamedAddr(f, false);
|
llvm::SetUnnamedAddr(f, false);
|
||||||
&self.intrinsics.borrow_mut().insert($name, f.clone());
|
self.intrinsics.borrow_mut().insert($name, f.clone());
|
||||||
return Some(f);
|
return Some(f);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
($name:expr, fn($($arg:expr),*) -> $ret:expr) => (
|
($name:expr, fn($($arg:expr),*) -> $ret:expr) => (
|
||||||
if key == $name {
|
if key == $name {
|
||||||
let f = declare::declare_cfn(&self, $name, &self.type_func(&[$($arg),*], $ret));
|
let f = declare::declare_cfn(&self, $name, self.type_func(&[$($arg),*], $ret));
|
||||||
llvm::SetUnnamedAddr(f, false);
|
llvm::SetUnnamedAddr(f, false);
|
||||||
&self.intrinsics.borrow_mut().insert($name, f.clone());
|
self.intrinsics.borrow_mut().insert($name, f.clone());
|
||||||
return Some(f);
|
return Some(f);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
macro_rules! mk_struct {
|
macro_rules! mk_struct {
|
||||||
($($field_ty:expr),*) => (&self.type_struct( &[$($field_ty),*], false))
|
($($field_ty:expr),*) => (self.type_struct( &[$($field_ty),*], false))
|
||||||
}
|
}
|
||||||
|
|
||||||
let i8p = &self.type_i8p();
|
let i8p = self.type_i8p();
|
||||||
let void = &self.type_void();
|
let void = self.type_void();
|
||||||
let i1 = &self.type_i1();
|
let i1 = self.type_i1();
|
||||||
let t_i8 = &self.type_i8();
|
let t_i8 = self.type_i8();
|
||||||
let t_i16 = &self.type_i16();
|
let t_i16 = self.type_i16();
|
||||||
let t_i32 = &self.type_i32();
|
let t_i32 = self.type_i32();
|
||||||
let t_i64 = &self.type_i64();
|
let t_i64 = self.type_i64();
|
||||||
let t_i128 = &self.type_i128();
|
let t_i128 = self.type_i128();
|
||||||
let t_f32 = &self.type_f32();
|
let t_f32 = self.type_f32();
|
||||||
let t_f64 = &self.type_f64();
|
let t_f64 = self.type_f64();
|
||||||
|
|
||||||
let t_v2f32 = &self.type_vector(t_f32, 2);
|
let t_v2f32 = self.type_vector(t_f32, 2);
|
||||||
let t_v4f32 = &self.type_vector(t_f32, 4);
|
let t_v4f32 = self.type_vector(t_f32, 4);
|
||||||
let t_v8f32 = &self.type_vector(t_f32, 8);
|
let t_v8f32 = self.type_vector(t_f32, 8);
|
||||||
let t_v16f32 = &self.type_vector(t_f32, 16);
|
let t_v16f32 = self.type_vector(t_f32, 16);
|
||||||
|
|
||||||
let t_v2f64 = &self.type_vector(t_f64, 2);
|
let t_v2f64 = self.type_vector(t_f64, 2);
|
||||||
let t_v4f64 = &self.type_vector(t_f64, 4);
|
let t_v4f64 = self.type_vector(t_f64, 4);
|
||||||
let t_v8f64 = &self.type_vector(t_f64, 8);
|
let t_v8f64 = self.type_vector(t_f64, 8);
|
||||||
|
|
||||||
ifn!("llvm.memset.p0i8.i16", fn(i8p, t_i8, t_i16, t_i32, i1) -> void);
|
ifn!("llvm.memset.p0i8.i16", fn(i8p, t_i8, t_i16, t_i32, i1) -> void);
|
||||||
ifn!("llvm.memset.p0i8.i32", fn(i8p, t_i8, t_i32, t_i32, i1) -> void);
|
ifn!("llvm.memset.p0i8.i32", fn(i8p, t_i8, t_i32, t_i32, i1) -> void);
|
||||||
|
@ -637,8 +637,8 @@ impl IntrinsicDeclarationMethods for CodegenCx<'b, 'tcx> {
|
||||||
ifn!("llvm.prefetch", fn(i8p, t_i32, t_i32, t_i32) -> void);
|
ifn!("llvm.prefetch", fn(i8p, t_i32, t_i32, t_i32) -> void);
|
||||||
|
|
||||||
if self.sess().opts.debuginfo != DebugInfo::None {
|
if self.sess().opts.debuginfo != DebugInfo::None {
|
||||||
ifn!("llvm.dbg.declare", fn(&self.type_metadata(), &self.type_metadata()) -> void);
|
ifn!("llvm.dbg.declare", fn(self.type_metadata(), self.type_metadata()) -> void);
|
||||||
ifn!("llvm.dbg.value", fn(&self.type_metadata(), t_i64, &self.type_metadata()) -> void);
|
ifn!("llvm.dbg.value", fn(self.type_metadata(), t_i64, self.type_metadata()) -> void);
|
||||||
}
|
}
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -694,7 +694,7 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
"rust_eh_personality"
|
"rust_eh_personality"
|
||||||
};
|
};
|
||||||
let fty = &self.type_variadic_func(&[], &self.type_i32());
|
let fty = self.type_variadic_func(&[], self.type_i32());
|
||||||
declare::declare_cfn(self, name, fty)
|
declare::declare_cfn(self, name, fty)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue