1 ; Check that when argument promotion changes a function in some parent node of
2 ; the call graph, any analyses that happened to be cached for that function are
3 ; actually invalidated. We are using `demanded-bits` here because when printed
4 ; it will end up caching a value for every instruction, making it easy to
5 ; detect the instruction-level changes that will fail here. With improper
6 ; invalidation this will crash in the second printer as it tries to reuse
7 ; now-invalid demanded bits.
9 ; RUN: opt < %s -passes='function(print<demanded-bits>),cgscc(argpromotion,function(print<demanded-bits>))' -S | FileCheck %s
13 define internal i32 @a(i32* %x) {
14 ; CHECK-LABEL: define internal i32 @a(
15 ; CHECK-SAME: i32 %[[V:.*]]) {
17 ; CHECK-NEXT: ret i32 %[[V]]
20 %v = load i32, i32* %x
25 ; CHECK-LABEL: define i32 @b()
27 ; CHECK-NEXT: %[[L:.*]] = load i32, i32* @G
28 ; CHECK-NEXT: %[[V:.*]] = call i32 @a(i32 %[[L]])
29 ; CHECK-NEXT: ret i32 %[[V]]
32 %v = call i32 @a(i32* @G)
37 ; CHECK-LABEL: define i32 @c()
39 ; CHECK-NEXT: %[[L:.*]] = load i32, i32* @G
40 ; CHECK-NEXT: %[[V1:.*]] = call i32 @a(i32 %[[L]])
41 ; CHECK-NEXT: %[[V2:.*]] = call i32 @b()
42 ; CHECK-NEXT: %[[RESULT:.*]] = add i32 %[[V1]], %[[V2]]
43 ; CHECK-NEXT: ret i32 %[[RESULT]]
46 %v1 = call i32 @a(i32* @G)
48 %result = add i32 %v1, %v2