File: merge-hashtree-concat.test

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,696 kB
  • sloc: cpp: 7,438,781; ansic: 1,393,871; asm: 1,012,926; python: 241,771; f90: 86,635; objc: 75,411; lisp: 42,144; pascal: 17,286; sh: 8,596; ml: 5,082; perl: 4,730; makefile: 3,591; awk: 3,523; javascript: 2,251; xml: 892; fortran: 672
file content (83 lines) | stat: -rw-r--r-- 2,974 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# REQUIRES: shell, aarch64-registered-target
# UNSUPPORTED: system-windows

# Merge a binary file (e.g., a linked executable) having concatenated cgdata (__llvm_outline)

RUN: split-file %s %t

# Synthesize two sets of raw cgdata without the header (32 byte) from the indexed cgdata.
# Concatenate them in merge-concat.ll
RUN: llvm-cgdata --convert --format binary %t/raw-1.cgtext -o %t/raw-1.cgdata
RUN: od -t x1 -j 32 -An %t/raw-1.cgdata | tr -d '\n\r\t' | sed 's/[ ]*$//' | sed 's/[ ][ ]*/\\\\/g' > %t/raw-1-bytes.txt
RUN: sed "s/<RAW_1_BYTES>/$(cat %t/raw-1-bytes.txt)/g" %t/merge-concat-template.ll > %t/merge-concat-template-2.ll
RUN: llvm-cgdata --convert --format binary %t/raw-2.cgtext -o %t/raw-2.cgdata
RUN: od -t x1 -j 32 -An %t/raw-2.cgdata | tr -d '\n\r\t' | sed 's/[ ]*$//' | sed 's/[ ][ ]*/\\\\/g' > %t/raw-2-bytes.txt
RUN: sed "s/<RAW_2_BYTES>/$(cat %t/raw-2-bytes.txt)/g" %t/merge-concat-template-2.ll > %t/merge-concat.ll

RUN: llc -filetype=obj -mtriple arm64-apple-darwin %t/merge-concat.ll -o %t/merge-concat.o
RUN: llvm-cgdata --merge %t/merge-concat.o -o %t/merge-concat.cgdata
RUN: llvm-cgdata --show %t/merge-concat.cgdata | FileCheck %s
CHECK: Outlined hash tree:
CHECK-NEXT:  Total Node Count: 4
CHECK-NEXT:  Terminal Node Count: 2
CHECK-NEXT:  Depth: 2

RUN: llvm-cgdata --convert %t/merge-concat.cgdata | FileCheck %s --check-prefix=TREE
TREE: # Outlined stable hash tree
TREE-NEXT: :outlined_hash_tree
TREE-NEXT: ---
TREE-NEXT: 0:
TREE-NEXT:   Hash:            0x0
TREE-NEXT:   Terminals:       0
TREE-NEXT:   SuccessorIds:    [ 1 ]
TREE-NEXT: 1:
TREE-NEXT:   Hash:            0x1
TREE-NEXT:   Terminals:       0
TREE-NEXT:   SuccessorIds:    [ 2, 3 ]
TREE-NEXT: 2:
TREE-NEXT:   Hash:            0x3
TREE-NEXT:   Terminals:       5
TREE-NEXT:   SuccessorIds:    [  ]
TREE-NEXT: 3:
TREE-NEXT:   Hash:            0x2
TREE-NEXT:   Terminals:       4
TREE-NEXT:   SuccessorIds:    [  ]
TREE-NEXT: ...

;--- raw-1.cgtext
:outlined_hash_tree
0:
  Hash:            0x0
  Terminals:       0
  SuccessorIds:    [ 1 ]
1:
  Hash:            0x1
  Terminals:       0
  SuccessorIds:    [ 2 ]
2:
  Hash:            0x2
  Terminals:       4
  SuccessorIds:    [  ]
...

;--- raw-2.cgtext
:outlined_hash_tree
0:
  Hash:            0x0
  Terminals:       0
  SuccessorIds:    [ 1 ]
1:
  Hash:            0x1
  Terminals:       0
  SuccessorIds:    [ 2 ]
2:
  Hash:            0x3
  Terminals:       5
  SuccessorIds:    [  ]
...

;--- merge-concat-template.ll

; In an linked executable (as opposed to an object file), cgdata in __llvm_outline might be concatenated. Although this is not a typical workflow, we simply support this case to parse cgdata that is concatenated. In other words, the following two trees are encoded back-to-back in a binary format.
@.data1 = private unnamed_addr constant [72 x i8] c"<RAW_1_BYTES>", section "__DATA,__llvm_outline"
@.data2 = private unnamed_addr constant [72 x i8] c"<RAW_2_BYTES>", section "__DATA,__llvm_outline"