[PATCH] D72523: [remark][diagnostics] Using clang diagnostic handler for IR input files

Rong Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 10 10:22:15 PST 2020


xur created this revision.
xur added a reviewer: tejohnson.
Herald added subscribers: dexonsmith, steven_wu, hiraditya, mehdi_amini.

For IR input files, we currently use LLVM diagnostic handler even the
compilation is from clang. As a result, we are not able to use -Rpass
to get the transformation reports. Some warnings are not handled
properly either: We found many mysterious warnings in our ThinLTO backend
compilations in SamplePGO and CSPGO. An example of the warning:

warning: net/proto2/public/metadata_lite.h:51:21: 0.02% (1 / 4999)

This turns out to be a warning by Wmisexpect, which is supposed to be
filtered out by default. But since the filter is in clang's
diagnostic hander, we emit these incomplete warnings from LLVM's
diagnostic handler.

This patch uses clang diagnostic handler for IR input files. We create
a fake backendconsumer just to install the diagnostic handler.
The location information is tightly coupled with the sourcemanager which
is not available in IR input files. I just prepend the location from DebugLoc
to the warning/remark messages. I think this is much simpler way than
to pass DebugLoc to DiagnosticEngine (I tried this approach, but it seemed to
require much more extensive changes).

With this change, we will have proper handling of all the warnings and we can
use -Rpass* options in IR input files compilation.
Also note that with is patch, LLVM's diagnostic options, like
"-mllvm -pass-remarks=*", are no longer be able to get optimization remarks.


https://reviews.llvm.org/D72523

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGen/thinlto-clang-diagnostic-handler-in-be.c
  clang/test/CodeGen/thinlto-diagnostic-handler-remarks-with-hotness.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72523.237376.patch
Type: text/x-patch
Size: 8321 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200110/ee73c18f/attachment.bin>


More information about the cfe-commits mailing list