[PATCH] D111105: [clang] Add option to clear AST memory before running LLVM passes

Arthur Eubanks via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 6 13:38:23 PDT 2021


aeubanks added inline comments.


================
Comment at: clang/test/Misc/clear-ast-before-backend.c:2-3
+// RUN: %clang -target x86_64-linux-gnu -c -Xclang -clear-ast-before-backend %s -S
+// RUN: %clang -target x86_64-linux-gnu -c -Xclang -clear-ast-before-backend %s -S -### 2>&1 | FileCheck %s
+// CHECK: "-clear-ast-before-backend"
----------------
dblaikie wrote:
> dblaikie wrote:
> > This is a driver test, but not a very interesting one - it tests that -Xclang arguments are passed directyl to cc1, which is probably tested elsewhere already?
> > 
> > I'm not sure there's anything we could really test with the first RUN line - though since it's not a Driver test and doesn't need to be a Driver test - it should probably just test cc1 -clear-ast-before-backend directly rather than going through the driver+-Xclang
> Might be worth fleshing this out somehow to observe some behavior? I'm not sure exactly how - not like we'd generally test other memory optimizations we might make without a flag to opt into them. But perhaps a simple Hello World, maybe with some optimizations applied (so making this one of those rare "actually check it going through some optimizations" - I guess ever -O0 with an always_inline function or the like to demonstrate that the optimizations were applied, etc)
> 
> Can't think of much else that wouldn't just be obnoxious in terms of memory usage - oh, unless there's some way to set an artificially low memory limit (some other tests might do this - clang/test/PCH/leakfiles.test puts a low ulimit for instance - some lldb and compiler-rt tests also set ulimits of various kinds to observe failures). An A/B test - showing some modest example hitting the memory limit without the flag, but passing with the flag, could be nice to have.
This is similar to perf testing which we don't really have in tree tests for. Typically these things are mostly monitored separately (e.g. llvm-compile-time-tracker).
As for making sure that optimizations still happen, `-emit-obj` requires that. If that isn't happening with `-emit-obj` then something is very wrong. I'll add a function and make this -O1 though so we test more passes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111105



More information about the cfe-commits mailing list