Commit 1ccc19f8 authored by Eduardo Souza's avatar Eduardo Souza

Fix bug when storing a pointer.

parent abf98404
Pipeline #5678 failed with stages
in 40 minutes and 6 seconds
......@@ -1806,7 +1806,6 @@ pub unsafe fn gen_instr_store(
let mem_loc = ins.ops.get(*mem_loc).unwrap();
let value = ins.ops.get(*value).unwrap();
let value_type = value.ty();
println!("{:?}", value_type);
// FIXME this should be the case, but apparently it is not
// assert_eq!(
......@@ -1829,27 +1828,6 @@ pub unsafe fn gen_instr_store(
_ => unimplemented!()
};
// May be assigning to a global variable, in which case,
// we need an addrspace cast, since poitners in globals are in addrspace(0)
if is_ptr {
let value_type = LLVMTypeOf(llvm_value);
let value_type_internal = LLVMGetElementType(value_type);
let dest_type = LLVMPointerType(value_type_internal, 0);
let location_type = LLVMTypeOf(*llvm_mem_loc);
let location_type_internal = LLVMGetElementType(location_type);
if LLVMGetPointerAddressSpace(location_type_internal) == 0 {
let value = value.as_value();
let new_name = format!("{}_ptr\0", value.hdr.name());
llvm_value = LLVMBuildAddrSpaceCast(
llvm_internal_context.builder,
llvm_value,
dest_type,
new_name.as_str().as_ptr() as *const c_char
);
}
}
// FIXME set order for store instruction
LLVMBuildStore(llvm_internal_context.builder, llvm_value, *llvm_mem_loc);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment