xref: /llvm-project/llvm/test/Transforms/Attributor/ArgumentPromotion/basictest.ll (revision 29441e4f5fa5f5c7709f7cf180815ba97f611297)
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
4target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
5
6define internal i32 @test(ptr %X, ptr %Y) {
7; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read)
8; CGSCC-LABEL: define {{[^@]+}}@test
9; CGSCC-SAME: (i32 [[TMP0:%.*]], ptr nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[Y:%.*]]) #[[ATTR0:[0-9]+]] {
10; CGSCC-NEXT:    [[X_PRIV:%.*]] = alloca i32, align 4
11; CGSCC-NEXT:    store i32 [[TMP0]], ptr [[X_PRIV]], align 4
12; CGSCC-NEXT:    [[A:%.*]] = load i32, ptr [[X_PRIV]], align 4
13; CGSCC-NEXT:    [[B:%.*]] = load i32, ptr [[Y]], align 4
14; CGSCC-NEXT:    [[C:%.*]] = add i32 [[A]], [[B]]
15; CGSCC-NEXT:    ret i32 [[C]]
16;
17  %A = load i32, ptr %X
18  %B = load i32, ptr %Y
19  %C = add i32 %A, %B
20  ret i32 %C
21}
22
23define internal i32 @caller(ptr %B) {
24; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
25; CGSCC-LABEL: define {{[^@]+}}@caller
26; CGSCC-SAME: (i32 [[TMP0:%.*]]) #[[ATTR1:[0-9]+]] {
27; CGSCC-NEXT:    [[B_PRIV:%.*]] = alloca i32, align 4
28; CGSCC-NEXT:    store i32 [[TMP0]], ptr [[B_PRIV]], align 4
29; CGSCC-NEXT:    [[C:%.*]] = call i32 @test(i32 noundef 1, ptr noalias nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[B_PRIV]]) #[[ATTR2:[0-9]+]]
30; CGSCC-NEXT:    ret i32 [[C]]
31;
32  %A = alloca i32
33  store i32 1, ptr %A
34  %C = call i32 @test(ptr %A, ptr %B)
35  ret i32 %C
36}
37
38define i32 @callercaller() {
39; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
40; TUNIT-LABEL: define {{[^@]+}}@callercaller
41; TUNIT-SAME: () #[[ATTR0:[0-9]+]] {
42; TUNIT-NEXT:    [[B:%.*]] = alloca i32, align 4
43; TUNIT-NEXT:    ret i32 3
44;
45; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
46; CGSCC-LABEL: define {{[^@]+}}@callercaller
47; CGSCC-SAME: () #[[ATTR1]] {
48; CGSCC-NEXT:    [[X:%.*]] = call i32 @caller(i32 noundef 2) #[[ATTR3:[0-9]+]]
49; CGSCC-NEXT:    ret i32 [[X]]
50;
51  %B = alloca i32
52  store i32 2, ptr %B
53  %X = call i32 @caller(ptr %B)
54  ret i32 %X
55}
56
57;.
58; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
59;.
60; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) }
61; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(none) }
62; CGSCC: attributes #[[ATTR2]] = { nofree willreturn memory(read) }
63; CGSCC: attributes #[[ATTR3]] = { nofree nosync willreturn }
64;.
65;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
66; CHECK: {{.*}}
67