IR: Add 'distinct' MDNodes to bitcode and assembly
[oota-llvm.git] / test / Transforms / Inline / byval.ll
index da0beab9dc7a762edac46e171bb5b365c98fc432..d7597adaf84f8b25a4d74e84d7b48842d1739b54 100644 (file)
@@ -26,7 +26,8 @@ entry:
        call void @f( %struct.ss* byval  %S ) nounwind 
        ret i32 0
 ; CHECK: @test1()
-; CHECK: %b = alloca %struct.ss
+; CHECK: %S1 = alloca %struct.ss
+; CHECK: %S = alloca %struct.ss
 ; CHECK: call void @llvm.memcpy
 ; CHECK: ret i32 0
 }
@@ -74,9 +75,55 @@ entry:
        call void @f3( %struct.ss* byval align 64 %S) nounwind 
        ret void
 ; CHECK: @test3()
-; CHECK: %b = alloca %struct.ss, align 64
+; CHECK: %S1 = alloca %struct.ss, align 64
 ; CHECK: %S = alloca %struct.ss
 ; CHECK: call void @llvm.memcpy
-; CHECK: call void @g3(%struct.ss* %b)
+; CHECK: call void @g3(%struct.ss* %S1)
 ; CHECK: ret void
 }
+
+
+; Inlining a byval struct should NOT cause an explicit copy 
+; into an alloca if the function is readonly, but should increase an alloca's
+; alignment to satisfy an explicit alignment request.
+
+define internal i32 @f4(%struct.ss* byval align 64 %b) nounwind readonly {
+        call void @g3(%struct.ss* %b)
+       ret i32 4
+}
+
+define i32 @test4() nounwind  {
+entry:
+       %S = alloca %struct.ss, align 2         ; <%struct.ss*> [#uses=4]
+       %X = call i32 @f4( %struct.ss* byval align 64 %S ) nounwind 
+       ret i32 %X
+; CHECK: @test4()
+; CHECK: %S = alloca %struct.ss, align 64
+; CHECK-NOT: call void @llvm.memcpy
+; CHECK: call void @g3
+; CHECK: ret i32 4
+}
+
+%struct.S0 = type { i32 }
+
+@b = global %struct.S0 { i32 1 }, align 4
+@a = common global i32 0, align 4
+
+define internal void @f5(%struct.S0* byval nocapture readonly align 4 %p) {
+entry:
+       store i32 0, i32* getelementptr inbounds (%struct.S0* @b, i64 0, i32 0), align 4
+       %f2 = getelementptr inbounds %struct.S0* %p, i64 0, i32 0
+       %0 = load i32* %f2, align 4
+       store i32 %0, i32* @a, align 4
+       ret void
+}
+
+define i32 @test5() {
+entry:
+       tail call void @f5(%struct.S0* byval align 4 @b)
+       %0 = load i32* @a, align 4
+       ret i32 %0
+; CHECK: @test5()
+; CHECK: store i32 0, i32* getelementptr inbounds (%struct.S0* @b, i64 0, i32 0), align 4
+; CHECK-NOT: load i32* getelementptr inbounds (%struct.S0* @b, i64 0, i32 0), align 4
+}