authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2023-07-01 20:25:25+02:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2023-07-01 20:28:17+02:00
log13c0624f23bbf63b31ae9b8f06aa2e32c1616e94
tree04cc6726a336dacf422a2488d7a3047091a14ce5
parent0a6cd257b9c8a9093b966e3851dc8261e19b531a
signaturebadge-check Signed by SSH key SHA256:CQ99aPxq+RueiL9u7z0FEki5Fm7V6T8q4PrEGmINrA4

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.

1 files changed, 10 insertions(+), 3 deletions(-)

src/codegen/llvm.zig+10-3
...@@ -2435,18 +2435,25 @@ pub const Object = struct {...@@ -2435,18 +2435,25 @@ pub const Object = struct {
2435 .ty = ty.toType(),2435 .ty = ty.toType(),
2436 .val = null_opt_usize.toValue(),2436 .val = null_opt_usize.toValue(),
2437 });2437 });
2438 const llvm_wanted_addrspace = toLlvmAddressSpace(.generic, target);
2439 const llvm_actual_addrspace = toLlvmGlobalAddressSpace(.generic, target);
2438 const global = o.llvm_module.addGlobalInAddressSpace(2440 const global = o.llvm_module.addGlobalInAddressSpace(
2439 llvm_init.typeOf(),2441 llvm_init.typeOf(),
2440 "",2442 "",
2441 toLlvmGlobalAddressSpace(.generic, target),2443 llvm_actual_addrspace,
2442 );2444 );
2443 global.setLinkage(.Internal);2445 global.setLinkage(.Internal);
2444 global.setUnnamedAddr(.True);2446 global.setUnnamedAddr(.True);
2445 global.setAlignment(ty.toType().abiAlignment(mod));2447 global.setAlignment(ty.toType().abiAlignment(mod));
2446 global.setInitializer(llvm_init);2448 global.setInitializer(llvm_init);
24472449
2448 o.null_opt_addr = global;2450 const addrspace_casted_global = if (llvm_wanted_addrspace != llvm_actual_addrspace)
2449 return global;2451 global.constAddrSpaceCast(o.context.pointerType(llvm_wanted_addrspace))
2452 else
2453 global;
2454
2455 o.null_opt_addr = addrspace_casted_global;
2456 return addrspace_casted_global;
2450 }2457 }
24512458
2452 /// If the llvm function does not exist, create it.2459 /// If the llvm function does not exist, create it.