1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00
Fangrui Song c9829bfb08 [LazyCallGraph] Build SCCs of the reference graph in order
```
// The legacy PM CGPassManager discovers SCCs this way:
for function in the source order
  tarjanSCC(function)

// While the new PM CGSCCPassManager does:
for function in the reversed source order [1]
  discover a reference graph SCC
  build call graph SCCs inside the reference graph SCC
```

In the common cases, reference graph ~= call graph, the new PM order is
undesired because for `a | b | c` (3 independent functions), the new PM will
process them in the reversed order: c, b, a. If `a <-> b <-> c`, we can see
that `-print-after-all` will report the sole SCC as `scc: (c, b, a)`.

This patch corrects the iteration order. The discovered SCC order will match
the legacy PM in the common cases.

For some tests (`Transforms/Inline/cgscc-*.ll` and
`unittests/Analysis/CGSCCPassManagerTest.cpp`), the behaviors are dependent on
the SCC discovery order and there are too many check lines for the particular
order.  This patch simply reverses the function order to avoid changing too many
check lines.

Differential Revision: https://reviews.llvm.org/D90566
2020-11-02 13:22:42 -08:00

39 lines
926 B
LLVM

; RUN: opt -disable-output -passes=print-lcg %s 2>&1 | FileCheck %s
;
; Aliased function should be reachable in CGSCC.
target triple = "x86_64-grtev4-linux-gnu"
; CHECK: Edges in function: foo
; CHECK: Edges in function: bar
; CHECK: Edges in function: baz
; CHECK: RefSCC with 1 call SCCs:
; CHECK-NEXT: SCC with 1 functions:
; CHECK-NEXT: foo
; CHECK-EMPTY:
; CHECK: RefSCC with 1 call SCCs:
; CHECK-NEXT: SCC with 1 functions:
; CHECK-NEXT: bar
; CHECK-NOT: baz
@alias1 = weak dso_local alias i8* (i8*), i8* (i8*)* @foo
define dso_local i8* @foo(i8* %returned) {
ret i8* %returned
}
@alias2 = weak dso_local alias i8* (i8*), i8* (i8*)* @bar
define internal i8* @bar(i8* %returned) {
ret i8* %returned
}
; Internal alias is not reachable.
@alias3 = internal alias i8* (i8*), i8* (i8*)* @baz
define internal i8* @baz(i8* %returned) {
ret i8* %returned
}