diff options
author | Pete Cooper <peter_cooper@apple.com> | 2015-11-18 22:17:24 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2015-11-18 22:17:24 +0000 |
commit | 8b170f7f290843dc3849eaa75b6f74a87a7a2de6 (patch) | |
tree | 698943dc126191d3c6399f9ee17050d56d3aea6b /test/Transforms/ObjCARC | |
parent | c4bfc2d61dff2bb6b904d12b756f5b2ebda4ea35 (diff) |
Change memcpy/memset/memmove to have dest and source alignments.
Note, this was reviewed (and more details are in) http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/312083.html
These intrinsics currently have an explicit alignment argument which is
required to be a constant integer. It represents the alignment of the
source and dest, and so must be the minimum of those.
This change allows source and dest to each have their own alignments
by using the alignment attribute on their arguments. The alignment
argument itself is removed.
There are a few places in the code for which the code needs to be
checked by an expert as to whether using only src/dest alignment is
safe. For those places, they currently take the minimum of src/dest
alignments which matches the current behaviour.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 500, i32 8, i1 false)
will now read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %dest, i8* align 8 %src, i32 500, i1 false)
For out of tree owners, I was able to strip alignment from calls using sed by replacing:
(call.*llvm\.memset.*)i32\ [0-9]*\,\ i1 false\)
with:
$1i1 false)
and similarly for memmove and memcpy.
I then added back in alignment to test cases which needed it.
A similar commit will be made to clang which actually has many differences in alignment as now
IRBuilder can generate different source/dest alignments on calls.
In IRBuilder itself, a new argument was added. Instead of calling:
CreateMemCpy(Dst, Src, getInt64(Size), DstAlign, /* isVolatile */ false)
you now call
CreateMemCpy(Dst, Src, getInt64(Size), DstAlign, SrcAlign, /* isVolatile */ false)
There is a temporary class (IntegerAlignment) which takes the source alignment and rejects
implicit conversion from bool. This is to prevent isVolatile here from passing its default
parameter to the source alignment.
Note, changes in future can now be made to codegen. I didn't change anything here, but this
change should enable better memcpy code sequences.
Reviewed by Hal Finkel.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253511 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/ObjCARC')
-rw-r--r-- | test/Transforms/ObjCARC/nested.ll | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/test/Transforms/ObjCARC/nested.ll b/test/Transforms/ObjCARC/nested.ll index cf14a1f9a66..589300c3586 100644 --- a/test/Transforms/ObjCARC/nested.ll +++ b/test/Transforms/ObjCARC/nested.ll @@ -12,7 +12,7 @@ declare i8* @returner() declare i8* @objc_retainAutoreleasedReturnValue(i8*) declare i8* @objc_retain(i8*) declare void @objc_enumerationMutation(i8*) -declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind +declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) nounwind declare i8* @objc_msgSend(i8*, i8*, ...) nonlazybind declare void @use(i8*) declare void @objc_release(i8*) @@ -35,7 +35,7 @@ entry: %items.ptr = alloca [16 x i8*], align 8 %0 = call i8* @objc_retain(i8* %a) nounwind %tmp = bitcast %struct.__objcFastEnumerationState* %state.ptr to i8* - call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i32 8, i1 false) + call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i1 false) %1 = call i8* @objc_retain(i8* %0) nounwind %tmp2 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8 %call = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, %struct.__objcFastEnumerationState*, [16 x i8*]*, i64)*)(i8* %1, i8* %tmp2, %struct.__objcFastEnumerationState* %state.ptr, [16 x i8*]* %items.ptr, i64 16) @@ -100,7 +100,7 @@ entry: %call = call i8* @returner() %0 = call i8* @objc_retainAutoreleasedReturnValue(i8* %call) nounwind %tmp = bitcast %struct.__objcFastEnumerationState* %state.ptr to i8* - call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i32 8, i1 false) + call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i1 false) %1 = call i8* @objc_retain(i8* %0) nounwind %tmp2 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8 %call3 = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, %struct.__objcFastEnumerationState*, [16 x i8*]*, i64)*)(i8* %1, i8* %tmp2, %struct.__objcFastEnumerationState* %state.ptr, [16 x i8*]* %items.ptr, i64 16) @@ -165,7 +165,7 @@ entry: %tmp = load i8*, i8** @g, align 8 %0 = call i8* @objc_retain(i8* %tmp) nounwind %tmp2 = bitcast %struct.__objcFastEnumerationState* %state.ptr to i8* - call void @llvm.memset.p0i8.i64(i8* %tmp2, i8 0, i64 64, i32 8, i1 false) + call void @llvm.memset.p0i8.i64(i8* %tmp2, i8 0, i64 64, i1 false) %1 = call i8* @objc_retain(i8* %0) nounwind %tmp4 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8 %call = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, %struct.__objcFastEnumerationState*, [16 x i8*]*, i64)*)(i8* %1, i8* %tmp4, %struct.__objcFastEnumerationState* %state.ptr, [16 x i8*]* %items.ptr, i64 16) @@ -230,7 +230,7 @@ entry: %call = call i8* @returner() %0 = call i8* @objc_retainAutoreleasedReturnValue(i8* %call) nounwind %tmp = bitcast %struct.__objcFastEnumerationState* %state.ptr to i8* - call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i32 8, i1 false) + call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i1 false) %1 = call i8* @objc_retain(i8* %0) nounwind %tmp2 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8 %call3 = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, %struct.__objcFastEnumerationState*, [16 x i8*]*, i64)*)(i8* %1, i8* %tmp2, %struct.__objcFastEnumerationState* %state.ptr, [16 x i8*]* %items.ptr, i64 16) @@ -296,7 +296,7 @@ entry: %call = call i8* @returner() %0 = call i8* @objc_retainAutoreleasedReturnValue(i8* %call) nounwind %tmp = bitcast %struct.__objcFastEnumerationState* %state.ptr to i8* - call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i32 8, i1 false) + call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i1 false) %1 = call i8* @objc_retain(i8* %0) nounwind %tmp2 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8 %call3 = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, %struct.__objcFastEnumerationState*, [16 x i8*]*, i64)*)(i8* %1, i8* %tmp2, %struct.__objcFastEnumerationState* %state.ptr, [16 x i8*]* %items.ptr, i64 16) @@ -365,7 +365,7 @@ entry: %0 = call i8* @objc_retainAutoreleasedReturnValue(i8* %call) nounwind call void @callee() %tmp = bitcast %struct.__objcFastEnumerationState* %state.ptr to i8* - call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i32 8, i1 false) + call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i1 false) %1 = call i8* @objc_retain(i8* %0) nounwind %tmp2 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8 %call3 = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, %struct.__objcFastEnumerationState*, [16 x i8*]*, i64)*)(i8* %1, i8* %tmp2, %struct.__objcFastEnumerationState* %state.ptr, [16 x i8*]* %items.ptr, i64 16) @@ -431,7 +431,7 @@ entry: %call = call i8* @returner() %0 = call i8* @objc_retainAutoreleasedReturnValue(i8* %call) nounwind %tmp = bitcast %struct.__objcFastEnumerationState* %state.ptr to i8* - call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i32 8, i1 false) + call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i1 false) %1 = call i8* @objc_retain(i8* %0) nounwind %tmp2 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8 %call3 = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, %struct.__objcFastEnumerationState*, [16 x i8*]*, i64)*)(i8* %1, i8* %tmp2, %struct.__objcFastEnumerationState* %state.ptr, [16 x i8*]* %items.ptr, i64 16) @@ -508,7 +508,7 @@ entry: %call1 = call i8* @returner() %1 = call i8* @objc_retainAutoreleasedReturnValue(i8* %call1) nounwind %tmp = bitcast %struct.__objcFastEnumerationState* %state.ptr to i8* - call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i32 8, i1 false) + call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i1 false) %2 = call i8* @objc_retain(i8* %0) nounwind %tmp3 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8 %call4 = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, %struct.__objcFastEnumerationState*, [16 x i8*]*, i64)*)(i8* %2, i8* %tmp3, %struct.__objcFastEnumerationState* %state.ptr, [16 x i8*]* %items.ptr, i64 16) @@ -575,7 +575,7 @@ entry: %call1 = call i8* @returner() %1 = call i8* @objc_retainAutoreleasedReturnValue(i8* %call1) nounwind %tmp = bitcast %struct.__objcFastEnumerationState* %state.ptr to i8* - call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i32 8, i1 false) + call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i1 false) %2 = call i8* @objc_retain(i8* %0) nounwind %tmp3 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8 %call4 = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, %struct.__objcFastEnumerationState*, [16 x i8*]*, i64)*)(i8* %2, i8* %tmp3, %struct.__objcFastEnumerationState* %state.ptr, [16 x i8*]* %items.ptr, i64 16) @@ -642,7 +642,7 @@ entry: %1 = call i8* @objc_retainAutoreleasedReturnValue(i8* %call1) nounwind call void @callee() %tmp = bitcast %struct.__objcFastEnumerationState* %state.ptr to i8* - call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i32 8, i1 false) + call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i1 false) %2 = call i8* @objc_retain(i8* %0) nounwind %tmp3 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8 %call4 = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, %struct.__objcFastEnumerationState*, [16 x i8*]*, i64)*)(i8* %2, i8* %tmp3, %struct.__objcFastEnumerationState* %state.ptr, [16 x i8*]* %items.ptr, i64 16) @@ -710,7 +710,7 @@ entry: %1 = call i8* @objc_retainAutoreleasedReturnValue(i8* %call1) nounwind call void @callee() %tmp = bitcast %struct.__objcFastEnumerationState* %state.ptr to i8* - call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i32 8, i1 false) + call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 64, i1 false) %2 = call i8* @objc_retain(i8* %0) nounwind %tmp3 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8 %call4 = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, %struct.__objcFastEnumerationState*, [16 x i8*]*, i64)*)(i8* %2, i8* %tmp3, %struct.__objcFastEnumerationState* %state.ptr, [16 x i8*]* %items.ptr, i64 16) |