1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes
2; Check that when argument promotion changes a function in some parent node of
3; the call graph, any analyses that happened to be cached for that function are
4; actually invalidated. We are using `demanded-bits` here because when printed
5; it will end up caching a value for every instruction, making it easy to
6; detect the instruction-level changes that will fail here. With improper
7; invalidation this will crash in the second printer as it tries to reuse
8; now-invalid demanded bits.
9;
10; RUN: opt < %s -passes='function(print<demanded-bits>),attributor,function(print<demanded-bits>)' -S | FileCheck %s
11
12@G = constant i32 0
13
14define internal i32 @a(i32* %x) {
15; CHECK: Function Attrs: nofree nosync nounwind readnone willreturn
16; CHECK-LABEL: define {{[^@]+}}@a
17; CHECK-SAME: () [[ATTR0:#.*]] {
18; CHECK-NEXT:  entry:
19; CHECK-NEXT:    [[V:%.*]] = load i32, i32* @G, align 4
20; CHECK-NEXT:    ret i32 [[V]]
21;
22entry:
23  %v = load i32, i32* %x
24  ret i32 %v
25}
26
27define i32 @b() {
28; CHECK: Function Attrs: nofree nosync nounwind readnone willreturn
29; CHECK-LABEL: define {{[^@]+}}@b
30; CHECK-SAME: () [[ATTR0]] {
31; CHECK-NEXT:  entry:
32; CHECK-NEXT:    [[V:%.*]] = call i32 @a() [[ATTR0]]
33; CHECK-NEXT:    ret i32 [[V]]
34;
35entry:
36  %v = call i32 @a(i32* @G)
37  ret i32 %v
38}
39
40define i32 @c() {
41; CHECK: Function Attrs: nofree nosync nounwind readnone willreturn
42; CHECK-LABEL: define {{[^@]+}}@c
43; CHECK-SAME: () [[ATTR0]] {
44; CHECK-NEXT:  entry:
45; CHECK-NEXT:    [[V1:%.*]] = call i32 @a() [[ATTR0]]
46; CHECK-NEXT:    [[V2:%.*]] = call i32 @b() [[ATTR0]]
47; CHECK-NEXT:    [[RESULT:%.*]] = add i32 [[V1]], [[V2]]
48; CHECK-NEXT:    ret i32 [[RESULT]]
49;
50entry:
51  %v1 = call i32 @a(i32* @G)
52  %v2 = call i32 @b()
53  %result = add i32 %v1, %v2
54  ret i32 %result
55}
56