[llvm-commits] [llvm] r43270 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp test/CodeGen/PowerPC/2007-10-23-UnalignedMemcpy.ll

Bill Wendling isanbard at gmail.com
Tue Oct 23 16:32:42 PDT 2007


Author: void
Date: Tue Oct 23 18:32:40 2007
New Revision: 43270

URL: http://llvm.org/viewvc/llvm-project?rev=43270&view=rev
Log:
If there's an unaligned memcpy to/from the stack, don't lower it. Just call the
memcpy library function instead.

Added:
    llvm/trunk/test/CodeGen/PowerPC/2007-10-23-UnalignedMemcpy.ll
Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=43270&r1=43269&r2=43270&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Tue Oct 23 18:32:40 2007
@@ -4329,6 +4329,19 @@
           }
         }
 
+        // Check to see if there is an unaligned memcpy from/onto the stack. If
+        // so, then ignore it for the present.
+        if (Op1.getOpcode() == ISD::FrameIndex ||
+            Op2.getOpcode() == ISD::FrameIndex) {
+          unsigned TotalSize = 0;
+
+          for (unsigned i = 0; i < NumMemOps; i++)
+            TotalSize += MVT::getSizeInBits(MemOps[i]) / 8;
+
+          if (TotalSize % Align != 0)
+            break;
+        }
+
         for (unsigned i = 0; i < NumMemOps; i++) {
           MVT::ValueType VT = MemOps[i];
           unsigned VTSize = MVT::getSizeInBits(VT) / 8;

Added: llvm/trunk/test/CodeGen/PowerPC/2007-10-23-UnalignedMemcpy.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/2007-10-23-UnalignedMemcpy.ll?rev=43270&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/2007-10-23-UnalignedMemcpy.ll (added)
+++ llvm/trunk/test/CodeGen/PowerPC/2007-10-23-UnalignedMemcpy.ll Tue Oct 23 18:32:40 2007
@@ -0,0 +1,13 @@
+; RUN: llvm-as < %s | llc -mtriple=powerpc64-apple-darwin9 -o - | grep memcpy
+
+ at C.0.1173 = external constant [33 x i8]         ; <[33 x i8]*> [#uses=1]
+
+define void @Bork() {
+entry:
+        %Qux = alloca [33 x i8]         ; <[33 x i8]*> [#uses=1]
+        %Qux1 = bitcast [33 x i8]* %Qux to i8*          ; <i8*> [#uses=1]
+        call void @llvm.memcpy.i64( i8* %Qux1, i8* getelementptr ([33 x i8]* @C.0.1173, i32 0, i32 0), i64 33, i32 8 )
+        ret void
+}
+
+declare void @llvm.memcpy.i64(i8*, i8*, i64, i32)





More information about the llvm-commits mailing list