Skip to content

Commit

Permalink
bitcast: ensure the target pointer address space is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed May 22, 2024
1 parent 3686743 commit 2f9e739
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,16 @@ static jl_cgval_t generic_bitcast(jl_codectx_t &ctx, ArrayRef<jl_cgval_t> argv)
if (isa<Instruction>(vx) && !vx->hasName())
// emit_inttoptr may undo an PtrToInt
setName(ctx.emission_context, vx, "bitcast_coercion");
} else if (vxt->isPointerTy() && llvmt->isPointerTy()) {
// emit_bitcast preserves the origin address space, which we can't have here
#if JL_LLVM_VERSION >= 170000
vx = ctx.builder.CreateAddrSpaceCast(vx, llvmt);
#else
vx = ctx.builder.CreatePointerBitCastOrAddrSpaceCast(vx, llvmt);
#endif
if (isa<Instruction>(vx) && !vx->hasName())
// cast may have been folded
setName(ctx.emission_context, vx, "bitcast_coercion");
} else {
vx = emit_bitcast(ctx, vx, llvmt);
if (isa<Instruction>(vx) && !vx->hasName())
Expand Down

0 comments on commit 2f9e739

Please sign in to comment.