llvm.org GIT mirror llvm / 2d0d1f3
Make globalaa-retained.ll test catching more cases. Summary: * Add checks for store. That is needed because GlobalsAA is called twice in the current pipeline with different sets of Function passes following it. However, the loads are eliminated using instcombine which happens everywhere. On the other hand, DeadStoreElimination is performed only once so by checking for store we'll be able to catch more cases when GlobalsAA is invalidated unintentionally. * Add empty function above/below the test so that we don't depend on the relative order of instcombine/dead-store-elimination and the pass that invalidates the analysis (inside the same FunctionPassManager). Reviewers: kristof.beyls Reviewed By: kristof.beyls Subscribers: llvm-commits, n.bozhenov Differential Revision: https://reviews.llvm.org/D32015 Patch by Andrei Elovikov <andrei.elovikov@intel.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300553 91177308-0d34-0410-b5e6-96231b3b80d8 Nikolai Bozhenov 2 years ago
1 changed file(s) with 43 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
33
44 @v = internal unnamed_addr global i32 0, align 4
55 @p = common global i32* null, align 8
6
7
8 ; This test checks that a number of loads and stores are eliminated,
9 ; that can only be eliminated based on GlobalsAA information. As such,
10 ; it tests that GlobalsAA information is retained until the passes
11 ; that perform this optimization, and it protects against accidentally
12 ; dropping the GlobalsAA information earlier in the pipeline, which
13 ; has happened a few times.
14
15 ; GlobalsAA invalidation might happen later in the FunctionPassManager
16 ; pipeline than the optimization eliminating unnecessary loads/stores.
17 ; Since GlobalsAA is a module-level analysis, any FunctionPass
18 ; invalidating the GlobalsAA information will affect FunctionPass
19 ; pipelines that execute later. For example, assume a FunctionPass1 |
20 ; FunctionPass2 pipeline and 2 functions to be processed: f1 and f2.
21 ; Assume furthermore that FunctionPass1 uses GlobalsAA info to do an
22 ; optimization, and FunctionPass2 invalidates GlobalsAA. Assume the
23 ; function passes run in the following order: FunctionPass1(f1),
24 ; FunctionPass2(f1), FunctionPass1(f2), FunctionPass2(f2). Then
25 ; FunctionPass1 will not be able to optimize f2, since GlobalsAA will
26 ; have been invalidated in FuntionPass2(f1).
27
28 ; To try and also test this scenario, there is an empty function
29 ; before and after the function we're checking so that one of them
30 ; will be processed by the whole set of FunctionPasses before @f. That
31 ; will ensure that if the invalidation happens, it happens before the
32 ; actual optimizations on @f start.
33 define void @bar() {
34 entry:
35 ret void
36 }
637
738 ; Function Attrs: norecurse nounwind
839 define void @f(i32 %n) {
1849 ret void
1950 }
2051
21 ; check variable v is loaded only once after optimization, which should be
22 ; prove that globalsAA survives until the optimization that can use it to
23 ; optimize away the duplicate load/stores on variable v.
52 ; check variable v is loaded/stored only once after optimization,
53 ; which should be prove that globalsAA survives until the optimization
54 ; that can use it to optimize away the duplicate load/stores on
55 ; variable v.
2456 ; CHECK: load i32, i32* @v, align 4
57 ; CHECK: store i32 {{.*}}, i32* @v, align 4
2558 ; CHECK-NOT: load i32, i32* @v, align 4
59 ; CHECK-NOT: store i32 {{.*}}, i32* @v, align 4
60
61 ; Same as @bar above, in case the functions are processed in reverse order.
62 define void @bar2() {
63 entry:
64 ret void
65 }