xref: /llvm-project/llvm/test/Transforms/Attributor/IPConstantProp/comdat-ipo.ll (revision cd3a4c31bc9694d160de54c6a4daa53e152cb463)
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
4
5; See PR26774
6
7define i32 @baz() {
8; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
9; CHECK-LABEL: define {{[^@]+}}@baz
10; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
11; CHECK-NEXT:    ret i32 10
12;
13  ret i32 10
14}
15
16; We can const-prop @baz's return value *into* @foo, but cannot
17; constprop @foo's return value into bar.
18
19define linkonce_odr i32 @foo() {
20; TUNIT-LABEL: define {{[^@]+}}@foo() {
21; TUNIT-NEXT:    ret i32 10
22;
23; CGSCC-LABEL: define {{[^@]+}}@foo() {
24; CGSCC-NEXT:    [[VAL:%.*]] = call i32 @baz()
25; CGSCC-NEXT:    ret i32 [[VAL]]
26;
27
28  %val = call i32 @baz()
29  ret i32 %val
30}
31
32define i32 @bar() {
33; CHECK-LABEL: define {{[^@]+}}@bar() {
34; CHECK-NEXT:    [[VAL:%.*]] = call i32 @foo()
35; CHECK-NEXT:    ret i32 [[VAL]]
36;
37
38  %val = call i32 @foo()
39  ret i32 %val
40}
41;.
42; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
43;.
44; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
45;.
46