[PATCH] D37196: [Clang] Bug 32352 - Provide a way for OptimizationRemarkEmitter::allowExtraAnalysis to check if (specific) remarks are enabled
Vivek Pandya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 27 08:59:32 PDT 2017
vivekvpandya created this revision.
Herald added a subscriber: fhahn.
Clang changes related to Bug 32352 - Provide a way for OptimizationRemarkEmitter::allowExtraAnalysis to check if (specific) remarks are enabled
https://reviews.llvm.org/D37196
Files:
lib/CodeGen/CodeGenAction.cpp
Index: lib/CodeGen/CodeGenAction.cpp
===================================================================
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -224,10 +224,10 @@
void *OldContext = Ctx.getInlineAsmDiagnosticContext();
Ctx.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, this);
- LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler =
- Ctx.getDiagnosticHandler();
- void *OldDiagnosticContext = Ctx.getDiagnosticContext();
- Ctx.setDiagnosticHandler(DiagnosticHandler, this);
+ //LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler =
+ // Ctx.getDiagnosticHandler();
+ // void *OldDiagnosticContext = Ctx.getDiagnosticContext();
+ // Ctx.setDiagnosticHandler(DiagnosticHandler, this);
Ctx.setDiagnosticsHotnessRequested(CodeGenOpts.DiagnosticsWithHotness);
if (CodeGenOpts.DiagnosticsHotnessThreshold != 0)
Ctx.setDiagnosticsHotnessThreshold(
@@ -264,7 +264,7 @@
Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
- Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext);
+ //Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext);
if (OptRecordFile)
OptRecordFile->keep();
@@ -756,6 +756,30 @@
}
#undef ComputeDiagID
+class ClangDiagnosticHandler final : public DiagnosticHandler {
+ public:
+ ClangDiagnosticHandler(const CodeGenOptions &CGOpts) : CodeGenOpts(CGOpts) {
+ }
+ bool handleDiagnostics(const DiagnosticInfo &DI, void *Context) {
+ ((BackendConsumer *)Context)->DiagnosticHandlerImpl(DI);
+ return true;
+ }
+ bool isAnalysisRemarkEnable(const std::string &PassName) {
+ return (CodeGenOpts.OptimizationRemarkAnalysisPattern
+ && CodeGenOpts.OptimizationRemarkAnalysisPattern->match(PassName));
+ }
+ bool isMissedOptRemarkEnable(const std::string &PassName) {
+ return (CodeGenOpts.OptimizationRemarkMissedPattern
+ && CodeGenOpts.OptimizationRemarkMissedPattern->match(PassName));
+ }
+ bool isPassedOptRemarkEnable(const std::string &PassName) {
+ return (CodeGenOpts.OptimizationRemarkPattern
+ && CodeGenOpts.OptimizationRemarkPattern->match(PassName));
+ }
+ private:
+ const CodeGenOptions &CodeGenOpts;
+};
+
CodeGenAction::CodeGenAction(unsigned _Act, LLVMContext *_VMContext)
: Act(_Act), VMContext(_VMContext ? _VMContext : new LLVMContext),
OwnsVMContext(!_VMContext) {}
@@ -853,7 +877,7 @@
CI.getLangOpts(), CI.getFrontendOpts().ShowTimers, InFile,
std::move(LinkModules), std::move(OS), *VMContext, CoverageInfo));
BEConsumer = Result.get();
-
+ VMContext->setDiagnosticHandler(llvm::make_unique<ClangDiagnosticHandler>(CI.getCodeGenOpts()), Result.get());
// Enable generating macro debug info only when debug info is not disabled and
// also macro debug info is enabled.
if (CI.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37196.112832.patch
Type: text/x-patch
Size: 2980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170827/607af5c3/attachment-0001.bin>
More information about the cfe-commits
mailing list