Skip to content

Commit 6f4c075

Browse files
committed
[NVPTX] Allow MemTransferInst in adjustByValArgAlignment (#112462)
Before b7b28e7, AreSupportedUsers will skip MemTransferInst, it may cause unexpected assertion. https://godbolt.org/z/z5d691fj1 In b7b28e7, we start to allow MemTransferInst, we should allow it in adjustByValArgAlignment too. (cherry picked from commit 0bbdc76)
1 parent a9e8cf6 commit 6f4c075

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,9 @@ static void adjustByValArgAlignment(Argument *Arg, Value *ArgInParamAS,
435435
continue;
436436
}
437437

438+
if (isa<MemTransferInst>(CurUser))
439+
continue;
440+
438441
// supported for grid_constant
439442
if (IsGridConstant &&
440443
(isa<CallInst>(CurUser) || isa<StoreInst>(CurUser) ||

llvm/test/CodeGen/NVPTX/lower-byval-args.ll

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,22 @@ entry:
225225
ret void
226226
}
227227

228+
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite)
229+
define dso_local void @memcpy_from_param_noalign (ptr nocapture noundef writeonly %out, ptr nocapture noundef readonly byval(%struct.S) %s) local_unnamed_addr #0 {
230+
; COMMON-LABEL: define dso_local void @memcpy_from_param_noalign(
231+
; COMMON-SAME: ptr nocapture noundef writeonly [[OUT:%.*]], ptr nocapture noundef readonly byval([[STRUCT_S:%.*]]) align 4 [[S:%.*]]) local_unnamed_addr #[[ATTR0]] {
232+
; COMMON-NEXT: [[ENTRY:.*:]]
233+
; COMMON-NEXT: [[S3:%.*]] = addrspacecast ptr [[S]] to ptr addrspace(101)
234+
; COMMON-NEXT: [[OUT1:%.*]] = addrspacecast ptr [[OUT]] to ptr addrspace(1)
235+
; COMMON-NEXT: [[OUT2:%.*]] = addrspacecast ptr addrspace(1) [[OUT1]] to ptr
236+
; COMMON-NEXT: call void @llvm.memcpy.p0.p101.i64(ptr [[OUT2]], ptr addrspace(101) [[S3]], i64 16, i1 true)
237+
; COMMON-NEXT: ret void
238+
;
239+
entry:
240+
tail call void @llvm.memcpy.p0.p0.i64(ptr %out, ptr %s, i64 16, i1 true)
241+
ret void
242+
}
243+
228244
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite)
229245
define dso_local void @memcpy_to_param(ptr nocapture noundef readonly %in, ptr nocapture noundef readnone byval(%struct.S) align 4 %s) local_unnamed_addr #0 {
230246
; COMMON-LABEL: define dso_local void @memcpy_to_param(
@@ -442,7 +458,7 @@ attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite
442458
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
443459

444460
!llvm.module.flags = !{!0, !1, !2, !3}
445-
!nvvm.annotations = !{!4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19}
461+
!nvvm.annotations = !{!4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !23}
446462
!llvm.ident = !{!20, !21}
447463

448464
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 11, i32 8]}
@@ -467,3 +483,4 @@ attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
467483
!19 = !{ptr @test_select_write, !"kernel", i32 1}
468484
!20 = !{!"clang version 20.0.0git"}
469485
!21 = !{!"clang version 3.8.0 (tags/RELEASE_380/final)"}
486+
!23 = !{ptr @memcpy_from_param_noalign, !"kernel", i32 1}

0 commit comments

Comments
 (0)