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 target datalayout = "A7"
7 ; Make sure we create allocas in AS 7 and cast them properly.
9 define i32 @bar(i32 %arg) {
10 ; TUNIT-LABEL: define {{[^@]+}}@bar
11 ; TUNIT-SAME: (i32 [[ARG:%.*]]) {
13 ; TUNIT-NEXT: [[STACK:%.*]] = alloca i32, align 4
14 ; TUNIT-NEXT: store i32 [[ARG]], ptr [[STACK]], align 4
15 ; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr [[STACK]], align 4
16 ; TUNIT-NEXT: [[CALL:%.*]] = call i32 @foo(i32 [[TMP0]])
17 ; TUNIT-NEXT: ret i32 [[CALL]]
19 ; CGSCC-LABEL: define {{[^@]+}}@bar
20 ; CGSCC-SAME: (i32 [[ARG:%.*]]) {
22 ; CGSCC-NEXT: [[STACK:%.*]] = alloca i32, align 4
23 ; CGSCC-NEXT: store i32 [[ARG]], ptr [[STACK]], align 4
24 ; CGSCC-NEXT: [[CALL:%.*]] = call i32 @foo(i32 [[ARG]])
25 ; CGSCC-NEXT: ret i32 [[CALL]]
29 store i32 %arg, ptr %stack
30 %call = call i32 @foo(ptr %stack)
34 define internal i32 @foo(ptr %arg) {
35 ; CHECK: Function Attrs: memory(readwrite, argmem: none)
36 ; CHECK-LABEL: define {{[^@]+}}@foo
37 ; CHECK-SAME: (i32 [[TMP0:%.*]]) #[[ATTR0:[0-9]+]] {
39 ; CHECK-NEXT: [[ARG_PRIV:%.*]] = alloca i32, align 4, addrspace(7)
40 ; CHECK-NEXT: store i32 [[TMP0]], ptr addrspace(7) [[ARG_PRIV]], align 4
41 ; CHECK-NEXT: [[TMP1:%.*]] = addrspacecast ptr addrspace(7) [[ARG_PRIV]] to ptr
42 ; CHECK-NEXT: [[L:%.*]] = load i32, ptr [[TMP1]], align 4
43 ; CHECK-NEXT: call void @use(i32 [[L]])
44 ; CHECK-NEXT: ret i32 [[L]]
47 %l = load i32, ptr %arg
48 call void @use(i32 %l)
52 declare void @use(i32)
54 ; CHECK: attributes #[[ATTR0]] = { memory(readwrite, argmem: none) }