summaryrefslogtreecommitdiffstats
path: root/llvm/test/Bitcode
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2015-11-18 22:17:24 +0000
committerPete Cooper <peter_cooper@apple.com>2015-11-18 22:17:24 +0000
commit72bc23ef02bad3873d3572b2be529404a461d449 (patch)
treef1a47c225592be2aa94fdcaf411d1d5f51a7c193 /llvm/test/Bitcode
parentb035bd03e4db325de2380ea9263e10de5b9be3b6 (diff)
downloadbcm5719-llvm-72bc23ef02bad3873d3572b2be529404a461d449.tar.gz
bcm5719-llvm-72bc23ef02bad3873d3572b2be529404a461d449.zip
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. llvm-svn: 253511
Diffstat (limited to 'llvm/test/Bitcode')
-rw-r--r--llvm/test/Bitcode/memintrinsics.3.7.ll33
-rw-r--r--llvm/test/Bitcode/memintrinsics.3.7.ll.bcbin0 -> 916 bytes
-rw-r--r--llvm/test/Bitcode/standardCIntrinsic.3.2.ll7
3 files changed, 36 insertions, 4 deletions
diff --git a/llvm/test/Bitcode/memintrinsics.3.7.ll b/llvm/test/Bitcode/memintrinsics.3.7.ll
new file mode 100644
index 00000000000..242aad6dec9
--- /dev/null
+++ b/llvm/test/Bitcode/memintrinsics.3.7.ll
@@ -0,0 +1,33 @@
+; RUN: llvm-dis < %s.bc| FileCheck %s
+
+; memintrinsics.3.7.ll.bc was generated by passing this file to llvm-as-3.7.
+; The test checks that LLVM does not misread memcpy/memmove/memset intrinsic functions
+; of older bitcode files.
+
+define void @memcpyintrinsic(i8* %dest, i8* %src, i32 %len) {
+entry:
+
+; CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 %len, i1 true)
+ call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i32 4, i1 true)
+ ret void
+}
+
+define void @memmoveintrinsic(i8* %dest, i8* %src, i32 %len) {
+entry:
+
+; CHECK: call void @llvm.memmove.p0i8.p0i8.i32(i8* align 8 %dest, i8* align 8 %src, i32 %len, i1 true)
+ call void @llvm.memmove.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i32 8, i1 true)
+ ret void
+}
+
+define void @memsetintrinsic(i8* %dest, i8* %src, i32 %len) {
+entry:
+
+; CHECK: call void @llvm.memset.p0i8.i32(i8* align 16 %dest, i8 0, i32 %len, i1 true)
+ call void @llvm.memset.p0i8.i32(i8* %dest, i8 0, i32 %len, i32 16, i1 true)
+ ret void
+}
+
+declare void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i32 %align, i1 %isvolatile)
+declare void @llvm.memmove.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i32 %align, i1 %isvolatile)
+declare void @llvm.memset.p0i8.i32(i8* %dest, i8 %src, i32 %len, i32 %align, i1 %isvolatile) \ No newline at end of file
diff --git a/llvm/test/Bitcode/memintrinsics.3.7.ll.bc b/llvm/test/Bitcode/memintrinsics.3.7.ll.bc
new file mode 100644
index 00000000000..187ef044db8
--- /dev/null
+++ b/llvm/test/Bitcode/memintrinsics.3.7.ll.bc
Binary files differ
diff --git a/llvm/test/Bitcode/standardCIntrinsic.3.2.ll b/llvm/test/Bitcode/standardCIntrinsic.3.2.ll
index 09f2378a221..69aed13b9f6 100644
--- a/llvm/test/Bitcode/standardCIntrinsic.3.2.ll
+++ b/llvm/test/Bitcode/standardCIntrinsic.3.2.ll
@@ -7,10 +7,9 @@
define void @memcpyintrinsic(i8* %dest, i8* %src, i32 %len) {
entry:
-; CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i32 1, i1 true)
- call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i32 1, i1 true)
-
+; CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %dest, i8* align 1 %src, i32 %len, i1 true)
+ call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i1 true)
ret void
}
-declare void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i32 %align, i1 %isvolatile) \ No newline at end of file
+declare void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i1 %isvolatile) \ No newline at end of file
OpenPOWER on IntegriCloud