-
Notifications
You must be signed in to change notification settings - Fork 13.4k
cleanup: remove pointee types #105545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cleanup: remove pointee types #105545
Changes from 2 commits
b654077
04303cf
def44c5
cf7788d
5580012
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -652,7 +652,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { | |
flags: MemFlags, | ||
) -> &'ll Value { | ||
debug!("Store {:?} -> {:?} ({:?})", val, ptr, flags); | ||
let ptr = self.check_store(val, ptr); | ||
let ptr = self.check_store(ptr); | ||
unsafe { | ||
let store = llvm::LLVMBuildStore(self.llbuilder, val, ptr); | ||
let align = | ||
|
@@ -682,7 +682,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { | |
size: Size, | ||
) { | ||
debug!("Store {:?} -> {:?}", val, ptr); | ||
let ptr = self.check_store(val, ptr); | ||
let ptr = self.check_store(ptr); | ||
unsafe { | ||
let store = llvm::LLVMRustBuildAtomicStore( | ||
self.llbuilder, | ||
|
@@ -873,8 +873,6 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { | |
assert!(!flags.contains(MemFlags::NONTEMPORAL), "non-temporal memcpy not supported"); | ||
let size = self.intcast(size, self.type_isize(), false); | ||
let is_volatile = flags.contains(MemFlags::VOLATILE); | ||
let dst = self.pointercast(dst, self.type_i8p()); | ||
let src = self.pointercast(src, self.type_i8p()); | ||
unsafe { | ||
llvm::LLVMRustBuildMemCpy( | ||
self.llbuilder, | ||
|
@@ -900,8 +898,6 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { | |
assert!(!flags.contains(MemFlags::NONTEMPORAL), "non-temporal memmove not supported"); | ||
let size = self.intcast(size, self.type_isize(), false); | ||
let is_volatile = flags.contains(MemFlags::VOLATILE); | ||
let dst = self.pointercast(dst, self.type_i8p()); | ||
let src = self.pointercast(src, self.type_i8p()); | ||
unsafe { | ||
llvm::LLVMRustBuildMemMove( | ||
self.llbuilder, | ||
|
@@ -924,7 +920,6 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { | |
flags: MemFlags, | ||
) { | ||
let is_volatile = flags.contains(MemFlags::VOLATILE); | ||
let ptr = self.pointercast(ptr, self.type_i8p()); | ||
unsafe { | ||
llvm::LLVMRustBuildMemSet( | ||
self.llbuilder, | ||
|
@@ -981,7 +976,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { | |
} | ||
|
||
fn cleanup_landing_pad(&mut self, pers_fn: &'ll Value) -> (&'ll Value, &'ll Value) { | ||
let ty = self.type_struct(&[self.type_i8p(), self.type_i32()], false); | ||
let ty = self.type_struct(&[self.type_ptr(), self.type_i32()], false); | ||
let landing_pad = self.landing_pad(ty, pers_fn, 0); | ||
unsafe { | ||
llvm::LLVMSetCleanup(landing_pad, llvm::True); | ||
|
@@ -990,14 +985,14 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { | |
} | ||
|
||
fn filter_landing_pad(&mut self, pers_fn: &'ll Value) -> (&'ll Value, &'ll Value) { | ||
let ty = self.type_struct(&[self.type_i8p(), self.type_i32()], false); | ||
let ty = self.type_struct(&[self.type_ptr(), self.type_i32()], false); | ||
let landing_pad = self.landing_pad(ty, pers_fn, 1); | ||
self.add_clause(landing_pad, self.const_array(self.type_i8p(), &[])); | ||
self.add_clause(landing_pad, self.const_array(self.type_ptr(), &[])); | ||
(self.extract_value(landing_pad, 0), self.extract_value(landing_pad, 1)) | ||
} | ||
|
||
fn resume(&mut self, exn0: &'ll Value, exn1: &'ll Value) { | ||
let ty = self.type_struct(&[self.type_i8p(), self.type_i32()], false); | ||
let ty = self.type_struct(&[self.type_ptr(), self.type_i32()], false); | ||
let mut exn = self.const_poison(ty); | ||
exn = self.insert_value(exn, exn0, 0); | ||
exn = self.insert_value(exn, exn1, 1); | ||
|
@@ -1161,7 +1156,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { | |
|
||
let llfn = unsafe { llvm::LLVMRustGetInstrProfIncrementIntrinsic(self.cx().llmod) }; | ||
let llty = self.cx.type_func( | ||
&[self.cx.type_i8p(), self.cx.type_i64(), self.cx.type_i32(), self.cx.type_i32()], | ||
&[self.cx.type_ptr(), self.cx.type_i64(), self.cx.type_i32(), self.cx.type_i32()], | ||
self.cx.type_void(), | ||
); | ||
let args = &[fn_name, hash, num_counters, index]; | ||
|
@@ -1387,23 +1382,12 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> { | |
ret.expect("LLVM does not have support for catchret") | ||
} | ||
|
||
fn check_store(&mut self, val: &'ll Value, ptr: &'ll Value) -> &'ll Value { | ||
fn check_store(&mut self, ptr: &'ll Value) -> &'ll Value { | ||
let dest_ptr_ty = self.cx.val_ty(ptr); | ||
let stored_ty = self.cx.val_ty(val); | ||
let stored_ptr_ty = self.cx.type_ptr_to(stored_ty); | ||
|
||
assert_eq!(self.cx.type_kind(dest_ptr_ty), TypeKind::Pointer); | ||
|
||
if dest_ptr_ty == stored_ptr_ty { | ||
ptr | ||
} else { | ||
debug!( | ||
"type mismatch in store. \ | ||
Expected {:?}, got {:?}; inserting bitcast", | ||
dest_ptr_ty, stored_ptr_ty | ||
); | ||
self.bitcast(ptr, stored_ptr_ty) | ||
} | ||
ptr | ||
} | ||
|
||
fn check_call<'b>( | ||
|
@@ -1468,7 +1452,6 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> { | |
return; | ||
} | ||
|
||
let ptr = self.pointercast(ptr, self.cx.type_i8p()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can pointercast be implemented as nop after these changes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can still be used to convert between different pointer address spaces, e.g. when casting data pointers to function pointers on harvard architecture targets: https://godbolt.org/z/c4nEb8sTW. (Note that we don't use pointercast for this today; that IR is actually invalid as a result. I'll open a PR to fix it.) On other targets it'll always do nothing. The LLVM side has a check to avoid creating a new instruction if the pointer is already the correct type. |
||
self.call_intrinsic(intrinsic, &[self.cx.const_u64(size), ptr]); | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.