Auto merge of #121282 - saethlin:gep-null-means-no-provenance, r=scot… · rust-lang/rust@0fa7fea (original) (raw)
4 files changed
lines changed
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -306,11 +306,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { | ||||
306 | 306 | bx.bitcast(imm, to_backend_ty) | ||
307 | 307 | } | ||
308 | 308 | (Pointer(..), Pointer(..)) => bx.pointercast(imm, to_backend_ty), | ||
309 | -(Int(..), Pointer(..)) => bx.inttoptr(imm, to_backend_ty), | |||
309 | +(Int(..), Pointer(..)) => bx.ptradd(bx.const_null(bx.type_ptr()), imm), | |||
310 | 310 | (Pointer(..), Int(..)) => bx.ptrtoint(imm, to_backend_ty), | ||
311 | 311 | (F16 | F32 | F64 | F128, Pointer(..)) => { |
312 | 312 | let int_imm = bx.bitcast(imm, bx.cx().type_isize()); | ||
313 | - bx.inttoptr(int_imm, to_backend_ty) | |||
313 | + bx.ptradd(bx.const_null(bx.type_ptr()), int_imm) | |||
314 | 314 | } | ||
315 | 315 | (Pointer(..), F16 | F32 | F64 | F128) => { |
316 | 316 | let int_imm = bx.ptrtoint(imm, bx.cx().type_isize()); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -296,7 +296,7 @@ pub unsafe fn check_pair_with_bool(x: (u8, bool)) -> (bool, i8) { | ||
296 | 296 | pub unsafe fn check_float_to_pointer(x: f64) -> *const () { |
297 | 297 | // CHECK-NOT: alloca |
298 | 298 | // CHECK: %0 = bitcast double %x to i64 |
299 | -// CHECK: %_0 = inttoptr i64 %0 to ptr | |
299 | +// CHECK: %_0 = getelementptr i8, ptr null, i64 %0 | |
300 | 300 | // CHECK: ret ptr %_0 |
301 | 301 | transmute(x) |
302 | 302 | } |
@@ -371,7 +371,7 @@ pub unsafe fn check_issue_110005(x: (usize, bool)) -> Option<Box<[u8]>> { | ||
371 | 371 | // CHECK-LABEL: @check_pair_to_dst_ref( |
372 | 372 | #[no_mangle] |
373 | 373 | pub unsafe fn check_pair_to_dst_ref<'a>(x: (usize, usize)) -> &'a [u8] { |
374 | -// CHECK: %_0.0 = inttoptr i64 %x.0 to ptr | |
374 | +// CHECK: %_0.0 = getelementptr i8, ptr null, i64 %x.0 | |
375 | 375 | // CHECK: %0 = insertvalue { ptr, i64 } poison, ptr %_0.0, 0 |
376 | 376 | // CHECK: %1 = insertvalue { ptr, i64 } %0, i64 %x.1, 1 |
377 | 377 | // CHECK: ret { ptr, i64 } %1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -49,7 +49,7 @@ pub fn ptr_to_int(p: *mut u16) -> usize { | ||
49 | 49 | } |
50 | 50 | |
51 | 51 | // CHECK: define{{.*}}ptr @int_to_ptr([[USIZE]] %i) |
52 | -// CHECK: %_0 = inttoptr [[USIZE]] %i to ptr | |
52 | +// CHECK: %_0 = getelementptr i8, ptr null, [[USIZE]] %i | |
53 | 53 | // CHECK-NEXT: ret ptr %_0 |
54 | 54 | #[no_mangle] |
55 | 55 | pub fn int_to_ptr(i: usize) -> *mut u16 { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -40,21 +40,21 @@ pub fn main() { | ||
40 | 40 | |
41 | 41 | extern "C" fn callback_isize(data: libc::uintptr_t) { |
42 | 42 | unsafe { |
43 | -let data: *const isize = mem::transmute(data); | |
43 | +let data = data as *const isize; | |
44 | 44 | assert_eq!(*data, 100); |
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | 48 | extern "C" fn callback_i64(data: libc::uintptr_t) { |
49 | 49 | unsafe { |
50 | -let data: *const i64 = mem::transmute(data); | |
50 | +let data = data as *const i64; | |
51 | 51 | assert_eq!(*data, 100); |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | 55 | extern "C" fn callback_i32(data: libc::uintptr_t) { |
56 | 56 | unsafe { |
57 | -let data: *const i32 = mem::transmute(data); | |
57 | +let data = data as *const i32; | |
58 | 58 | assert_eq!(*data, 100); |
59 | 59 | } |
60 | 60 | } |