Merge pull request #14078 from jacobly0/llvm-opaque-ptrs

llvm: remove unnecessary code for opaque pointers
This commit is contained in:
Andrew Kelley 2022-12-27 04:57:01 -05:00 committed by GitHub
commit 3a7a39cb91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 183 additions and 330 deletions

File diff suppressed because it is too large Load Diff

View File

@ -287,9 +287,6 @@ pub const Type = opaque {
pub const getUndef = LLVMGetUndef;
extern fn LLVMGetUndef(Ty: *Type) *Value;
pub const pointerType = LLVMPointerType;
extern fn LLVMPointerType(ElementType: *Type, AddressSpace: c_uint) *Type;
pub const arrayType = LLVMArrayType;
extern fn LLVMArrayType(ElementType: *Type, ElementCount: c_uint) *Type;

View File

@ -1430,6 +1430,12 @@ test "struct has only one reference" {
fn errorUnionStructReturn() error{Foo}!struct { x: u8 } {
return error.Foo;
}
fn pointerPackedStruct(_: *packed struct { x: u8 }) void {}
fn nestedPointerPackedStruct(_: struct { x: *packed struct { x: u8 } }) void {}
fn pointerNestedPackedStruct(_: *struct { x: packed struct { x: u8 } }) void {}
fn pointerNestedPointerPackedStruct(_: *struct { x: *packed struct { x: u8 } }) void {}
fn optionalComptimeIntParam(comptime x: ?comptime_int) comptime_int {
return x.?;
}
@ -1446,6 +1452,14 @@ test "struct has only one reference" {
const error_union_struct_return: *const anyopaque = &S.errorUnionStructReturn;
try expect(optional_struct_return != error_union_struct_return);
const pointer_packed_struct: *const anyopaque = &S.pointerPackedStruct;
const nested_pointer_packed_struct: *const anyopaque = &S.nestedPointerPackedStruct;
try expect(pointer_packed_struct != nested_pointer_packed_struct);
const pointer_nested_packed_struct: *const anyopaque = &S.pointerNestedPackedStruct;
const pointer_nested_pointer_packed_struct: *const anyopaque = &S.pointerNestedPointerPackedStruct;
try expect(pointer_nested_packed_struct != pointer_nested_pointer_packed_struct);
try expectEqual(@alignOf(struct {}), S.optionalComptimeIntParam(@alignOf(struct {})));
try expectEqual(@alignOf(struct { x: u8 }), S.errorUnionComptimeIntParam(@alignOf(struct { x: u8 })));
try expectEqual(@sizeOf(struct { x: u16 }), S.optionalComptimeIntParam(@sizeOf(struct { x: u16 })));