[llvm] [SPIR-V] Fix some GEP legalization (PR #150943)

Nathan Gauër via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 29 02:20:17 PDT 2025


================
@@ -33,7 +33,7 @@ define spir_func void @foo(ptr noundef byval(%tprange) align 8 %_arg_UserRange)
   %RoundedRangeKernel = alloca %tprange, align 8
   call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %RoundedRangeKernel)
   call void @llvm.memcpy.p0.p0.i64(ptr align 8 %RoundedRangeKernel, ptr align 8 %_arg_UserRange, i64 16, i1 false)
-  %KernelFunc = getelementptr inbounds i8, ptr %RoundedRangeKernel, i64 16
+  %KernelFunc = getelementptr inbounds i8, ptr %RoundedRangeKernel, i64 8
----------------
Keenuts wrote:

The size of %tprange is 16 bytes. If you do a GEP to +16, you are doing an out-of-bounds access. Because we have a literal index, we'd generate an out-of-bounds OpInBoundsAccessChain
This test is about testing lifetime intrinsics, so seems OK to change the GEP index to something valid.


https://github.com/llvm/llvm-project/pull/150943


More information about the llvm-commits mailing list