xref: /llvm-project/llvm/test/Transforms/SCCP/comdat-ipo.ll (revision 8ebb3eac02a926ffa4298c12834c57aefb2e8579)
1599955ebSFlorian Hahn; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2*8ebb3eacSBjorn Pettersson; RUN: opt < %s -passes=ipsccp -S | FileCheck %s
3cee313d2SEric Christopher
4cee313d2SEric Christopher; See PR26774
5cee313d2SEric Christopher
6cee313d2SEric Christopherdefine i32 @baz() {
7599955ebSFlorian Hahn; CHECK-LABEL: @baz(
8599955ebSFlorian Hahn; CHECK-NEXT:    ret i32 10
9599955ebSFlorian Hahn;
10cee313d2SEric Christopher  ret i32 10
11cee313d2SEric Christopher}
12cee313d2SEric Christopher
13cee313d2SEric Christopher; We can const-prop @baz's return value *into* @foo, but cannot
14cee313d2SEric Christopher; constprop @foo's return value into bar.
15cee313d2SEric Christopher
16cee313d2SEric Christopherdefine linkonce_odr i32 @foo() {
17cee313d2SEric Christopher; CHECK-LABEL: @foo(
18599955ebSFlorian Hahn; CHECK-NEXT:    [[VAL:%.*]] = call i32 @baz()
19cee313d2SEric Christopher; CHECK-NEXT:    ret i32 10
20599955ebSFlorian Hahn;
21cee313d2SEric Christopher
22cee313d2SEric Christopher  %val = call i32 @baz()
23cee313d2SEric Christopher  ret i32 %val
24cee313d2SEric Christopher}
25cee313d2SEric Christopher
26cee313d2SEric Christopherdefine i32 @bar() {
27cee313d2SEric Christopher; CHECK-LABEL: @bar(
28599955ebSFlorian Hahn; CHECK-NEXT:    [[VAL:%.*]] = call i32 @foo()
29599955ebSFlorian Hahn; CHECK-NEXT:    ret i32 [[VAL]]
30599955ebSFlorian Hahn;
31cee313d2SEric Christopher
32cee313d2SEric Christopher  %val = call i32 @foo()
33cee313d2SEric Christopher  ret i32 %val
34cee313d2SEric Christopher}
35