Skip to content

Commit bfc6fbf

Browse files
committed
[HWASAN] regression test we do not instrument dynamic allocas
Reviewed By: browneee Differential Revision: https://reviews.llvm.org/D119606
1 parent fc51099 commit bfc6fbf

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; Test that unintersted allocas (e.g. dynamic, because we do not know
3+
; their size) are not instrumented.
4+
;
5+
; RUN: opt < %s -passes=hwasan -S | FileCheck %s --check-prefixes=CHECK
6+
7+
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
8+
target triple = "aarch64--linux-android10000"
9+
10+
declare void @use32(i32*)
11+
12+
define void @test_dyn_alloca(i32 %n) sanitize_hwaddress !dbg !15 {
13+
; CHECK-LABEL: @test_dyn_alloca(
14+
; CHECK-NEXT: entry:
15+
; CHECK-NEXT: [[X:%.*]] = alloca i32, i32 [[N:%.*]], align 4
16+
; CHECK-NEXT: call void @llvm.dbg.value(metadata !DIArgList(i32* [[X]], i32* [[X]]), metadata [[META10:![0-9]+]], metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_deref)), !dbg [[DBG12:![0-9]+]]
17+
; CHECK-NEXT: call void @use32(i32* nonnull [[X]]), !dbg [[DBG13:![0-9]+]]
18+
; CHECK-NEXT: ret void, !dbg [[DBG14:![0-9]+]]
19+
;
20+
21+
entry:
22+
%x = alloca i32, i32 %n, align 4
23+
call void @llvm.dbg.value(metadata !DIArgList(i32* %x, i32* %x), metadata !22, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_deref)), !dbg !21
24+
call void @use32(i32* nonnull %x), !dbg !23
25+
ret void, !dbg !24
26+
}
27+
28+
declare void @llvm.dbg.value(metadata, metadata, metadata)
29+
30+
!llvm.dbg.cu = !{!0}
31+
!llvm.module.flags = !{!3, !4}
32+
!llvm.ident = !{!14}
33+
34+
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 13.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
35+
!1 = !DIFile(filename: "alloca.cpp", directory: "/")
36+
!2 = !{}
37+
!3 = !{i32 7, !"Dwarf Version", i32 4}
38+
!4 = !{i32 2, !"Debug Info Version", i32 3}
39+
!14 = !{!"clang version 13.0.0"}
40+
!15 = distinct !DISubprogram(name: "test_alloca", linkageName: "_Z11test_allocav", scope: !1, file: !1, line: 4, type: !16, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
41+
!16 = !DISubroutineType(types: !17)
42+
!17 = !{null}
43+
!19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 64)
44+
!20 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
45+
!21 = !DILocation(line: 0, scope: !15)
46+
!22 = !DILocalVariable(name: "x", scope: !15, file: !1, line: 5, type: !20)
47+
!23 = !DILocation(line: 7, column: 5, scope: !15)
48+
!24 = !DILocation(line: 8, column: 1, scope: !15)

0 commit comments

Comments
 (0)