xref: /llvm-project/llvm/test/Transforms/Attributor/ArgumentPromotion/nonzero-address-spaces.ll (revision cd3a4c31bc9694d160de54c6a4daa53e152cb463)
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
4
5; ArgumentPromotion should preserve the default function address space
6; from the data layout.
7
8target datalayout = "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8"
9
10@g = common global i32 0, align 4
11
12;.
13; CHECK: @g = common global i32 0, align 4
14;.
15define i32 @bar() {
16; CHECK-LABEL: define {{[^@]+}}@bar() addrspace(1) {
17; CHECK-NEXT:  entry:
18; CHECK-NEXT:    [[CALL:%.*]] = call addrspace(1) i32 @foo() #[[ATTR1:[0-9]+]]
19; CHECK-NEXT:    unreachable
20;
21
22entry:
23  %call = call i32 @foo(ptr @g)
24  ret i32 %call
25}
26
27define internal i32 @foo(ptr) {
28; CHECK: Function Attrs: noreturn memory(readwrite, argmem: none)
29; CHECK-LABEL: define {{[^@]+}}@foo
30; CHECK-SAME: () addrspace(1) #[[ATTR0:[0-9]+]] {
31; CHECK-NEXT:  entry:
32; CHECK-NEXT:    [[RETVAL:%.*]] = alloca i32, align 4
33; CHECK-NEXT:    [[RETVAL1:%.*]] = alloca i8, i32 0, align 4
34; CHECK-NEXT:    call addrspace(0) void asm sideeffect "ldr r0, [r0] \0Abx lr \0A", ""()
35; CHECK-NEXT:    unreachable
36;
37entry:
38  %retval = alloca i32, align 4
39  call void asm sideeffect "ldr r0, [r0] \0Abx lr        \0A", ""()
40  unreachable
41}
42
43;.
44; CHECK: attributes #[[ATTR0]] = { noreturn memory(readwrite, argmem: none) }
45; CHECK: attributes #[[ATTR1]] = { noreturn }
46;.
47;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
48; CGSCC: {{.*}}
49; TUNIT: {{.*}}
50