aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/StringRef.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2023-05-12 10:46:06 -0700
committerFangrui Song <i@maskray.me>2023-05-12 10:46:06 -0700
commit49b87b05726b4395503230c3d400f93c626e6dce (patch)
treee22d50a86cd372c4639a260233ba3713fddc9352 /llvm/lib/Support/StringRef.cpp
parentb700a90cc0aa08252d764b1f7da67bd300469a76 (diff)
downloadllvm-49b87b05726b4395503230c3d400f93c626e6dce.zip
llvm-49b87b05726b4395503230c3d400f93c626e6dce.tar.gz
llvm-49b87b05726b4395503230c3d400f93c626e6dce.tar.bz2
[Driver] -ftime-trace: derive trace file names from -o and -dumpdir
Inspired by D133662. Close https://github.com/llvm/llvm-project/issues/57285 When -ftime-trace is specified and the driver performs both compilation and linking phases, the trace files are currently placed in the temporary directory (/tmp by default on *NIX). A more sensible behavior would be to derive the trace file names from the -o option, similar to how GCC derives auxiliary and dump file names. Use -dumpdir (D149193) to implement the -gsplit-dwarf like behavior. The following script demonstrates the time trace filenames. ``` #!/bin/sh -e PATH=/tmp/Rel/bin:$PATH # adapt according to your build directory mkdir -p d e f echo 'int main() {}' > d/a.c echo > d/b.c a() { rm $1 || exit 1; } clang -ftime-trace d/a.c d/b.c # previously /tmp/[ab]-*.json a a-a.json; a a-b.json clang -ftime-trace d/a.c d/b.c -o e/x # previously /tmp/[ab]-*.json a e/x-a.json; a e/x-b.json clang -ftime-trace d/a.c d/b.c -o e/x -dumpdir f/ a f/a.json; a f/b.json clang -ftime-trace=f d/a.c d/b.c -o e/x a f/a-*.json; a f/b-*.json clang -c -ftime-trace d/a.c d/b.c a a.json b.json clang -c -ftime-trace=f d/a.c d/b.c a f/a.json f/b.json clang -c -ftime-trace d/a.c -o e/xa.o a e/xa.json clang -c -ftime-trace d/a.c -o e/xa.o -dumpdir f/g a f/ga.json ``` The driver checks `-ftime-trace` and `-ftime-trace=`, infers the trace file name, and passes `-ftime-trace=` to cc1. The `-ftime-trace` cc1 option is removed. With offloading, previously `-ftime-trace` is passed to all offloading actions, causing the same trace file to be overwritten by host and offloading actions. This patch doesn't attempt to support offloading (D133662), but makes a sensible change (`OffloadingPrefix.empty()`) to ensure we don't overwrite the trace file. Minor behavior differences: the trace file is now a result file, which will be removed upon an error. -ftime-trace-granularity=0, like -ftime-trace, can now cause a -Wunused-command-line-argument warning. Reviewed By: Maetveis Differential Revision: https://reviews.llvm.org/D150282
Diffstat (limited to 'llvm/lib/Support/StringRef.cpp')
0 files changed, 0 insertions, 0 deletions