[PATCH] D141451: [clang] report inlining decisions with -Wattribute-{warning|error}

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 11 16:03:04 PST 2023


nickdesaulniers added a comment.

In D141451#4045414 <https://reviews.llvm.org/D141451#4045414>, @efriedma wrote:

> There are two different approaches we use for getting source locations for diagnostics coming out of the backend; either embedding clang SourceLocations into IR, or trying to translate DWARF locations.  The advantage of using clang SourceLocations is that we never lose any fidelity, even in complex cases involving the preprocessor, and the compiler doesn't have to spend time generating complete DWARF info.  The advantage of DWARF, of course, is that it's existing, mature infrastructure.
>
> We use clang SourceLocations for inline asm and for the warning/error attributes, we use DWARF for optimization remarks.

Yep.

> There's probably some argument for using DWARF here.

Yeah, my thoughts too. Though if we don't compiler with `-g`, does that mean if I use DILocation (or w/e metadata for "inlining occurred") that .debug_info will get emitted, even if the user didn't ask for it?  If not, I can probably switch everything to use DILocation.

> ----
>
> Am I reading the correctly, that currently the inlining notes don't have source locations?  That's not very friendly (particularly for display in IDEs).

Correct; we pessimistically don't record the srcloc of every call ever. We'd need to do that to support line info on the inlining notes. That seems very expensive.

Perhaps we only show these notes if debug info is enabled (`-g`) where we can then use DiagnosticInfoWithLocationBase? (Do we have precendent for warnings that are better with DebugInfo enabled?)

That said, the information provided is A MASSIVE LEAP FORWARD in debugging these errors (mostly observed in FORTIFY_SOURCE implementations in the Linux kernel) by simply providing the call chain, even without line/col numbers.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141451/new/

https://reviews.llvm.org/D141451



More information about the cfe-commits mailing list