xref: /llvm-project/llvm/test/Transforms/ArgumentPromotion/sret.ll (revision bcbc6151640f53e9d78392c66de9760c664d8b1d)
1c0cfdd32SJohannes Doerfert; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
2cee313d2SEric Christopher; RUN: opt < %s -passes=argpromotion -S | FileCheck %s
3cee313d2SEric Christopher
4cee313d2SEric Christophertarget datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
5cee313d2SEric Christophertarget triple = "x86_64-pc-windows-msvc"
6cee313d2SEric Christopher
7*bcbc6151SNikita Popovdefine internal void @add(ptr %this, ptr sret(i32) %r) {
8c0cfdd32SJohannes Doerfert; CHECK-LABEL: define {{[^@]+}}@add
9*bcbc6151SNikita Popov; CHECK-SAME: (i32 [[THIS_0_VAL:%.*]], i32 [[THIS_4_VAL:%.*]], ptr noalias [[R:%.*]]) {
10a2ce8df4SValery Pykhtin; CHECK-NEXT:    [[AB:%.*]] = add i32 [[THIS_0_VAL]], [[THIS_4_VAL]]
11*bcbc6151SNikita Popov; CHECK-NEXT:    store i32 [[AB]], ptr [[R]], align 4
12c0cfdd32SJohannes Doerfert; CHECK-NEXT:    ret void
13c0cfdd32SJohannes Doerfert;
14*bcbc6151SNikita Popov  %ap = getelementptr {i32, i32}, ptr %this, i32 0, i32 0
15*bcbc6151SNikita Popov  %bp = getelementptr {i32, i32}, ptr %this, i32 0, i32 1
16*bcbc6151SNikita Popov  %a = load i32, ptr %ap
17*bcbc6151SNikita Popov  %b = load i32, ptr %bp
18cee313d2SEric Christopher  %ab = add i32 %a, %b
19*bcbc6151SNikita Popov  store i32 %ab, ptr %r
20cee313d2SEric Christopher  ret void
21cee313d2SEric Christopher}
22cee313d2SEric Christopher
23cee313d2SEric Christopherdefine void @f() {
24a2ce8df4SValery Pykhtin; CHECK-LABEL: define {{[^@]+}}@f() {
25a2ce8df4SValery Pykhtin; CHECK-NEXT:    [[R:%.*]] = alloca i32, align 4
26a2ce8df4SValery Pykhtin; CHECK-NEXT:    [[PAIR:%.*]] = alloca { i32, i32 }, align 8
27*bcbc6151SNikita Popov; CHECK-NEXT:    [[PAIR_VAL:%.*]] = load i32, ptr [[PAIR]], align 4
28*bcbc6151SNikita Popov; CHECK-NEXT:    [[TMP1:%.*]] = getelementptr i8, ptr [[PAIR]], i64 4
29*bcbc6151SNikita Popov; CHECK-NEXT:    [[PAIR_VAL1:%.*]] = load i32, ptr [[TMP1]], align 4
30*bcbc6151SNikita Popov; CHECK-NEXT:    call void @add(i32 [[PAIR_VAL]], i32 [[PAIR_VAL1]], ptr noalias [[R]])
31c0cfdd32SJohannes Doerfert; CHECK-NEXT:    ret void
32c0cfdd32SJohannes Doerfert;
33cee313d2SEric Christopher  %r = alloca i32
34cee313d2SEric Christopher  %pair = alloca {i32, i32}
35cee313d2SEric Christopher
36*bcbc6151SNikita Popov  call void @add(ptr %pair, ptr sret(i32) %r)
37cee313d2SEric Christopher  ret void
38cee313d2SEric Christopher}
39