2018-04-14 02:05:21 +08:00
|
|
|
; Test KHWASan instrumentation.
|
2018-01-18 07:24:38 +08:00
|
|
|
;
|
2018-02-22 03:52:23 +08:00
|
|
|
; RUN: opt < %s -hwasan -hwasan-kernel=1 -S | FileCheck %s --allow-empty --check-prefixes=INIT
|
2018-04-14 02:05:21 +08:00
|
|
|
; RUN: opt < %s -hwasan -hwasan-kernel=1 -S | FileCheck %s --check-prefixes=CHECK,NOOFFSET,MATCH-ALL
|
|
|
|
; RUN: opt < %s -hwasan -hwasan-kernel=1 -hwasan-mapping-offset=12345678 -S | FileCheck %s --check-prefixes=CHECK,OFFSET,MATCH-ALL
|
|
|
|
; RUN: opt < %s -hwasan -hwasan-kernel=1 -hwasan-recover=0 -S | FileCheck %s --check-prefixes=CHECK,NOOFFSET,ABORT,MATCH-ALL
|
|
|
|
; RUN: opt < %s -hwasan -hwasan-kernel=1 -hwasan-recover=1 -S | FileCheck %s --check-prefixes=CHECK,NOOFFSET,RECOVER,MATCH-ALL
|
|
|
|
; RUN: opt < %s -hwasan -hwasan-kernel=1 -hwasan-recover=1 -hwasan-match-all-tag=-1 -S | FileCheck %s --check-prefixes=CHECK,NOOFFSET,RECOVER,NO-MATCH-ALL
|
2018-01-18 07:24:38 +08:00
|
|
|
|
|
|
|
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
|
|
|
|
target triple = "aarch64--linux-android"
|
|
|
|
|
|
|
|
define i8 @test_load(i8* %a) sanitize_hwaddress {
|
2018-02-22 03:52:23 +08:00
|
|
|
; CHECK-LABEL: @test_load(
|
|
|
|
; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %a to i64
|
|
|
|
; CHECK: %[[B:[^ ]*]] = lshr i64 %[[A]], 56
|
|
|
|
; CHECK: %[[PTRTAG:[^ ]*]] = trunc i64 %[[B]] to i8
|
|
|
|
; CHECK: %[[C:[^ ]*]] = or i64 %[[A]], -72057594037927936
|
|
|
|
; CHECK: %[[D:[^ ]*]] = lshr i64 %[[C]], 4
|
|
|
|
|
|
|
|
; NOOFFSET: %[[E:[^ ]*]] = inttoptr i64 %[[D]] to i8*
|
|
|
|
|
2018-01-18 07:24:38 +08:00
|
|
|
; OFFSET: %[[D1:[^ ]*]] = add i64 %[[D]], 12345678
|
|
|
|
; OFFSET: %[[E:[^ ]*]] = inttoptr i64 %[[D1]] to i8*
|
2018-02-22 03:52:23 +08:00
|
|
|
|
|
|
|
; CHECK: %[[MEMTAG:[^ ]*]] = load i8, i8* %[[E]]
|
|
|
|
; CHECK: %[[F:[^ ]*]] = icmp ne i8 %[[PTRTAG]], %[[MEMTAG]]
|
2018-04-05 04:44:59 +08:00
|
|
|
|
|
|
|
; MATCH-ALL: %[[G:[^ ]*]] = icmp ne i8 %[[PTRTAG]], -1
|
|
|
|
; MATCH-ALL: %[[H:[^ ]*]] = and i1 %[[F]], %[[G]]
|
|
|
|
; MATCH-ALL: br i1 %[[H]], label {{.*}}, label {{.*}}, !prof {{.*}}
|
|
|
|
|
|
|
|
; NO-MATCH-ALL: br i1 %[[F]], label {{.*}}, label {{.*}}, !prof {{.*}}
|
2018-02-22 03:52:23 +08:00
|
|
|
|
|
|
|
; ABORT: call void asm sideeffect "brk #2304", "{x0}"(i64 %[[A]])
|
|
|
|
; ABORT: unreachable
|
|
|
|
; RECOVER: call void asm sideeffect "brk #2336", "{x0}"(i64 %[[A]])
|
|
|
|
; RECOVER: br label
|
|
|
|
|
|
|
|
; CHECK: %[[G:[^ ]*]] = load i8, i8* %a, align 4
|
|
|
|
; CHECK: ret i8 %[[G]]
|
2018-01-18 07:24:38 +08:00
|
|
|
|
|
|
|
entry:
|
|
|
|
%b = load i8, i8* %a, align 4
|
|
|
|
ret i8 %b
|
|
|
|
}
|
|
|
|
|
2018-02-22 03:52:23 +08:00
|
|
|
; INIT-NOT: call void @__hwasan_init
|