llvm.org GIT mirror llvm / 9afbd6f
[PM] Port CorrelatedValuePropagation git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274705 91177308-0d34-0410-b5e6-96231b3b80d8 Sean Silva 4 years ago
5 changed file(s) with 54 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
0 //===---- CorrelatedValuePropagation.h --------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_TRANSFORMS_SCALAR_CORRELATEDVALUEPROPAGATION_H
10 #define LLVM_TRANSFORMS_SCALAR_CORRELATEDVALUEPROPAGATION_H
11
12 #include "llvm/IR/Function.h"
13 #include "llvm/IR/PassManager.h"
14
15 namespace llvm {
16
17 struct CorrelatedValuePropagationPass
18 : PassInfoMixin {
19 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
20 };
21 }
22
23 #endif // LLVM_TRANSFORMS_SCALAR_CORRELATEDVALUEPROPAGATION_H
7474 #include "llvm/Transforms/Scalar/ADCE.h"
7575 #include "llvm/Transforms/Scalar/AlignmentFromAssumptions.h"
7676 #include "llvm/Transforms/Scalar/BDCE.h"
77 #include "llvm/Transforms/Scalar/CorrelatedValuePropagation.h"
7778 #include "llvm/Transforms/Scalar/DCE.h"
7879 #include "llvm/Transforms/Scalar/ConstantHoisting.h"
7980 #include "llvm/Transforms/Scalar/DeadStoreElimination.h"
126126 FUNCTION_PASS("alignment-from-assumptions", AlignmentFromAssumptionsPass())
127127 FUNCTION_PASS("bdce", BDCEPass())
128128 FUNCTION_PASS("consthoist", ConstantHoistingPass())
129 FUNCTION_PASS("correlated-propagation", CorrelatedValuePropagationPass())
129130 FUNCTION_PASS("dce", DCEPass())
130131 FUNCTION_PASS("dse", DSEPass())
131132 FUNCTION_PASS("early-cse", EarlyCSEPass())
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/Transforms/Scalar/CorrelatedValuePropagation.h"
1314 #include "llvm/Transforms/Scalar.h"
1415 #include "llvm/ADT/Statistic.h"
1516 #include "llvm/Analysis/GlobalsModRef.h"
3839
3940 namespace {
4041 class CorrelatedValuePropagation : public FunctionPass {
41 LazyValueInfo *LVI;
4242 public:
4343 static char ID;
4444 CorrelatedValuePropagation(): FunctionPass(ID) {
383383 ConstantInt::getFalse(C->getContext());
384384 }
385385
386 bool CorrelatedValuePropagation::runOnFunction(Function &F) {
387 if (skipFunction(F))
388 return false;
389
390 LVI = &getAnalysis().getLVI();
391
386 static bool runImpl(Function &F, LazyValueInfo *LVI) {
392387 bool FnChanged = false;
393388
394389 for (BasicBlock &BB : F) {
446441
447442 return FnChanged;
448443 }
444
445 bool CorrelatedValuePropagation::runOnFunction(Function &F) {
446 if (skipFunction(F))
447 return false;
448
449 LazyValueInfo *LVI = &getAnalysis().getLVI();
450 return runImpl(F, LVI);
451 }
452
453 PreservedAnalyses
454 CorrelatedValuePropagationPass::run(Function &F, FunctionAnalysisManager &AM) {
455
456 LazyValueInfo *LVI = &AM.getResult(F);
457 bool Changed = runImpl(F, LVI);
458
459 // FIXME: We need to invalidate LVI to avoid PR28400. Is there a better
460 // solution?
461 AM.invalidate(F);
462
463 if (!Changed)
464 return PreservedAnalyses::all();
465 PreservedAnalyses PA;
466 PA.preserve();
467 return PA;
468 }
0 ; RUN: opt -correlated-propagation -S %s | FileCheck %s
1 ; RUN: opt -passes=correlated-propagation -S %s | FileCheck %s
12
23 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
34 target triple = "x86_64-apple-macosx10.10.0"