90 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 in the yaml format. `main.o` is dropped due to missing __llvm_merge.30# RUN: llvm-cgdata --merge %t/merge-2.o %t/merge-1.o -o %t/merge-cgdata-shuffle31# RUN: llvm-cgdata --convert %t/out-cgdata -o %t/out-cgdata.yaml32# RUN: llvm-cgdata --convert %t/merge-cgdata-shuffle -o %t/merge-cgdata-shuffle.yaml33# RUN: diff %t/out-cgdata.yaml %t/merge-cgdata-shuffle.yaml34 35# We can also generate the merged codegen data from the executable that is not dead-stripped.36# RUN: llvm-objdump -h %t/out| FileCheck %s37# CHECK: __llvm_merge38# RUN: llvm-cgdata --merge %t/out -o %t/merge-cgdata-exe39# RUN: diff %t/merge-cgdata-exe %t/merge-cgdata40 41# Dead-strip will remove __llvm_merge sections from the final executable.42# But the codeden data is still correctly produced from the linker.43# RUN: %no-arg-lld -dylib -arch arm64 -platform_version ios 14.0 15.0 -o %t/out-strip \44# RUN: %t/merge-1.o %t/merge-2.o %t/main.o -dead_strip --codegen-data-generate-path=%t/out-cgdata-strip45# RUN: llvm-cgdata --merge %t/merge-1.o %t/merge-2.o %t/main.o -o %t/merge-cgdata-strip46# RUN: diff %t/out-cgdata-strip %t/merge-cgdata-strip47# RUN: diff %t/out-cgdata-strip %t/merge-cgdata48 49# Ensure no __llvm_merge section remains in the executable.50# RUN: llvm-objdump -h %t/out-strip | FileCheck %s --check-prefix=STRIP51# STRIP-NOT: __llvm_merge52 53#--- raw-1.cgtext54:stable_function_map55---56- Hash: 12357 FunctionName: f158 ModuleName: 'foo.bc'59 InstCount: 760 IndexOperandHashes:61 - InstIndex: 362 OpndIndex: 063 OpndHash: 45664...65 66#--- raw-2.cgtext67:stable_function_map68---69- Hash: 12370 FunctionName: f271 ModuleName: 'goo.bc'72 InstCount: 773 IndexOperandHashes:74 - InstIndex: 375 OpndIndex: 076 OpndHash: 78977...78 79#--- merge-template.s80.section __DATA,__llvm_merge81_data:82.byte <RAW_BYTES>83 84#--- main.s85.globl _main86 87.text88_main:89 ret90