| 1 |
; Test that the LLD produces expected time trace output for DTLTO. |
| 2 |
|
| 3 |
RUN: rm -rf %t && split-file %s %t && cd %t |
| 4 |
|
| 5 |
; Generate bitcode files with summary. |
| 6 |
RUN: opt -thinlto-bc t1.ll -o t1.bc |
| 7 |
RUN: opt -thinlto-bc t2.ll -o t2.bc |
| 8 |
|
| 9 |
; Generate fake object files for mock.py to return. |
| 10 |
RUN: touch t1.o t2.o |
| 11 |
|
| 12 |
; Perform DTLTO and generate a time trace. mock.py does not do any compilation, |
| 13 |
; instead it simply writes the contents of the object files supplied on the |
| 14 |
; command line into the output object files in job order. |
| 15 |
RUN: llvm-lto2 run t1.bc t2.bc -o t.o \ |
| 16 |
RUN: -dtlto-distributor=%python \ |
| 17 |
RUN: -dtlto-distributor-arg=%llvm_src_root/utils/dtlto/mock.py,t1.o,t2.o \ |
| 18 |
RUN: --time-trace --time-trace-granularity=0 --time-trace-file=%t.json \ |
| 19 |
RUN: -r=t1.bc,t1,px \ |
| 20 |
RUN: -r=t2.bc,t2,px |
| 21 |
RUN: %python filter_order_and_pprint.py %t.json | FileCheck %s |
| 22 |
|
| 23 |
## Check that DTLTO events are recorded. |
| 24 |
CHECK-NOT: "name" |
| 25 |
CHECK: "name": "Add DTLTO files to the link" |
| 26 |
CHECK-SAME: "pid": [[#PID:]], |
| 27 |
CHECK-NEXT: "name": "Emit DTLTO JSON" |
| 28 |
CHECK-NEXT: "name": "Emit individual index for DTLTO" |
| 29 |
CHECK-SAME: t1.1.[[#PID]].native.o.thinlto.bc" |
| 30 |
CHECK-NEXT: "name": "Emit individual index for DTLTO" |
| 31 |
CHECK-SAME: t2.2.[[#PID]].native.o.thinlto.bc" |
| 32 |
CHECK-NEXT: "name": "Execute DTLTO distributor", "{{.*}}" |
| 33 |
CHECK-NEXT: "name": "Remove DTLTO temporary files" |
| 34 |
CHECK-NEXT: "name": "Total Add DTLTO files to the link" |
| 35 |
CHECK-SAME: "count": 1, |
| 36 |
CHECK-NEXT: "name": "Total Emit DTLTO JSON" |
| 37 |
CHECK-SAME: "count": 1, |
| 38 |
CHECK-NEXT: "name": "Total Emit individual index for DTLTO" |
| 39 |
CHECK-SAME: "count": 2, |
| 40 |
CHECK-NEXT: "name": "Total Execute DTLTO distributor" |
| 41 |
CHECK-SAME: "count": 1, |
| 42 |
CHECK-NEXT: "name": "Total Remove DTLTO temporary files" |
| 43 |
CHECK-SAME: "count": 1, |
| 44 |
CHECK-NOT: "name" |
| 45 |
|
| 46 |
;--- t1.ll |
| 47 |
target triple = "x86_64-unknown-linux-gnu" |
| 48 |
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 49 |
|
| 50 |
define void @t1() { |
| 51 |
ret void |
| 52 |
} |
| 53 |
|
| 54 |
;--- t2.ll |
| 55 |
target triple = "x86_64-unknown-linux-gnu" |
| 56 |
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 57 |
|
| 58 |
define void @t2() { |
| 59 |
ret void |
| 60 |
} |
| 61 |
|
| 62 |
#--- filter_order_and_pprint.py |
| 63 |
import json, sys |
| 64 |
|
| 65 |
data = json.load(open(sys.argv[1], "r", encoding="utf-8")) |
| 66 |
|
| 67 |
# Get DTLTO events. |
| 68 |
events = [e for e in data["traceEvents"] if "DTLTO" in e["name"]] |
| 69 |
events.sort(key=lambda e: (e["name"], str(e.get("args", {}).get("detail", "")))) |
| 70 |
|
| 71 |
# Print an event per line. Ensure 'name' is the first key. |
| 72 |
for ev in events: |
| 73 |
name = ev.pop("name") |
| 74 |
print(json.dumps({"name": name, **ev})) |
| 75 |
|