68 lines · plain
1; Test basic address sanitizer instrumentation.2;3; RUN: opt < %s -passes=hwasan -hwasan-instrument-with-calls -S | FileCheck %s --check-prefixes=CHECK,ABORT4; RUN: opt < %s -passes=hwasan -hwasan-instrument-with-calls -hwasan-recover=1 -S | FileCheck %s --check-prefixes=CHECK,RECOVER5 6target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"7target triple = "x86_64-unknown-linux-gnu"8 9define i8 @test_load8(ptr %a) sanitize_hwaddress {10; CHECK-LABEL: @test_load8(11; CHECK: %[[A:[^ ]*]] = ptrtoint ptr %a to i6412 13; ABORT: call void @__hwasan_load1(i64 %[[A]])14; RECOVER: call void @__hwasan_load1_noabort(i64 %[[A]])15 16; CHECK: %[[B:[^ ]*]] = load i8, ptr %a17; CHECK: ret i8 %[[B]]18 19entry:20 %b = load i8, ptr %a, align 421 ret i8 %b22}23 24define i40 @test_load40(ptr %a) sanitize_hwaddress {25; CHECK-LABEL: @test_load40(26; CHECK: %[[A:[^ ]*]] = ptrtoint ptr %a to i6427 28; ABORT: call void @__hwasan_loadN(i64 %[[A]], i64 5)29; RECOVER: call void @__hwasan_loadN_noabort(i64 %[[A]], i64 5)30 31; CHECK: %[[B:[^ ]*]] = load i40, ptr %a32; CHECK: ret i40 %[[B]]33 34entry:35 %b = load i40, ptr %a, align 436 ret i40 %b37}38 39define void @test_store8(ptr %a, i8 %b) sanitize_hwaddress {40; CHECK-LABEL: @test_store8(41; CHECK: %[[A:[^ ]*]] = ptrtoint ptr %a to i6442 43; ABORT: call void @__hwasan_store1(i64 %[[A]])44; RECOVER: call void @__hwasan_store1_noabort(i64 %[[A]])45 46; CHECK: store i8 %b, ptr %a47; CHECK: ret void48 49entry:50 store i8 %b, ptr %a, align 451 ret void52}53 54define void @test_store40(ptr %a, i40 %b) sanitize_hwaddress {55; CHECK-LABEL: @test_store40(56; CHECK: %[[A:[^ ]*]] = ptrtoint ptr %a to i6457 58; ABORT: call void @__hwasan_storeN(i64 %[[A]], i64 5)59; RECOVER: call void @__hwasan_storeN_noabort(i64 %[[A]], i64 5)60 61; CHECK: store i40 %b, ptr %a62; CHECK: ret void63 64entry:65 store i40 %b, ptr %a, align 466 ret void67}68