File: jump_table_bitcast.ll

package info (click to toggle)
llvm-toolchain-3.5 1%3A3.5-10
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 282,028 kB
  • ctags: 310,872
  • sloc: cpp: 1,883,926; ansic: 310,731; objc: 86,612; python: 79,565; asm: 65,844; sh: 9,829; makefile: 6,057; perl: 5,589; ml: 5,254; pascal: 3,285; lisp: 1,640; xml: 686; cs: 239; csh: 117
file content (46 lines) | stat: -rw-r--r-- 1,558 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
; RUN: llc <%s -jump-table-type=single | FileCheck %s
target triple = "x86_64-unknown-linux-gnu"
define i32 @f() unnamed_addr jumptable {
  ret i32 0
}

define i32 @g(i8* %a) unnamed_addr jumptable {
  ret i32 0
}

define void @h(void ()* %func) unnamed_addr jumptable {
  ret void
}

define i32 @main() {
  %g = alloca i32 (...)*, align 8
  store i32 (...)* bitcast (i32 ()* @f to i32 (...)*), i32 (...)** %g, align 8
; CHECK: movq    $__llvm_jump_instr_table_0_[[ENTRY:1|2|3]], (%rsp)
; CHECK: movl    $__llvm_jump_instr_table_0_[[ENTRY]], %ecx
  %1 = load i32 (...)** %g, align 8
  %call = call i32 (...)* %1()
  call void (void ()*)* @h(void ()* bitcast (void (void ()*)* @h to void ()*))
; CHECK: movl    $__llvm_jump_instr_table_0_{{1|2|3}}, %edi
; CHECK: callq   h

  %a = call i32 (i32*)* bitcast (i32 (i8*)* @g to i32(i32*)*)(i32* null)
; CHECK: callq g
  ret i32 %a
}

; CHECK:         .globl  __llvm_jump_instr_table_0_1
; CHECK:         .align  8, 0x90
; CHECK:         .type   __llvm_jump_instr_table_0_1,@function
; CHECK: __llvm_jump_instr_table_0_1:
; CHECK:         jmp     {{f|g|h}}@PLT
; CHECK:         .globl  __llvm_jump_instr_table_0_2
; CHECK:         .align  8, 0x90
; CHECK:         .type   __llvm_jump_instr_table_0_2,@function
; CHECK: __llvm_jump_instr_table_0_2:
; CHECK:         jmp     {{f|g|h}}@PLT
; CHECK:         .globl  __llvm_jump_instr_table_0_3
; CHECK:         .align  8, 0x90
; CHECK:         .type   __llvm_jump_instr_table_0_3,@function
; CHECK: __llvm_jump_instr_table_0_3:
; CHECK:         jmp     {{f|g|h}}@PLT