-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch fixes https://bugs.llvm.org/show_bug.cgi?id=32352
It enables OptimizationRemarkEmitter::allowExtraAnalysis and MachineOptimizationRemarkEmitter::allowExtraAnalysis to return true not only for -fsave-optimization-record but when specific remarks are requested with command line options. The diagnostic handler used to be callback now this patch adds a class DiagnosticHandler. It has virtual method to provide custom diagnostic handler and methods to control which particular remarks are enabled. However LLVM-C API users can still provide callback function for diagnostic handler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313382 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
1 parent
d3108e5
commit bb8204f
Showing
23 changed files
with
417 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//===- DiagnosticHandler.h - DiagnosticHandler class for LLVM -*- C++ ---*-===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// Base DiagnosticHandler class declaration. Derive from this class to provide | ||
// custom diagnostic reporting. | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "llvm/ADT/StringRef.h" | ||
|
||
namespace llvm { | ||
class DiagnosticInfo; | ||
|
||
/// \brief This is the base class for diagnostic handling in LLVM. | ||
/// The handleDiagnostics method must be overriden by the subclasses to handle | ||
/// diagnostic. The *RemarkEnabled methods can be overriden to control | ||
/// which remarks are enabled. | ||
struct DiagnosticHandler { | ||
void *DiagnosticContext = nullptr; | ||
DiagnosticHandler(void *DiagContext = nullptr) | ||
: DiagnosticContext(DiagContext) {} | ||
virtual ~DiagnosticHandler() = default; | ||
|
||
using DiagnosticHandlerTy = void (*)(const DiagnosticInfo &DI, void *Context); | ||
|
||
/// DiagHandlerCallback is settable from the C API and base implementation | ||
/// of DiagnosticHandler will call it from handleDiagnostics(). Any derived | ||
/// class of DiagnosticHandler should not use callback but | ||
/// implement handleDiagnostics(). | ||
DiagnosticHandlerTy DiagHandlerCallback = nullptr; | ||
|
||
/// Override handleDiagnostics to provide custom implementation. | ||
/// Return true if it handles diagnostics reporting properly otherwise | ||
/// return false to make LLVMContext::diagnose() to print the message | ||
/// with a prefix based on the severity. | ||
virtual bool handleDiagnostics(const DiagnosticInfo &DI) { | ||
if (DiagHandlerCallback) { | ||
DiagHandlerCallback(DI, DiagnosticContext); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/// Return true if analysis remarks are enabled, override | ||
/// to provide different implementation. | ||
virtual bool isAnalysisRemarkEnabled(StringRef PassName) const; | ||
|
||
/// Return true if missed optimization remarks are enabled, override | ||
/// to provide different implementation. | ||
virtual bool isMissedOptRemarkEnabled(StringRef PassName) const; | ||
|
||
/// Return true if passed optimization remarks are enabled, override | ||
/// to provide different implementation. | ||
virtual bool isPassedOptRemarkEnabled(StringRef PassName) const; | ||
|
||
/// Return true if any type of remarks are enabled. | ||
bool isAnyRemarkEnabled(StringRef PassName) const { | ||
return (isMissedOptRemarkEnabled(PassName) || | ||
isPassedOptRemarkEnabled(PassName) || | ||
isAnalysisRemarkEnabled(PassName)); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.