1
+ # REQUIRES: shell
2
+ # UNSUPPORTED: system-windows
3
+
1
4
# Merge a binary file (e.g., a linked executable) having concatnated cgdata (__llvm_outline)
2
5
3
6
RUN: split-file %s %t
4
7
8
+ # Synthesize two set of raw cgdata without the header (24 byte) from the indexed cgdata.
9
+ # Concatenate them in merge-concat.ll
10
+ RUN: llvm-cgdata dump -binary %t/raw-1.cgtext -o %t/raw-1.cgdata
11
+ RUN: od -t x1 -j 24 -An %t/raw-1.cgdata | tr -d '\n' | sed 's/ /\\\\/g' > %t/raw-1-bytes.txt
12
+ RUN: sed -i "s/<RAW_1_BYTES>/$(cat %t/raw-1-bytes.txt)/g" %t/merge-concat.ll
13
+ RUN: llvm-cgdata dump -binary %t/raw-2.cgtext -o %t/raw-2.cgdata
14
+ RUN: od -t x1 -j 24 -An %t/raw-2.cgdata | tr -d '\n' | sed 's/ /\\\\/g' > %t/raw-2-bytes.txt
15
+ RUN: sed -i "s/<RAW_2_BYTES>/$(cat %t/raw-2-bytes.txt)/g" %t/merge-concat.ll
16
+
5
17
RUN: llc -filetype=obj -mtriple arm64-apple-darwin %t/merge-concat.ll -o %t/merge-concat.o
6
18
RUN: llvm-cgdata merge %t/merge-concat.o -o %t/merge-concat.cgdata
7
19
RUN: llvm-cgdata show %t/merge-concat.cgdata | FileCheck %s
@@ -10,7 +22,7 @@ CHECK-NEXT: Total Node Count: 4
10
22
CHECK-NEXT: Terminal Node Count: 2
11
23
CHECK-NEXT: Depth: 2
12
24
13
- RUN: llvm-cgdata dump %t/merge-concat.cgdata | FileCheck %s --check-prefix TREE
25
+ RUN: llvm-cgdata dump %t/merge-concat.cgdata | FileCheck %s --check-prefix= TREE
14
26
TREE: # Outlined stable hash tree
15
27
TREE-NEXT: :outlined_hash_tree
16
28
TREE-NEXT: ---
@@ -32,37 +44,40 @@ TREE-NEXT: Terminals: 4
32
44
TREE-NEXT: SuccessorIds: [ ]
33
45
TREE-NEXT: ...
34
46
35
- ;--- merge-concat.ll
47
+ ;--- raw-1.cgtext
48
+ :outlined_hash_tree
49
+ 0:
50
+ Hash: 0x0
51
+ Terminals: 0
52
+ SuccessorIds: [ 1 ]
53
+ 1:
54
+ Hash: 0x1
55
+ Terminals: 0
56
+ SuccessorIds: [ 2 ]
57
+ 2:
58
+ Hash: 0x2
59
+ Terminals: 4
60
+ SuccessorIds: [ ]
61
+ ...
36
62
37
- ; 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 word, the following two trees are encoded back-to-back in a binary format.
38
- ;---
39
- ;0:
40
- ; Hash: 0x0
41
- ; Terminals: 0
42
- ; SuccessorIds: [ 1 ]
43
- ;1:
44
- ; Hash: 0x1
45
- ; Terminals: 0
46
- ; SuccessorIds: [ 2 ]
47
- ;2:
48
- ; Hash: 0x2
49
- ; Terminals: 4
50
- ; SuccessorIds: [ ]
51
- ;...
52
- ;---
53
- ;0:
54
- ; Hash: 0x0
55
- ; Terminals: 0
56
- ; SuccessorIds: [ 1 ]
57
- ;1:
58
- ; Hash: 0x1
59
- ; Terminals: 0
60
- ; SuccessorIds: [ 2 ]
61
- ;2:
62
- ; Hash: 0x3
63
- ; Terminals: 5
64
- ; SuccessorIds: [ ]
65
- ;...
63
+ ;--- raw-2.cgtext
64
+ :outlined_hash_tree
65
+ 0:
66
+ Hash: 0x0
67
+ Terminals: 0
68
+ SuccessorIds: [ 1 ]
69
+ 1:
70
+ Hash: 0x1
71
+ Terminals: 0
72
+ SuccessorIds: [ 2 ]
73
+ 2:
74
+ Hash: 0x3
75
+ Terminals: 5
76
+ SuccessorIds: [ ]
77
+ ...
78
+
79
+ ;--- merge-concat.ll
66
80
67
- @.data1 = private unnamed_addr constant [72 x i8] c"\03\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\02\00\00\00\02\00\00\00\02\00\00\00\00\00\00\00\04\00\00\00\00\00\00\00", section "__DATA,__llvm_outline"
68
- @.data2 = private unnamed_addr constant [72 x i8] c"\03\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\02\00\00\00\02\00\00\00\03\00\00\00\00\00\00\00\05\00\00\00\00\00\00\00", section "__DATA,__llvm_outline"
81
+ ; 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.
82
+ @.data1 = private unnamed_addr constant [72 x i8] c"<RAW_1_BYTES>", section "__DATA,__llvm_outline"
83
+ @.data2 = private unnamed_addr constant [72 x i8] c"<RAW_2_BYTES>", section "__DATA,__llvm_outline"
0 commit comments