llvm.org GIT mirror llvm / e3e438a
Mark that SpeculativeExecution preserves Globals Alias Analysis. A few benchmarks with lots of accesses to global variables in the hot loops regressed a lot since r266399, which added the SpeculativeExecution pass to the default pipeline. The problem is that this pass doesn't mark Globals Alias Analysis as preserved. Globals Alias Analysis is computed in a module pass, whereas SpeculativeExecution is a function pass, and a lot of passes dependent on the Globals Alias Analysis to optimize these benchmarks are also function passes. As such, the Globals Alias Analysis information cannot be recomputed between SpeculativeExecution and the following function passes needing that information. SpeculativeExecution doesn't invalidate Globals Alias Analysis, so mark it as such to fix those performance regressions. Differential Revision: http://reviews.llvm.org/D19806 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268370 91177308-0d34-0410-b5e6-96231b3b80d8 Kristof Beyls 3 years ago
2 changed file(s) with 28 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
6161 //===----------------------------------------------------------------------===//
6262
6363 #include "llvm/ADT/SmallSet.h"
64 #include "llvm/Analysis/GlobalsModRef.h"
6465 #include "llvm/Analysis/TargetTransformInfo.h"
6566 #include "llvm/Analysis/ValueTracking.h"
6667 #include "llvm/IR/Instructions.h"
137138
138139 void SpeculativeExecution::getAnalysisUsage(AnalysisUsage &AU) const {
139140 AU.addRequired();
141 AU.addPreserved();
140142 }
141143
142144 bool SpeculativeExecution::runOnFunction(Function &F) {
0 ; RUN: opt -O3 -S < %s | FileCheck %s
1 target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
2 target triple = "aarch64"
3
4 @v = internal unnamed_addr global i32 0, align 4
5 @p = common global i32* null, align 8
6
7 ; Function Attrs: norecurse nounwind
8 define void @f(i32 %n) {
9 entry:
10 %0 = load i32, i32* @v, align 4
11 %inc = add nsw i32 %0, 1
12 store i32 %inc, i32* @v, align 4
13 %1 = load i32*, i32** @p, align 8
14 store i32 %n, i32* %1, align 4
15 %2 = load i32, i32* @v, align 4
16 %inc1 = add nsw i32 %2, 1
17 store i32 %inc1, i32* @v, align 4
18 ret void
19 }
20
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.
24 ; CHECK: load i32, i32* @v, align 4
25 ; CHECK-NOT: load i32, i32* @v, align 4