llvm.org GIT mirror llvm / d52ad61
Revert "[GVN] Basic optimization remark support" This reverts commit r288210. The failure on the stage2 LTO build is back. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288226 91177308-0d34-0410-b5e6-96231b3b80d8 Adam Nemet 3 years ago
5 changed file(s) with 4 addition(s) and 89 deletion(s). Raw diff Collapse all Expand all
391391
392392 explicit Argument(StringRef Str = "") : Key("String"), Val(Str) {}
393393 Argument(StringRef Key, Value *V);
394 Argument(StringRef Key, Type *T);
395394 Argument(StringRef Key, int N);
396395 Argument(StringRef Key, unsigned N);
397396 Argument(StringRef Key, bool B) : Key(Key), Val(B ? "true" : "false") {}
2727 #include "llvm/IR/PassManager.h"
2828
2929 namespace llvm {
30 class OptimizationRemarkEmitter;
3130
3231 /// A private "module" namespace for types and utilities used by GVN. These
3332 /// are implementation details and should not be used by clients.
109108 const TargetLibraryInfo *TLI;
110109 AssumptionCache *AC;
111110 SetVector DeadBlocks;
112 OptimizationRemarkEmitter *ORE;
113111
114112 ValueTable VN;
115113
135133
136134 bool runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
137135 const TargetLibraryInfo &RunTLI, AAResults &RunAA,
138 MemoryDependenceResults *RunMD, OptimizationRemarkEmitter *ORE);
136 MemoryDependenceResults *RunMD);
139137
140138 /// Push a new Value to the LeaderTable onto the list for its value number.
141139 void addToLeaderTable(uint32_t N, Value *V, const BasicBlock *BB) {
179179 DLoc = I->getDebugLoc();
180180 }
181181
182 DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, Type *T)
183 : Key(Key) {
184 raw_string_ostream OS(Val);
185 OS << *T;
186 }
187
188182 DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, int N)
189183 : Key(Key), Val(itostr(N)) {}
190184
3232 #include "llvm/Analysis/Loads.h"
3333 #include "llvm/Analysis/MemoryBuiltins.h"
3434 #include "llvm/Analysis/MemoryDependenceAnalysis.h"
35 #include "llvm/Analysis/OptimizationDiagnosticInfo.h"
3635 #include "llvm/Analysis/PHITransAddr.h"
3736 #include "llvm/Analysis/TargetLibraryInfo.h"
3837 #include "llvm/Analysis/ValueTracking.h"
586585 auto &TLI = AM.getResult(F);
587586 auto &AA = AM.getResult(F);
588587 auto &MemDep = AM.getResult(F);
589 auto &ORE = AM.getResult(F);
590 bool Changed = runImpl(F, AC, DT, TLI, AA, &MemDep, &ORE);
588 bool Changed = runImpl(F, AC, DT, TLI, AA, &MemDep);
591589 if (!Changed)
592590 return PreservedAnalyses::all();
593591 PreservedAnalyses PA;
15831581 if (V->getType()->getScalarType()->isPointerTy())
15841582 MD->invalidateCachedPointerInfo(V);
15851583 markInstructionForDeletion(LI);
1586 ORE->emit(OptimizationRemark(DEBUG_TYPE, "LoadPRE", LI)
1587 << "load eliminated by PRE");
15881584 ++NumPRELoad;
15891585 return true;
1590 }
1591
1592 static void reportLoadElim(LoadInst *LI, OptimizationRemarkEmitter *ORE) {
1593 ORE->emit(OptimizationRemark(DEBUG_TYPE, "LoadElim", LI)
1594 << "load of type " << ore::NV("Type", LI->getType())
1595 << " eliminated");
15961586 }
15971587
15981588 /// Attempt to eliminate a load whose dependencies are
16651655 MD->invalidateCachedPointerInfo(V);
16661656 markInstructionForDeletion(LI);
16671657 ++NumGVNLoad;
1668 reportLoadElim(LI, ORE);
16691658 return true;
16701659 }
16711660
18121801 patchAndReplaceAllUsesWith(L, AvailableValue);
18131802 markInstructionForDeletion(L);
18141803 ++NumGVNLoad;
1815 reportLoadElim(L, ORE);
18161804 // Tell MDA to rexamine the reused pointer since we might have more
18171805 // information after forwarding it.
18181806 if (MD && AvailableValue->getType()->getScalarType()->isPointerTy())
21902178 /// runOnFunction - This is the main transformation entry point for a function.
21912179 bool GVN::runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
21922180 const TargetLibraryInfo &RunTLI, AAResults &RunAA,
2193 MemoryDependenceResults *RunMD,
2194 OptimizationRemarkEmitter *RunORE) {
2181 MemoryDependenceResults *RunMD) {
21952182 AC = &RunAC;
21962183 DT = &RunDT;
21972184 VN.setDomTree(DT);
21992186 VN.setAliasAnalysis(&RunAA);
22002187 MD = RunMD;
22012188 VN.setMemDep(MD);
2202 ORE = RunORE;
22032189
22042190 bool Changed = false;
22052191 bool ShouldContinue = true;
27122698 getAnalysis().getTLI(),
27132699 getAnalysis().getAAResults(),
27142700 NoLoads ? nullptr
2715 : &getAnalysis().getMemDep(),
2716 &getAnalysis().getORE());
2701 : &getAnalysis().getMemDep());
27172702 }
27182703
27192704 void getAnalysisUsage(AnalysisUsage &AU) const override {
27262711
27272712 AU.addPreserved();
27282713 AU.addPreserved();
2729 AU.addRequired();
27302714 }
27312715
27322716 private:
27482732 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
27492733 INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
27502734 INITIALIZE_PASS_DEPENDENCY(GlobalsAAWrapperPass)
2751 INITIALIZE_PASS_DEPENDENCY(OptimizationRemarkEmitterWrapperPass)
27522735 INITIALIZE_PASS_END(GVNLegacyPass, "gvn", "Global Value Numbering", false, false)
+0
-59
test/Transforms/GVN/opt-remarks.ll less more
None ; RUN: opt < %s -gvn -o /dev/null -pass-remarks-output=%t -S -pass-remarks=gvn \
1 ; RUN: 2>&1 | FileCheck %s
2 ; RUN: cat %t | FileCheck -check-prefix=YAML %s
3
4 ; CHECK: remark: :0:0: load of type i32 eliminated{{$}}
5 ; CHECK-NEXT: remark: :0:0: load of type i32 eliminated{{$}}
6 ; CHECK-NEXT: remark: :0:0: load of type i32 eliminated{{$}}
7 ; CHECK-NOT: remark:
8
9 ; YAML: --- !Passed
10 ; YAML-NEXT: Pass: gvn
11 ; YAML-NEXT: Name: LoadElim
12 ; YAML-NEXT: Function: arg
13 ; YAML-NEXT: Args:
14 ; YAML-NEXT: - String: 'load of type '
15 ; YAML-NEXT: - Type: i32
16 ; YAML-NEXT: - String: ' eliminated'
17 ; YAML-NEXT: ...
18 ; YAML-NEXT: --- !Passed
19 ; YAML-NEXT: Pass: gvn
20 ; YAML-NEXT: Name: LoadElim
21 ; YAML-NEXT: Function: const
22 ; YAML-NEXT: Args:
23 ; YAML-NEXT: - String: 'load of type '
24 ; YAML-NEXT: - Type: i32
25 ; YAML-NEXT: - String: ' eliminated'
26 ; YAML-NEXT: ...
27 ; YAML-NEXT: --- !Passed
28 ; YAML-NEXT: Pass: gvn
29 ; YAML-NEXT: Name: LoadElim
30 ; YAML-NEXT: Function: inst
31 ; YAML-NEXT: Args:
32 ; YAML-NEXT: - String: 'load of type '
33 ; YAML-NEXT: - Type: i32
34 ; YAML-NEXT: - String: ' eliminated'
35 ; YAML-NEXT: ...
36
37
38 define i32 @arg(i32* %p, i32 %i) {
39 entry:
40 store i32 %i, i32* %p
41 %load = load i32, i32* %p
42 ret i32 %load
43 }
44
45 define i32 @const(i32* %p) {
46 entry:
47 store i32 4, i32* %p
48 %load = load i32, i32* %p
49 ret i32 %load
50 }
51
52 define i32 @inst(i32* %p) {
53 entry:
54 %load1 = load i32, i32* %p
55 %load = load i32, i32* %p
56 %add = add i32 %load1, %load
57 ret i32 %add
58 }