mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
63dea2c952
This commit adds a new pass that can inject checks before indirect calls to make sure that these calls target known locations. It supports three types of checks and, at compile time, it can take the name of a custom function to call when an indirect call check fails. The default failure function ignores the error and continues. This pass incidentally moves the function JumpInstrTables::transformType from private to public and makes it static (with a new argument that specifies the table type to use); this is so that the CFI code can transform function types at call sites to determine which jump-instruction table to use for the check at that site. Also, this removes support for jumptables in ARM, pending further performance analysis and discussion. Review: http://reviews.llvm.org/D4167 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221708 91177308-0d34-0410-b5e6-96231b3b80d8
30 lines
994 B
LLVM
30 lines
994 B
LLVM
; RUN: llc -filetype=obj <%s -jump-table-type=single -o %t1
|
|
; RUN: llvm-objdump -triple=x86_64-unknown-linux-gnu -d %t1 | 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
|
|
%1 = load i32 (...)** %g, align 8
|
|
%call = call i32 (...)* %1()
|
|
call void (void ()*)* @h(void ()* bitcast (void (void ()*)* @h to void ()*))
|
|
%a = call i32 (i32*)* bitcast (i32 (i8*)* @g to i32(i32*)*)(i32* null)
|
|
ret i32 %a
|
|
}
|
|
|
|
; Make sure that the padding from getJumpInstrTableEntryBound is right.
|
|
; CHECK: __llvm_jump_instr_table_0_1:
|
|
; CHECK-NEXT: e9 00 00 00 00 jmp 0
|
|
; CHECK-NEXT: 0f 1f 00 nopl (%rax)
|