1; Test alloca instrumentation. 2; 3; RUN: opt < %s -hwasan -S | FileCheck %s --check-prefixes=CHECK,DYNAMIC-SHADOW,NO-UAR-TAGS 4; RUN: opt < %s -hwasan -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,ZERO-BASED-SHADOW,NO-UAR-TAGS 5; RUN: opt < %s -hwasan -hwasan-uar-retag-to-zero=0 -S | FileCheck %s --check-prefixes=CHECK,DYNAMIC-SHADOW,UAR-TAGS 6 7target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 8target triple = "aarch64--linux-android" 9 10declare void @use32(i32*) 11 12define void @test_alloca() sanitize_hwaddress { 13; CHECK-LABEL: @test_alloca( 14; CHECK: %[[FP:[^ ]*]] = call i8* @llvm.frameaddress(i32 0) 15; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %[[FP]] to i64 16; CHECK: %[[B:[^ ]*]] = lshr i64 %[[A]], 20 17; CHECK: %[[BASE_TAG:[^ ]*]] = xor i64 %[[A]], %[[B]] 18 19; CHECK: %[[X:[^ ]*]] = alloca i32, align 16 20; CHECK: %[[X_TAG:[^ ]*]] = xor i64 %[[BASE_TAG]], 0 21; CHECK: %[[X1:[^ ]*]] = ptrtoint i32* %[[X]] to i64 22; CHECK: %[[C:[^ ]*]] = shl i64 %[[X_TAG]], 56 23; CHECK: %[[D:[^ ]*]] = or i64 %[[X1]], %[[C]] 24; CHECK: %[[X_HWASAN:[^ ]*]] = inttoptr i64 %[[D]] to i32* 25 26; CHECK: %[[X_TAG2:[^ ]*]] = trunc i64 %[[X_TAG]] to i8 27; CHECK: %[[E:[^ ]*]] = ptrtoint i32* %[[X]] to i64 28; CHECK: %[[F:[^ ]*]] = lshr i64 %[[E]], 4 29; DYNAMIC-SHADOW: %[[F_DYN:[^ ]*]] = add i64 %[[F]], %.hwasan.shadow 30; DYNAMIC-SHADOW: %[[X_SHADOW:[^ ]*]] = inttoptr i64 %[[F_DYN]] to i8* 31; ZERO-BASED-SHADOW: %[[X_SHADOW:[^ ]*]] = inttoptr i64 %[[F]] to i8* 32; CHECK: call void @llvm.memset.p0i8.i64(i8* align 1 %[[X_SHADOW]], i8 %[[X_TAG2]], i64 1, i1 false) 33; CHECK: call void @use32(i32* nonnull %[[X_HWASAN]]) 34 35; UAR-TAGS: %[[BASE_TAG_COMPL:[^ ]*]] = xor i64 %[[BASE_TAG]], 255 36; UAR-TAGS: %[[X_TAG_UAR:[^ ]*]] = trunc i64 %[[BASE_TAG_COMPL]] to i8 37; CHECK: %[[E2:[^ ]*]] = ptrtoint i32* %[[X]] to i64 38; CHECK: %[[F2:[^ ]*]] = lshr i64 %[[E2]], 4 39; DYNAMIC-SHADOW: %[[F2_DYN:[^ ]*]] = add i64 %[[F2]], %.hwasan.shadow 40; DYNAMIC-SHADOW: %[[X_SHADOW2:[^ ]*]] = inttoptr i64 %[[F2_DYN]] to i8* 41; ZERO-BASED-SHADOW: %[[X_SHADOW2:[^ ]*]] = inttoptr i64 %[[F2]] to i8* 42; NO-UAR-TAGS: call void @llvm.memset.p0i8.i64(i8* align 1 %[[X_SHADOW2]], i8 0, i64 1, i1 false) 43; UAR-TAGS: call void @llvm.memset.p0i8.i64(i8* align 1 %[[X_SHADOW2]], i8 %[[X_TAG_UAR]], i64 1, i1 false) 44; CHECK: ret void 45 46 47entry: 48 %x = alloca i32, align 4 49 call void @use32(i32* nonnull %x) 50 ret void 51} 52