| ... | @@ -7212,11 +7212,17 @@ pub const FuncGen = struct { | ... | @@ -7212,11 +7212,17 @@ pub const FuncGen = struct { |
| 7212 | fn airRetAddr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value { | 7212 | fn airRetAddr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value { |
| 7213 | if (self.liveness.isUnused(inst)) return null; | 7213 | if (self.liveness.isUnused(inst)) return null; |
| 7214 | | 7214 | |
| | 7215 | const llvm_usize = try self.dg.lowerType(Type.usize); |
| | 7216 | const target = self.dg.module.getTarget(); |
| | 7217 | if (!target_util.supportsReturnAddress(target)) { |
| | 7218 | // https://github.com/ziglang/zig/issues/11946 |
| | 7219 | return llvm_usize.constNull(); |
| | 7220 | } |
| | 7221 | |
| 7215 | const llvm_i32 = self.context.intType(32); | 7222 | const llvm_i32 = self.context.intType(32); |
| 7216 | const llvm_fn = self.getIntrinsic("llvm.returnaddress", &.{}); | 7223 | const llvm_fn = self.getIntrinsic("llvm.returnaddress", &.{}); |
| 7217 | const params = [_]*const llvm.Value{llvm_i32.constNull()}; | 7224 | const params = [_]*const llvm.Value{llvm_i32.constNull()}; |
| 7218 | const ptr_val = self.builder.buildCall(llvm_fn, &params, params.len, .Fast, .Auto, ""); | 7225 | const ptr_val = self.builder.buildCall(llvm_fn, &params, params.len, .Fast, .Auto, ""); |
| 7219 | const llvm_usize = try self.dg.lowerType(Type.usize); | | |
| 7220 | return self.builder.buildPtrToInt(ptr_val, llvm_usize, ""); | 7226 | return self.builder.buildPtrToInt(ptr_val, llvm_usize, ""); |
| 7221 | } | 7227 | } |
| 7222 | | 7228 | |
| ... | @@ -8021,7 +8027,6 @@ pub const FuncGen = struct { | ... | @@ -8021,7 +8027,6 @@ pub const FuncGen = struct { |
| 8021 | assert(union_obj.haveFieldTypes()); | 8027 | assert(union_obj.haveFieldTypes()); |
| 8022 | const field = union_obj.fields.values()[extra.field_index]; | 8028 | const field = union_obj.fields.values()[extra.field_index]; |
| 8023 | const field_llvm_ty = try self.dg.lowerType(field.ty); | 8029 | const field_llvm_ty = try self.dg.lowerType(field.ty); |
| 8024 | const tag_llvm_ty = try self.dg.lowerType(union_obj.tag_ty); | | |
| 8025 | const field_size = field.ty.abiSize(target); | 8030 | const field_size = field.ty.abiSize(target); |
| 8026 | const field_align = field.normalAlignment(target); | 8031 | const field_align = field.normalAlignment(target); |
| 8027 | | 8032 | |
| ... | @@ -8044,6 +8049,7 @@ pub const FuncGen = struct { | ... | @@ -8044,6 +8049,7 @@ pub const FuncGen = struct { |
| 8044 | const fields: [1]*const llvm.Type = .{payload}; | 8049 | const fields: [1]*const llvm.Type = .{payload}; |
| 8045 | break :t self.context.structType(&fields, fields.len, .False); | 8050 | break :t self.context.structType(&fields, fields.len, .False); |
| 8046 | } | 8051 | } |
| | 8052 | const tag_llvm_ty = try self.dg.lowerType(union_obj.tag_ty); |
| 8047 | var fields: [3]*const llvm.Type = undefined; | 8053 | var fields: [3]*const llvm.Type = undefined; |
| 8048 | var fields_len: c_uint = 2; | 8054 | var fields_len: c_uint = 2; |
| 8049 | if (layout.tag_align >= layout.payload_align) { | 8055 | if (layout.tag_align >= layout.payload_align) { |
| ... | @@ -8100,6 +8106,7 @@ pub const FuncGen = struct { | ... | @@ -8100,6 +8106,7 @@ pub const FuncGen = struct { |
| 8100 | index_type.constInt(@boolToInt(layout.tag_align < layout.payload_align), .False), | 8106 | index_type.constInt(@boolToInt(layout.tag_align < layout.payload_align), .False), |
| 8101 | }; | 8107 | }; |
| 8102 | const field_ptr = self.builder.buildInBoundsGEP(casted_ptr, &indices, indices.len, ""); | 8108 | const field_ptr = self.builder.buildInBoundsGEP(casted_ptr, &indices, indices.len, ""); |
| | 8109 | const tag_llvm_ty = try self.dg.lowerType(union_obj.tag_ty); |
| 8103 | const llvm_tag = tag_llvm_ty.constInt(extra.field_index, .False); | 8110 | const llvm_tag = tag_llvm_ty.constInt(extra.field_index, .False); |
| 8104 | const store_inst = self.builder.buildStore(llvm_tag, field_ptr); | 8111 | const store_inst = self.builder.buildStore(llvm_tag, field_ptr); |
| 8105 | store_inst.setAlignment(union_obj.tag_ty.abiAlignment(target)); | 8112 | store_inst.setAlignment(union_obj.tag_ty.abiAlignment(target)); |