mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix issue #92
This commit is contained in:
+11
-9
@@ -3178,11 +3178,7 @@ irValue *ir_emit_transmute(irProcedure *proc, irValue *value, Type *t) {
|
|||||||
|
|
||||||
Type *src = base_type(src_type);
|
Type *src = base_type(src_type);
|
||||||
Type *dst = base_type(t);
|
Type *dst = base_type(t);
|
||||||
#if 0
|
|
||||||
if (are_types_identical(t, src_type)) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
irModule *m = proc->module;
|
irModule *m = proc->module;
|
||||||
|
|
||||||
i64 sz = type_size_of(m->allocator, src);
|
i64 sz = type_size_of(m->allocator, src);
|
||||||
@@ -3190,6 +3186,14 @@ irValue *ir_emit_transmute(irProcedure *proc, irValue *value, Type *t) {
|
|||||||
|
|
||||||
GB_ASSERT_MSG(sz == dz, "Invalid transmute conversion: `%s` to `%s`", type_to_string(src_type), type_to_string(t));
|
GB_ASSERT_MSG(sz == dz, "Invalid transmute conversion: `%s` to `%s`", type_to_string(src_type), type_to_string(t));
|
||||||
|
|
||||||
|
// NOTE(bill): Casting between an integer and a pointer cannot be done through a bitcast
|
||||||
|
if (is_type_int_or_uint(src) && is_type_pointer(dst)) {
|
||||||
|
return ir_emit_int_to_ptr(proc, value, t);
|
||||||
|
}
|
||||||
|
if (is_type_pointer(src) && is_type_int_or_uint(dst)) {
|
||||||
|
return ir_emit_ptr_to_int(proc, value, t);
|
||||||
|
}
|
||||||
|
|
||||||
if (ir_is_type_aggregate(src) || ir_is_type_aggregate(dst)) {
|
if (ir_is_type_aggregate(src) || ir_is_type_aggregate(dst)) {
|
||||||
irValue *s = ir_address_from_load_or_generate_local(proc, value);
|
irValue *s = ir_address_from_load_or_generate_local(proc, value);
|
||||||
irValue *d = ir_emit_bitcast(proc, s, make_type_pointer(m->allocator, t));
|
irValue *d = ir_emit_bitcast(proc, s, make_type_pointer(m->allocator, t));
|
||||||
@@ -3197,7 +3201,6 @@ irValue *ir_emit_transmute(irProcedure *proc, irValue *value, Type *t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO(bill): Actually figure out what the conversion needs to be correctly 'cause LLVM
|
// TODO(bill): Actually figure out what the conversion needs to be correctly 'cause LLVM
|
||||||
|
|
||||||
return ir_emit_bitcast(proc, value, dst);
|
return ir_emit_bitcast(proc, value, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3705,13 +3708,12 @@ void ir_gen_global_type_name(irModule *m, Entity *e, String name) {
|
|||||||
}
|
}
|
||||||
if (is_poly) {
|
if (is_poly) {
|
||||||
auto found = map_get(&m->info->gen_types, hash_pointer(e->type));
|
auto found = map_get(&m->info->gen_types, hash_pointer(e->type));
|
||||||
if (found == nullptr) {
|
if (found != nullptr) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
for_array(i, *found) {
|
for_array(i, *found) {
|
||||||
Entity *e = (*found)[i];
|
Entity *e = (*found)[i];
|
||||||
ir_mangle_add_sub_type_name(m, e, name);
|
ir_mangle_add_sub_type_name(m, e, name);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user