[WIP] Add a Trap sink to code generation (#279)
* First draft of TrapSink implementation. * Add trap sink calls to 'trapif' and 'trapff' recipes. * Add SourceLoc to trap sink calls, and add trap sink calls to all loads and stores. * Add IntegerDivisionByZero trap to div recipe. * Only emit load/store traps if 'notrap' flag is not set on the instruction. * Update filetest machinery to add new trap sink functionality. * Update filetests to include traps in output. * Add a few more trap outputs to filetests. * Add trap output to CLI tool.
This commit is contained in:
committed by
Dan Gohman
parent
d566faa8fb
commit
951ff11f85
@@ -128,13 +128,13 @@ ebb0:
|
||||
; asm: movl $2, %edx
|
||||
[-,%rdx] v53 = iconst.i32 2 ; bin: ba 00000002
|
||||
; asm: idivl %ecx
|
||||
[-,%rax,%rdx] v54, v55 = x86_sdivmodx v52, v53, v1 ; bin: f7 f9
|
||||
[-,%rax,%rdx] v54, v55 = x86_sdivmodx v52, v53, v1 ; bin: int_divz f7 f9
|
||||
; asm: idivl %esi
|
||||
[-,%rax,%rdx] v56, v57 = x86_sdivmodx v52, v53, v2 ; bin: f7 fe
|
||||
[-,%rax,%rdx] v56, v57 = x86_sdivmodx v52, v53, v2 ; bin: int_divz f7 fe
|
||||
; asm: divl %ecx
|
||||
[-,%rax,%rdx] v58, v59 = x86_udivmodx v52, v53, v1 ; bin: f7 f1
|
||||
[-,%rax,%rdx] v58, v59 = x86_udivmodx v52, v53, v1 ; bin: int_divz f7 f1
|
||||
; asm: divl %esi
|
||||
[-,%rax,%rdx] v60, v61 = x86_udivmodx v52, v53, v2 ; bin: f7 f6
|
||||
[-,%rax,%rdx] v60, v61 = x86_udivmodx v52, v53, v2 ; bin: int_divz f7 f6
|
||||
|
||||
; Register copies.
|
||||
|
||||
@@ -155,105 +155,105 @@ ebb0:
|
||||
; Register indirect addressing with no displacement.
|
||||
|
||||
; asm: movl %ecx, (%esi)
|
||||
store v1, v2 ; bin: 89 0e
|
||||
store v1, v2 ; bin: heap_oob 89 0e
|
||||
; asm: movl %esi, (%ecx)
|
||||
store v2, v1 ; bin: 89 31
|
||||
store v2, v1 ; bin: heap_oob 89 31
|
||||
; asm: movw %cx, (%esi)
|
||||
istore16 v1, v2 ; bin: 66 89 0e
|
||||
istore16 v1, v2 ; bin: heap_oob 66 89 0e
|
||||
; asm: movw %si, (%ecx)
|
||||
istore16 v2, v1 ; bin: 66 89 31
|
||||
istore16 v2, v1 ; bin: heap_oob 66 89 31
|
||||
; asm: movb %cl, (%esi)
|
||||
istore8 v1, v2 ; bin: 88 0e
|
||||
istore8 v1, v2 ; bin: heap_oob 88 0e
|
||||
; Can't store %sil in 32-bit mode (needs REX prefix).
|
||||
|
||||
; asm: movl (%ecx), %edi
|
||||
[-,%rdi] v100 = load.i32 v1 ; bin: 8b 39
|
||||
[-,%rdi] v100 = load.i32 v1 ; bin: heap_oob 8b 39
|
||||
; asm: movl (%esi), %edx
|
||||
[-,%rdx] v101 = load.i32 v2 ; bin: 8b 16
|
||||
[-,%rdx] v101 = load.i32 v2 ; bin: heap_oob 8b 16
|
||||
; asm: movzwl (%ecx), %edi
|
||||
[-,%rdi] v102 = uload16.i32 v1 ; bin: 0f b7 39
|
||||
[-,%rdi] v102 = uload16.i32 v1 ; bin: heap_oob 0f b7 39
|
||||
; asm: movzwl (%esi), %edx
|
||||
[-,%rdx] v103 = uload16.i32 v2 ; bin: 0f b7 16
|
||||
[-,%rdx] v103 = uload16.i32 v2 ; bin: heap_oob 0f b7 16
|
||||
; asm: movswl (%ecx), %edi
|
||||
[-,%rdi] v104 = sload16.i32 v1 ; bin: 0f bf 39
|
||||
[-,%rdi] v104 = sload16.i32 v1 ; bin: heap_oob 0f bf 39
|
||||
; asm: movswl (%esi), %edx
|
||||
[-,%rdx] v105 = sload16.i32 v2 ; bin: 0f bf 16
|
||||
[-,%rdx] v105 = sload16.i32 v2 ; bin: heap_oob 0f bf 16
|
||||
; asm: movzbl (%ecx), %edi
|
||||
[-,%rdi] v106 = uload8.i32 v1 ; bin: 0f b6 39
|
||||
[-,%rdi] v106 = uload8.i32 v1 ; bin: heap_oob 0f b6 39
|
||||
; asm: movzbl (%esi), %edx
|
||||
[-,%rdx] v107 = uload8.i32 v2 ; bin: 0f b6 16
|
||||
[-,%rdx] v107 = uload8.i32 v2 ; bin: heap_oob 0f b6 16
|
||||
; asm: movsbl (%ecx), %edi
|
||||
[-,%rdi] v108 = sload8.i32 v1 ; bin: 0f be 39
|
||||
[-,%rdi] v108 = sload8.i32 v1 ; bin: heap_oob 0f be 39
|
||||
; asm: movsbl (%esi), %edx
|
||||
[-,%rdx] v109 = sload8.i32 v2 ; bin: 0f be 16
|
||||
[-,%rdx] v109 = sload8.i32 v2 ; bin: heap_oob 0f be 16
|
||||
|
||||
; Register-indirect with 8-bit signed displacement.
|
||||
|
||||
; asm: movl %ecx, 100(%esi)
|
||||
store v1, v2+100 ; bin: 89 4e 64
|
||||
store v1, v2+100 ; bin: heap_oob 89 4e 64
|
||||
; asm: movl %esi, -100(%ecx)
|
||||
store v2, v1-100 ; bin: 89 71 9c
|
||||
store v2, v1-100 ; bin: heap_oob 89 71 9c
|
||||
; asm: movw %cx, 100(%esi)
|
||||
istore16 v1, v2+100 ; bin: 66 89 4e 64
|
||||
istore16 v1, v2+100 ; bin: heap_oob 66 89 4e 64
|
||||
; asm: movw %si, -100(%ecx)
|
||||
istore16 v2, v1-100 ; bin: 66 89 71 9c
|
||||
istore16 v2, v1-100 ; bin: heap_oob 66 89 71 9c
|
||||
; asm: movb %cl, 100(%esi)
|
||||
istore8 v1, v2+100 ; bin: 88 4e 64
|
||||
istore8 v1, v2+100 ; bin: heap_oob 88 4e 64
|
||||
|
||||
; asm: movl 50(%ecx), %edi
|
||||
[-,%rdi] v110 = load.i32 v1+50 ; bin: 8b 79 32
|
||||
[-,%rdi] v110 = load.i32 v1+50 ; bin: heap_oob 8b 79 32
|
||||
; asm: movl -50(%esi), %edx
|
||||
[-,%rdx] v111 = load.i32 v2-50 ; bin: 8b 56 ce
|
||||
[-,%rdx] v111 = load.i32 v2-50 ; bin: heap_oob 8b 56 ce
|
||||
; asm: movzwl 50(%ecx), %edi
|
||||
[-,%rdi] v112 = uload16.i32 v1+50 ; bin: 0f b7 79 32
|
||||
[-,%rdi] v112 = uload16.i32 v1+50 ; bin: heap_oob 0f b7 79 32
|
||||
; asm: movzwl -50(%esi), %edx
|
||||
[-,%rdx] v113 = uload16.i32 v2-50 ; bin: 0f b7 56 ce
|
||||
[-,%rdx] v113 = uload16.i32 v2-50 ; bin: heap_oob 0f b7 56 ce
|
||||
; asm: movswl 50(%ecx), %edi
|
||||
[-,%rdi] v114 = sload16.i32 v1+50 ; bin: 0f bf 79 32
|
||||
[-,%rdi] v114 = sload16.i32 v1+50 ; bin: heap_oob 0f bf 79 32
|
||||
; asm: movswl -50(%esi), %edx
|
||||
[-,%rdx] v115 = sload16.i32 v2-50 ; bin: 0f bf 56 ce
|
||||
[-,%rdx] v115 = sload16.i32 v2-50 ; bin: heap_oob 0f bf 56 ce
|
||||
; asm: movzbl 50(%ecx), %edi
|
||||
[-,%rdi] v116 = uload8.i32 v1+50 ; bin: 0f b6 79 32
|
||||
[-,%rdi] v116 = uload8.i32 v1+50 ; bin: heap_oob 0f b6 79 32
|
||||
; asm: movzbl -50(%esi), %edx
|
||||
[-,%rdx] v117 = uload8.i32 v2-50 ; bin: 0f b6 56 ce
|
||||
[-,%rdx] v117 = uload8.i32 v2-50 ; bin: heap_oob 0f b6 56 ce
|
||||
; asm: movsbl 50(%ecx), %edi
|
||||
[-,%rdi] v118 = sload8.i32 v1+50 ; bin: 0f be 79 32
|
||||
[-,%rdi] v118 = sload8.i32 v1+50 ; bin: heap_oob 0f be 79 32
|
||||
; asm: movsbl -50(%esi), %edx
|
||||
[-,%rdx] v119 = sload8.i32 v2-50 ; bin: 0f be 56 ce
|
||||
[-,%rdx] v119 = sload8.i32 v2-50 ; bin: heap_oob 0f be 56 ce
|
||||
|
||||
; Register-indirect with 32-bit signed displacement.
|
||||
|
||||
; asm: movl %ecx, 10000(%esi)
|
||||
store v1, v2+10000 ; bin: 89 8e 00002710
|
||||
store v1, v2+10000 ; bin: heap_oob 89 8e 00002710
|
||||
; asm: movl %esi, -10000(%ecx)
|
||||
store v2, v1-10000 ; bin: 89 b1 ffffd8f0
|
||||
store v2, v1-10000 ; bin: heap_oob 89 b1 ffffd8f0
|
||||
; asm: movw %cx, 10000(%esi)
|
||||
istore16 v1, v2+10000 ; bin: 66 89 8e 00002710
|
||||
istore16 v1, v2+10000 ; bin: heap_oob 66 89 8e 00002710
|
||||
; asm: movw %si, -10000(%ecx)
|
||||
istore16 v2, v1-10000 ; bin: 66 89 b1 ffffd8f0
|
||||
istore16 v2, v1-10000 ; bin: heap_oob 66 89 b1 ffffd8f0
|
||||
; asm: movb %cl, 10000(%esi)
|
||||
istore8 v1, v2+10000 ; bin: 88 8e 00002710
|
||||
istore8 v1, v2+10000 ; bin: heap_oob 88 8e 00002710
|
||||
|
||||
; asm: movl 50000(%ecx), %edi
|
||||
[-,%rdi] v120 = load.i32 v1+50000 ; bin: 8b b9 0000c350
|
||||
[-,%rdi] v120 = load.i32 v1+50000 ; bin: heap_oob 8b b9 0000c350
|
||||
; asm: movl -50000(%esi), %edx
|
||||
[-,%rdx] v121 = load.i32 v2-50000 ; bin: 8b 96 ffff3cb0
|
||||
[-,%rdx] v121 = load.i32 v2-50000 ; bin: heap_oob 8b 96 ffff3cb0
|
||||
; asm: movzwl 50000(%ecx), %edi
|
||||
[-,%rdi] v122 = uload16.i32 v1+50000 ; bin: 0f b7 b9 0000c350
|
||||
[-,%rdi] v122 = uload16.i32 v1+50000 ; bin: heap_oob 0f b7 b9 0000c350
|
||||
; asm: movzwl -50000(%esi), %edx
|
||||
[-,%rdx] v123 = uload16.i32 v2-50000 ; bin: 0f b7 96 ffff3cb0
|
||||
[-,%rdx] v123 = uload16.i32 v2-50000 ; bin: heap_oob 0f b7 96 ffff3cb0
|
||||
; asm: movswl 50000(%ecx), %edi
|
||||
[-,%rdi] v124 = sload16.i32 v1+50000 ; bin: 0f bf b9 0000c350
|
||||
[-,%rdi] v124 = sload16.i32 v1+50000 ; bin: heap_oob 0f bf b9 0000c350
|
||||
; asm: movswl -50000(%esi), %edx
|
||||
[-,%rdx] v125 = sload16.i32 v2-50000 ; bin: 0f bf 96 ffff3cb0
|
||||
[-,%rdx] v125 = sload16.i32 v2-50000 ; bin: heap_oob 0f bf 96 ffff3cb0
|
||||
; asm: movzbl 50000(%ecx), %edi
|
||||
[-,%rdi] v126 = uload8.i32 v1+50000 ; bin: 0f b6 b9 0000c350
|
||||
[-,%rdi] v126 = uload8.i32 v1+50000 ; bin: heap_oob 0f b6 b9 0000c350
|
||||
; asm: movzbl -50000(%esi), %edx
|
||||
[-,%rdx] v127 = uload8.i32 v2-50000 ; bin: 0f b6 96 ffff3cb0
|
||||
[-,%rdx] v127 = uload8.i32 v2-50000 ; bin: heap_oob 0f b6 96 ffff3cb0
|
||||
; asm: movsbl 50000(%ecx), %edi
|
||||
[-,%rdi] v128 = sload8.i32 v1+50000 ; bin: 0f be b9 0000c350
|
||||
[-,%rdi] v128 = sload8.i32 v1+50000 ; bin: heap_oob 0f be b9 0000c350
|
||||
; asm: movsbl -50000(%esi), %edx
|
||||
[-,%rdx] v129 = sload8.i32 v2-50000 ; bin: 0f be 96 ffff3cb0
|
||||
[-,%rdx] v129 = sload8.i32 v2-50000 ; bin: heap_oob 0f be 96 ffff3cb0
|
||||
|
||||
; Bit-counting instructions.
|
||||
|
||||
@@ -437,7 +437,7 @@ ebb1:
|
||||
|
||||
; asm: ebb2:
|
||||
ebb2:
|
||||
trap user0 ; bin: 0f 0b
|
||||
trap user0 ; bin: user0 0f 0b
|
||||
}
|
||||
|
||||
; Special branch encodings only for I32 mode.
|
||||
@@ -524,25 +524,25 @@ ebb1:
|
||||
|
||||
; The trapif instructions are encoded as macros: a conditional jump over a ud2.
|
||||
; asm: jne .+4; ud2
|
||||
trapif eq v11, user0 ; bin: 75 02 0f 0b
|
||||
trapif eq v11, user0 ; bin: 75 02 user0 0f 0b
|
||||
; asm: je .+4; ud2
|
||||
trapif ne v11, user0 ; bin: 74 02 0f 0b
|
||||
trapif ne v11, user0 ; bin: 74 02 user0 0f 0b
|
||||
; asm: jnl .+4; ud2
|
||||
trapif slt v11, user0 ; bin: 7d 02 0f 0b
|
||||
trapif slt v11, user0 ; bin: 7d 02 user0 0f 0b
|
||||
; asm: jnge .+4; ud2
|
||||
trapif sge v11, user0 ; bin: 7c 02 0f 0b
|
||||
trapif sge v11, user0 ; bin: 7c 02 user0 0f 0b
|
||||
; asm: jng .+4; ud2
|
||||
trapif sgt v11, user0 ; bin: 7e 02 0f 0b
|
||||
trapif sgt v11, user0 ; bin: 7e 02 user0 0f 0b
|
||||
; asm: jnle .+4; ud2
|
||||
trapif sle v11, user0 ; bin: 7f 02 0f 0b
|
||||
trapif sle v11, user0 ; bin: 7f 02 user0 0f 0b
|
||||
; asm: jnb .+4; ud2
|
||||
trapif ult v11, user0 ; bin: 73 02 0f 0b
|
||||
trapif ult v11, user0 ; bin: 73 02 user0 0f 0b
|
||||
; asm: jnae .+4; ud2
|
||||
trapif uge v11, user0 ; bin: 72 02 0f 0b
|
||||
trapif uge v11, user0 ; bin: 72 02 user0 0f 0b
|
||||
; asm: jna .+4; ud2
|
||||
trapif ugt v11, user0 ; bin: 76 02 0f 0b
|
||||
trapif ugt v11, user0 ; bin: 76 02 user0 0f 0b
|
||||
; asm: jnbe .+4; ud2
|
||||
trapif ule v11, user0 ; bin: 77 02 0f 0b
|
||||
trapif ule v11, user0 ; bin: 77 02 user0 0f 0b
|
||||
|
||||
; Stack check.
|
||||
; asm: cmpl %esp, %ecx
|
||||
@@ -576,7 +576,7 @@ ebb0:
|
||||
; asm: movzbl %cl, %esi
|
||||
[-,%rsi] v30 = uextend.i32 v11 ; bin: 0f b6 f1
|
||||
|
||||
trap user0 ; bin: 0f 0b
|
||||
trap user0 ; bin: user0 0f 0b
|
||||
}
|
||||
|
||||
; Tests for i32/i16 conversion instructions.
|
||||
@@ -592,5 +592,5 @@ ebb0:
|
||||
; asm: movzwl %cx, %esi
|
||||
[-,%rsi] v30 = uextend.i32 v11 ; bin: 0f b7 f1
|
||||
|
||||
trap user0 ; bin: 0f 0b
|
||||
trap user0 ; bin: user0 0f 0b
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user