[NFC][MLIR][Linalg] Refactor linalg.matmul tablegen ODS and related C++ code. (#116377)
[llvm-project.git] / bolt / test / runtime / X86 / asm-dump.c
blob7656fda44d8d4a7ee01482b37b2f91705241651e
1 /**
2 ** Test for asm-dump functionality.
4 * REQUIRES: x86_64-linux,bolt-runtime
6 * Compile the source
7 * RUN: %clang -fPIC %s -o %t.exe -Wl,-q
9 * Profile collection: instrument the binary
10 * RUN: llvm-bolt %t.exe --instrument --instrumentation-file=%t.fdata -o \
11 * RUN: %t.instr
13 * Profile collection: run instrumented binary (and capture output)
14 * RUN: %t.instr > %t.result
16 * Run BOLT with asm-dump
17 * RUN: llvm-bolt %t.exe -p %t.fdata --funcs=main --asm-dump=%t -o %t.null \
18 * RUN: | FileCheck %s --check-prefix=CHECK-BOLT
20 * Check asm file contents
21 * RUN: cat %t/main.s | FileCheck %s --check-prefix=CHECK-FILE
23 * Now check if asm-dump file can be consumed by BOLT infra
24 * Strip dot from compiler-local symbols:
25 * RUN: sed -i 's/\.L/L/g' %t/main.s
27 * Recompile the asm file into objfile
28 * RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o
30 * Reconstruct fdata
31 * RUN: link_fdata %t/main.s %t.o %t.fdata.reconst
33 * XXX: reenable once dumping data is supported
34 * Check if reoptimized file produces the same results
35 * dontrun: %t.exe.reopt > %t.result.reopt
36 * dontrun: cmp %t.result %t.result.reopt
38 * Delete our BB symbols so BOLT doesn't mark them as entry points
39 * RUN: llvm-strip --strip-unneeded %t.o
41 * Recompile the binary
42 * RUN: %clang -fPIC %t.o -o %t.exe.reopt -Wl,-q
44 * Finally consume reoptimized file with reconstructed fdata
45 * RUN: llvm-bolt %t.exe.reopt -p %t.fdata.reconst -o %t.null \
46 * RUN: | FileCheck %s --check-prefix=CHECK-REOPT
48 * CHECK-BOLT: BOLT-INFO: Dumping function assembly to {{.*}}/main.s
50 * CHECK-FILE: .globl main
51 * CHECK-FILE-NEXT: .type main, %function
52 * CHECK-FILE-NEXT: main:
53 * CHECK-FILE-NEXT: # FDATA: 0 [unknown] 0 1 main 0 0 1
54 * CHECK-FILE-NEXT: .cfi_startproc
55 * CHECK-FILE-NEXT: .LBB{{.*}}:
56 * CHECK-FILE: .cfi_def_cfa_offset 16
57 * CHECK-FILE: leaq {{.*}}(%rip)
58 * CHECK-FILE: callq puts@PLT
59 * CHECK-FILE: .cfi_endproc
60 * CHECK-FILE-NEXT: .size main, .-main
61 * CHECK-FILE: .section .rodata
63 * CHECK-REOPT: BOLT-INFO: 1 out of {{.*}} functions in the binary {{.*}} have
64 * CHECK-REOPT: non-empty execution profile
66 #include <stdio.h>
67 #include <string.h>
69 int main(int argc, char* argv[]) {
70 for (int I = 0; I < 10; I++) {
71 if (I != 9)
72 continue;
73 if (argc > 1 &&
74 strncmp(argv[1], "--help", strlen("--help")) == 0) {
75 puts("Help message\n");
76 } else {
77 puts("Hello, World!\n");
80 return 0;