ArgumentPromotion: Drop sret attribute on functions that are only called directly.
[oota-llvm.git] / test / Transforms / ArgumentPromotion / sret.ll
1 ; RUN: opt < %s -argpromotion -S | FileCheck %s
2
3 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-pc-windows-msvc"
5
6 ; CHECK: define internal void @add(i32 %[[THIS1:.*]], i32 %[[THIS2:.*]], i32* noalias %[[SR:.*]])
7 define internal void @add({i32, i32}* %this, i32* sret %r) {
8   %ap = getelementptr {i32, i32}, {i32, i32}* %this, i32 0, i32 0
9   %bp = getelementptr {i32, i32}, {i32, i32}* %this, i32 0, i32 1
10   %a = load i32, i32* %ap
11   %b = load i32, i32* %bp
12   ; CHECK: %[[AB:.*]] = add i32 %[[THIS1]], %[[THIS2]]
13   %ab = add i32 %a, %b
14   ; CHECK: store i32 %[[AB]], i32* %[[SR]]
15   store i32 %ab, i32* %r
16   ret void
17 }
18
19 ; CHECK: define void @f()
20 define void @f() {
21   ; CHECK: %[[R:.*]] = alloca i32
22   %r = alloca i32
23   %pair = alloca {i32, i32}
24
25   ; CHECK: call void @add(i32 %{{.*}}, i32 %{{.*}}, i32* noalias %[[R]])
26   call void @add({i32, i32}* %pair, i32* sret %r)
27   ret void
28 }