85 lines · plain
1# REQUIRES: aarch64-registered-target2# UNSUPPORTED: system-windows3 4# Merge a binary file (e.g., a linked executable) having concatenated cgdata (__llvm_merge)5 6RUN: split-file %s %t7 8# Synthesize two sets of raw cgdata without the header (32 byte) from the indexed cgdata.9# Concatenate them in merge-concat.ll10RUN: llvm-cgdata --convert --format binary %t/raw-1.cgtext -o %t/raw-1.cgdata11RUN: echo -n "s/<RAW_1_BYTES>/" > %t/raw-1-sed.txt12RUN: od -t x1 -j 32 -An %t/raw-1.cgdata | tr -d '\n\r\t' | sed 's/[ ]*$//' | sed 's/[ ][ ]*/\\\\/g' >> %t/raw-1-sed.txt13RUN: echo "/g" >> %t/raw-1-sed.txt14RUN: sed -f %t/raw-1-sed.txt %t/merge-concat-template.ll > %t/merge-concat-template-2.ll15RUN: llvm-cgdata --convert --format binary %t/raw-2.cgtext -o %t/raw-2.cgdata16RUN: echo -n "s/<RAW_2_BYTES>/" > %t/raw-2-sed.txt17RUN: od -t x1 -j 32 -An %t/raw-2.cgdata | tr -d '\n\r\t' | sed 's/[ ]*$//' | sed 's/[ ][ ]*/\\\\/g' >> %t/raw-2-sed.txt18RUN: echo "/g" >> %t/raw-2-sed.txt19RUN: sed -f %t/raw-2-sed.txt %t/merge-concat-template-2.ll > %t/merge-concat.ll20 21RUN: llc -filetype=obj -mtriple arm64-apple-darwin %t/merge-concat.ll -o %t/merge-concat.o22RUN: llvm-cgdata --merge --skip-trim %t/merge-concat.o -o %t/merge-concat.cgdata23RUN: llvm-cgdata --show %t/merge-concat.cgdata | FileCheck %s24RUN: llvm-cgdata --merge --skip-trim %t/merge-concat.o -o %t/merge-concat-lazy.cgdata -indexed-codegen-data-lazy-loading25RUN: llvm-cgdata --show %t/merge-concat-lazy.cgdata -indexed-codegen-data-lazy-loading | FileCheck %s26 27CHECK: Stable function map:28CHECK-NEXT: Unique hash Count: 129CHECK-NEXT: Total function Count: 230CHECK-NEXT: Mergeable function Count: 231 32RUN: llvm-cgdata --convert %t/merge-concat.cgdata| FileCheck %s --check-prefix=MAP33MAP: # Stable function map34MAP-NEXT: :stable_function_map35MAP-NEXT: ---36MAP-NEXT: - Hash: 137MAP-NEXT: FunctionName: Func138MAP-NEXT: ModuleName: Mod139MAP-NEXT: InstCount: 240MAP-NEXT: IndexOperandHashes:41MAP-NEXT: - InstIndex: 042MAP-NEXT: OpndIndex: 143MAP-NEXT: OpndHash: 344MAP-NEXT: - Hash: 145MAP-NEXT: FunctionName: Func246MAP-NEXT: ModuleName: Mod147MAP-NEXT: InstCount: 248MAP-NEXT: IndexOperandHashes:49MAP-NEXT: - InstIndex: 050MAP-NEXT: OpndIndex: 151MAP-NEXT: OpndHash: 452MAP-NEXT: ...53 54;--- raw-1.cgtext55:stable_function_map56- Hash: 157 FunctionName: Func258 ModuleName: Mod159 InstCount: 260 IndexOperandHashes:61 - InstIndex: 062 OpndIndex: 163 OpndHash: 464...65 66;--- raw-2.cgtext67:stable_function_map68- Hash: 169 FunctionName: Func170 ModuleName: Mod171 InstCount: 272 IndexOperandHashes:73 - InstIndex: 074 OpndIndex: 175 OpndHash: 376...77 78;--- merge-concat-template.ll79 80; In an linked executable (as opposed to an object file), cgdata in __llvm_merge might be concatenated.81; Although this is not a typical workflow, we simply support this case to parse cgdata that is concatenated.82; In other words, the following two trees are encoded back-to-back in a binary format.83@.data1 = private unnamed_addr constant [84 x i8] c"<RAW_1_BYTES>", section "__DATA,__llvm_merge"84@.data2 = private unnamed_addr constant [84 x i8] c"<RAW_2_BYTES>", section "__DATA,__llvm_merge"85