133 lines · plain
1## Check that jump table detection does not fail on a false2## reference to a jump table.3 4# REQUIRES: system-linux5 6# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \7# RUN: %s -o %t.o8# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q9 10# RUN: llvm-bolt %t.exe --print-cfg \11# RUN: --print-only=inc_dup -o %t.out | FileCheck %s12 13 .file "jump_table.c"14 .section .rodata15.LC0:16 .string "0"17.LC1:18 .string "1"19.LC2:20 .string "2"21.LC3:22 .string "3"23.LC4:24 .string "4"25.LC5:26 .string "5"27 .text28 .globl inc_dup29 .type inc_dup, @function30inc_dup:31.LFB0:32 .cfi_startproc33 pushq %rbp34 .cfi_def_cfa_offset 1635 .cfi_offset 6, -1636 movq %rsp, %rbp37 .cfi_def_cfa_register 638 subq $16, %rsp39 movl %edi, -4(%rbp)40 movl -4(%rbp), %eax41 subl $10, %eax42 cmpl $5, %eax43 ja .L244# Control flow confusing for JT detection45# CHECK: leaq "JUMP_TABLE{{.*}}"(%rip), %rdx46 leaq .L4(%rip), %rdx47 jmp .LJT48# CHECK: leaq {{.*}}(%rip), %rdx49 leaq .LC0(%rip), %rdx50 jmp .L1051.LJT:52 movslq (%rdx,%rax,4), %rax53 addq %rdx, %rax54# CHECK: jmpq *%rax # UNKNOWN CONTROL FLOW55 jmp *%rax56 .section .rodata57 .align 458 .align 459.L4:60 .long .L3-.L461 .long .L5-.L462 .long .L6-.L463 .long .L7-.L464 .long .L8-.L465 .long .L9-.L466 .text67.L3:68 leaq .LC0(%rip), %rdi69 call puts@PLT70 movl $1, %eax71 jmp .L1072.L5:73 leaq .LC1(%rip), %rdi74 call puts@PLT75 movl $2, %eax76 jmp .L1077.L6:78 leaq .LC2(%rip), %rdi79 call puts@PLT80 movl $3, %eax81 jmp .L1082.L7:83 leaq .LC3(%rip), %rdi84 call puts@PLT85 movl $4, %eax86 jmp .L1087.L8:88 leaq .LC4(%rip), %rdi89 call puts@PLT90 movl $5, %eax91 jmp .L1092.L9:93 leaq .LC5(%rip), %rdi94 call puts@PLT95 movl $6, %eax96 jmp .L1097.L2:98 movl -4(%rbp), %eax99 addl $1, %eax100.L10:101 leave102 .cfi_def_cfa 7, 8103 ret104 .cfi_endproc105.LFE0:106 .size inc_dup, .-inc_dup107 .text108 .globl main109 .type main, @function110main:111.LFB1:112 .cfi_startproc113 pushq %rbp114 .cfi_def_cfa_offset 16115 .cfi_offset 6, -16116 movq %rsp, %rbp117 .cfi_def_cfa_register 6118 subq $16, %rsp119 movl %edi, -4(%rbp)120 movq %rsi, -16(%rbp)121 movl -4(%rbp), %eax122 addl $9, %eax123 movl %eax, %edi124 call inc_dup@PLT125 leave126 .cfi_def_cfa 7, 8127 ret128 .cfi_endproc129.LFE1:130 .size main, .-main131 .ident "GCC: (GNU) 6.3.0"132 .section .note.GNU-stack,"",@progbits133