xref: /aosp_15_r20/external/llvm/test/Feature/OperandBundles/adce.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -S -adce < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; While it is normally okay to DCE out calls to @readonly_function and
4*9880d681SAndroid Build Coastguard Worker; @readnone_function, we cannot do that if they're carrying operand
5*9880d681SAndroid Build Coastguard Worker; bundles since the presence of unknown operand bundles implies
6*9880d681SAndroid Build Coastguard Worker; arbitrary memory effects.
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Workerdeclare void @readonly_function() readonly nounwind
9*9880d681SAndroid Build Coastguard Workerdeclare void @readnone_function() readnone nounwind
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Workerdefine void @test0() {
12*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test0(
13*9880d681SAndroid Build Coastguard Worker entry:
14*9880d681SAndroid Build Coastguard Worker  call void @readonly_function() [ "tag"() ]
15*9880d681SAndroid Build Coastguard Worker; CHECK: call void @readonly_function
16*9880d681SAndroid Build Coastguard Worker  ret void
17*9880d681SAndroid Build Coastguard Worker}
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Workerdefine void @test1() {
20*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test1(
21*9880d681SAndroid Build Coastguard Worker entry:
22*9880d681SAndroid Build Coastguard Worker  call void @readnone_function() [ "tag"() ]
23*9880d681SAndroid Build Coastguard Worker; CHECK: call void @readnone_function
24*9880d681SAndroid Build Coastguard Worker  ret void
25*9880d681SAndroid Build Coastguard Worker}
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workerdefine void @test2() {
28*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test2(
29*9880d681SAndroid Build Coastguard Worker entry:
30*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: @readonly_function(
31*9880d681SAndroid Build Coastguard Worker  call void @readonly_function() readonly [ "tag"() ]
32*9880d681SAndroid Build Coastguard Worker  ret void
33*9880d681SAndroid Build Coastguard Worker}
34*9880d681SAndroid Build Coastguard Worker
35*9880d681SAndroid Build Coastguard Workerdefine void @test3() {
36*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test3(
37*9880d681SAndroid Build Coastguard Worker entry:
38*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: @readnone_function(
39*9880d681SAndroid Build Coastguard Worker  call void @readnone_function() readnone [ "tag"() ]
40*9880d681SAndroid Build Coastguard Worker  ret void
41*9880d681SAndroid Build Coastguard Worker}
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Workerdefine void @test4() {
44*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test4(
45*9880d681SAndroid Build Coastguard Worker entry:
46*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: @readonly_function()
47*9880d681SAndroid Build Coastguard Worker  call void @readonly_function() [ "deopt"() ]
48*9880d681SAndroid Build Coastguard Worker  ret void
49*9880d681SAndroid Build Coastguard Worker}
50