xref: /llvm-project/llvm/test/Transforms/Attributor/ArgumentPromotion/invalidation.ll (revision cd3a4c31bc9694d160de54c6a4daa53e152cb463)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
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
14;.
15; CHECK: @G = constant i32 0
16;.
17define internal i32 @a(ptr %x) {
18entry:
19  %v = load i32, ptr %x
20  ret i32 %v
21}
22
23define i32 @b() {
24; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
25; CHECK-LABEL: define {{[^@]+}}@b
26; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
27; CHECK-NEXT:  entry:
28; CHECK-NEXT:    ret i32 0
29;
30entry:
31  %v = call i32 @a(ptr @G)
32  ret i32 %v
33}
34
35define i32 @c() {
36; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
37; CHECK-LABEL: define {{[^@]+}}@c
38; CHECK-SAME: () #[[ATTR0]] {
39; CHECK-NEXT:  entry:
40; CHECK-NEXT:    ret i32 0
41;
42entry:
43  %v1 = call i32 @a(ptr @G)
44  %v2 = call i32 @b()
45  %result = add i32 %v1, %v2
46  ret i32 %result
47}
48;.
49; CHECK: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
50;.
51