Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Driver / ftime-trace.cpp
blob5fe63de915a7184e6df854f26e0e19efc490e168
1 // RUN: rm -rf %t && mkdir -p %t && cd %t
2 // RUN: %clangxx -S -no-canonical-prefixes -ftime-trace -ftime-trace-granularity=0 -o out %s
3 // RUN: cat out.json \
4 // RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
5 // RUN: | FileCheck %s
6 // RUN: %clangxx -S -no-canonical-prefixes -ftime-trace=new-name.json -ftime-trace-granularity=0 -o out %s
7 // RUN: cat new-name.json \
8 // RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
9 // RUN: | FileCheck %s
10 // RUN: mkdir dir1 dir2
11 // RUN: %clangxx -S -no-canonical-prefixes -ftime-trace=dir1 -ftime-trace-granularity=0 -o out %s
12 // RUN: cat dir1/out.json \
13 // RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
14 // RUN: | FileCheck %s
15 // RUN: %clangxx -S -no-canonical-prefixes -ftime-trace=dir2/ -ftime-trace-granularity=0 -o out %s
16 // RUN: cat dir2/out.json \
17 // RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
18 // RUN: | FileCheck %s
20 // CHECK: "beginningOfTime": {{[0-9]{16},}}
21 // CHECK-NEXT: "traceEvents": [
22 // CHECK: "args":
23 // CHECK: "detail":
24 // CHECK: "dur":
25 // CHECK: "name":
26 // CHECK-NEXT: "ph":
27 // CHECK-NEXT: "pid":
28 // CHECK-NEXT: "tid":
29 // CHECK-NEXT: "ts":
30 // CHECK: "name": "{{clang|llvm}}{{.*}}"
31 // CHECK: "name": "process_name"
32 // CHECK: "name": "thread_name"
34 // RUN: mkdir d e f && cp %s d/a.cpp && touch d/b.c
36 /// TODO: Support -fno-integrated-as.
37 // RUN: %clang -### -c -ftime-trace -ftime-trace-granularity=0 -fintegrated-as d/a.cpp -o e/a.o 2>&1 | FileCheck %s --check-prefix=COMPILE1
38 // COMPILE1: -cc1{{.*}} "-ftime-trace=e/a.json" "-ftime-trace-granularity=0"
40 // RUN: %clang -### -c -ftime-trace -ftime-trace-granularity=0 d/a.cpp d/b.c -dumpdir f/ 2>&1 | FileCheck %s --check-prefix=COMPILE2
41 // COMPILE2: -cc1{{.*}} "-ftime-trace=f/a.json" "-ftime-trace-granularity=0"
42 // COMPILE2: -cc1{{.*}} "-ftime-trace=f/b.json" "-ftime-trace-granularity=0"
44 /// -o specifies the link output. Create ${output}-${basename}.json.
45 // RUN: %clang -### -ftime-trace -ftime-trace-granularity=0 d/a.cpp d/b.c -o e/x 2>&1 | FileCheck %s --check-prefix=LINK1
46 // LINK1: -cc1{{.*}} "-ftime-trace=e/x-a.json" "-ftime-trace-granularity=0"
47 // LINK1: -cc1{{.*}} "-ftime-trace=e/x-b.json" "-ftime-trace-granularity=0"
49 /// -dumpdir is f/g, not ending with a path separator. We create f/g${basename}.json.
50 // RUN: %clang -### -ftime-trace -ftime-trace-granularity=0 d/a.cpp d/b.c -o e/x -dumpdir f/g 2>&1 | FileCheck %s --check-prefix=LINK2
51 // LINK2: -cc1{{.*}} "-ftime-trace=f/ga.json" "-ftime-trace-granularity=0"
52 // LINK2: -cc1{{.*}} "-ftime-trace=f/gb.json" "-ftime-trace-granularity=0"
54 // RUN: %clang -### -ftime-trace=e -ftime-trace-granularity=0 d/a.cpp d/b.c -o f/x -dumpdir f/ 2>&1 | FileCheck %s --check-prefix=LINK3
55 // LINK3: -cc1{{.*}} "-ftime-trace=e{{/|\\\\}}a-{{[^.]*}}.json" "-ftime-trace-granularity=0"
56 // LINK3: -cc1{{.*}} "-ftime-trace=e{{/|\\\\}}b-{{[^.]*}}.json" "-ftime-trace-granularity=0"
58 // RUN: %clang -### -ftime-trace -ftime-trace=e -ftime-trace-granularity=1 -xassembler d/a.cpp 2>&1 | \
59 // RUN: FileCheck %s --check-prefix=UNUSED
60 // UNUSED: warning: argument unused during compilation: '-ftime-trace'
61 // UNUSED-NEXT: warning: argument unused during compilation: '-ftime-trace=e'
62 // UNUSED-NEXT: warning: argument unused during compilation: '-ftime-trace-granularity=1'
63 // UNUSED-NOT: warning:
65 template <typename T>
66 struct Struct {
67 T Num;
70 int main() {
71 Struct<int> S;
73 return 0;