1
Fork 0

cg_llvm: remove pointee types and pointercast/bitcast-of-ptr

This commit is contained in:
Erik Desjardins 2022-12-06 00:07:28 -05:00
parent 4c96822796
commit b6540777fe
17 changed files with 118 additions and 283 deletions

View file

@ -103,7 +103,7 @@ pub fn const_alloc_to_llvm<'ll>(cx: &CodegenCx<'ll, '_>, alloc: ConstAllocation<
value: Primitive::Pointer(address_space),
valid_range: WrappingRange::full(dl.pointer_size),
},
cx.type_i8p_ext(address_space),
cx.type_ptr_ext(address_space),
));
next_offset = offset + pointer_size;
}
@ -179,7 +179,7 @@ fn check_and_apply_linkage<'ll, 'tcx>(
})
});
llvm::LLVMRustSetLinkage(g2, llvm::Linkage::InternalLinkage);
llvm::LLVMSetInitializer(g2, cx.const_ptrcast(g1, llty));
llvm::LLVMSetInitializer(g2, g1);
g2
}
} else if cx.tcx.sess.target.arch == "x86" &&
@ -251,7 +251,7 @@ impl<'ll> CodegenCx<'ll, '_> {
let g = if def_id.is_local() && !self.tcx.is_foreign_item(def_id) {
let llty = self.layout_of(ty).llvm_type(self);
if let Some(g) = self.get_declared_value(sym) {
if self.val_ty(g) != self.type_ptr_to(llty) {
if self.val_ty(g) != self.type_ptr() {
span_bug!(self.tcx.def_span(def_id), "Conflicting types for static");
}
}
@ -552,16 +552,14 @@ impl<'ll> StaticMethods for CodegenCx<'ll, '_> {
}
}
/// Add a global value to a list to be stored in the `llvm.used` variable, an array of i8*.
/// Add a global value to a list to be stored in the `llvm.used` variable, an array of ptr.
fn add_used_global(&self, global: &'ll Value) {
let cast = unsafe { llvm::LLVMConstPointerCast(global, self.type_i8p()) };
self.used_statics.borrow_mut().push(cast);
self.used_statics.borrow_mut().push(global);
}
/// Add a global value to a list to be stored in the `llvm.compiler.used` variable,
/// an array of i8*.
/// an array of ptr.
fn add_compiler_used_global(&self, global: &'ll Value) {
let cast = unsafe { llvm::LLVMConstPointerCast(global, self.type_i8p()) };
self.compiler_used_statics.borrow_mut().push(cast);
self.compiler_used_statics.borrow_mut().push(global);
}
}