[PATCH] D150282: [Driver] -ftime-trace: derive trace file names from -o and -dumpdir
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 10 11:10:23 PDT 2023
MaskRay created this revision.
MaskRay added reviewers: clang, jamieschmeiser, Whitney, Maetveis, dblaikie, scott.linder.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Inspired by D133662 <https://reviews.llvm.org/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 <https://reviews.llvm.org/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/
a f/a.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.
This patch doesn't attempt to change offloading behavior (D133662 <https://reviews.llvm.org/D133662>).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D150282
Files:
clang/include/clang/Driver/Compilation.h
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/FrontendOptions.h
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/ftime-trace.cpp
clang/tools/driver/cc1_main.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150282.521044.patch
Type: text/x-patch
Size: 9938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230510/80852939/attachment-0001.bin>
More information about the cfe-commits
mailing list