CallInst *CI = Builder.CreateCall(F, Args);
CI->setTailCall();
CI->setCallingConv(F->getCallingConv());
+ CI->setAttributes(F->getAttributes());
if (NewG->getReturnType()->isVoidTy()) {
Builder.CreateRetVoid();
} else {
--- /dev/null
+; RUN: opt -S -mergefunc < %s | FileCheck %s
+%Si = type <{ i32 }>
+
+define void @sum(%Si* noalias sret %a, i32 %x, i32 %y) {
+ %sum = add i32 %x, %y
+ %sum2 = add i32 %sum, %y
+ %sum3 = add i32 %sum2, %y
+ ret void
+}
+
+define void @add(%Si* noalias sret %a, i32 %x, i32 %y) {
+ %sum = add i32 %x, %y
+ %sum2 = add i32 %sum, %y
+ %sum3 = add i32 %sum2, %y
+ ret void
+}
+
+; Make sure we transfer the parameter attributes to the call site.
+
+; CHECK-LABEL: define void @sum(%Si* noalias sret, i32, i32)
+; CHECK: tail call void @add(%Si* noalias sret %{{.*}}, i32 %{{.*}}, i32 %{{.*}})
+; CHECK: ret void
bb:
; CHECK-LABEL: @func35(
; CHECK: %[[V2:.+]] = bitcast %.qux.2585 addrspace(1)* %{{.*}} to %.qux.2496 addrspace(1)*
-; CHECK: %[[V3:.+]] = tail call i32 @func10(%.qux.2496 addrspace(1)* %[[V2]])
+; CHECK: %[[V3:.+]] = tail call i32 @func10(%.qux.2496 addrspace(1)* nocapture %[[V2]])
; CHECK: %{{.*}} = inttoptr i32 %[[V3]] to i8*
%tmp = getelementptr inbounds %.qux.2585, %.qux.2585 addrspace(1)* %this, i32 0, i32 2
%tmp1 = load i8*, i8* addrspace(1)* %tmp, align 4
bb:
; CHECK-LABEL: @func35(
; CHECK: %[[V2:.+]] = bitcast %.qux.2585* %{{.*}} to %.qux.2496*
-; CHECK: %[[V3:.+]] = tail call i32 @func10(%.qux.2496* %[[V2]])
+; CHECK: %[[V3:.+]] = tail call i32 @func10(%.qux.2496* nocapture %[[V2]])
; CHECK: %{{.*}} = inttoptr i32 %[[V3]] to i8*
%tmp = getelementptr inbounds %.qux.2585, %.qux.2585* %this, i32 0, i32 2
%tmp1 = load i8*, i8** %tmp, align 4