1# UNSUPPORTED: system-windows 2# REQUIRES: aarch64 3 4# RUN: rm -rf %t; split-file %s %t 5 6# Synthesize raw cgdata without the header (32 byte) from the indexed cgdata. 7# RUN: llvm-cgdata --convert --format binary %t/raw-1.cgtext -o %t/raw-1.cgdata 8# RUN: od -t x1 -j 32 -An %t/raw-1.cgdata | tr -d '\n\r\t' | sed 's/[ ][ ]*/ /g; s/^[ ]*//; s/[ ]*$//; s/[ ]/,0x/g; s/^/0x/' > %t/raw-1-bytes.txt 9# RUN: sed "s/<RAW_BYTES>/$(cat %t/raw-1-bytes.txt)/g" %t/merge-template.s > %t/merge-1.s 10# RUN: llvm-cgdata --convert --format binary %t/raw-2.cgtext -o %t/raw-2.cgdata 11# RUN: od -t x1 -j 32 -An %t/raw-2.cgdata | tr -d '\n\r\t' | sed 's/[ ][ ]*/ /g; s/^[ ]*//; s/[ ]*$//; s/[ ]/,0x/g; s/^/0x/' > %t/raw-2-bytes.txt 12# RUN: sed "s/<RAW_BYTES>/$(cat %t/raw-2-bytes.txt)/g" %t/merge-template.s > %t/merge-2.s 13 14# RUN: llvm-mc -filetype obj -triple arm64-apple-darwin %t/merge-1.s -o %t/merge-1.o 15# RUN: llvm-mc -filetype obj -triple arm64-apple-darwin %t/merge-2.s -o %t/merge-2.o 16# RUN: llvm-mc -filetype obj -triple arm64-apple-darwin %t/main.s -o %t/main.o 17 18# This checks if the codegen data from the linker is identical to the merged codegen data 19# from each object file, which is obtained using the llvm-cgdata tool. 20# RUN: %no-arg-lld -dylib -arch arm64 -platform_version ios 14.0 15.0 -o %t/out \ 21# RUN: %t/merge-1.o %t/merge-2.o %t/main.o --codegen-data-generate-path=%t/out-cgdata 22# RUN: llvm-cgdata --merge %t/merge-1.o %t/merge-2.o %t/main.o -o %t/merge-cgdata 23# RUN: diff %t/out-cgdata %t/merge-cgdata 24 25# Merge order doesn't matter. `main.o` is dropped due to missing __llvm_outline. 26# RUN: llvm-cgdata --merge %t/merge-2.o %t/merge-1.o -o %t/merge-cgdata-shuffle 27# RUN: diff %t/out-cgdata %t/merge-cgdata-shuffle 28 29# We can also generate the merged codegen data from the executable that is not dead-stripped. 30# RUN: llvm-objdump -h %t/out| FileCheck %s 31# CHECK: __llvm_outline 32# RUN: llvm-cgdata --merge %t/out -o %t/merge-cgdata-exe 33# RUN: diff %t/merge-cgdata-exe %t/merge-cgdata 34 35# Dead-strip will remove __llvm_outline sections from the final executable. 36# But the codeden data is still correctly produced from the linker. 37# RUN: %no-arg-lld -dylib -arch arm64 -platform_version ios 14.0 15.0 -o %t/out-strip \ 38# RUN: %t/merge-1.o %t/merge-2.o %t/main.o -dead_strip --codegen-data-generate-path=%t/out-cgdata-strip 39# RUN: llvm-cgdata --merge %t/merge-1.o %t/merge-2.o %t/main.o -o %t/merge-cgdata-strip 40# RUN: diff %t/out-cgdata-strip %t/merge-cgdata-strip 41# RUN: diff %t/out-cgdata-strip %t/merge-cgdata 42 43# Ensure no __llvm_outline section remains in the executable. 44# RUN: llvm-objdump -h %t/out-strip | FileCheck %s --check-prefix=STRIP 45# STRIP-NOT: __llvm_outline 46 47#--- raw-1.cgtext 48:outlined_hash_tree 490: 50 Hash: 0x0 51 Terminals: 0 52 SuccessorIds: [ 1 ] 531: 54 Hash: 0x1 55 Terminals: 0 56 SuccessorIds: [ 2 ] 572: 58 Hash: 0x2 59 Terminals: 4 60 SuccessorIds: [ ] 61... 62 63#--- raw-2.cgtext 64:outlined_hash_tree 650: 66 Hash: 0x0 67 Terminals: 0 68 SuccessorIds: [ 1 ] 691: 70 Hash: 0x1 71 Terminals: 0 72 SuccessorIds: [ 2 ] 732: 74 Hash: 0x3 75 Terminals: 5 76 SuccessorIds: [ ] 77... 78 79#--- merge-template.s 80.section __DATA,__llvm_outline 81_data: 82.byte <RAW_BYTES> 83 84#--- main.s 85.globl _main 86 87.text 88_main: 89 ret 90