1; RUN: llc -verify-machineinstrs -O3 -mtriple=x86_64-apple-macosx -enable-implicit-null-checks < %s | FileCheck %s 2 3; RUN: llc < %s -mtriple=x86_64-apple-macosx -enable-implicit-null-checks \ 4; RUN: | llvm-mc -triple x86_64-apple-macosx -filetype=obj -o - \ 5; RUN: | llvm-objdump --triple=x86_64-apple-macosx --fault-map-section - \ 6; RUN: | FileCheck %s -check-prefix OBJDUMP 7 8; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -enable-implicit-null-checks \ 9; RUN: | llvm-mc -triple x86_64-unknown-linux-gnu -filetype=obj -o - \ 10; RUN: | llvm-objdump --triple=x86_64-unknown-linux-gnu --fault-map-section - \ 11; RUN: | FileCheck %s -check-prefix OBJDUMP 12 13;; The tests in this file exist just to check basic validity of the FaultMap 14;; section. Please don't add to this file unless you're testing the FaultMap 15;; serialization code itself. 16 17define i32 @imp_null_check_load(ptr %x) { 18; CHECK-LABEL: _imp_null_check_load: 19; CHECK: [[BB0_imp_null_check_load:L[^:]+]]: 20; CHECK: movl (%rdi), %eax 21; CHECK: retq 22; CHECK: [[BB1_imp_null_check_load:LBB0_[0-9]+]]: 23; CHECK: movl $42, %eax 24; CHECK: retq 25 26 entry: 27 %c = icmp eq ptr %x, null 28 br i1 %c, label %is_null, label %not_null, !make.implicit !0 29 30 is_null: 31 ret i32 42 32 33 not_null: 34 %t = load i32, ptr %x 35 ret i32 %t 36} 37 38define void @imp_null_check_store(ptr %x) { 39; CHECK-LABEL: _imp_null_check_store: 40; CHECK: [[BB0_imp_null_check_store:L[^:]+]]: 41; CHECK: movl $1, (%rdi) 42; CHECK: retq 43; CHECK: [[BB1_imp_null_check_store:LBB1_[0-9]+]]: 44; CHECK: retq 45 46 entry: 47 %c = icmp eq ptr %x, null 48 br i1 %c, label %is_null, label %not_null, !make.implicit !0 49 50 is_null: 51 ret void 52 53 not_null: 54 store i32 1, ptr %x 55 ret void 56} 57 58!0 = !{} 59 60; CHECK-LABEL: __LLVM_FaultMaps: 61 62; Version: 63; CHECK-NEXT: .byte 1 64 65; Reserved x2 66; CHECK-NEXT: .byte 0 67; CHECK-NEXT: .short 0 68 69; # functions: 70; CHECK-NEXT: .long 2 71 72; FunctionAddr: 73; CHECK-NEXT: .quad _imp_null_check_load 74; NumFaultingPCs 75; CHECK-NEXT: .long 1 76; Reserved: 77; CHECK-NEXT: .long 0 78; Fault[0].Type: 79; CHECK-NEXT: .long 1 80; Fault[0].FaultOffset: 81; CHECK-NEXT: .long [[BB0_imp_null_check_load]]-_imp_null_check_load 82; Fault[0].HandlerOffset: 83; CHECK-NEXT: .long [[BB1_imp_null_check_load]]-_imp_null_check_load 84 85; FunctionAddr: 86; CHECK-NEXT: .quad _imp_null_check_store 87; NumFaultingPCs 88; CHECK-NEXT: .long 1 89; Reserved: 90; CHECK-NEXT: .long 0 91; Fault[0].Type: 92; CHECK-NEXT: .long 3 93; Fault[0].FaultOffset: 94; CHECK-NEXT: .long [[BB0_imp_null_check_store]]-_imp_null_check_store 95; Fault[0].HandlerOffset: 96; CHECK-NEXT: .long [[BB1_imp_null_check_store]]-_imp_null_check_store 97 98; OBJDUMP: FaultMap table: 99; OBJDUMP-NEXT: Version: 0x1 100; OBJDUMP-NEXT: NumFunctions: 2 101; OBJDUMP-NEXT: FunctionAddress: 0x000000, NumFaultingPCs: 1 102; OBJDUMP-NEXT: Fault kind: FaultingLoad, faulting PC offset: 0, handling PC offset: 3 103; OBJDUMP-NEXT: FunctionAddress: 0x000000, NumFaultingPCs: 1 104; OBJDUMP-NEXT: Fault kind: FaultingStore, faulting PC offset: 0, handling PC offset: 7 105