Skip to content

Commit

Permalink
Do not use void pointer for ptr_mask intrinsic
Browse files Browse the repository at this point in the history
I couldn't find where exactly it's documented, but apperantly pointers to void
type are invalid in llvm - void is only allowed as a return type of functions.
  • Loading branch information
WaffleLapkin committed Aug 21, 2022
1 parent 55ba58c commit 92b05db
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,6 @@ impl<'ll> CodegenCx<'ll, '_> {

let i8p = self.type_i8p();
let void = self.type_void();
let voidp = self.type_ptr_to(void);
let i1 = self.type_i1();
let t_i8 = self.type_i8();
let t_i16 = self.type_i16();
Expand Down Expand Up @@ -888,7 +887,7 @@ impl<'ll> CodegenCx<'ll, '_> {
ifn!("llvm.dbg.value", fn(t_metadata, t_i64, t_metadata) -> void);
}

ifn!("llvm.ptrmask", fn(voidp, t_isize) -> voidp);
ifn!("llvm.ptrmask", fn(i8p, t_isize) -> i8p);

None
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/codegen/intrinsics/mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// CHECK-LABEL: @mask_ptr
// CHECK-SAME: [[WORD:i[0-9]+]] %mask
#[no_mangle]
pub fn mask_ptr(ptr: *const u8, mask: usize) -> *const u8 {
pub fn mask_ptr(ptr: *const u16, mask: usize) -> *const u16 {
// CHECK: call
// CHECK-SAME: @llvm.ptrmask.p0isVoid.[[WORD]](
// CHECK-SAME: @llvm.ptrmask.p0i8.[[WORD]](
core::intrinsics::ptr_mask(ptr, mask)
}

0 comments on commit 92b05db

Please sign in to comment.