xref: /llvm-project/llvm/test/Instrumentation/AddressSanitizer/debug-info-alloca.ll (revision 855fe35064674c4601ea9c659a015cacdcec9f63)
1; Checks that asan prologue does not add debug locations, which would
2; fool findPrologueEndLoc because it sets the end of the prologue to the
3; first instruction.  Breaking on the instrumented function in a debugger
4; would then stop at that instruction, before the prologue is finished.
5
6; RUN: opt < %s -passes=asan -S | FileCheck %s
7; 1: void f(int *arg) {
8; 2: }
9; 3: int main(int argc, char **argv) {
10; 4:   f(&argc);
11; 5: }
12; clang 1.cc -g -S -emit-llvm -o - | sed 's/#0 = {/#0 = { sanitize_address/'
13
14target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
15target triple = "x86_64-unknown-linux-gnu"
16
17define dso_local i32 @main(i32 %argc, ptr %argv) #0 !dbg !15 {
18entry:
19; No suffix like !dbg !123
20; CHECK: %asan_local_stack_base = alloca i64, align 8{{$}}
21; CHECK:     %3 = call i64 @__asan_stack_malloc_0(i64 64){{$}}
22  %argc.addr = alloca i32, align 4
23  %argv.addr = alloca ptr, align 8
24  store i32 %argc, ptr %argc.addr, align 4
25  call void @llvm.dbg.declare(metadata ptr %argc.addr, metadata !21, metadata !DIExpression()), !dbg !22
26  store ptr %argv, ptr %argv.addr, align 8
27  call void @llvm.dbg.declare(metadata ptr %argv.addr, metadata !23, metadata !DIExpression()), !dbg !24
28  call void @f(ptr %argc.addr), !dbg !25
29  ret i32 0, !dbg !26
30}
31
32define dso_local void @f(ptr %arg) #0 !dbg !7 {
33entry:
34  %arg.addr = alloca ptr, align 8
35  store ptr %arg, ptr %arg.addr, align 8
36  call void @llvm.dbg.declare(metadata ptr %arg.addr, metadata !12, metadata !DIExpression()), !dbg !13
37  ret void, !dbg !14
38}
39
40declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
41
42attributes #0 = { sanitize_address noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
43attributes #1 = { nounwind readnone speculatable willreturn }
44
45!llvm.dbg.cu = !{!0}
46!llvm.module.flags = !{!3, !4, !5}
47!llvm.ident = !{!6}
48
49!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0 (git@github.com:llvm/llvm-project 1ac700cdef787383ad49a0e37d9894491ef19480)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
50!1 = !DIFile(filename: "2.c", directory: "/home/builduser")
51!2 = !{}
52!3 = !{i32 7, !"Dwarf Version", i32 4}
53!4 = !{i32 2, !"Debug Info Version", i32 3}
54!5 = !{i32 1, !"wchar_size", i32 4}
55!6 = !{!"clang version 10.0.0 (git@github.com:llvm/llvm-project 1ac700cdef787383ad49a0e37d9894491ef19480)"}
56!7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
57!8 = !DISubroutineType(types: !9)
58!9 = !{null, !10}
59!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)
60!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
61!12 = !DILocalVariable(name: "arg", arg: 1, scope: !7, file: !1, line: 1, type: !10)
62!13 = !DILocation(line: 1, column: 13, scope: !7)
63!14 = !DILocation(line: 2, column: 1, scope: !7)
64!15 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 3, type: !16, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
65!16 = !DISubroutineType(types: !17)
66!17 = !{!11, !11, !18}
67!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64)
68!19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 64)
69!20 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
70!21 = !DILocalVariable(name: "argc", arg: 1, scope: !15, file: !1, line: 3, type: !11)
71!22 = !DILocation(line: 3, column: 14, scope: !15)
72!23 = !DILocalVariable(name: "argv", arg: 2, scope: !15, file: !1, line: 3, type: !18)
73!24 = !DILocation(line: 3, column: 27, scope: !15)
74!25 = !DILocation(line: 4, column: 3, scope: !15)
75!26 = !DILocation(line: 5, column: 1, scope: !15)
76