From 01a81dca413fd9962f954e529447aedb91c4b119 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Fri, 8 Oct 2021 18:23:32 -0700 Subject: [PATCH] [BOLT][TEST] Imported small tests Summary: Imported small internal tests: - shared_object.test - shrinkwrapping.test - static_exe.test - tailcall.test - vararg.test (cherry picked from FBD31523478) --- bolt/test/X86/Inputs/exc4sw.S | 493 ++++++++++++++++++++++++++ bolt/test/X86/Inputs/exc4sw.fdata | 2 + bolt/test/X86/Inputs/static_exe.s | 10 + bolt/test/X86/Inputs/tailcall.s | 29 ++ bolt/test/X86/Inputs/vararg.s | 567 ++++++++++++++++++++++++++++++ bolt/test/X86/Inputs/vararg_pic.s | 567 ++++++++++++++++++++++++++++++ bolt/test/X86/shared_object.test | 5 + bolt/test/X86/shrinkwrapping.test | 45 +++ bolt/test/X86/static_exe.test | 6 + bolt/test/X86/tailcall.test | 13 + bolt/test/X86/vararg.test | 19 + 11 files changed, 1756 insertions(+) create mode 100644 bolt/test/X86/Inputs/exc4sw.S create mode 100644 bolt/test/X86/Inputs/exc4sw.fdata create mode 100644 bolt/test/X86/Inputs/static_exe.s create mode 100644 bolt/test/X86/Inputs/tailcall.s create mode 100644 bolt/test/X86/Inputs/vararg.s create mode 100644 bolt/test/X86/Inputs/vararg_pic.s create mode 100644 bolt/test/X86/shared_object.test create mode 100644 bolt/test/X86/shrinkwrapping.test create mode 100644 bolt/test/X86/static_exe.test create mode 100644 bolt/test/X86/tailcall.test create mode 100644 bolt/test/X86/vararg.test diff --git a/bolt/test/X86/Inputs/exc4sw.S b/bolt/test/X86/Inputs/exc4sw.S new file mode 100644 index 000000000000..f1ffc178b0c0 --- /dev/null +++ b/bolt/test/X86/Inputs/exc4sw.S @@ -0,0 +1,493 @@ +// Generated from g++ exception4.cpp -fomit-frame-pointer -S -O3 +// Manually modified to trigger shrink-wrapping in function main + .text + .p2align 4,,15 + .globl _Z3fooi + .type _Z3fooi, @function +_Z3fooi: +.LFB12: + .cfi_startproc + subq $8, %rsp + .cfi_def_cfa_offset 16 + cmpl $1, %edi + movl $1, %edi + jle .L2 + call __cxa_allocate_exception + xorl %edx, %edx + movl $_ZTI4ExcG, %esi + movq %rax, %rdi + call __cxa_throw +.L2: + call __cxa_allocate_exception + xorl %edx, %edx + movl $_ZTI4ExcC, %esi + movq %rax, %rdi + call __cxa_throw + .cfi_endproc +.LFE12: + .size _Z3fooi, .-_Z3fooi + .p2align 4,,15 + .globl _Z11filter_onlyi + .type _Z11filter_onlyi, @function +_Z11filter_onlyi: +.LFB13: + .cfi_startproc + .cfi_personality 0x3,__gxx_personality_v0 + .cfi_lsda 0x3,.LLSDA13 + subq $8, %rsp + .cfi_def_cfa_offset 16 +.LEHB0: + call _Z3fooi +.LEHE0: +.L8: + addq $1, %rdx + movq %rax, %rdi + je .L7 +.LEHB1: + call _Unwind_Resume +.L7: + call __cxa_call_unexpected +.LEHE1: + .cfi_endproc +.LFE13: + .globl __gxx_personality_v0 + .section .gcc_except_table,"a",@progbits + .align 4 +.LLSDA13: + .byte 0xff + .byte 0x3 + .uleb128 .LLSDATT13-.LLSDATTD13 +.LLSDATTD13: + .byte 0x1 + .uleb128 .LLSDACSE13-.LLSDACSB13 +.LLSDACSB13: + .uleb128 .LEHB0-.LFB13 + .uleb128 .LEHE0-.LEHB0 + .uleb128 .L8-.LFB13 + .uleb128 0x1 + .uleb128 .LEHB1-.LFB13 + .uleb128 .LEHE1-.LEHB1 + .uleb128 0 + .uleb128 0 +.LLSDACSE13: + .byte 0x7f + .byte 0 + .align 4 + .long _ZTI4ExcA + .long _ZTI4ExcB + .long _ZTI4ExcC + .long _ZTI4ExcD + .long _ZTI4ExcE + .long _ZTI4ExcF +.LLSDATT13: + .byte 0x1 + .byte 0x2 + .byte 0x3 + .byte 0x4 + .byte 0x5 + .byte 0x6 + .byte 0 + .text + .size _Z11filter_onlyi, .-_Z11filter_onlyi + .section .rodata.str1.8,"aMS",@progbits,1 + .align 8 +.LC0: + .string "this statement is cold and should be outlined" + .text + .p2align 4,,15 + .globl _Z12never_throwsv + .type _Z12never_throwsv, @function +_Z12never_throwsv: +.LFB14: + .cfi_startproc + .cfi_personality 0x3,__gxx_personality_v0 + .cfi_lsda 0x3,.LLSDA14 + subq $8, %rsp + .cfi_def_cfa_offset 16 + movl $.LC0, %edi +.LEHB2: + call puts +.LEHE2: + addq $8, %rsp + .cfi_remember_state + .cfi_def_cfa_offset 8 + ret +.L13: + .cfi_restore_state + addq $1, %rdx + movq %rax, %rdi + je .L12 +.LEHB3: + call _Unwind_Resume +.L12: + call __cxa_call_unexpected +.LEHE3: + .cfi_endproc +.LFE14: + .section .gcc_except_table + .align 4 +.LLSDA14: + .byte 0xff + .byte 0x3 + .uleb128 .LLSDATT14-.LLSDATTD14 +.LLSDATTD14: + .byte 0x1 + .uleb128 .LLSDACSE14-.LLSDACSB14 +.LLSDACSB14: + .uleb128 .LEHB2-.LFB14 + .uleb128 .LEHE2-.LEHB2 + .uleb128 .L13-.LFB14 + .uleb128 0x1 + .uleb128 .LEHB3-.LFB14 + .uleb128 .LEHE3-.LEHB3 + .uleb128 0 + .uleb128 0 +.LLSDACSE14: + .byte 0x7f + .byte 0 + .align 4 +.LLSDATT14: + .byte 0 + .text + .size _Z12never_throwsv, .-_Z12never_throwsv + .section .rodata.str1.1,"aMS",@progbits,1 +.LC1: + .string "catch 2" +.LC2: + .string "catch 1" +.LC3: + .string "caught ExcC" +.LC4: + .string "caught ExcG" + .section .text.startup,"ax",@progbits + .p2align 4,,15 + .globl main + .type main, @function +main: +.LFB15: + .cfi_startproc + .cfi_personality 0x3,__gxx_personality_v0 + .cfi_lsda 0x3,.LLSDA15 + pushq %r13 + .cfi_def_cfa_offset 16 + .cfi_offset 13, -16 + pushq %r12 + .cfi_def_cfa_offset 24 + .cfi_offset 12, -24 + pushq %rbp + .cfi_def_cfa_offset 32 + .cfi_offset 6, -32 + movl $10, %ebp + pushq %rbx + .cfi_def_cfa_offset 40 + .cfi_offset 3, -40 + movl %edi, %ebx + subq $8, %rsp + .cfi_def_cfa_offset 48 +.Lcheck: + cmpl $2, %ebx + je .Lmyexit +.Lloop_pre_header: + movl $10, %ebp + jmp .L18 +.L18: + cmpl $2, %ebx + je .Lmyexit +.L17: + movl $1, %edi + call __cxa_allocate_exception + xorl %edx, %edx + movl $_ZTI4ExcA, %esi + movq %rax, %rdi +.LEHB4: + call __cxa_throw +.LEHE4: +.L47: + call _Z12never_throwsv + call _Z12never_throwsv + .p2align 4,,5 + jmp .L17 +.L37: + cmpq $2, %rdx + movq %rax, %rdi + jne .L22 + call __cxa_begin_catch + movl $.LC1, %edi +.LEHB5: + call puts +.LEHE5: + movl $8, %edi + call __cxa_allocate_exception + movl $4, %edi + movq %rax, %r12 +.LEHB6: + call _Znwm +.LEHE6: + movl $0, (%rax) + xorl %edx, %edx + movq %rax, (%r12) + movl $_ZTIPi, %esi + movq %r12, %rdi +.LEHB7: + call __cxa_throw +.LEHE7: +.L39: + movq %rax, %r13 + movq %r12, %rdi + movq %r13, %r12 + call __cxa_free_exception +.L24: + call __cxa_end_catch + movq %r12, %rdi +.L22: + call __cxa_begin_catch + movl $.LC2, %edi +.LEHB8: + call puts +.LEHE8: +.LEHB9: + call __cxa_end_catch +.LEHE9: + movl %ebx, %edi +.LEHB10: + call _Z11filter_onlyi +.LEHE10: +.L38: + movq %rax, %r12 + jmp .L24 +.L41: + cmpq $4, %rdx + movq %rax, %rdi + movq %rdx, %rax + jne .L29 + call __cxa_begin_catch + movl $.LC3, %edi +.LEHB11: + call puts +.LEHE11: +.L35: + call __cxa_end_catch + subl $1, %ebp + jne .L18 +.Lmyexit: + popq %rdx + .cfi_remember_state + .cfi_def_cfa_offset 40 + popq %rbx + .cfi_def_cfa_offset 32 + popq %rbp + .cfi_def_cfa_offset 24 + popq %r12 + .cfi_def_cfa_offset 16 + xorl %eax, %eax + popq %r13 + .cfi_def_cfa_offset 8 + ret +.L40: + .cfi_restore_state + movq %rax, %rbx + call __cxa_end_catch + movq %rbx, %rdi +.LEHB12: + call _Unwind_Resume +.LEHE12: +.L42: + movq %rax, %r13 + movq %rdx, %r12 + call __cxa_end_catch + movq %r13, %rdi + movq %r12, %rax +.L29: + cmpq $3, %rax + jne .L46 + call __cxa_begin_catch + movl $.LC4, %edi +.LEHB13: + call puts +.LEHE13: + jmp .L35 +.L43: + movq %rax, %rbx + call __cxa_end_catch + movq %rbx, %rdi +.L46: +.LEHB14: + call _Unwind_Resume + jmp .L43 +.LEHE14: + .cfi_endproc +.LFE15: + .section .gcc_except_table + .align 4 +.LLSDA15: + .byte 0xff + .byte 0x3 + .uleb128 .LLSDATT15-.LLSDATTD15 +.LLSDATTD15: + .byte 0x1 + .uleb128 .LLSDACSE15-.LLSDACSB15 +.LLSDACSB15: + .uleb128 .LEHB4-.LFB15 + .uleb128 .LEHE4-.LEHB4 + .uleb128 .L37-.LFB15 + .uleb128 0x3 + .uleb128 .LEHB5-.LFB15 + .uleb128 .LEHE5-.LEHB5 + .uleb128 .L38-.LFB15 + .uleb128 0x5 + .uleb128 .LEHB6-.LFB15 + .uleb128 .LEHE6-.LEHB6 + .uleb128 .L39-.LFB15 + .uleb128 0x5 + .uleb128 .LEHB7-.LFB15 + .uleb128 .LEHE7-.LEHB7 + .uleb128 .L38-.LFB15 + .uleb128 0x5 + .uleb128 .LEHB8-.LFB15 + .uleb128 .LEHE8-.LEHB8 + .uleb128 .L40-.LFB15 + .uleb128 0 + .uleb128 .LEHB9-.LFB15 + .uleb128 .LEHE9-.LEHB9 + .uleb128 0 + .uleb128 0 + .uleb128 .LEHB10-.LFB15 + .uleb128 .LEHE10-.LEHB10 + .uleb128 .L41-.LFB15 + .uleb128 0x9 + .uleb128 .LEHB11-.LFB15 + .uleb128 .LEHE11-.LEHB11 + .uleb128 .L42-.LFB15 + .uleb128 0xb + .uleb128 .LEHB12-.LFB15 + .uleb128 .LEHE12-.LEHB12 + .uleb128 0 + .uleb128 0 + .uleb128 .LEHB13-.LFB15 + .uleb128 .LEHE13-.LEHB13 + .uleb128 .L43-.LFB15 + .uleb128 0 + .uleb128 .LEHB14-.LFB15 + .uleb128 .LEHE14-.LEHB14 + .uleb128 0 + .uleb128 0 +.LLSDACSE15: + .byte 0x1 + .byte 0 + .byte 0x2 + .byte 0x7d + .byte 0 + .byte 0x7b + .byte 0x3 + .byte 0 + .byte 0x4 + .byte 0x7d + .byte 0 + .byte 0x7b + .align 4 + .long _ZTI4ExcC + .long _ZTI4ExcG + .long _ZTI4ExcA + .long 0 + +.LLSDATT15: + .section .text.startup + .size main, .-main + .weak _ZTI4ExcG + .section .rodata._ZTI4ExcG,"aG",@progbits,_ZTI4ExcG,comdat + .align 16 + .type _ZTI4ExcG, @object + .size _ZTI4ExcG, 16 +_ZTI4ExcG: + .quad _ZTVN10__cxxabiv117__class_type_infoE+16 + .quad _ZTS4ExcG + .weak _ZTS4ExcG + .section .rodata._ZTS4ExcG,"aG",@progbits,_ZTS4ExcG,comdat + .type _ZTS4ExcG, @object + .size _ZTS4ExcG, 6 +_ZTS4ExcG: + .string "4ExcG" + .weak _ZTI4ExcC + .section .rodata._ZTI4ExcC,"aG",@progbits,_ZTI4ExcC,comdat + .align 16 + .type _ZTI4ExcC, @object + .size _ZTI4ExcC, 16 +_ZTI4ExcC: + .quad _ZTVN10__cxxabiv117__class_type_infoE+16 + .quad _ZTS4ExcC + .weak _ZTS4ExcC + .section .rodata._ZTS4ExcC,"aG",@progbits,_ZTS4ExcC,comdat + .type _ZTS4ExcC, @object + .size _ZTS4ExcC, 6 +_ZTS4ExcC: + .string "4ExcC" + .weak _ZTI4ExcA + .section .rodata._ZTI4ExcA,"aG",@progbits,_ZTI4ExcA,comdat + .align 16 + .type _ZTI4ExcA, @object + .size _ZTI4ExcA, 16 +_ZTI4ExcA: + .quad _ZTVN10__cxxabiv117__class_type_infoE+16 + .quad _ZTS4ExcA + .weak _ZTS4ExcA + .section .rodata._ZTS4ExcA,"aG",@progbits,_ZTS4ExcA,comdat + .type _ZTS4ExcA, @object + .size _ZTS4ExcA, 6 +_ZTS4ExcA: + .string "4ExcA" + .weak _ZTI4ExcB + .section .rodata._ZTI4ExcB,"aG",@progbits,_ZTI4ExcB,comdat + .align 16 + .type _ZTI4ExcB, @object + .size _ZTI4ExcB, 16 +_ZTI4ExcB: + .quad _ZTVN10__cxxabiv117__class_type_infoE+16 + .quad _ZTS4ExcB + .weak _ZTS4ExcB + .section .rodata._ZTS4ExcB,"aG",@progbits,_ZTS4ExcB,comdat + .type _ZTS4ExcB, @object + .size _ZTS4ExcB, 6 +_ZTS4ExcB: + .string "4ExcB" + .weak _ZTI4ExcD + .section .rodata._ZTI4ExcD,"aG",@progbits,_ZTI4ExcD,comdat + .align 16 + .type _ZTI4ExcD, @object + .size _ZTI4ExcD, 16 +_ZTI4ExcD: + .quad _ZTVN10__cxxabiv117__class_type_infoE+16 + .quad _ZTS4ExcD + .weak _ZTS4ExcD + .section .rodata._ZTS4ExcD,"aG",@progbits,_ZTS4ExcD,comdat + .type _ZTS4ExcD, @object + .size _ZTS4ExcD, 6 +_ZTS4ExcD: + .string "4ExcD" + .weak _ZTI4ExcE + .section .rodata._ZTI4ExcE,"aG",@progbits,_ZTI4ExcE,comdat + .align 16 + .type _ZTI4ExcE, @object + .size _ZTI4ExcE, 16 +_ZTI4ExcE: + .quad _ZTVN10__cxxabiv117__class_type_infoE+16 + .quad _ZTS4ExcE + .weak _ZTS4ExcE + .section .rodata._ZTS4ExcE,"aG",@progbits,_ZTS4ExcE,comdat + .type _ZTS4ExcE, @object + .size _ZTS4ExcE, 6 +_ZTS4ExcE: + .string "4ExcE" + .weak _ZTI4ExcF + .section .rodata._ZTI4ExcF,"aG",@progbits,_ZTI4ExcF,comdat + .align 16 + .type _ZTI4ExcF, @object + .size _ZTI4ExcF, 16 +_ZTI4ExcF: + .quad _ZTVN10__cxxabiv117__class_type_infoE+16 + .quad _ZTS4ExcF + .weak _ZTS4ExcF + .section .rodata._ZTS4ExcF,"aG",@progbits,_ZTS4ExcF,comdat + .type _ZTS4ExcF, @object + .size _ZTS4ExcF, 6 +_ZTS4ExcF: + .string "4ExcF" diff --git a/bolt/test/X86/Inputs/exc4sw.fdata b/bolt/test/X86/Inputs/exc4sw.fdata new file mode 100644 index 000000000000..a12b7dea14f4 --- /dev/null +++ b/bolt/test/X86/Inputs/exc4sw.fdata @@ -0,0 +1,2 @@ +0 xxx 0 1 main 0 0 100 +1 main 14 1 main f9 0 100 diff --git a/bolt/test/X86/Inputs/static_exe.s b/bolt/test/X86/Inputs/static_exe.s new file mode 100644 index 000000000000..241076fb82db --- /dev/null +++ b/bolt/test/X86/Inputs/static_exe.s @@ -0,0 +1,10 @@ + .globl main + .type main, %function +main: + pushq %rbp + movq %rsp, %rbp + hlt + movl $0x0, %eax + popq %rbp + retq +.size main, .-main diff --git a/bolt/test/X86/Inputs/tailcall.s b/bolt/test/X86/Inputs/tailcall.s new file mode 100644 index 000000000000..2dd8209ff8f5 --- /dev/null +++ b/bolt/test/X86/Inputs/tailcall.s @@ -0,0 +1,29 @@ + .globl main + .type main, %function +main: + subq $0x8, %rsp + callq foo + movl $0x400638, %edi + callq puts@PLT + xorl %eax, %eax + addq $0x8, %rsp + retq +.size main, .-main + + .globl foo + .type foo, %function +foo: + jmp bar +.size foo, .-foo + + .globl bar + .type bar, %function +bar: + jmp baz +.size bar, .-bar + + .globl baz + .type baz, %function +baz: + retq +.size baz, .-baz diff --git a/bolt/test/X86/Inputs/vararg.s b/bolt/test/X86/Inputs/vararg.s new file mode 100644 index 000000000000..b191443f37fb --- /dev/null +++ b/bolt/test/X86/Inputs/vararg.s @@ -0,0 +1,567 @@ + .file "vararg.cpp" + .section .debug_abbrev,"",@progbits +.Ldebug_abbrev0: + .section .debug_info,"",@progbits +.Ldebug_info0: + .section .debug_line,"",@progbits +.Ldebug_line0: + .text +.Ltext0: +.globl _Z8myprintfPKcz + .type _Z8myprintfPKcz, @function +_Z8myprintfPKcz: +.LFB0: + .file 1 "./example.cpp" + .loc 1 3 0 + .cfi_startproc + pushq %rbp +.LCFI0: + .cfi_def_cfa_offset 16 + movq %rsp, %rbp + .cfi_offset 6, -16 +.LCFI1: + .cfi_def_cfa_register 6 + subq $104, %rsp + movq %rsi, -168(%rbp) + movq %rdx, -160(%rbp) + movq %rcx, -152(%rbp) + movq %r8, -144(%rbp) + movq %r9, -136(%rbp) + movzbl %al, %eax + leaq 0(,%rax,4), %rdx + movl $.L2, %eax + subq %rdx, %rax + leaq -1(%rbp), %rdx + jmp *%rax + movaps %xmm7, -15(%rdx) + movaps %xmm6, -31(%rdx) + movaps %xmm5, -47(%rdx) + movaps %xmm4, -63(%rdx) + movaps %xmm3, -79(%rdx) + movaps %xmm2, -95(%rdx) + movaps %xmm1, -111(%rdx) + movaps %xmm0, -127(%rdx) +.L2: + movq %rdi, -216(%rbp) +.LBB2: + .loc 1 5 0 + leaq -208(%rbp), %rax + movl $8, (%rax) + leaq -208(%rbp), %rax + movl $48, 4(%rax) + leaq -208(%rbp), %rax + leaq 16(%rbp), %rdx + movq %rdx, 8(%rax) + leaq -208(%rbp), %rax + leaq -176(%rbp), %rdx + movq %rdx, 16(%rax) + .loc 1 7 0 + movl $1, %eax +.LBE2: + .loc 1 8 0 + leave +.LCFI2: + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE0: + .size _Z8myprintfPKcz, .-_Z8myprintfPKcz +.globl main + .type main, @function +main: +.LFB1: + .loc 1 10 0 + .cfi_startproc + pushq %rbp +.LCFI3: + .cfi_def_cfa_offset 16 + movq %rsp, %rbp + .cfi_offset 6, -16 +.LCFI4: + .cfi_def_cfa_register 6 + .loc 1 11 0 + movl $0, %eax + .loc 1 12 0 + leave +.LCFI5: + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE1: + .size main, .-main +.Letext0: + .section .debug_loc,"",@progbits +.Ldebug_loc0: +.LLST0: + .quad .LFB0-.Ltext0 + .quad .LCFI0-.Ltext0 + .value 0x2 + .byte 0x77 + .sleb128 8 + .quad .LCFI0-.Ltext0 + .quad .LCFI1-.Ltext0 + .value 0x2 + .byte 0x77 + .sleb128 16 + .quad .LCFI1-.Ltext0 + .quad .LCFI2-.Ltext0 + .value 0x2 + .byte 0x76 + .sleb128 16 + .quad .LCFI2-.Ltext0 + .quad .LFE0-.Ltext0 + .value 0x2 + .byte 0x77 + .sleb128 8 + .quad 0x0 + .quad 0x0 +.LLST1: + .quad .LFB1-.Ltext0 + .quad .LCFI3-.Ltext0 + .value 0x2 + .byte 0x77 + .sleb128 8 + .quad .LCFI3-.Ltext0 + .quad .LCFI4-.Ltext0 + .value 0x2 + .byte 0x77 + .sleb128 16 + .quad .LCFI4-.Ltext0 + .quad .LCFI5-.Ltext0 + .value 0x2 + .byte 0x76 + .sleb128 16 + .quad .LCFI5-.Ltext0 + .quad .LFE1-.Ltext0 + .value 0x2 + .byte 0x77 + .sleb128 8 + .quad 0x0 + .quad 0x0 + .file 2 "" + .file 3 "/opt/compiler-explorer/gcc-4.5.3/bin/../lib/gcc/x86_64-linux-gnu/4.5.3/include/stdarg.h" + .section .debug_info + .long 0x138 + .value 0x2 + .long .Ldebug_abbrev0 + .byte 0x8 + .uleb128 0x1 + .long .LASF9 + .byte 0x4 + .long .LASF10 + .long .LASF11 + .quad .Ltext0 + .quad .Letext0 + .long .Ldebug_line0 + .uleb128 0x2 + .long .LASF6 + .byte 0x3 + .byte 0x28 + .long 0x38 + .uleb128 0x3 + .long 0x4f + .long 0x48 + .uleb128 0x4 + .long 0x48 + .byte 0x0 + .byte 0x0 + .uleb128 0x5 + .byte 0x8 + .byte 0x7 + .long .LASF4 + .uleb128 0x6 + .long .LASF12 + .byte 0x18 + .byte 0x2 + .byte 0x0 + .long 0x94 + .uleb128 0x7 + .long .LASF0 + .byte 0x2 + .byte 0x0 + .long 0x94 + .byte 0x2 + .byte 0x23 + .uleb128 0x0 + .uleb128 0x7 + .long .LASF1 + .byte 0x2 + .byte 0x0 + .long 0x94 + .byte 0x2 + .byte 0x23 + .uleb128 0x4 + .uleb128 0x7 + .long .LASF2 + .byte 0x2 + .byte 0x0 + .long 0x9b + .byte 0x2 + .byte 0x23 + .uleb128 0x8 + .uleb128 0x7 + .long .LASF3 + .byte 0x2 + .byte 0x0 + .long 0x9b + .byte 0x2 + .byte 0x23 + .uleb128 0x10 + .byte 0x0 + .uleb128 0x5 + .byte 0x4 + .byte 0x7 + .long .LASF5 + .uleb128 0x8 + .byte 0x8 + .uleb128 0x2 + .long .LASF7 + .byte 0x3 + .byte 0x66 + .long 0x2d + .uleb128 0x9 + .byte 0x1 + .long .LASF13 + .byte 0x1 + .byte 0x3 + .long .LASF14 + .long 0x102 + .quad .LFB0 + .quad .LFE0 + .long .LLST0 + .long 0x102 + .uleb128 0xa + .long .LASF15 + .byte 0x1 + .byte 0x3 + .long 0x109 + .byte 0x3 + .byte 0x91 + .sleb128 -232 + .uleb128 0xb + .uleb128 0xc + .quad .LBB2 + .quad .LBE2 + .uleb128 0xd + .long .LASF16 + .byte 0x1 + .byte 0x4 + .long 0x9d + .byte 0x3 + .byte 0x91 + .sleb128 -224 + .byte 0x0 + .byte 0x0 + .uleb128 0xe + .byte 0x4 + .byte 0x5 + .string "int" + .uleb128 0xf + .byte 0x8 + .long 0x10f + .uleb128 0x10 + .long 0x114 + .uleb128 0x5 + .byte 0x1 + .byte 0x6 + .long .LASF8 + .uleb128 0x11 + .byte 0x1 + .long .LASF17 + .byte 0x1 + .byte 0xa + .long 0x102 + .quad .LFB1 + .quad .LFE1 + .long .LLST1 + .byte 0x0 + .section .debug_abbrev + .uleb128 0x1 + .uleb128 0x11 + .byte 0x1 + .uleb128 0x25 + .uleb128 0xe + .uleb128 0x13 + .uleb128 0xb + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x1b + .uleb128 0xe + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x12 + .uleb128 0x1 + .uleb128 0x10 + .uleb128 0x6 + .byte 0x0 + .byte 0x0 + .uleb128 0x2 + .uleb128 0x16 + .byte 0x0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .byte 0x0 + .byte 0x0 + .uleb128 0x3 + .uleb128 0x1 + .byte 0x1 + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x1 + .uleb128 0x13 + .byte 0x0 + .byte 0x0 + .uleb128 0x4 + .uleb128 0x21 + .byte 0x0 + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x2f + .uleb128 0xb + .byte 0x0 + .byte 0x0 + .uleb128 0x5 + .uleb128 0x24 + .byte 0x0 + .uleb128 0xb + .uleb128 0xb + .uleb128 0x3e + .uleb128 0xb + .uleb128 0x3 + .uleb128 0xe + .byte 0x0 + .byte 0x0 + .uleb128 0x6 + .uleb128 0x13 + .byte 0x1 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0xb + .uleb128 0xb + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x1 + .uleb128 0x13 + .byte 0x0 + .byte 0x0 + .uleb128 0x7 + .uleb128 0xd + .byte 0x0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x38 + .uleb128 0xa + .byte 0x0 + .byte 0x0 + .uleb128 0x8 + .uleb128 0xf + .byte 0x0 + .uleb128 0xb + .uleb128 0xb + .byte 0x0 + .byte 0x0 + .uleb128 0x9 + .uleb128 0x2e + .byte 0x1 + .uleb128 0x3f + .uleb128 0xc + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x2007 + .uleb128 0xe + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x12 + .uleb128 0x1 + .uleb128 0x40 + .uleb128 0x6 + .uleb128 0x1 + .uleb128 0x13 + .byte 0x0 + .byte 0x0 + .uleb128 0xa + .uleb128 0x5 + .byte 0x0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x2 + .uleb128 0xa + .byte 0x0 + .byte 0x0 + .uleb128 0xb + .uleb128 0x18 + .byte 0x0 + .byte 0x0 + .byte 0x0 + .uleb128 0xc + .uleb128 0xb + .byte 0x1 + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x12 + .uleb128 0x1 + .byte 0x0 + .byte 0x0 + .uleb128 0xd + .uleb128 0x34 + .byte 0x0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x2 + .uleb128 0xa + .byte 0x0 + .byte 0x0 + .uleb128 0xe + .uleb128 0x24 + .byte 0x0 + .uleb128 0xb + .uleb128 0xb + .uleb128 0x3e + .uleb128 0xb + .uleb128 0x3 + .uleb128 0x8 + .byte 0x0 + .byte 0x0 + .uleb128 0xf + .uleb128 0xf + .byte 0x0 + .uleb128 0xb + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .byte 0x0 + .byte 0x0 + .uleb128 0x10 + .uleb128 0x26 + .byte 0x0 + .uleb128 0x49 + .uleb128 0x13 + .byte 0x0 + .byte 0x0 + .uleb128 0x11 + .uleb128 0x2e + .byte 0x0 + .uleb128 0x3f + .uleb128 0xc + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x12 + .uleb128 0x1 + .uleb128 0x40 + .uleb128 0x6 + .byte 0x0 + .byte 0x0 + .byte 0x0 + .section .debug_pubnames,"",@progbits + .long 0x24 + .value 0x2 + .long .Ldebug_info0 + .long 0x13c + .long 0xa8 + .string "myprintf" + .long 0x11b + .string "main" + .long 0x0 + .section .debug_pubtypes,"",@progbits + .long 0x3f + .value 0x2 + .long .Ldebug_info0 + .long 0x13c + .long 0x4f + .string "__va_list_tag" + .long 0x2d + .string "__gnuc_va_list" + .long 0x9d + .string "va_list" + .long 0x0 + .section .debug_aranges,"",@progbits + .long 0x2c + .value 0x2 + .long .Ldebug_info0 + .byte 0x8 + .byte 0x0 + .value 0x0 + .value 0x0 + .quad .Ltext0 + .quad .Letext0-.Ltext0 + .quad 0x0 + .quad 0x0 + .section .debug_str,"MS",@progbits,1 +.LASF5: + .string "unsigned int" +.LASF12: + .string "typedef __va_list_tag __va_list_tag" +.LASF6: + .string "__gnuc_va_list" +.LASF13: + .string "myprintf" +.LASF0: + .string "gp_offset" +.LASF1: + .string "fp_offset" +.LASF7: + .string "va_list" +.LASF11: + .string "/home/ubuntu" +.LASF3: + .string "reg_save_area" +.LASF15: + .string "format" +.LASF17: + .string "main" +.LASF4: + .string "long unsigned int" +.LASF14: + .string "_Z8myprintfPKcz" +.LASF9: + .string "GNU C++ 4.5.3" +.LASF16: + .string "argp" +.LASF10: + .string "./example.cpp" +.LASF2: + .string "overflow_arg_area" +.LASF8: + .string "char" + .ident "GCC: (GCC-Explorer-Build) 4.5.3" + .section .note.GNU-stack,"",@progbits diff --git a/bolt/test/X86/Inputs/vararg_pic.s b/bolt/test/X86/Inputs/vararg_pic.s new file mode 100644 index 000000000000..2a2930f201ce --- /dev/null +++ b/bolt/test/X86/Inputs/vararg_pic.s @@ -0,0 +1,567 @@ + .file "example.cpp" + .section .debug_abbrev,"",@progbits +.Ldebug_abbrev0: + .section .debug_info,"",@progbits +.Ldebug_info0: + .section .debug_line,"",@progbits +.Ldebug_line0: + .text +.Ltext0: +.globl _Z8myprintfPKcz + .type _Z8myprintfPKcz, @function +_Z8myprintfPKcz: +.LFB0: + .file 1 "./example.cpp" + .loc 1 3 0 + .cfi_startproc + pushq %rbp +.LCFI0: + .cfi_def_cfa_offset 16 + movq %rsp, %rbp + .cfi_offset 6, -16 +.LCFI1: + .cfi_def_cfa_register 6 + subq $104, %rsp + movq %rsi, -168(%rbp) + movq %rdx, -160(%rbp) + movq %rcx, -152(%rbp) + movq %r8, -144(%rbp) + movq %r9, -136(%rbp) + movzbl %al, %eax + leaq 0(,%rax,4), %rdx + leaq .L2(%rip), %rax + subq %rdx, %rax + leaq -1(%rbp), %rdx + jmp *%rax + movaps %xmm7, -15(%rdx) + movaps %xmm6, -31(%rdx) + movaps %xmm5, -47(%rdx) + movaps %xmm4, -63(%rdx) + movaps %xmm3, -79(%rdx) + movaps %xmm2, -95(%rdx) + movaps %xmm1, -111(%rdx) + movaps %xmm0, -127(%rdx) +.L2: + movq %rdi, -216(%rbp) +.LBB2: + .loc 1 5 0 + leaq -208(%rbp), %rax + movl $8, (%rax) + leaq -208(%rbp), %rax + movl $48, 4(%rax) + leaq -208(%rbp), %rax + leaq 16(%rbp), %rdx + movq %rdx, 8(%rax) + leaq -208(%rbp), %rax + leaq -176(%rbp), %rdx + movq %rdx, 16(%rax) + .loc 1 7 0 + movl $1, %eax +.LBE2: + .loc 1 8 0 + leave +.LCFI2: + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE0: + .size _Z8myprintfPKcz, .-_Z8myprintfPKcz +.globl main + .type main, @function +main: +.LFB1: + .loc 1 10 0 + .cfi_startproc + pushq %rbp +.LCFI3: + .cfi_def_cfa_offset 16 + movq %rsp, %rbp + .cfi_offset 6, -16 +.LCFI4: + .cfi_def_cfa_register 6 + .loc 1 11 0 + movl $0, %eax + .loc 1 12 0 + leave +.LCFI5: + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE1: + .size main, .-main +.Letext0: + .section .debug_loc,"",@progbits +.Ldebug_loc0: +.LLST0: + .quad .LFB0-.Ltext0 + .quad .LCFI0-.Ltext0 + .value 0x2 + .byte 0x77 + .sleb128 8 + .quad .LCFI0-.Ltext0 + .quad .LCFI1-.Ltext0 + .value 0x2 + .byte 0x77 + .sleb128 16 + .quad .LCFI1-.Ltext0 + .quad .LCFI2-.Ltext0 + .value 0x2 + .byte 0x76 + .sleb128 16 + .quad .LCFI2-.Ltext0 + .quad .LFE0-.Ltext0 + .value 0x2 + .byte 0x77 + .sleb128 8 + .quad 0x0 + .quad 0x0 +.LLST1: + .quad .LFB1-.Ltext0 + .quad .LCFI3-.Ltext0 + .value 0x2 + .byte 0x77 + .sleb128 8 + .quad .LCFI3-.Ltext0 + .quad .LCFI4-.Ltext0 + .value 0x2 + .byte 0x77 + .sleb128 16 + .quad .LCFI4-.Ltext0 + .quad .LCFI5-.Ltext0 + .value 0x2 + .byte 0x76 + .sleb128 16 + .quad .LCFI5-.Ltext0 + .quad .LFE1-.Ltext0 + .value 0x2 + .byte 0x77 + .sleb128 8 + .quad 0x0 + .quad 0x0 + .file 2 "" + .file 3 "/opt/compiler-explorer/gcc-4.5.3/bin/../lib/gcc/x86_64-linux-gnu/4.5.3/include/stdarg.h" + .section .debug_info + .long 0x138 + .value 0x2 + .long .Ldebug_abbrev0 + .byte 0x8 + .uleb128 0x1 + .long .LASF9 + .byte 0x4 + .long .LASF10 + .long .LASF11 + .quad .Ltext0 + .quad .Letext0 + .long .Ldebug_line0 + .uleb128 0x2 + .long .LASF6 + .byte 0x3 + .byte 0x28 + .long 0x38 + .uleb128 0x3 + .long 0x4f + .long 0x48 + .uleb128 0x4 + .long 0x48 + .byte 0x0 + .byte 0x0 + .uleb128 0x5 + .byte 0x8 + .byte 0x7 + .long .LASF4 + .uleb128 0x6 + .long .LASF12 + .byte 0x18 + .byte 0x2 + .byte 0x0 + .long 0x94 + .uleb128 0x7 + .long .LASF0 + .byte 0x2 + .byte 0x0 + .long 0x94 + .byte 0x2 + .byte 0x23 + .uleb128 0x0 + .uleb128 0x7 + .long .LASF1 + .byte 0x2 + .byte 0x0 + .long 0x94 + .byte 0x2 + .byte 0x23 + .uleb128 0x4 + .uleb128 0x7 + .long .LASF2 + .byte 0x2 + .byte 0x0 + .long 0x9b + .byte 0x2 + .byte 0x23 + .uleb128 0x8 + .uleb128 0x7 + .long .LASF3 + .byte 0x2 + .byte 0x0 + .long 0x9b + .byte 0x2 + .byte 0x23 + .uleb128 0x10 + .byte 0x0 + .uleb128 0x5 + .byte 0x4 + .byte 0x7 + .long .LASF5 + .uleb128 0x8 + .byte 0x8 + .uleb128 0x2 + .long .LASF7 + .byte 0x3 + .byte 0x66 + .long 0x2d + .uleb128 0x9 + .byte 0x1 + .long .LASF13 + .byte 0x1 + .byte 0x3 + .long .LASF14 + .long 0x102 + .quad .LFB0 + .quad .LFE0 + .long .LLST0 + .long 0x102 + .uleb128 0xa + .long .LASF15 + .byte 0x1 + .byte 0x3 + .long 0x109 + .byte 0x3 + .byte 0x91 + .sleb128 -232 + .uleb128 0xb + .uleb128 0xc + .quad .LBB2 + .quad .LBE2 + .uleb128 0xd + .long .LASF16 + .byte 0x1 + .byte 0x4 + .long 0x9d + .byte 0x3 + .byte 0x91 + .sleb128 -224 + .byte 0x0 + .byte 0x0 + .uleb128 0xe + .byte 0x4 + .byte 0x5 + .string "int" + .uleb128 0xf + .byte 0x8 + .long 0x10f + .uleb128 0x10 + .long 0x114 + .uleb128 0x5 + .byte 0x1 + .byte 0x6 + .long .LASF8 + .uleb128 0x11 + .byte 0x1 + .long .LASF17 + .byte 0x1 + .byte 0xa + .long 0x102 + .quad .LFB1 + .quad .LFE1 + .long .LLST1 + .byte 0x0 + .section .debug_abbrev + .uleb128 0x1 + .uleb128 0x11 + .byte 0x1 + .uleb128 0x25 + .uleb128 0xe + .uleb128 0x13 + .uleb128 0xb + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x1b + .uleb128 0xe + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x12 + .uleb128 0x1 + .uleb128 0x10 + .uleb128 0x6 + .byte 0x0 + .byte 0x0 + .uleb128 0x2 + .uleb128 0x16 + .byte 0x0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .byte 0x0 + .byte 0x0 + .uleb128 0x3 + .uleb128 0x1 + .byte 0x1 + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x1 + .uleb128 0x13 + .byte 0x0 + .byte 0x0 + .uleb128 0x4 + .uleb128 0x21 + .byte 0x0 + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x2f + .uleb128 0xb + .byte 0x0 + .byte 0x0 + .uleb128 0x5 + .uleb128 0x24 + .byte 0x0 + .uleb128 0xb + .uleb128 0xb + .uleb128 0x3e + .uleb128 0xb + .uleb128 0x3 + .uleb128 0xe + .byte 0x0 + .byte 0x0 + .uleb128 0x6 + .uleb128 0x13 + .byte 0x1 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0xb + .uleb128 0xb + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x1 + .uleb128 0x13 + .byte 0x0 + .byte 0x0 + .uleb128 0x7 + .uleb128 0xd + .byte 0x0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x38 + .uleb128 0xa + .byte 0x0 + .byte 0x0 + .uleb128 0x8 + .uleb128 0xf + .byte 0x0 + .uleb128 0xb + .uleb128 0xb + .byte 0x0 + .byte 0x0 + .uleb128 0x9 + .uleb128 0x2e + .byte 0x1 + .uleb128 0x3f + .uleb128 0xc + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x2007 + .uleb128 0xe + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x12 + .uleb128 0x1 + .uleb128 0x40 + .uleb128 0x6 + .uleb128 0x1 + .uleb128 0x13 + .byte 0x0 + .byte 0x0 + .uleb128 0xa + .uleb128 0x5 + .byte 0x0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x2 + .uleb128 0xa + .byte 0x0 + .byte 0x0 + .uleb128 0xb + .uleb128 0x18 + .byte 0x0 + .byte 0x0 + .byte 0x0 + .uleb128 0xc + .uleb128 0xb + .byte 0x1 + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x12 + .uleb128 0x1 + .byte 0x0 + .byte 0x0 + .uleb128 0xd + .uleb128 0x34 + .byte 0x0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x2 + .uleb128 0xa + .byte 0x0 + .byte 0x0 + .uleb128 0xe + .uleb128 0x24 + .byte 0x0 + .uleb128 0xb + .uleb128 0xb + .uleb128 0x3e + .uleb128 0xb + .uleb128 0x3 + .uleb128 0x8 + .byte 0x0 + .byte 0x0 + .uleb128 0xf + .uleb128 0xf + .byte 0x0 + .uleb128 0xb + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .byte 0x0 + .byte 0x0 + .uleb128 0x10 + .uleb128 0x26 + .byte 0x0 + .uleb128 0x49 + .uleb128 0x13 + .byte 0x0 + .byte 0x0 + .uleb128 0x11 + .uleb128 0x2e + .byte 0x0 + .uleb128 0x3f + .uleb128 0xc + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x12 + .uleb128 0x1 + .uleb128 0x40 + .uleb128 0x6 + .byte 0x0 + .byte 0x0 + .byte 0x0 + .section .debug_pubnames,"",@progbits + .long 0x24 + .value 0x2 + .long .Ldebug_info0 + .long 0x13c + .long 0xa8 + .string "myprintf" + .long 0x11b + .string "main" + .long 0x0 + .section .debug_pubtypes,"",@progbits + .long 0x3f + .value 0x2 + .long .Ldebug_info0 + .long 0x13c + .long 0x4f + .string "__va_list_tag" + .long 0x2d + .string "__gnuc_va_list" + .long 0x9d + .string "va_list" + .long 0x0 + .section .debug_aranges,"",@progbits + .long 0x2c + .value 0x2 + .long .Ldebug_info0 + .byte 0x8 + .byte 0x0 + .value 0x0 + .value 0x0 + .quad .Ltext0 + .quad .Letext0-.Ltext0 + .quad 0x0 + .quad 0x0 + .section .debug_str,"MS",@progbits,1 +.LASF5: + .string "unsigned int" +.LASF12: + .string "typedef __va_list_tag __va_list_tag" +.LASF6: + .string "__gnuc_va_list" +.LASF13: + .string "myprintf" +.LASF0: + .string "gp_offset" +.LASF1: + .string "fp_offset" +.LASF7: + .string "va_list" +.LASF11: + .string "/home/ubuntu" +.LASF3: + .string "reg_save_area" +.LASF15: + .string "format" +.LASF17: + .string "main" +.LASF4: + .string "long unsigned int" +.LASF14: + .string "_Z8myprintfPKcz" +.LASF9: + .string "GNU C++ 4.5.3" +.LASF16: + .string "argp" +.LASF10: + .string "./example.cpp" +.LASF2: + .string "overflow_arg_area" +.LASF8: + .string "char" + .ident "GCC: (GCC-Explorer-Build) 4.5.3" + .section .note.GNU-stack,"",@progbits diff --git a/bolt/test/X86/shared_object.test b/bolt/test/X86/shared_object.test new file mode 100644 index 000000000000..d00fedc982d8 --- /dev/null +++ b/bolt/test/X86/shared_object.test @@ -0,0 +1,5 @@ +# Test that llvm-bolt processes *.so without a failure +RUN: %clang %S/Inputs/icf-jump-tables.c -o %t.so -shared -fPIC -Wl,--build-id +RUN: llvm-bolt %t.so -o %t | FileCheck %s + +CHECK: patched build-id diff --git a/bolt/test/X86/shrinkwrapping.test b/bolt/test/X86/shrinkwrapping.test new file mode 100644 index 000000000000..85fa47accb8c --- /dev/null +++ b/bolt/test/X86/shrinkwrapping.test @@ -0,0 +1,45 @@ +# Verifies that llvm-bolt updates CFI correctly after +# shrink-wrapping when optimizing a function without +# frame pointers. + +RUN: %clangxx -O3 %S/Inputs/exc4sw.S -o %t.exe -Wl,-q +RUN: llvm-bolt %t.exe -o %t -relocs -frame-opt=all \ +RUN: -data=%p/Inputs/exc4sw.fdata -reorder-blocks=cache 2>&1 | \ +RUN: FileCheck %s --check-prefix=CHECK-BOLT + +RUN: llvm-objdump --dwarf=frames %t.exe | grep -A20 -e \ +RUN: `llvm-nm --numeric-sort %t.exe | grep main | tail -n 1 | \ +RUN: cut -f1 -d' ' | tail -c9` 2>&1 | FileCheck %s --check-prefix=CHECK-INPUT + +RUN: llvm-objdump --dwarf=frames %t | grep -A20 -e \ +RUN: `llvm-nm --numeric-sort %t | grep main | tail -n 1 | cut -f1 -d' ' | \ +RUN: tail -c9` 2>&1 | FileCheck %s --check-prefix=CHECK-OUTPUT + +CHECK-BOLT: Shrink wrapping moved 2 spills inserting load/stores and 0 spills inserting push/pops + +CHECK-INPUT: DW_CFA_advance_loc: 2 +CHECK-INPUT-NEXT: DW_CFA_def_cfa_offset: +16 +CHECK-INPUT-NEXT: DW_CFA_offset: reg13 -16 +CHECK-INPUT-NEXT: DW_CFA_advance_loc: 2 +CHECK-INPUT-NEXT: DW_CFA_def_cfa_offset: +24 +CHECK-INPUT-NEXT: DW_CFA_offset: reg12 -24 +CHECK-INPUT-NEXT: DW_CFA_advance_loc: 1 +CHECK-INPUT-NEXT: DW_CFA_def_cfa_offset: +32 +CHECK-INPUT-NEXT: DW_CFA_offset: reg6 -32 +CHECK-INPUT-NEXT: DW_CFA_advance_loc: 6 +CHECK-INPUT-NEXT: DW_CFA_def_cfa_offset: +40 +CHECK-INPUT-NEXT: DW_CFA_offset: reg3 -40 +CHECK-INPUT-NEXT: DW_CFA_advance_loc: 6 +CHECK-INPUT-NEXT: DW_CFA_def_cfa_offset: +48 + +CHECK-OUTPUT: DW_CFA_advance_loc: 4 +CHECK-OUTPUT-NEXT: DW_CFA_def_cfa_offset: +16 +CHECK-OUTPUT-NEXT: DW_CFA_def_cfa_offset: +24 +CHECK-OUTPUT-NEXT: DW_CFA_advance_loc: 1 +CHECK-OUTPUT-NEXT: DW_CFA_def_cfa_offset: +32 +CHECK-OUTPUT-NEXT: DW_CFA_offset: reg6 -32 +CHECK-OUTPUT-NEXT: DW_CFA_advance_loc: 6 +CHECK-OUTPUT-NEXT: DW_CFA_def_cfa_offset: +40 +CHECK-OUTPUT-NEXT: DW_CFA_offset: reg3 -40 +CHECK-OUTPUT-NEXT: DW_CFA_advance_loc: 6 +CHECK-OUTPUT-NEXT: DW_CFA_def_cfa_offset: +48 diff --git a/bolt/test/X86/static_exe.test b/bolt/test/X86/static_exe.test new file mode 100644 index 000000000000..2c1029d646b9 --- /dev/null +++ b/bolt/test/X86/static_exe.test @@ -0,0 +1,6 @@ +# Check that llvm-bolt can rewrite static executable + +RUN: %clang %S/Inputs/static_exe.s -static -o %t.exe -nostdlib +RUN: llvm-bolt %t.exe -o %t |& FileCheck %s + +CHECK: 1 out of 1 functions were overwritten diff --git a/bolt/test/X86/tailcall.test b/bolt/test/X86/tailcall.test new file mode 100644 index 000000000000..f73bb37d6d3e --- /dev/null +++ b/bolt/test/X86/tailcall.test @@ -0,0 +1,13 @@ +# Verifies that llvm-bolt recognizes tailcalls and mark them +# in control flow graph. + +RUN: %clang %S/Inputs/tailcall.s -o %t.exe +RUN: llvm-bolt %t.exe -o /dev/null -print-cfg 2>&1 | FileCheck %s + +CHECK: Binary Function "foo" +CHECK: jmp bar # TAILCALL +CHECK: End of Function "foo" + +CHECK: Binary Function "bar" +CHECK: jmp baz # TAILCALL +CHECK: End of Function "bar" diff --git a/bolt/test/X86/vararg.test b/bolt/test/X86/vararg.test new file mode 100644 index 000000000000..66b83e550191 --- /dev/null +++ b/bolt/test/X86/vararg.test @@ -0,0 +1,19 @@ +# Check that a function that references a label inside itself, +# as in the case of vararg handling code generated by GCC 4.5 +# and earlier, is recognized as multi-entry. + +REQUIRES: x86_64-linux + +RUN: %clangxx %p/Inputs/vararg.s -o %t -Wl,-q +RUN: llvm-bolt %t -o /dev/null -print-cfg -print-only=.*printf.* |& FileCheck %s +RUN: %clangxx %p/Inputs/vararg_pic.s -o %t.pic -Wl,-q +RUN: llvm-bolt %t.pic -o /dev/null -print-cfg -print-only=.*printf.* \ +RUN: |& FileCheck -check-prefix=CHECK-PIC %s + +CHECK: IsSimple : 0 +CHECK: Entry Point +CHECK: Entry Point + +CHECK-PIC: IsSimple : 0 +CHECK-PIC: Entry Point +CHECK-PIC: Entry Point