[RISCV][FMV] Support target_clones (#85786)
[llvm-project.git] / clang / test / Driver / ftime-trace-sections.py
blob02afa4ac54eb7baa3831d8d119885dc94c0a770f
1 #!/usr/bin/env python
3 import json, sys, time
6 def is_inside(range1, range2):
7 a = range1["ts"]
8 b = a + range1["dur"]
9 c = range2["ts"]
10 d = c + range2["dur"]
11 return (a >= c and a <= d) and (b >= c and b <= d)
14 def is_before(range1, range2):
15 b = range1["ts"] + range1["dur"]
16 c = range2["ts"]
17 return b <= c
20 log_contents = json.loads(sys.stdin.read())
21 events = log_contents["traceEvents"]
22 codegens = [event for event in events if event["name"] == "CodeGen Function"]
23 frontends = [event for event in events if event["name"] == "Frontend"]
24 backends = [event for event in events if event["name"] == "Backend"]
26 beginning_of_time = log_contents["beginningOfTime"] / 1000000
27 seconds_since_epoch = time.time()
29 # Make sure that the 'beginningOfTime' is not later than now.
30 if beginning_of_time > seconds_since_epoch:
31 sys.exit(
32 "'beginningOfTime' should represent the absolute time when the "
33 "process has started"
36 if not all(
38 any([is_inside(codegen, frontend) for frontend in frontends])
39 for codegen in codegens
42 sys.exit("Not all CodeGen sections are inside any Frontend section!")
44 if not all(
46 all([is_before(frontend, backend) for frontend in frontends])
47 for backend in backends
50 sys.exit("Not all Frontend section are before all Backend sections!")