mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
9e6192bcdf
Have funcattrs expand all implied attributes into the IR. This expands the infrastructure from D100400, but for definitions not declarations this time. Somewhat subtly, this mostly isn't semantic. Because the accessors did the inference, any client which used the accessor was already getting the stronger result. Clients that directly checked presence of attributes (there are some), will see a stronger result now. The old behavior can end up quite confusing for two reasons: * Without this change, we have situations where function-attrs appears to fail when inferring an attribute (as seen by a human reading IR), but that consuming code will see that it should have been implied. As a human trying to sanity check test results and study IR for optimization possibilities, this is exceeding error prone and confusing. (I'll note that I wasted several hours recently because of this.) * We can have transforms which trigger without the IR appearing (on inspection) to meet the preconditions. This change doesn't prevent this from happening (as the accessors still involve multiple checks), but it should make it less frequent. I'd argue in favor of deleting the extra checks out of the accessors after this lands, but I want that in it's own review as a) it's purely stylistic, and b) I already know there's some disagreement. Once this lands, I'm also going to do a cleanup change which will delete some now redundant duplicate predicates in the inference code, but again, that deserves to be a change of it's own. Differential Revision: https://reviews.llvm.org/D100226
342 lines
6.4 KiB
LLVM
342 lines
6.4 KiB
LLVM
; RUN: opt -aa-pipeline=basic-aa -passes='cgscc(function-attrs,function(simplify-cfg))' -S < %s | FileCheck %s
|
|
|
|
declare void @readnone() nofree nosync readnone
|
|
declare void @unknown()
|
|
declare void @reference_function_pointer(void()*) nofree nosync readnone
|
|
|
|
; The @test1_* set of functions checks that when we mutate functions with
|
|
; simplify-cfg to delete call edges and this ends up splitting both the SCCs
|
|
; and the RefSCCs that those functions are in, we re-run the CGSCC passes to
|
|
; observe the refined call graph structure.
|
|
|
|
; CHECK: define void @test1_a() {
|
|
define void @test1_a() {
|
|
call void @test1_b1()
|
|
call void @test1_b2()
|
|
call void @test1_b3()
|
|
call void @test1_b4()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test1_b1() #0 {
|
|
define void @test1_b1() {
|
|
call void @readnone()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test1_b2() #0 {
|
|
define void @test1_b2() {
|
|
call void @readnone()
|
|
br i1 false, label %dead, label %exit
|
|
|
|
dead:
|
|
call void @test1_a()
|
|
br label %exit
|
|
|
|
exit:
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test1_b3() {
|
|
define void @test1_b3() {
|
|
call void @unknown()
|
|
br i1 false, label %dead, label %exit
|
|
|
|
dead:
|
|
call void @test1_a()
|
|
br label %exit
|
|
|
|
exit:
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test1_b4() #0 {
|
|
define void @test1_b4() {
|
|
call void @readnone()
|
|
br i1 false, label %dead, label %exit
|
|
|
|
dead:
|
|
call void @test1_a()
|
|
br label %exit
|
|
|
|
exit:
|
|
ret void
|
|
}
|
|
|
|
|
|
; The @test2_* set of functions provide similar checks to @test1_* but only
|
|
; splitting the SCCs while leaving the RefSCC intact. This is accomplished by
|
|
; having dummy ref edges to the root function.
|
|
|
|
; CHECK: define void @test2_a() {
|
|
define void @test2_a() {
|
|
call void @test2_b1()
|
|
call void @test2_b2()
|
|
call void @test2_b3()
|
|
call void @test2_b4()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test2_b1() #0 {
|
|
define void @test2_b1() {
|
|
call void @readnone()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test2_b2() #0 {
|
|
define void @test2_b2() {
|
|
call void @reference_function_pointer(void()* @test2_a)
|
|
br i1 false, label %dead, label %exit
|
|
|
|
dead:
|
|
call void @test2_a()
|
|
br label %exit
|
|
|
|
exit:
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test2_b3() {
|
|
define void @test2_b3() {
|
|
call void @reference_function_pointer(void()* @test2_a)
|
|
call void @unknown()
|
|
br i1 false, label %dead, label %exit
|
|
|
|
dead:
|
|
call void @test2_a()
|
|
br label %exit
|
|
|
|
exit:
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test2_b4() #0 {
|
|
define void @test2_b4() {
|
|
call void @reference_function_pointer(void()* @test2_a)
|
|
br i1 false, label %dead, label %exit
|
|
|
|
dead:
|
|
call void @test2_a()
|
|
br label %exit
|
|
|
|
exit:
|
|
ret void
|
|
}
|
|
|
|
|
|
; The @test3_* set of functions are the same challenge as @test1_* but with
|
|
; multiple layers that have to be traversed in the correct order instead of
|
|
; a single node.
|
|
|
|
; CHECK: define void @test3_a() {
|
|
define void @test3_a() {
|
|
call void @test3_b11()
|
|
call void @test3_b21()
|
|
call void @test3_b31()
|
|
call void @test3_b41()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test3_b11() #0 {
|
|
define void @test3_b11() {
|
|
call void @test3_b12()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test3_b12() #0 {
|
|
define void @test3_b12() {
|
|
call void @test3_b13()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test3_b13() #0 {
|
|
define void @test3_b13() {
|
|
call void @readnone()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test3_b21() #0 {
|
|
define void @test3_b21() {
|
|
call void @test3_b22()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test3_b22() #0 {
|
|
define void @test3_b22() {
|
|
call void @test3_b23()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test3_b23() #0 {
|
|
define void @test3_b23() {
|
|
call void @readnone()
|
|
br i1 false, label %dead, label %exit
|
|
|
|
dead:
|
|
call void @test3_a()
|
|
br label %exit
|
|
|
|
exit:
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test3_b31() {
|
|
define void @test3_b31() {
|
|
call void @test3_b32()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test3_b32() {
|
|
define void @test3_b32() {
|
|
call void @test3_b33()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test3_b33() {
|
|
define void @test3_b33() {
|
|
call void @unknown()
|
|
br i1 false, label %dead, label %exit
|
|
|
|
dead:
|
|
call void @test3_a()
|
|
br label %exit
|
|
|
|
exit:
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test3_b41() #0 {
|
|
define void @test3_b41() {
|
|
call void @test3_b42()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test3_b42() #0 {
|
|
define void @test3_b42() {
|
|
call void @test3_b43()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test3_b43() #0 {
|
|
define void @test3_b43() {
|
|
call void @readnone()
|
|
br i1 false, label %dead, label %exit
|
|
|
|
dead:
|
|
call void @test3_a()
|
|
br label %exit
|
|
|
|
exit:
|
|
ret void
|
|
}
|
|
|
|
|
|
; The @test4_* functions exercise the same core challenge as the @test2_*
|
|
; functions, but again include long chains instead of single nodes and ensure
|
|
; we traverse the chains in the correct order.
|
|
|
|
; CHECK: define void @test4_a() {
|
|
define void @test4_a() {
|
|
call void @test4_b11()
|
|
call void @test4_b21()
|
|
call void @test4_b31()
|
|
call void @test4_b41()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test4_b11() #0 {
|
|
define void @test4_b11() {
|
|
call void @test4_b12()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test4_b12() #0 {
|
|
define void @test4_b12() {
|
|
call void @test4_b13()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test4_b13() #0 {
|
|
define void @test4_b13() {
|
|
call void @readnone()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test4_b21() #0 {
|
|
define void @test4_b21() {
|
|
call void @test4_b22()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test4_b22() #0 {
|
|
define void @test4_b22() {
|
|
call void @test4_b23()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test4_b23() #0 {
|
|
define void @test4_b23() {
|
|
call void @reference_function_pointer(void()* @test4_a)
|
|
br i1 false, label %dead, label %exit
|
|
|
|
dead:
|
|
call void @test4_a()
|
|
br label %exit
|
|
|
|
exit:
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test4_b31() {
|
|
define void @test4_b31() {
|
|
call void @test4_b32()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test4_b32() {
|
|
define void @test4_b32() {
|
|
call void @test4_b33()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test4_b33() {
|
|
define void @test4_b33() {
|
|
call void @reference_function_pointer(void()* @test4_a)
|
|
call void @unknown()
|
|
br i1 false, label %dead, label %exit
|
|
|
|
dead:
|
|
call void @test4_a()
|
|
br label %exit
|
|
|
|
exit:
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test4_b41() #0 {
|
|
define void @test4_b41() {
|
|
call void @test4_b42()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test4_b42() #0 {
|
|
define void @test4_b42() {
|
|
call void @test4_b43()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test4_b43() #0 {
|
|
define void @test4_b43() {
|
|
call void @reference_function_pointer(void()* @test4_a)
|
|
br i1 false, label %dead, label %exit
|
|
|
|
dead:
|
|
call void @test4_a()
|
|
br label %exit
|
|
|
|
exit:
|
|
ret void
|
|
}
|
|
|
|
; CHECK: attributes #0 = { nofree nosync readnone }
|