|
| 1 | +# REQUIRES: aarch64 |
| 2 | + |
| 3 | +# RUN: rm -rf %t; split-file %s %t |
| 4 | + |
| 5 | +# RUN: llvm-mc -filetype obj -triple arm64-apple-darwin %t/merge-1.s -o %t/merge-1.o |
| 6 | +# RUN: llvm-mc -filetype obj -triple arm64-apple-darwin %t/merge-2.s -o %t/merge-2.o |
| 7 | +# RUN: llvm-mc -filetype obj -triple arm64-apple-darwin %t/main.s -o %t/main.o |
| 8 | + |
| 9 | +# This checks if the codegen data from the linker is identical to the merged codegen data |
| 10 | +# from each object file, which is obtained using the llvm-cgdata tool. |
| 11 | +# RUN: %no-arg-lld -dylib -arch arm64 -platform_version ios 14.0 15.0 -o %t/out \ |
| 12 | +# RUN: %t/merge-1.o %t/merge-2.o %t/main.o --codegen-data-generate-path=%t/out-cgdata |
| 13 | +# RUN: llvm-cgdata merge %t/merge-1.o %t/merge-2.o %t/main.o -o %t/merge-cgdata |
| 14 | +# RUN: diff %t/out-cgdata %t/merge-cgdata |
| 15 | + |
| 16 | +# Merge order doesn't matter. `main.o` is dropped due to missing __llvm_outline. |
| 17 | +# RUN: llvm-cgdata merge %t/merge-2.o %t/merge-1.o -o %t/merge-cgdata-shuffle |
| 18 | +# RUN: diff %t/out-cgdata %t/merge-cgdata-shuffle |
| 19 | + |
| 20 | +# We can also generate the merged codegen data from the executable that is not dead-stripped. |
| 21 | +# RUN: llvm-objdump -h %t/out| FileCheck %s |
| 22 | +CHECK: __llvm_outline |
| 23 | +# RUN: llvm-cgdata merge %t/out -o %t/merge-cgdata-exe |
| 24 | +# RUN: diff %t/merge-cgdata-exe %t/merge-cgdata |
| 25 | + |
| 26 | +# Dead-strip will remove __llvm_outline sections from the final executable. |
| 27 | +# But the codeden data is still correctly produced from the linker. |
| 28 | +# RUN: %no-arg-lld -dylib -arch arm64 -platform_version ios 14.0 15.0 -o %t/out-strip \ |
| 29 | +# RUN: %t/merge-1.o %t/merge-2.o %t/main.o -dead_strip --codegen-data-generate-path=%t/out-cgdata-strip |
| 30 | +# RUN: llvm-cgdata merge %t/merge-1.o %t/merge-2.o %t/main.o -o %t/merge-cgdata-strip |
| 31 | +# RUN: diff %t/out-cgdata-strip %t/merge-cgdata-strip |
| 32 | +# RUN: diff %t/out-cgdata-strip %t/merge-cgdata |
| 33 | + |
| 34 | +# Ensure no __llvm_outline section remains in the executable. |
| 35 | +# RUN: llvm-objdump -h %t/out-strip | FileCheck %s --check-prefix=STRIP |
| 36 | +STRIP-NOT: __llvm_outline |
| 37 | + |
| 38 | +#--- merge-1.s |
| 39 | +# The .data is encoded in a binary form based on the following yaml form. See serialize() in OutlinedHashTreeRecord.cpp |
| 40 | +#--- |
| 41 | +#0: |
| 42 | +# Hash: 0x0 |
| 43 | +# Terminals: 0 |
| 44 | +# SuccessorIds: [ 1 ] |
| 45 | +#1: |
| 46 | +# Hash: 0x1 |
| 47 | +# Terminals: 0 |
| 48 | +# SuccessorIds: [ 2 ] |
| 49 | +#2: |
| 50 | +# Hash: 0x2 |
| 51 | +# Terminals: 4 |
| 52 | +# SuccessorIds: [ ] |
| 53 | +#... |
| 54 | +.section __DATA,__llvm_outline |
| 55 | +_data: |
| 56 | +.byte 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
| 57 | + |
| 58 | +#--- merge-2.s |
| 59 | +# The .data is encoded in a binary form based on the following yaml form. See serialize() in OutlinedHashTreeRecord.cpp |
| 60 | +#--- |
| 61 | +#0: |
| 62 | +# Hash: 0x0 |
| 63 | +# Terminals: 0 |
| 64 | +# SuccessorIds: [ 1 ] |
| 65 | +#1: |
| 66 | +# Hash: 0x1 |
| 67 | +# Terminals: 0 |
| 68 | +# SuccessorIds: [ 2 ] |
| 69 | +#2: |
| 70 | +# Hash: 0x3 |
| 71 | +# Terminals: 5 |
| 72 | +# SuccessorIds: [ ] |
| 73 | +#... |
| 74 | +.section __DATA,__llvm_outline |
| 75 | +_data: |
| 76 | +.byte 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
| 77 | + |
| 78 | +#--- main.s |
| 79 | +.globl _main |
| 80 | + |
| 81 | +.text |
| 82 | +_main: |
| 83 | + ret |
0 commit comments