forked from OSchip/llvm-project
parent
384d376545
commit
b025d375a1
|
@ -0,0 +1,24 @@
|
||||||
|
//===---- CorrelatedValuePropagation.h --------------------------*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_TRANSFORMS_SCALAR_CORRELATEDVALUEPROPAGATION_H
|
||||||
|
#define LLVM_TRANSFORMS_SCALAR_CORRELATEDVALUEPROPAGATION_H
|
||||||
|
|
||||||
|
#include "llvm/IR/Function.h"
|
||||||
|
#include "llvm/IR/PassManager.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
|
||||||
|
struct CorrelatedValuePropagationPass
|
||||||
|
: PassInfoMixin<CorrelatedValuePropagationPass> {
|
||||||
|
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // LLVM_TRANSFORMS_SCALAR_CORRELATEDVALUEPROPAGATION_H
|
|
@ -75,6 +75,7 @@
|
||||||
#include "llvm/Transforms/Scalar/ADCE.h"
|
#include "llvm/Transforms/Scalar/ADCE.h"
|
||||||
#include "llvm/Transforms/Scalar/AlignmentFromAssumptions.h"
|
#include "llvm/Transforms/Scalar/AlignmentFromAssumptions.h"
|
||||||
#include "llvm/Transforms/Scalar/BDCE.h"
|
#include "llvm/Transforms/Scalar/BDCE.h"
|
||||||
|
#include "llvm/Transforms/Scalar/CorrelatedValuePropagation.h"
|
||||||
#include "llvm/Transforms/Scalar/DCE.h"
|
#include "llvm/Transforms/Scalar/DCE.h"
|
||||||
#include "llvm/Transforms/Scalar/ConstantHoisting.h"
|
#include "llvm/Transforms/Scalar/ConstantHoisting.h"
|
||||||
#include "llvm/Transforms/Scalar/DeadStoreElimination.h"
|
#include "llvm/Transforms/Scalar/DeadStoreElimination.h"
|
||||||
|
|
|
@ -127,6 +127,7 @@ FUNCTION_PASS("add-discriminators", AddDiscriminatorsPass())
|
||||||
FUNCTION_PASS("alignment-from-assumptions", AlignmentFromAssumptionsPass())
|
FUNCTION_PASS("alignment-from-assumptions", AlignmentFromAssumptionsPass())
|
||||||
FUNCTION_PASS("bdce", BDCEPass())
|
FUNCTION_PASS("bdce", BDCEPass())
|
||||||
FUNCTION_PASS("consthoist", ConstantHoistingPass())
|
FUNCTION_PASS("consthoist", ConstantHoistingPass())
|
||||||
|
FUNCTION_PASS("correlated-propagation", CorrelatedValuePropagationPass())
|
||||||
FUNCTION_PASS("dce", DCEPass())
|
FUNCTION_PASS("dce", DCEPass())
|
||||||
FUNCTION_PASS("dse", DSEPass())
|
FUNCTION_PASS("dse", DSEPass())
|
||||||
FUNCTION_PASS("early-cse", EarlyCSEPass())
|
FUNCTION_PASS("early-cse", EarlyCSEPass())
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/Transforms/Scalar/CorrelatedValuePropagation.h"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/Analysis/GlobalsModRef.h"
|
#include "llvm/Analysis/GlobalsModRef.h"
|
||||||
|
@ -39,7 +40,6 @@ STATISTIC(NumSDivs, "Number of sdiv converted to udiv");
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class CorrelatedValuePropagation : public FunctionPass {
|
class CorrelatedValuePropagation : public FunctionPass {
|
||||||
LazyValueInfo *LVI;
|
|
||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
CorrelatedValuePropagation(): FunctionPass(ID) {
|
CorrelatedValuePropagation(): FunctionPass(ID) {
|
||||||
|
@ -384,12 +384,7 @@ static Constant *getConstantAt(Value *V, Instruction *At, LazyValueInfo *LVI) {
|
||||||
ConstantInt::getFalse(C->getContext());
|
ConstantInt::getFalse(C->getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CorrelatedValuePropagation::runOnFunction(Function &F) {
|
static bool runImpl(Function &F, LazyValueInfo *LVI) {
|
||||||
if (skipFunction(F))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
LVI = &getAnalysis<LazyValueInfoWrapperPass>().getLVI();
|
|
||||||
|
|
||||||
bool FnChanged = false;
|
bool FnChanged = false;
|
||||||
|
|
||||||
for (BasicBlock &BB : F) {
|
for (BasicBlock &BB : F) {
|
||||||
|
@ -447,3 +442,28 @@ bool CorrelatedValuePropagation::runOnFunction(Function &F) {
|
||||||
|
|
||||||
return FnChanged;
|
return FnChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CorrelatedValuePropagation::runOnFunction(Function &F) {
|
||||||
|
if (skipFunction(F))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
LazyValueInfo *LVI = &getAnalysis<LazyValueInfoWrapperPass>().getLVI();
|
||||||
|
return runImpl(F, LVI);
|
||||||
|
}
|
||||||
|
|
||||||
|
PreservedAnalyses
|
||||||
|
CorrelatedValuePropagationPass::run(Function &F, FunctionAnalysisManager &AM) {
|
||||||
|
|
||||||
|
LazyValueInfo *LVI = &AM.getResult<LazyValueAnalysis>(F);
|
||||||
|
bool Changed = runImpl(F, LVI);
|
||||||
|
|
||||||
|
// FIXME: We need to invalidate LVI to avoid PR28400. Is there a better
|
||||||
|
// solution?
|
||||||
|
AM.invalidate<LazyValueAnalysis>(F);
|
||||||
|
|
||||||
|
if (!Changed)
|
||||||
|
return PreservedAnalyses::all();
|
||||||
|
PreservedAnalyses PA;
|
||||||
|
PA.preserve<GlobalsAA>();
|
||||||
|
return PA;
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
; RUN: opt -correlated-propagation -S %s | FileCheck %s
|
; RUN: opt -correlated-propagation -S %s | FileCheck %s
|
||||||
|
; RUN: opt -passes=correlated-propagation -S %s | FileCheck %s
|
||||||
|
|
||||||
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
||||||
target triple = "x86_64-apple-macosx10.10.0"
|
target triple = "x86_64-apple-macosx10.10.0"
|
||||||
|
|
Loading…
Reference in New Issue