From 91d4d93f94c09fbb33da6dd1d646da2a8cd49149 Mon Sep 17 00:00:00 2001 From: Adam Nemet Date: Tue, 29 Nov 2016 18:32:00 +0000 Subject: [PATCH] Revert "[GVN, OptDiag] Include the value that is forwarded in load elimination" This reverts commit r288047. Trying to see if the revert fixes a compiler crash during a stage2 LTO build with a GVN backtrace. llvm-svn: 288178 --- .../llvm/Analysis/OptimizationDiagnosticInfo.h | 1 - llvm/include/llvm/IR/DiagnosticInfo.h | 12 ----------- llvm/lib/IR/DiagnosticInfo.cpp | 24 ++-------------------- llvm/lib/Transforms/Scalar/GVN.cpp | 13 +++++------- llvm/test/Transforms/GVN/opt-remarks.ll | 6 ------ 5 files changed, 7 insertions(+), 49 deletions(-) diff --git a/llvm/include/llvm/Analysis/OptimizationDiagnosticInfo.h b/llvm/include/llvm/Analysis/OptimizationDiagnosticInfo.h index fa0b3eed..b065336 100644 --- a/llvm/include/llvm/Analysis/OptimizationDiagnosticInfo.h +++ b/llvm/include/llvm/Analysis/OptimizationDiagnosticInfo.h @@ -223,7 +223,6 @@ private: namespace ore { using NV = DiagnosticInfoOptimizationBase::Argument; using setIsVerbose = DiagnosticInfoOptimizationBase::setIsVerbose; -using setExtraArgs = DiagnosticInfoOptimizationBase::setExtraArgs; } /// OptimizationRemarkEmitter legacy analysis pass diff --git a/llvm/include/llvm/IR/DiagnosticInfo.h b/llvm/include/llvm/IR/DiagnosticInfo.h index a93c180..e739dfb 100644 --- a/llvm/include/llvm/IR/DiagnosticInfo.h +++ b/llvm/include/llvm/IR/DiagnosticInfo.h @@ -382,12 +382,6 @@ public: /// \brief Used to set IsVerbose via the stream interface. struct setIsVerbose {}; - /// \brief When an instance of this is inserted into the stream, the arguments - /// following will not appear in the remark printed in the compiler output - /// (-Rpass) but only in the optimization record file - /// (-fsave-optimization-record). - struct setExtraArgs {}; - /// \brief Used in the streaming interface as the general argument type. It /// internally converts everything into a key-value pair. struct Argument { @@ -458,7 +452,6 @@ public: DiagnosticInfoOptimizationBase &operator<<(StringRef S); DiagnosticInfoOptimizationBase &operator<<(Argument A); DiagnosticInfoOptimizationBase &operator<<(setIsVerbose V); - DiagnosticInfoOptimizationBase &operator<<(setExtraArgs EA); /// \see DiagnosticInfo::print. void print(DiagnosticPrinter &DP) const override; @@ -508,11 +501,6 @@ private: /// The remark is expected to be noisy. bool IsVerbose = false; - /// \brief If positive, the index of the first argument that only appear in - /// the optimization records and not in the remark printed in the compiler - /// output. - int FirstExtraArgIndex = -1; - friend struct yaml::MappingTraits; }; diff --git a/llvm/lib/IR/DiagnosticInfo.cpp b/llvm/lib/IR/DiagnosticInfo.cpp index ea71fde..6a3fdcf 100644 --- a/llvm/lib/IR/DiagnosticInfo.cpp +++ b/llvm/lib/IR/DiagnosticInfo.cpp @@ -170,25 +170,14 @@ const std::string DiagnosticInfoWithDebugLocBase::getLocationStr() const { getLocation(&Filename, &Line, &Column); return (Filename + ":" + Twine(Line) + ":" + Twine(Column)).str(); } - DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, Value *V) - : Key(Key) { + : Key(Key), Val(GlobalValue::getRealLinkageName(V->getName())) { if (auto *F = dyn_cast(V)) { if (DISubprogram *SP = F->getSubprogram()) DLoc = DebugLoc::get(SP->getScopeLine(), 0, SP); } else if (auto *I = dyn_cast(V)) DLoc = I->getDebugLoc(); - - // Only include names that correspond to user variables. FIXME: we should use - // debug info if available to get the name of the user variable. - if (isa(V) || isa(V)) - Val = GlobalValue::getRealLinkageName(V->getName()); - else if (isa(V)) { - raw_string_ostream OS(Val); - V->printAsOperand(OS, /*PrintType=*/false); - } else if (auto *I = dyn_cast(V)) - Val = I->getOpcodeName(); } DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, Type *T) @@ -370,19 +359,10 @@ operator<<(setIsVerbose V) { return *this; } -DiagnosticInfoOptimizationBase &DiagnosticInfoOptimizationBase:: -operator<<(setExtraArgs EA) { - FirstExtraArgIndex = Args.size(); - return *this; -} - std::string DiagnosticInfoOptimizationBase::getMsg() const { std::string Str; raw_string_ostream OS(Str); - for (const DiagnosticInfoOptimizationBase::Argument &Arg : - make_range(Args.begin(), FirstExtraArgIndex == -1 - ? Args.end() - : Args.begin() + FirstExtraArgIndex)) + for (const DiagnosticInfoOptimizationBase::Argument &Arg : Args) OS << Arg.Val; return OS.str(); } diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 4f66c5d..83a7efe 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -1590,13 +1590,10 @@ bool GVN::PerformLoadPRE(LoadInst *LI, AvailValInBlkVect &ValuesPerBlock, return true; } -static void reportLoadElim(LoadInst *LI, Value *AvailableValue, - OptimizationRemarkEmitter *ORE) { - using namespace ore; +static void reportLoadElim(LoadInst *LI, OptimizationRemarkEmitter *ORE) { ORE->emit(OptimizationRemark(DEBUG_TYPE, "LoadElim", LI) - << "load of type " << NV("Type", LI->getType()) << " eliminated" - << setExtraArgs() << " in favor of " - << NV("InfavorOfValue", AvailableValue)); + << "load of type " << ore::NV("Type", LI->getType()) + << " eliminated"); } /// Attempt to eliminate a load whose dependencies are @@ -1669,7 +1666,7 @@ bool GVN::processNonLocalLoad(LoadInst *LI) { MD->invalidateCachedPointerInfo(V); markInstructionForDeletion(LI); ++NumGVNLoad; - reportLoadElim(LI, V, ORE); + reportLoadElim(LI, ORE); return true; } @@ -1816,7 +1813,7 @@ bool GVN::processLoad(LoadInst *L) { patchAndReplaceAllUsesWith(L, AvailableValue); markInstructionForDeletion(L); ++NumGVNLoad; - reportLoadElim(L, AvailableValue, ORE); + reportLoadElim(L, ORE); // Tell MDA to rexamine the reused pointer since we might have more // information after forwarding it. if (MD && AvailableValue->getType()->getScalarType()->isPointerTy()) diff --git a/llvm/test/Transforms/GVN/opt-remarks.ll b/llvm/test/Transforms/GVN/opt-remarks.ll index 14c1fef..c451833 100644 --- a/llvm/test/Transforms/GVN/opt-remarks.ll +++ b/llvm/test/Transforms/GVN/opt-remarks.ll @@ -15,8 +15,6 @@ ; YAML-NEXT: - String: 'load of type ' ; YAML-NEXT: - Type: i32 ; YAML-NEXT: - String: ' eliminated' -; YAML-NEXT: - String: ' in favor of ' -; YAML-NEXT: - InfavorOfValue: i ; YAML-NEXT: ... ; YAML-NEXT: --- !Passed ; YAML-NEXT: Pass: gvn @@ -26,8 +24,6 @@ ; YAML-NEXT: - String: 'load of type ' ; YAML-NEXT: - Type: i32 ; YAML-NEXT: - String: ' eliminated' -; YAML-NEXT: - String: ' in favor of ' -; YAML-NEXT: - InfavorOfValue: '4' ; YAML-NEXT: ... ; YAML-NEXT: --- !Passed ; YAML-NEXT: Pass: gvn @@ -37,8 +33,6 @@ ; YAML-NEXT: - String: 'load of type ' ; YAML-NEXT: - Type: i32 ; YAML-NEXT: - String: ' eliminated' -; YAML-NEXT: - String: ' in favor of ' -; YAML-NEXT: - InfavorOfValue: load ; YAML-NEXT: ... -- 2.7.4