diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2017-02-07 19:19:49 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2017-02-07 19:19:49 +0000 |
commit | 2f63cbcc0c508c502e1f59cd911a36f73d1c460a (patch) | |
tree | 922f8ec26ff5fdcd0b29a58cda5655b363933aad /llvm/test/CodeGen/X86/implicit-null-check.ll | |
parent | ef6d573f67466494fd65dfce650908043527da37 (diff) | |
download | bcm5719-llvm-2f63cbcc0c508c502e1f59cd911a36f73d1c460a.tar.gz bcm5719-llvm-2f63cbcc0c508c502e1f59cd911a36f73d1c460a.zip |
[ImplicitNullCheck] Extend Implicit Null Check scope by using stores
Summary:
This change allows usage of store instruction for implicit null check.
Memory Aliasing Analisys is not used and change conservatively supposes
that any store and load may access the same memory. As a result
re-ordering of store-store, store-load and load-store is prohibited.
Patch by Serguei Katkov!
Reviewers: reames, sanjoy
Reviewed By: sanjoy
Subscribers: atrick, llvm-commits
Differential Revision: https://reviews.llvm.org/D29400
llvm-svn: 294338
Diffstat (limited to 'llvm/test/CodeGen/X86/implicit-null-check.ll')
-rw-r--r-- | llvm/test/CodeGen/X86/implicit-null-check.ll | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/llvm/test/CodeGen/X86/implicit-null-check.ll b/llvm/test/CodeGen/X86/implicit-null-check.ll index 286b4fa7a81..ee795667cdb 100644 --- a/llvm/test/CodeGen/X86/implicit-null-check.ll +++ b/llvm/test/CodeGen/X86/implicit-null-check.ll @@ -162,6 +162,26 @@ define i32 @imp_null_check_gep_load_with_use_dep(i32* %x, i32 %a) { ret i32 %z } +define void @imp_null_check_store(i32* %x) { +; CHECK-LABEL: _imp_null_check_store: +; CHECK: [[BB0_imp_null_check_store:L[^:]+]]: +; CHECK: movl $1, (%rdi) +; CHECK: retq +; CHECK: [[BB1_imp_null_check_store:LBB6_[0-9]+]]: +; CHECK: retq + + entry: + %c = icmp eq i32* %x, null + br i1 %c, label %is_null, label %not_null, !make.implicit !0 + + is_null: + ret void + + not_null: + store i32 1, i32* %x + ret void +} + !0 = !{} ; CHECK-LABEL: __LLVM_FaultMaps: @@ -174,7 +194,7 @@ define i32 @imp_null_check_gep_load_with_use_dep(i32* %x, i32 %a) { ; CHECK-NEXT: .short 0 ; # functions: -; CHECK-NEXT: .long 6 +; CHECK-NEXT: .long 7 ; FunctionAddr: ; CHECK-NEXT: .quad _imp_null_check_add_result @@ -242,6 +262,19 @@ define i32 @imp_null_check_gep_load_with_use_dep(i32* %x, i32 %a) { ; CHECK-NEXT: .long [[BB1_imp_null_check_load]]-_imp_null_check_load ; FunctionAddr: +; CHECK-NEXT: .quad _imp_null_check_store +; NumFaultingPCs +; CHECK-NEXT: .long 1 +; Reserved: +; CHECK-NEXT: .long 0 +; Fault[0].Type: +; CHECK-NEXT: .long 3 +; Fault[0].FaultOffset: +; CHECK-NEXT: .long [[BB0_imp_null_check_store]]-_imp_null_check_store +; Fault[0].HandlerOffset: +; CHECK-NEXT: .long [[BB1_imp_null_check_store]]-_imp_null_check_store + +; FunctionAddr: ; CHECK-NEXT: .quad _imp_null_check_via_mem_comparision ; NumFaultingPCs ; CHECK-NEXT: .long 1 @@ -256,7 +289,7 @@ define i32 @imp_null_check_gep_load_with_use_dep(i32* %x, i32 %a) { ; OBJDUMP: FaultMap table: ; OBJDUMP-NEXT: Version: 0x1 -; OBJDUMP-NEXT: NumFunctions: 6 +; OBJDUMP-NEXT: NumFunctions: 7 ; OBJDUMP-NEXT: FunctionAddress: 0x000000, NumFaultingPCs: 1 ; OBJDUMP-NEXT: Fault kind: FaultingLoad, faulting PC offset: 0, handling PC offset: 5 ; OBJDUMP-NEXT: FunctionAddress: 0x000000, NumFaultingPCs: 1 @@ -267,3 +300,7 @@ define i32 @imp_null_check_gep_load_with_use_dep(i32* %x, i32 %a) { ; OBJDUMP-NEXT: Fault kind: FaultingLoad, faulting PC offset: 0, handling PC offset: 7 ; OBJDUMP-NEXT: FunctionAddress: 0x000000, NumFaultingPCs: 1 ; OBJDUMP-NEXT: Fault kind: FaultingLoad, faulting PC offset: 0, handling PC offset: 3 +; OBJDUMP-NEXT: FunctionAddress: 0x000000, NumFaultingPCs: 1 +; OBJDUMP-NEXT: Fault kind: FaultingStore, faulting PC offset: 0, handling PC offset: 7 +; OBJDUMP-NEXT: FunctionAddress: 0x000000, NumFaultingPCs: 1 +; OBJDUMP-NEXT: Fault kind: FaultingLoad, faulting PC offset: 0, handling PC offset: 11 |