diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-07-29 04:46:19 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-07-29 04:46:19 +0000 |
| commit | 3a44c7e55df3cadfddefda988450fe8e5fe5169e (patch) | |
| tree | 5455774de0b048fd5f072490f00b88f4642bc75f /clang/test/CodeGenObjC | |
| parent | 029c0f168112ed0949b7aad8e7cfabc8a0d0059b (diff) | |
| download | bcm5719-llvm-3a44c7e55df3cadfddefda988450fe8e5fe5169e.tar.gz bcm5719-llvm-3a44c7e55df3cadfddefda988450fe8e5fe5169e.zip | |
now that we have CGT around, we can start using preferred types
for return values too. Instead of compiling something like:
struct foo {
int *X;
float *Y;
};
struct foo test(struct foo *P) { return *P; }
to:
%1 = type { i64, i64 }
define %1 @test(%struct.foo* %P) nounwind {
entry:
%retval = alloca %struct.foo, align 8 ; <%struct.foo*> [#uses=2]
%P.addr = alloca %struct.foo*, align 8 ; <%struct.foo**> [#uses=2]
store %struct.foo* %P, %struct.foo** %P.addr
%tmp = load %struct.foo** %P.addr ; <%struct.foo*> [#uses=1]
%tmp1 = bitcast %struct.foo* %retval to i8* ; <i8*> [#uses=1]
%tmp2 = bitcast %struct.foo* %tmp to i8* ; <i8*> [#uses=1]
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp1, i8* %tmp2, i64 16, i32 8, i1 false)
%0 = bitcast %struct.foo* %retval to %1* ; <%1*> [#uses=1]
%1 = load %1* %0, align 1 ; <%1> [#uses=1]
ret %1 %1
}
We now get the result more type safe, with:
define %struct.foo @test(%struct.foo* %P) nounwind {
entry:
%retval = alloca %struct.foo, align 8 ; <%struct.foo*> [#uses=2]
%P.addr = alloca %struct.foo*, align 8 ; <%struct.foo**> [#uses=2]
store %struct.foo* %P, %struct.foo** %P.addr
%tmp = load %struct.foo** %P.addr ; <%struct.foo*> [#uses=1]
%tmp1 = bitcast %struct.foo* %retval to i8* ; <i8*> [#uses=1]
%tmp2 = bitcast %struct.foo* %tmp to i8* ; <i8*> [#uses=1]
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp1, i8* %tmp2, i64 16, i32 8, i1 false)
%0 = load %struct.foo* %retval ; <%struct.foo> [#uses=1]
ret %struct.foo %0
}
That memcpy is completely terrible, but I don't know how to fix it.
llvm-svn: 109729
Diffstat (limited to 'clang/test/CodeGenObjC')
| -rw-r--r-- | clang/test/CodeGenObjC/x86_64-struct-return-gc.m | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/test/CodeGenObjC/x86_64-struct-return-gc.m b/clang/test/CodeGenObjC/x86_64-struct-return-gc.m index c62a33f2d16..8022d5903ec 100644 --- a/clang/test/CodeGenObjC/x86_64-struct-return-gc.m +++ b/clang/test/CodeGenObjC/x86_64-struct-return-gc.m @@ -9,7 +9,7 @@ struct Coerce coerce_func(void); void Coerce_test(void) { struct Coerce c; - // CHECK: call i64 @coerce_func + // CHECK: call i8* @coerce_func // CHECK: call i8* @objc_memmove_collectable( c = coerce_func(); } |

