summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-07-29 04:46:19 +0000
committerChris Lattner <sabre@nondot.org>2010-07-29 04:46:19 +0000
commit3a44c7e55df3cadfddefda988450fe8e5fe5169e (patch)
tree5455774de0b048fd5f072490f00b88f4642bc75f /clang/test/CodeGen
parent029c0f168112ed0949b7aad8e7cfabc8a0d0059b (diff)
downloadbcm5719-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/CodeGen')
-rw-r--r--clang/test/CodeGen/x86_64-arguments.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/test/CodeGen/x86_64-arguments.c b/clang/test/CodeGen/x86_64-arguments.c
index b4500d6de69..7bff70088a8 100644
--- a/clang/test/CodeGen/x86_64-arguments.c
+++ b/clang/test/CodeGen/x86_64-arguments.c
@@ -159,4 +159,12 @@ v4f32 f25(v4f32 X) {
return X+X;
}
+struct foo26 {
+ int *X;
+ float *Y;
+};
+struct foo26 f26(struct foo26 *P) {
+ // CHECK: define %struct.foo26 @f26(%struct.foo26* %P)
+ return *P;
+}
OpenPOWER on IntegriCloud