1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
5 ; FIXME: The GEP + BC + GEP solution we create is not great but correct.
7 declare void @use(ptr nocapture readonly %arg)
9 define void @caller() {
10 ; TUNIT-LABEL: define {{[^@]+}}@caller() {
12 ; TUNIT-NEXT: [[LEFT:%.*]] = alloca [3 x i32], align 4
13 ; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr [[LEFT]], align 4
14 ; TUNIT-NEXT: [[LEFT_B4:%.*]] = getelementptr i8, ptr [[LEFT]], i64 4
15 ; TUNIT-NEXT: [[TMP1:%.*]] = load i32, ptr [[LEFT_B4]], align 4
16 ; TUNIT-NEXT: [[LEFT_B8:%.*]] = getelementptr i8, ptr [[LEFT]], i64 8
17 ; TUNIT-NEXT: [[TMP2:%.*]] = load i32, ptr [[LEFT_B8]], align 4
18 ; TUNIT-NEXT: call void @callee(i32 [[TMP0]], i32 [[TMP1]], i32 [[TMP2]])
19 ; TUNIT-NEXT: ret void
21 ; CGSCC-LABEL: define {{[^@]+}}@caller() {
23 ; CGSCC-NEXT: call void @callee(i32 undef, i32 undef, i32 undef)
24 ; CGSCC-NEXT: ret void
27 %left = alloca [3 x i32], align 4
28 call void @callee(ptr %left)
32 define internal void @callee(ptr noalias %arg) {
33 ; CHECK: Function Attrs: memory(readwrite, argmem: none)
34 ; CHECK-LABEL: define {{[^@]+}}@callee
35 ; CHECK-SAME: (i32 [[TMP0:%.*]], i32 [[TMP1:%.*]], i32 [[TMP2:%.*]]) #[[ATTR0:[0-9]+]] {
37 ; CHECK-NEXT: [[ARG_PRIV:%.*]] = alloca [3 x i32], align 4
38 ; CHECK-NEXT: store i32 [[TMP0]], ptr [[ARG_PRIV]], align 4
39 ; CHECK-NEXT: [[ARG_PRIV_B4:%.*]] = getelementptr i8, ptr [[ARG_PRIV]], i64 4
40 ; CHECK-NEXT: store i32 [[TMP1]], ptr [[ARG_PRIV_B4]], align 4
41 ; CHECK-NEXT: [[ARG_PRIV_B8:%.*]] = getelementptr i8, ptr [[ARG_PRIV]], i64 8
42 ; CHECK-NEXT: store i32 [[TMP2]], ptr [[ARG_PRIV_B8]], align 4
43 ; CHECK-NEXT: call void @use(ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(12) [[ARG_PRIV]])
44 ; CHECK-NEXT: ret void
47 call void @use(ptr %arg)
51 ; TUNIT: attributes #[[ATTR0]] = { memory(readwrite, argmem: none) }
53 ; CGSCC: attributes #[[ATTR0]] = { memory(readwrite, argmem: none) }