xref: /llvm-project/llvm/test/Instrumentation/HWAddressSanitizer/X86/alloca-array.ll (revision e8893133d192b7559691e589a0f8f775edaa6bc8)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2; RUN: opt < %s -passes=hwasan -S | FileCheck %s
3
4target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
5target triple = "x86_64-unknown-linux-gnu"
6
7declare void @use(ptr, ptr)
8
9define void @test_alloca() sanitize_hwaddress {
10; CHECK-LABEL: define void @test_alloca
11; CHECK-SAME: () #[[ATTR0:[0-9]+]] personality ptr @__hwasan_personality_thunk {
12; CHECK-NEXT:    [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
13; CHECK-NEXT:    [[TMP1:%.*]] = call ptr @llvm.frameaddress.p0(i32 0)
14; CHECK-NEXT:    [[TMP2:%.*]] = ptrtoint ptr [[TMP1]] to i64
15; CHECK-NEXT:    [[TMP3:%.*]] = lshr i64 [[TMP2]], 20
16; CHECK-NEXT:    [[TMP4:%.*]] = xor i64 [[TMP2]], [[TMP3]]
17; CHECK-NEXT:    [[HWASAN_STACK_BASE_TAG:%.*]] = and i64 [[TMP4]], 63
18; CHECK-NEXT:    [[TMP5:%.*]] = lshr i64 [[TMP2]], 57
19; CHECK-NEXT:    [[HWASAN_UAR_TAG:%.*]] = and i64 [[TMP5]], 63
20; CHECK-NEXT:    [[X:%.*]] = alloca { [4 x i8], [12 x i8] }, align 16
21; CHECK-NEXT:    [[TMP6:%.*]] = xor i64 [[HWASAN_STACK_BASE_TAG]], 0
22; CHECK-NEXT:    [[TMP7:%.*]] = ptrtoint ptr [[X]] to i64
23; CHECK-NEXT:    [[TMP8:%.*]] = and i64 [[TMP7]], -9079256848778919937
24; CHECK-NEXT:    [[TMP9:%.*]] = shl i64 [[TMP6]], 57
25; CHECK-NEXT:    [[TMP10:%.*]] = or i64 [[TMP8]], [[TMP9]]
26; CHECK-NEXT:    [[X_HWASAN:%.*]] = inttoptr i64 [[TMP10]] to ptr
27; CHECK-NEXT:    [[TMP11:%.*]] = trunc i64 [[TMP6]] to i8
28; CHECK-NEXT:    call void @__hwasan_tag_memory(ptr [[X]], i8 [[TMP11]], i64 16)
29; CHECK-NEXT:    [[Y:%.*]] = alloca i8, i64 16, align 16
30; CHECK-NEXT:    [[TMP12:%.*]] = xor i64 [[HWASAN_STACK_BASE_TAG]], 1
31; CHECK-NEXT:    [[TMP13:%.*]] = ptrtoint ptr [[Y]] to i64
32; CHECK-NEXT:    [[TMP14:%.*]] = and i64 [[TMP13]], -9079256848778919937
33; CHECK-NEXT:    [[TMP15:%.*]] = shl i64 [[TMP12]], 57
34; CHECK-NEXT:    [[TMP16:%.*]] = or i64 [[TMP14]], [[TMP15]]
35; CHECK-NEXT:    [[Y_HWASAN:%.*]] = inttoptr i64 [[TMP16]] to ptr
36; CHECK-NEXT:    [[TMP17:%.*]] = trunc i64 [[TMP12]] to i8
37; CHECK-NEXT:    call void @__hwasan_tag_memory(ptr [[Y]], i8 [[TMP17]], i64 16)
38; CHECK-NEXT:    call void @use(ptr [[X_HWASAN]], ptr [[Y_HWASAN]])
39; CHECK-NEXT:    [[TMP18:%.*]] = trunc i64 [[HWASAN_UAR_TAG]] to i8
40; CHECK-NEXT:    call void @__hwasan_tag_memory(ptr [[X]], i8 [[TMP18]], i64 16)
41; CHECK-NEXT:    [[TMP19:%.*]] = trunc i64 [[HWASAN_UAR_TAG]] to i8
42; CHECK-NEXT:    call void @__hwasan_tag_memory(ptr [[Y]], i8 [[TMP19]], i64 16)
43; CHECK-NEXT:    ret void
44;
45  %x = alloca i8, i64 4
46  %y = alloca i8, i64 16
47  call void @use(ptr %x, ptr %y)
48  ret void
49}
50