[all-commits] [llvm/llvm-project] d0a5f6: [clang] Support -clear-ast-before-backend without ...

aeubanks via All-commits all-commits at lists.llvm.org
Thu Oct 14 13:46:26 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d0a5f61c4f6fccec87fd5207e3fcd9502dd59854
      https://github.com/llvm/llvm-project/commit/d0a5f61c4f6fccec87fd5207e3fcd9502dd59854
  Author: Arthur Eubanks <aeubanks at google.com>
  Date:   2021-10-14 (Thu, 14 Oct 2021)

  Changed paths:
    M clang/include/clang/AST/ASTContext.h
    M clang/lib/AST/ASTContext.cpp
    M clang/lib/AST/DeclBase.cpp
    M clang/lib/CodeGen/CodeGenAction.cpp

  Log Message:
  -----------
  [clang] Support -clear-ast-before-backend without -disable-free

Previously without -disable-free, -clear-ast-before-backend would crash in ~ASTContext() due to various reasons.
This works around that by doing a lot of the cleanup ahead of the destructor so that the destructor doesn't actually do any manual cleanup if we've already cleaned up beforehand.

This actually does save a measurable amount of memory with -clear-ast-before-backend, although at an almost unnoticeable runtime cost:
https://llvm-compile-time-tracker.com/compare.php?from=5d755b32f2775b9219f6d6e2feda5e1417dc993b&to=58ef1c7ad7e2ad45f9c97597905a8cf05a26258c&stat=max-rss

Previously we weren't doing any cleanup with -disable-free, so I tried measuring the impact of always doing the cleanup and didn't measure anything noticeable on llvm-compile-time-tracker.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D111767




More information about the All-commits mailing list