1; Test KHWASan instrumentation. 2; 3; RUN: opt < %s -hwasan -hwasan-kernel=1 -S | FileCheck %s --allow-empty --check-prefixes=INIT 4; RUN: opt < %s -hwasan -hwasan-kernel=1 -S | FileCheck %s --check-prefixes=CHECK,NOOFFSET,MATCH-ALL 5; RUN: opt < %s -hwasan -hwasan-kernel=1 -hwasan-mapping-offset=12345678 -S | FileCheck %s --check-prefixes=CHECK,OFFSET,MATCH-ALL 6; RUN: opt < %s -hwasan -hwasan-kernel=1 -hwasan-recover=0 -S | FileCheck %s --check-prefixes=CHECK,NOOFFSET,ABORT,MATCH-ALL 7; RUN: opt < %s -hwasan -hwasan-kernel=1 -hwasan-recover=1 -S | FileCheck %s --check-prefixes=CHECK,NOOFFSET,RECOVER,MATCH-ALL 8; 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 9 10target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 11target triple = "aarch64--linux-android" 12 13define i8 @test_load(i8* %a) sanitize_hwaddress { 14; CHECK-LABEL: @test_load( 15; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %a to i64 16; CHECK: %[[B:[^ ]*]] = lshr i64 %[[A]], 56 17; CHECK: %[[PTRTAG:[^ ]*]] = trunc i64 %[[B]] to i8 18; CHECK: %[[C:[^ ]*]] = or i64 %[[A]], -72057594037927936 19; CHECK: %[[D:[^ ]*]] = lshr i64 %[[C]], 4 20 21; NOOFFSET: %[[E:[^ ]*]] = inttoptr i64 %[[D]] to i8* 22 23; OFFSET: %[[D1:[^ ]*]] = add i64 %[[D]], 12345678 24; OFFSET: %[[E:[^ ]*]] = inttoptr i64 %[[D1]] to i8* 25 26; CHECK: %[[MEMTAG:[^ ]*]] = load i8, i8* %[[E]] 27; CHECK: %[[F:[^ ]*]] = icmp ne i8 %[[PTRTAG]], %[[MEMTAG]] 28 29; MATCH-ALL: %[[G:[^ ]*]] = icmp ne i8 %[[PTRTAG]], -1 30; MATCH-ALL: %[[H:[^ ]*]] = and i1 %[[F]], %[[G]] 31; MATCH-ALL: br i1 %[[H]], label {{.*}}, label {{.*}}, !prof {{.*}} 32 33; NO-MATCH-ALL: br i1 %[[F]], label {{.*}}, label {{.*}}, !prof {{.*}} 34 35; ABORT: call void asm sideeffect "brk #2304", "{x0}"(i64 %[[A]]) 36; ABORT: unreachable 37; RECOVER: call void asm sideeffect "brk #2336", "{x0}"(i64 %[[A]]) 38; RECOVER: br label 39 40; CHECK: %[[G:[^ ]*]] = load i8, i8* %a, align 4 41; CHECK: ret i8 %[[G]] 42 43entry: 44 %b = load i8, i8* %a, align 4 45 ret i8 %b 46} 47 48; INIT-NOT: call void @__hwasan_init 49