[clang] ab41a1c - [clang] Disable -clear-ast-before-backend with -print-stats

Arthur Eubanks via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 18 08:43:51 PDT 2021


Author: Arthur Eubanks
Date: 2021-10-18T08:43:32-07:00
New Revision: ab41a1c50558f23e5b6aa7a3b68825f9b4a71fe7

URL: https://github.com/llvm/llvm-project/commit/ab41a1c50558f23e5b6aa7a3b68825f9b4a71fe7
DIFF: https://github.com/llvm/llvm-project/commit/ab41a1c50558f23e5b6aa7a3b68825f9b4a71fe7.diff

LOG: [clang] Disable -clear-ast-before-backend with -print-stats

We still need access to various things in the ASTContext when printing stats.

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

Added: 
    

Modified: 
    clang/lib/Frontend/CompilerInvocation.cpp
    clang/test/Misc/clear-ast-before-backend.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 7360e6b40d69a..410702d51ed2a 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -454,6 +454,8 @@ static bool FixupInvocation(CompilerInvocation &Invocation,
   CodeGenOpts.XRayAlwaysEmitTypedEvents = LangOpts.XRayAlwaysEmitTypedEvents;
   CodeGenOpts.DisableFree = FrontendOpts.DisableFree;
   FrontendOpts.GenerateGlobalModuleIndex = FrontendOpts.UseGlobalModuleIndex;
+  if (FrontendOpts.ShowStats)
+    CodeGenOpts.ClearASTBeforeBackend = false;
   LangOpts.SanitizeCoverage = CodeGenOpts.hasSanitizeCoverage();
   LangOpts.ForceEmitVTables = CodeGenOpts.ForceEmitVTables;
   LangOpts.SpeculativeLoadHardening = CodeGenOpts.SpeculativeLoadHardening;

diff  --git a/clang/test/Misc/clear-ast-before-backend.c b/clang/test/Misc/clear-ast-before-backend.c
index 8e46d3bcb0682..88809b86f866e 100644
--- a/clang/test/Misc/clear-ast-before-backend.c
+++ b/clang/test/Misc/clear-ast-before-backend.c
@@ -1,3 +1,9 @@
 // RUN: %clang_cc1 -clear-ast-before-backend %s -emit-obj -o /dev/null -O1
+// RUN: %clang_cc1 -clear-ast-before-backend %s -emit-obj -o /dev/null -print-stats 2>&1 | FileCheck %s
+
+// CHECK: *** Decl Stats:
+// CHECK: {{.*}} decls total
+// CHECK: 1 Function decls
+// CHECK: Total bytes =
 
 void f() {}


        


More information about the cfe-commits mailing list