94 lines · plain
1# UNSUPPORTED: system-windows2# REQUIRES: aarch643 4# RUN: rm -rf %t; split-file %s %t5 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.cgdata8# RUN: echo -n "s/<RAW_BYTES>/" > %t/raw-1-sed.txt9# 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-sed.txt10# RUN: echo "/g" >> %t/raw-1-sed.txt11# RUN: sed -f %t/raw-1-sed.txt %t/merge-template.s > %t/merge-1.s12# RUN: llvm-cgdata --convert --format binary %t/raw-2.cgtext -o %t/raw-2.cgdata13# RUN: echo -n "s/<RAW_BYTES>/" > %t/raw-2-sed.txt14# 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-sed.txt15# RUN: echo "/g" >> %t/raw-2-sed.txt16# RUN: sed -f %t/raw-2-sed.txt %t/merge-template.s > %t/merge-2.s17 18# RUN: llvm-mc -filetype obj -triple arm64-apple-darwin %t/merge-1.s -o %t/merge-1.o19# RUN: llvm-mc -filetype obj -triple arm64-apple-darwin %t/merge-2.s -o %t/merge-2.o20# RUN: llvm-mc -filetype obj -triple arm64-apple-darwin %t/main.s -o %t/main.o21 22# This checks if the codegen data from the linker is identical to the merged codegen data23# from each object file, which is obtained using the llvm-cgdata tool.24# RUN: %no-arg-lld -dylib -arch arm64 -platform_version ios 14.0 15.0 -o %t/out \25# RUN: %t/merge-1.o %t/merge-2.o %t/main.o --codegen-data-generate-path=%t/out-cgdata26# RUN: llvm-cgdata --merge %t/merge-1.o %t/merge-2.o %t/main.o -o %t/merge-cgdata27# RUN: diff %t/out-cgdata %t/merge-cgdata28 29# Merge order doesn't matter. `main.o` is dropped due to missing __llvm_outline.30# RUN: llvm-cgdata --merge %t/merge-2.o %t/merge-1.o -o %t/merge-cgdata-shuffle31# RUN: diff %t/out-cgdata %t/merge-cgdata-shuffle32 33# We can also generate the merged codegen data from the executable that is not dead-stripped.34# RUN: llvm-objdump -h %t/out| FileCheck %s35# CHECK: __llvm_outline36# RUN: llvm-cgdata --merge %t/out -o %t/merge-cgdata-exe37# RUN: diff %t/merge-cgdata-exe %t/merge-cgdata38 39# Dead-strip will remove __llvm_outline sections from the final executable.40# But the codeden data is still correctly produced from the linker.41# RUN: %no-arg-lld -dylib -arch arm64 -platform_version ios 14.0 15.0 -o %t/out-strip \42# RUN: %t/merge-1.o %t/merge-2.o %t/main.o -dead_strip --codegen-data-generate-path=%t/out-cgdata-strip43# RUN: llvm-cgdata --merge %t/merge-1.o %t/merge-2.o %t/main.o -o %t/merge-cgdata-strip44# RUN: diff %t/out-cgdata-strip %t/merge-cgdata-strip45# RUN: diff %t/out-cgdata-strip %t/merge-cgdata46 47# Ensure no __llvm_outline section remains in the executable.48# RUN: llvm-objdump -h %t/out-strip | FileCheck %s --check-prefix=STRIP49# STRIP-NOT: __llvm_outline50 51#--- raw-1.cgtext52:outlined_hash_tree530:54 Hash: 0x055 Terminals: 056 SuccessorIds: [ 1 ]571:58 Hash: 0x159 Terminals: 060 SuccessorIds: [ 2 ]612:62 Hash: 0x263 Terminals: 464 SuccessorIds: [ ]65...66 67#--- raw-2.cgtext68:outlined_hash_tree690:70 Hash: 0x071 Terminals: 072 SuccessorIds: [ 1 ]731:74 Hash: 0x175 Terminals: 076 SuccessorIds: [ 2 ]772:78 Hash: 0x379 Terminals: 580 SuccessorIds: [ ]81...82 83#--- merge-template.s84.section __DATA,__llvm_outline85_data:86.byte <RAW_BYTES>87 88#--- main.s89.globl _main90 91.text92_main:93 ret94