1; Test basic address sanitizer instrumentation. 2; Generic code is covered by ../basic.ll, only the x86_64 specific code is 3; tested here. 4; 5; RUN: opt < %s -hwasan -hwasan-recover=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT 6; RUN: opt < %s -hwasan -hwasan-recover=1 -S | FileCheck %s --check-prefixes=CHECK,RECOVER 7 8target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 9target triple = "x86_64-unknown-linux-gnu" 10 11define i8 @test_load8(i8* %a) sanitize_hwaddress { 12; CHECK-LABEL: @test_load8( 13; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %a to i64 14 15; ABORT: call void @__hwasan_load1(i64 %[[A]]) 16; RECOVER: call void @__hwasan_load1_noabort(i64 %[[A]]) 17 18; CHECK: %[[G:[^ ]*]] = load i8, i8* %a, align 4 19; CHECK: ret i8 %[[G]] 20 21entry: 22 %b = load i8, i8* %a, align 4 23 ret i8 %b 24} 25 26define i40 @test_load40(i40* %a) sanitize_hwaddress { 27; CHECK-LABEL: @test_load40( 28; CHECK: %[[A:[^ ]*]] = ptrtoint i40* %a to i64 29 30; ABORT: call void @__hwasan_loadN(i64 %[[A]], i64 5) 31; RECOVER: call void @__hwasan_loadN_noabort(i64 %[[A]], i64 5) 32 33; CHECK: %[[B:[^ ]*]] = load i40, i40* %a 34; CHECK: ret i40 %[[B]] 35 36entry: 37 %b = load i40, i40* %a, align 4 38 ret i40 %b 39} 40 41define void @test_store8(i8* %a, i8 %b) sanitize_hwaddress { 42; CHECK-LABEL: @test_store8( 43; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %a to i64 44 45; ABORT: call void @__hwasan_store1(i64 %[[A]]) 46; RECOVER: call void @__hwasan_store1_noabort(i64 %[[A]]) 47 48; CHECK: store i8 %b, i8* %a, align 4 49; CHECK: ret void 50 51entry: 52 store i8 %b, i8* %a, align 4 53 ret void 54} 55 56define void @test_store40(i40* %a, i40 %b) sanitize_hwaddress { 57; CHECK-LABEL: @test_store40( 58; CHECK: %[[A:[^ ]*]] = ptrtoint i40* %a to i64 59 60; ABORT: call void @__hwasan_storeN(i64 %[[A]], i64 5) 61; RECOVER: call void @__hwasan_storeN_noabort(i64 %[[A]], i64 5) 62 63; CHECK: store i40 %b, i40* %a 64; CHECK: ret void 65 66entry: 67 store i40 %b, i40* %a, align 4 68 ret void 69} 70 71define void @test_store_unaligned(i64* %a, i64 %b) sanitize_hwaddress { 72; CHECK-LABEL: @test_store_unaligned( 73; CHECK: %[[A:[^ ]*]] = ptrtoint i64* %a to i64 74 75; ABORT: call void @__hwasan_storeN(i64 %[[A]], i64 8) 76; RECOVER: call void @__hwasan_storeN_noabort(i64 %[[A]], i64 8) 77 78; CHECK: store i64 %b, i64* %a, align 4 79; CHECK: ret void 80 81entry: 82 store i64 %b, i64* %a, align 4 83 ret void 84} 85