From f817b3b9abd926db6c565ddd5215170361cda3b3 Mon Sep 17 00:00:00 2001 From: gbaraldi Date: Fri, 12 Jul 2024 15:15:23 +0200 Subject: [PATCH 1/2] Make the memory GEP an inbounds GEP since the bounds check has happened somewhere else --- src/cgutils.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cgutils.cpp b/src/cgutils.cpp index 1d285cfaef937..23e467656f5a6 100644 --- a/src/cgutils.cpp +++ b/src/cgutils.cpp @@ -4262,9 +4262,8 @@ static jl_cgval_t emit_memoryref(jl_codectx_t &ctx, const jl_cgval_t &ref, jl_cg ovflw = ctx.builder.CreateICmpUGE(ctx.builder.CreateAdd(offset, mlen), ctx.builder.CreateNUWAdd(mlen, mlen)); } #endif - //Is this change fine boffset = ctx.builder.CreateMul(offset, elsz); - newdata = ctx.builder.CreateGEP(getInt8Ty(ctx.builder.getContext()), data, boffset); + newdata = ctx.builder.CreateInboundsGEP(getInt8Ty(ctx.builder.getContext()), data, boffset); (void)boffset; // LLVM is very bad at handling GEP with types different from the load if (bc) { BasicBlock *failBB, *endBB; From 81b0e99f9e342cfd3103f448aa88020c0b601f89 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Sat, 13 Jul 2024 04:10:43 -0400 Subject: [PATCH 2/2] Update src/cgutils.cpp Co-authored-by: Zentrik --- src/cgutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cgutils.cpp b/src/cgutils.cpp index 23e467656f5a6..56417dfcafeff 100644 --- a/src/cgutils.cpp +++ b/src/cgutils.cpp @@ -4263,7 +4263,7 @@ static jl_cgval_t emit_memoryref(jl_codectx_t &ctx, const jl_cgval_t &ref, jl_cg } #endif boffset = ctx.builder.CreateMul(offset, elsz); - newdata = ctx.builder.CreateInboundsGEP(getInt8Ty(ctx.builder.getContext()), data, boffset); + newdata = ctx.builder.CreateInBoundsGEP(getInt8Ty(ctx.builder.getContext()), data, boffset); (void)boffset; // LLVM is very bad at handling GEP with types different from the load if (bc) { BasicBlock *failBB, *endBB;