mirror of
https://github.com/ziglang/zig.git
synced 2025-12-16 11:13:08 +00:00
llvm: cast optional null ptr representation to generic address space
The panic handler expects that this value is represented with the generic address space, so cast the global to the generic address- space before caching and returning the value.
This commit is contained in:
parent
0a6cd257b9
commit
13c0624f23
@ -2435,18 +2435,25 @@ pub const Object = struct {
|
|||||||
.ty = ty.toType(),
|
.ty = ty.toType(),
|
||||||
.val = null_opt_usize.toValue(),
|
.val = null_opt_usize.toValue(),
|
||||||
});
|
});
|
||||||
|
const llvm_wanted_addrspace = toLlvmAddressSpace(.generic, target);
|
||||||
|
const llvm_actual_addrspace = toLlvmGlobalAddressSpace(.generic, target);
|
||||||
const global = o.llvm_module.addGlobalInAddressSpace(
|
const global = o.llvm_module.addGlobalInAddressSpace(
|
||||||
llvm_init.typeOf(),
|
llvm_init.typeOf(),
|
||||||
"",
|
"",
|
||||||
toLlvmGlobalAddressSpace(.generic, target),
|
llvm_actual_addrspace,
|
||||||
);
|
);
|
||||||
global.setLinkage(.Internal);
|
global.setLinkage(.Internal);
|
||||||
global.setUnnamedAddr(.True);
|
global.setUnnamedAddr(.True);
|
||||||
global.setAlignment(ty.toType().abiAlignment(mod));
|
global.setAlignment(ty.toType().abiAlignment(mod));
|
||||||
global.setInitializer(llvm_init);
|
global.setInitializer(llvm_init);
|
||||||
|
|
||||||
o.null_opt_addr = global;
|
const addrspace_casted_global = if (llvm_wanted_addrspace != llvm_actual_addrspace)
|
||||||
return global;
|
global.constAddrSpaceCast(o.context.pointerType(llvm_wanted_addrspace))
|
||||||
|
else
|
||||||
|
global;
|
||||||
|
|
||||||
|
o.null_opt_addr = addrspace_casted_global;
|
||||||
|
return addrspace_casted_global;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the llvm function does not exist, create it.
|
/// If the llvm function does not exist, create it.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user