mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:50:30 +00:00
aa98e229de
Summary: This change is part of step five in the series of changes to remove alignment argument from memcpy/memmove/memset in favour of alignment attributes. In particular, this changes the MemCpyOpt pass to cease using: 1) The old getAlignment() API of MemoryIntrinsic in favour of getting source & dest specific alignments through the new API. 2) The old IRBuilder CreateMemCpy/CreateMemMove single-alignment APIs in favour of the new API that allows setting source and destination alignments independently. We also add a few tests to fill gaps in the testing of this pass. Steps: Step 1) Remove alignment parameter and create alignment parameter attributes for memcpy/memmove/memset. ( rL322965, rC322964, rL322963 ) Step 2) Expand the IRBuilder API to allow creation of memcpy/memmove with differing source and dest alignments. ( rL323597 ) Step 3) Update Clang to use the new IRBuilder API. ( rC323617 ) Step 4) Update Polly to use the new IRBuilder API. ( rL323618 ) Step 5) Update LLVM passes that create memcpy/memmove calls to use the new IRBuilder API, and those that use use MemIntrinsicInst::[get|set]Alignment() to use [get|set]DestAlignment() and [get|set]SourceAlignment() instead. ( rL323886, rL323891, rL324148, rL324273, rL324278, rL324384, rL324395, rL324402, rL324626, rL324642, rL324653, rL324654, rL324773, rL324774, rL324781, rL324784, rL324955, rL324960, rL325816, rL327398, rL327421 ) Step 6) Remove the single-alignment IRBuilder API for memcpy/memmove, and the MemIntrinsicInst::[get|set]Alignment() methods. Reference http://lists.llvm.org/pipermail/llvm-dev/2015-August/089384.html http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/312083.html llvm-svn: 328097
65 lines
2.2 KiB
LLVM
65 lines
2.2 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt -basicaa -scoped-noalias -memcpyopt -S %s | FileCheck %s
|
|
|
|
%T = type { i8, i32 }
|
|
|
|
; Ensure load-store forwarding of an aggregate is interpreted as
|
|
; a memmove when the source and dest may alias
|
|
define void @test_memmove(%T* align 8 %a, %T* align 16 %b) {
|
|
; CHECK-LABEL: @test_memmove(
|
|
; CHECK-NEXT: [[TMP1:%.*]] = bitcast %T* [[B:%.*]] to i8*
|
|
; CHECK-NEXT: [[TMP2:%.*]] = bitcast %T* [[A:%.*]] to i8*
|
|
; CHECK-NEXT: call void @llvm.memmove.p0i8.p0i8.i64(i8* align 16 [[TMP1]], i8* align 8 [[TMP2]], i64 8, i1 false)
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
%val = load %T, %T* %a, align 8
|
|
store %T %val, %T* %b, align 16
|
|
ret void
|
|
}
|
|
|
|
; Ensure load-store forwarding of an aggregate is interpreted as
|
|
; a memcpy when the source and dest do not alias
|
|
define void @test_memcpy(%T* noalias align 8 %a, %T* noalias align 16 %b) {
|
|
; CHECK-LABEL: @test_memcpy(
|
|
; CHECK-NEXT: [[TMP1:%.*]] = bitcast %T* [[B:%.*]] to i8*
|
|
; CHECK-NEXT: [[TMP2:%.*]] = bitcast %T* [[A:%.*]] to i8*
|
|
; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 [[TMP1]], i8* align 8 [[TMP2]], i64 8, i1 false)
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
%val = load %T, %T* %a, align 8
|
|
store %T %val, %T* %b, align 16
|
|
ret void
|
|
}
|
|
|
|
; memcpy(%d, %a) should not be generated since store2 may-aliases load %a.
|
|
define void @f(%T* %a, %T* %b, %T* %c, %T* %d) {
|
|
; CHECK-LABEL: @f(
|
|
; CHECK-NEXT: [[VAL:%.*]] = load %T, %T* %a, !alias.scope !0
|
|
; CHECK-NEXT: store %T { i8 23, i32 23 }, %T* %b, !alias.scope !3
|
|
; CHECK-NEXT: store %T { i8 44, i32 44 }, %T* %c, !alias.scope !6, !noalias !3
|
|
; CHECK-NEXT: store %T [[VAL]], %T* %d, !alias.scope !9, !noalias !12
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
%val = load %T, %T* %a, !alias.scope !{!10}
|
|
|
|
; store1 may-aliases the load
|
|
store %T { i8 23, i32 23 }, %T* %b, !alias.scope !{!11}
|
|
|
|
; store2 may-aliases the load and store3
|
|
store %T { i8 44, i32 44 }, %T* %c, !alias.scope !{!12}, !noalias !{!11}
|
|
|
|
; store3
|
|
store %T %val, %T* %d, !alias.scope !{!13}, !noalias !{!10, !11}
|
|
ret void
|
|
}
|
|
|
|
!0 = !{!0}
|
|
!1 = !{!1}
|
|
!2 = !{!2}
|
|
!3 = !{!3}
|
|
|
|
!10 = !{ !10, !0 }
|
|
!11 = !{ !11, !1 }
|
|
!12 = !{ !12, !2 }
|
|
!13 = !{ !13, !3 }
|