mirror of
https://github.com/ziglang/zig.git
synced 2024-11-16 09:03:12 +00:00
stage2: fix bitcast to optional ptr in llvm backend; omit safety check for intToPtr on optional ptr
This commit is contained in:
parent
950d840be6
commit
1bbca4f935
@ -865,13 +865,19 @@ pub fn flock(fd: fd_t, operation: i32) usize {
|
||||
return syscall2(.flock, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, operation)));
|
||||
}
|
||||
|
||||
var vdso_clock_gettime = @ptrCast(?*const anyopaque, init_vdso_clock_gettime);
|
||||
var vdso_clock_gettime = if (builtin.zig_backend == .stage1)
|
||||
@ptrCast(?*const anyopaque, init_vdso_clock_gettime)
|
||||
else
|
||||
@ptrCast(?*const anyopaque, &init_vdso_clock_gettime);
|
||||
|
||||
// We must follow the C calling convention when we call into the VDSO
|
||||
const vdso_clock_gettime_ty = fn (i32, *timespec) callconv(.C) usize;
|
||||
const vdso_clock_gettime_ty = if (builtin.zig_backend == .stage1)
|
||||
fn (i32, *timespec) callconv(.C) usize
|
||||
else
|
||||
*const fn (i32, *timespec) callconv(.C) usize;
|
||||
|
||||
pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
|
||||
if (@hasDecl(VDSO, "CGT_SYM") and builtin.zig_backend == .stage1) {
|
||||
if (@hasDecl(VDSO, "CGT_SYM")) {
|
||||
const ptr = @atomicLoad(?*const anyopaque, &vdso_clock_gettime, .Unordered);
|
||||
if (ptr) |fn_ptr| {
|
||||
const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr);
|
||||
|
@ -3892,7 +3892,7 @@ pub const FuncGen = struct {
|
||||
return self.builder.buildBitCast(operand, llvm_dest_ty.pointerType(0), "");
|
||||
}
|
||||
|
||||
if (operand_ty.zigTypeTag() == .Int and inst_ty.zigTypeTag() == .Pointer) {
|
||||
if (operand_ty.zigTypeTag() == .Int and inst_ty.isPtrAtRuntime()) {
|
||||
return self.builder.buildIntToPtr(operand, llvm_dest_ty, "");
|
||||
}
|
||||
|
||||
|
@ -2602,7 +2602,7 @@ pub const Type = extern union {
|
||||
const payload = self.castTag(.pointer).?.data;
|
||||
return payload.@"allowzero";
|
||||
},
|
||||
else => false,
|
||||
else => return self.zigTypeTag() == .Optional,
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user