[llvm-commits] llvm-gcc aggregate copy

Chris Lattner clattner at apple.com
Tue May 27 22:38:30 PDT 2008


After looking into PR2371, I tried out this C testcase with llvm-gcc  
to see what it is generating:

struct foo { double x[100]; };
void T(struct foo *F, struct foo* G) {
   *F = *G;
}

llvm-gcc currently compiles this into:

define void @T(%struct.foo* %F, %struct.foo* %G) nounwind  {
entry:
	%tmp2 = bitcast %struct.foo* %F to i8*		; <i8*> [#uses=1]
	%tmp13 = bitcast %struct.foo* %G to i8*		; <i8*> [#uses=1]
	tail call void @llvm.memcpy.i32( i8* %tmp2, i8* %tmp13, i32 800, i32  
4 )
	ret void
}

The problem is that F/G can be the same pointer, so using memcpy is  
undefined.  Should llvm-gcc start emitting llvm.memmove calls, or is  
there something with GCC trees that can be improved to know when  
memmove is needed?

-Chirs



More information about the llvm-commits mailing list