[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / redeclare-function-addrspace.c
blobbb434b99812d05ca1b5734df1db3ebe147ba9c06
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature
2 // REQUIRES: avr-registered-target
3 // RUN: %clang_cc1 -triple avr-- -Wno-strict-prototypes -Wno-deprecated-non-prototype -emit-llvm -o - -verify %s | FileCheck %s
4 // expected-no-diagnostics
6 // Make sure redeclarations of functions as a different type work when functions
7 // use non-0 address spaces.
9 int g();
11 // CHECK-LABEL: define {{[^@]+}}@bar
12 // CHECK-SAME: (i16 noundef [[I:%.*]], i16 noundef [[J:%.*]]) addrspace(1) #[[ATTR0:[0-9]+]] {
13 // CHECK-NEXT: entry:
14 // CHECK-NEXT: [[I_ADDR:%.*]] = alloca i16, align 1
15 // CHECK-NEXT: [[J_ADDR:%.*]] = alloca i16, align 1
16 // CHECK-NEXT: store i16 [[I]], ptr [[I_ADDR]], align 1
17 // CHECK-NEXT: store i16 [[J]], ptr [[J_ADDR]], align 1
18 // CHECK-NEXT: [[TMP0:%.*]] = load i16, ptr [[I_ADDR]], align 1
19 // CHECK-NEXT: [[TMP1:%.*]] = load i16, ptr [[J_ADDR]], align 1
20 // CHECK-NEXT: [[CALL:%.*]] = call addrspace(1) i16 @g(i16 noundef [[TMP0]], i16 noundef [[TMP1]])
21 // CHECK-NEXT: ret i16 [[CALL]]
23 int bar(int i, int j) {
24 return g(i, j);
27 // CHECK-LABEL: define {{[^@]+}}@foo
28 // CHECK-SAME: (i16 noundef [[I:%.*]]) addrspace(1) #[[ATTR0]] {
29 // CHECK-NEXT: entry:
30 // CHECK-NEXT: [[I_ADDR:%.*]] = alloca i16, align 1
31 // CHECK-NEXT: store i16 [[I]], ptr [[I_ADDR]], align 1
32 // CHECK-NEXT: [[TMP0:%.*]] = load i16, ptr [[I_ADDR]], align 1
33 // CHECK-NEXT: [[CALL:%.*]] = call addrspace(1) i16 @g(i16 noundef [[TMP0]])
34 // CHECK-NEXT: ret i16 [[CALL]]
36 int foo(int i) {
37 return g(i);
40 // CHECK-LABEL: define {{[^@]+}}@g
41 // CHECK-SAME: (i16 noundef [[X:%.*]], i16 noundef [[Y:%.*]]) addrspace(1) #[[ATTR0]] {
42 // CHECK-NEXT: entry:
43 // CHECK-NEXT: [[X_ADDR:%.*]] = alloca i16, align 1
44 // CHECK-NEXT: [[Y_ADDR:%.*]] = alloca i16, align 1
45 // CHECK-NEXT: store i16 [[X]], ptr [[X_ADDR]], align 1
46 // CHECK-NEXT: store i16 [[Y]], ptr [[Y_ADDR]], align 1
47 // CHECK-NEXT: [[TMP0:%.*]] = load i16, ptr [[X_ADDR]], align 1
48 // CHECK-NEXT: [[TMP1:%.*]] = load i16, ptr [[Y_ADDR]], align 1
49 // CHECK-NEXT: [[ADD:%.*]] = add nsw i16 [[TMP0]], [[TMP1]]
50 // CHECK-NEXT: ret i16 [[ADD]]
52 int g(int x, int y) {
53 return x + y;