1 ; Test kernel hwasan instrumentation for alloca.
3 ; RUN: opt < %s -hwasan -hwasan-kernel=1 -S | FileCheck %s
5 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
6 target triple = "aarch64--linux-android"
8 declare void @use32(i32*)
10 define void @test_alloca() sanitize_hwaddress {
11 ; CHECK-LABEL: @test_alloca(
12 ; CHECK: %[[FP:[^ ]*]] = call i8* @llvm.frameaddress.p0i8(i32 0)
13 ; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %[[FP]] to i64
14 ; CHECK: %[[B:[^ ]*]] = lshr i64 %[[A]], 20
15 ; CHECK: %[[BASE_TAG:[^ ]*]] = xor i64 %[[A]], %[[B]]
17 ; CHECK: %[[X:[^ ]*]] = alloca { i32, [12 x i8] }, align 16
18 ; CHECK: %[[X_BC:[^ ]*]] = bitcast { i32, [12 x i8] }* %[[X]] to i32*
19 ; CHECK: %[[X_TAG:[^ ]*]] = xor i64 %[[BASE_TAG]], 0
20 ; CHECK: %[[X1:[^ ]*]] = ptrtoint i32* %[[X_BC]] to i64
21 ; CHECK: %[[C:[^ ]*]] = shl i64 %[[X_TAG]], 56
22 ; CHECK: %[[D:[^ ]*]] = or i64 %[[C]], 72057594037927935
23 ; CHECK: %[[E:[^ ]*]] = and i64 %[[X1]], %[[D]]
24 ; CHECK: %[[X_HWASAN:[^ ]*]] = inttoptr i64 %[[E]] to i32*
27 %x = alloca i32, align 4
28 call void @use32(i32* nonnull %x)