[cfe-dev] [RFC] Clearing Clang AST before running backend optimizations/codegen to save memory

Arthur Eubanks via cfe-dev cfe-dev at lists.llvm.org
Tue Sep 21 16:25:15 PDT 2021

> But yeah - we do have the https://reviews.llvm.org/D4234
> "LocTrackingOnly" mode which looks like it could be used for Rpass
> diagnostics, for instance. (& removing use of the AST from the LLVM
> diagnostic system might help make it more consistent behavior even when
> doing LTO or other separations between AST parsing and IR transformations)

Thanks for the pointer to that. I was getting confused because "-Rpass=foo"
was triggering LocTrackingOnly but "-Rpass" wasn't, which I've fixed. So
-Rpass is no longer a concern.

So we just have to worry about non-Rpass diagnostics, e.g.
-fwarn-stack-size. All of these only use the function name for source
locations. We can either just give up and have worse diagnostics for these,
meaning no demangling and no source location per diagnostic, or create a
side table of these right before codegen as you suggested. For now I'll go
with creating a side table to preserve the status quo, hopefully its
construction runtime is not measurable.

Inline asm is special in that it carries around a source location token
even in the IR, so we don't need to go through the AST to find a source
location which is nice.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210921/1bd4bfb6/attachment.html>

More information about the cfe-dev mailing list