forked from OSchip/llvm-project
Revert "[GVN] Basic optimization remark support"
This reverts commit r288046. Trying to see if the revert fixes a compiler crash during a stage2 LTO build with a GVN backtrace. llvm-svn: 288179
This commit is contained in:
parent
91d4d93f94
commit
c2ed4b35b4
|
@ -392,7 +392,6 @@ public:
|
||||||
|
|
||||||
explicit Argument(StringRef Str = "") : Key("String"), Val(Str) {}
|
explicit Argument(StringRef Str = "") : Key("String"), Val(Str) {}
|
||||||
Argument(StringRef Key, Value *V);
|
Argument(StringRef Key, Value *V);
|
||||||
Argument(StringRef Key, Type *T);
|
|
||||||
Argument(StringRef Key, int N);
|
Argument(StringRef Key, int N);
|
||||||
Argument(StringRef Key, unsigned N);
|
Argument(StringRef Key, unsigned N);
|
||||||
Argument(StringRef Key, bool B) : Key(Key), Val(B ? "true" : "false") {}
|
Argument(StringRef Key, bool B) : Key(Key), Val(B ? "true" : "false") {}
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "llvm/IR/PassManager.h"
|
#include "llvm/IR/PassManager.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class OptimizationRemarkEmitter;
|
|
||||||
|
|
||||||
/// A private "module" namespace for types and utilities used by GVN. These
|
/// A private "module" namespace for types and utilities used by GVN. These
|
||||||
/// are implementation details and should not be used by clients.
|
/// are implementation details and should not be used by clients.
|
||||||
|
@ -110,7 +109,6 @@ private:
|
||||||
const TargetLibraryInfo *TLI;
|
const TargetLibraryInfo *TLI;
|
||||||
AssumptionCache *AC;
|
AssumptionCache *AC;
|
||||||
SetVector<BasicBlock *> DeadBlocks;
|
SetVector<BasicBlock *> DeadBlocks;
|
||||||
OptimizationRemarkEmitter *ORE;
|
|
||||||
|
|
||||||
ValueTable VN;
|
ValueTable VN;
|
||||||
|
|
||||||
|
@ -136,7 +134,7 @@ private:
|
||||||
|
|
||||||
bool runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
|
bool runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
|
||||||
const TargetLibraryInfo &RunTLI, AAResults &RunAA,
|
const TargetLibraryInfo &RunTLI, AAResults &RunAA,
|
||||||
MemoryDependenceResults *RunMD, OptimizationRemarkEmitter *ORE);
|
MemoryDependenceResults *RunMD);
|
||||||
|
|
||||||
/// Push a new Value to the LeaderTable onto the list for its value number.
|
/// Push a new Value to the LeaderTable onto the list for its value number.
|
||||||
void addToLeaderTable(uint32_t N, Value *V, const BasicBlock *BB) {
|
void addToLeaderTable(uint32_t N, Value *V, const BasicBlock *BB) {
|
||||||
|
|
|
@ -180,12 +180,6 @@ DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, Value *V)
|
||||||
DLoc = I->getDebugLoc();
|
DLoc = I->getDebugLoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, Type *T)
|
|
||||||
: Key(Key) {
|
|
||||||
raw_string_ostream OS(Val);
|
|
||||||
OS << *T;
|
|
||||||
}
|
|
||||||
|
|
||||||
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, int N)
|
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, int N)
|
||||||
: Key(Key), Val(itostr(N)) {}
|
: Key(Key), Val(itostr(N)) {}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#include "llvm/Analysis/Loads.h"
|
#include "llvm/Analysis/Loads.h"
|
||||||
#include "llvm/Analysis/MemoryBuiltins.h"
|
#include "llvm/Analysis/MemoryBuiltins.h"
|
||||||
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
|
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
|
||||||
#include "llvm/Analysis/OptimizationDiagnosticInfo.h"
|
|
||||||
#include "llvm/Analysis/PHITransAddr.h"
|
#include "llvm/Analysis/PHITransAddr.h"
|
||||||
#include "llvm/Analysis/TargetLibraryInfo.h"
|
#include "llvm/Analysis/TargetLibraryInfo.h"
|
||||||
#include "llvm/Analysis/ValueTracking.h"
|
#include "llvm/Analysis/ValueTracking.h"
|
||||||
|
@ -587,8 +586,7 @@ PreservedAnalyses GVN::run(Function &F, FunctionAnalysisManager &AM) {
|
||||||
auto &TLI = AM.getResult<TargetLibraryAnalysis>(F);
|
auto &TLI = AM.getResult<TargetLibraryAnalysis>(F);
|
||||||
auto &AA = AM.getResult<AAManager>(F);
|
auto &AA = AM.getResult<AAManager>(F);
|
||||||
auto &MemDep = AM.getResult<MemoryDependenceAnalysis>(F);
|
auto &MemDep = AM.getResult<MemoryDependenceAnalysis>(F);
|
||||||
auto &ORE = AM.getResult<OptimizationRemarkEmitterAnalysis>(F);
|
bool Changed = runImpl(F, AC, DT, TLI, AA, &MemDep);
|
||||||
bool Changed = runImpl(F, AC, DT, TLI, AA, &MemDep, &ORE);
|
|
||||||
if (!Changed)
|
if (!Changed)
|
||||||
return PreservedAnalyses::all();
|
return PreservedAnalyses::all();
|
||||||
PreservedAnalyses PA;
|
PreservedAnalyses PA;
|
||||||
|
@ -1584,18 +1582,10 @@ bool GVN::PerformLoadPRE(LoadInst *LI, AvailValInBlkVect &ValuesPerBlock,
|
||||||
if (V->getType()->getScalarType()->isPointerTy())
|
if (V->getType()->getScalarType()->isPointerTy())
|
||||||
MD->invalidateCachedPointerInfo(V);
|
MD->invalidateCachedPointerInfo(V);
|
||||||
markInstructionForDeletion(LI);
|
markInstructionForDeletion(LI);
|
||||||
ORE->emit(OptimizationRemark(DEBUG_TYPE, "LoadPRE", LI)
|
|
||||||
<< "load eliminated by PRE");
|
|
||||||
++NumPRELoad;
|
++NumPRELoad;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reportLoadElim(LoadInst *LI, OptimizationRemarkEmitter *ORE) {
|
|
||||||
ORE->emit(OptimizationRemark(DEBUG_TYPE, "LoadElim", LI)
|
|
||||||
<< "load of type " << ore::NV("Type", LI->getType())
|
|
||||||
<< " eliminated");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Attempt to eliminate a load whose dependencies are
|
/// Attempt to eliminate a load whose dependencies are
|
||||||
/// non-local by performing PHI construction.
|
/// non-local by performing PHI construction.
|
||||||
bool GVN::processNonLocalLoad(LoadInst *LI) {
|
bool GVN::processNonLocalLoad(LoadInst *LI) {
|
||||||
|
@ -1666,7 +1656,6 @@ bool GVN::processNonLocalLoad(LoadInst *LI) {
|
||||||
MD->invalidateCachedPointerInfo(V);
|
MD->invalidateCachedPointerInfo(V);
|
||||||
markInstructionForDeletion(LI);
|
markInstructionForDeletion(LI);
|
||||||
++NumGVNLoad;
|
++NumGVNLoad;
|
||||||
reportLoadElim(LI, ORE);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1813,7 +1802,6 @@ bool GVN::processLoad(LoadInst *L) {
|
||||||
patchAndReplaceAllUsesWith(L, AvailableValue);
|
patchAndReplaceAllUsesWith(L, AvailableValue);
|
||||||
markInstructionForDeletion(L);
|
markInstructionForDeletion(L);
|
||||||
++NumGVNLoad;
|
++NumGVNLoad;
|
||||||
reportLoadElim(L, ORE);
|
|
||||||
// Tell MDA to rexamine the reused pointer since we might have more
|
// Tell MDA to rexamine the reused pointer since we might have more
|
||||||
// information after forwarding it.
|
// information after forwarding it.
|
||||||
if (MD && AvailableValue->getType()->getScalarType()->isPointerTy())
|
if (MD && AvailableValue->getType()->getScalarType()->isPointerTy())
|
||||||
|
@ -2191,8 +2179,7 @@ bool GVN::processInstruction(Instruction *I) {
|
||||||
/// runOnFunction - This is the main transformation entry point for a function.
|
/// runOnFunction - This is the main transformation entry point for a function.
|
||||||
bool GVN::runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
|
bool GVN::runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
|
||||||
const TargetLibraryInfo &RunTLI, AAResults &RunAA,
|
const TargetLibraryInfo &RunTLI, AAResults &RunAA,
|
||||||
MemoryDependenceResults *RunMD,
|
MemoryDependenceResults *RunMD) {
|
||||||
OptimizationRemarkEmitter *RunORE) {
|
|
||||||
AC = &RunAC;
|
AC = &RunAC;
|
||||||
DT = &RunDT;
|
DT = &RunDT;
|
||||||
VN.setDomTree(DT);
|
VN.setDomTree(DT);
|
||||||
|
@ -2200,7 +2187,6 @@ bool GVN::runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
|
||||||
VN.setAliasAnalysis(&RunAA);
|
VN.setAliasAnalysis(&RunAA);
|
||||||
MD = RunMD;
|
MD = RunMD;
|
||||||
VN.setMemDep(MD);
|
VN.setMemDep(MD);
|
||||||
ORE = RunORE;
|
|
||||||
|
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
bool ShouldContinue = true;
|
bool ShouldContinue = true;
|
||||||
|
@ -2713,8 +2699,7 @@ public:
|
||||||
getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(),
|
getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(),
|
||||||
getAnalysis<AAResultsWrapperPass>().getAAResults(),
|
getAnalysis<AAResultsWrapperPass>().getAAResults(),
|
||||||
NoLoads ? nullptr
|
NoLoads ? nullptr
|
||||||
: &getAnalysis<MemoryDependenceWrapperPass>().getMemDep(),
|
: &getAnalysis<MemoryDependenceWrapperPass>().getMemDep());
|
||||||
&getAnalysis<OptimizationRemarkEmitterWrapperPass>().getORE());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||||
|
@ -2727,7 +2712,6 @@ public:
|
||||||
|
|
||||||
AU.addPreserved<DominatorTreeWrapperPass>();
|
AU.addPreserved<DominatorTreeWrapperPass>();
|
||||||
AU.addPreserved<GlobalsAAWrapperPass>();
|
AU.addPreserved<GlobalsAAWrapperPass>();
|
||||||
AU.addRequired<OptimizationRemarkEmitterWrapperPass>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -2749,5 +2733,4 @@ INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
|
||||||
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
|
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
|
||||||
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
|
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
|
||||||
INITIALIZE_PASS_DEPENDENCY(GlobalsAAWrapperPass)
|
INITIALIZE_PASS_DEPENDENCY(GlobalsAAWrapperPass)
|
||||||
INITIALIZE_PASS_DEPENDENCY(OptimizationRemarkEmitterWrapperPass)
|
|
||||||
INITIALIZE_PASS_END(GVNLegacyPass, "gvn", "Global Value Numbering", false, false)
|
INITIALIZE_PASS_END(GVNLegacyPass, "gvn", "Global Value Numbering", false, false)
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
; RUN: opt < %s -gvn -o /dev/null -pass-remarks-output=%t -S -pass-remarks=gvn \
|
|
||||||
; RUN: 2>&1 | FileCheck %s
|
|
||||||
; RUN: cat %t | FileCheck -check-prefix=YAML %s
|
|
||||||
|
|
||||||
; CHECK: remark: <unknown>:0:0: load of type i32 eliminated{{$}}
|
|
||||||
; CHECK-NEXT: remark: <unknown>:0:0: load of type i32 eliminated{{$}}
|
|
||||||
; CHECK-NEXT: remark: <unknown>:0:0: load of type i32 eliminated{{$}}
|
|
||||||
; CHECK-NOT: remark:
|
|
||||||
|
|
||||||
; YAML: --- !Passed
|
|
||||||
; YAML-NEXT: Pass: gvn
|
|
||||||
; YAML-NEXT: Name: LoadElim
|
|
||||||
; YAML-NEXT: Function: arg
|
|
||||||
; YAML-NEXT: Args:
|
|
||||||
; YAML-NEXT: - String: 'load of type '
|
|
||||||
; YAML-NEXT: - Type: i32
|
|
||||||
; YAML-NEXT: - String: ' eliminated'
|
|
||||||
; YAML-NEXT: ...
|
|
||||||
; YAML-NEXT: --- !Passed
|
|
||||||
; YAML-NEXT: Pass: gvn
|
|
||||||
; YAML-NEXT: Name: LoadElim
|
|
||||||
; YAML-NEXT: Function: const
|
|
||||||
; YAML-NEXT: Args:
|
|
||||||
; YAML-NEXT: - String: 'load of type '
|
|
||||||
; YAML-NEXT: - Type: i32
|
|
||||||
; YAML-NEXT: - String: ' eliminated'
|
|
||||||
; YAML-NEXT: ...
|
|
||||||
; YAML-NEXT: --- !Passed
|
|
||||||
; YAML-NEXT: Pass: gvn
|
|
||||||
; YAML-NEXT: Name: LoadElim
|
|
||||||
; YAML-NEXT: Function: inst
|
|
||||||
; YAML-NEXT: Args:
|
|
||||||
; YAML-NEXT: - String: 'load of type '
|
|
||||||
; YAML-NEXT: - Type: i32
|
|
||||||
; YAML-NEXT: - String: ' eliminated'
|
|
||||||
; YAML-NEXT: ...
|
|
||||||
|
|
||||||
|
|
||||||
define i32 @arg(i32* %p, i32 %i) {
|
|
||||||
entry:
|
|
||||||
store i32 %i, i32* %p
|
|
||||||
%load = load i32, i32* %p
|
|
||||||
ret i32 %load
|
|
||||||
}
|
|
||||||
|
|
||||||
define i32 @const(i32* %p) {
|
|
||||||
entry:
|
|
||||||
store i32 4, i32* %p
|
|
||||||
%load = load i32, i32* %p
|
|
||||||
ret i32 %load
|
|
||||||
}
|
|
||||||
|
|
||||||
define i32 @inst(i32* %p) {
|
|
||||||
entry:
|
|
||||||
%load1 = load i32, i32* %p
|
|
||||||
%load = load i32, i32* %p
|
|
||||||
%add = add i32 %load1, %load
|
|
||||||
ret i32 %add
|
|
||||||
}
|
|
Loading…
Reference in New Issue