85 lines · plain
1; RUN: opt -S -passes=asan %s | FileCheck %s2 3; The IR of this testcase is generated from the following C code:4; void bar (int);5;6; void foo() {7; __block int x;8; bar(x);9; }10; by compiling it with 'clang -emit-llvm -g -S' and then by manually11; adding the sanitize_address attribute to the @foo() function (so12; that ASAN accepts to instrument the function in the above opt run).13 14; Check that the location of the ASAN instrumented __block variable is15; correct.16; CHECK: !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 32, DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_plus_uconst, 24)17 18target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"19 20%struct.__block_byref_x = type { ptr, ptr, i32, i32, i32 }21 22; Function Attrs: nounwind ssp uwtable23define void @foo() #0 !dbg !4 {24entry:25 %x = alloca %struct.__block_byref_x, align 826 call void @llvm.dbg.declare(metadata ptr %x, metadata !12, metadata !22), !dbg !2327 store ptr null, ptr %x, !dbg !2428 %byref.forwarding = getelementptr inbounds %struct.__block_byref_x, ptr %x, i32 0, i32 1, !dbg !2429 store ptr %x, ptr %byref.forwarding, !dbg !2430 %byref.flags = getelementptr inbounds %struct.__block_byref_x, ptr %x, i32 0, i32 2, !dbg !2431 store i32 0, ptr %byref.flags, !dbg !2432 %byref.size = getelementptr inbounds %struct.__block_byref_x, ptr %x, i32 0, i32 3, !dbg !2433 store i32 32, ptr %byref.size, !dbg !2434 %forwarding = getelementptr inbounds %struct.__block_byref_x, ptr %x, i32 0, i32 1, !dbg !2535 %0 = load ptr, ptr %forwarding, !dbg !2536 %x1 = getelementptr inbounds %struct.__block_byref_x, ptr %0, i32 0, i32 4, !dbg !2537 %1 = load i32, ptr %x1, align 4, !dbg !2538 call void @bar(i32 %1), !dbg !2539 call void @_Block_object_dispose(ptr %x, i32 8) #3, !dbg !2640 ret void, !dbg !2641}42 43; Function Attrs: nounwind readnone44declare void @llvm.dbg.declare(metadata, metadata, metadata) #145 46declare void @bar(i32) #247 48declare void @_Block_object_dispose(ptr, i32)49 50attributes #0 = { nounwind ssp uwtable sanitize_address "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }51attributes #1 = { nounwind readnone }52attributes #2 = { "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }53attributes #3 = { nounwind }54 55!llvm.dbg.cu = !{!0}56!llvm.module.flags = !{!8, !9, !10}57!llvm.ident = !{!11}58 59!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.6.0 (trunk 223120) (llvm/trunk 223119)", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)60!1 = !DIFile(filename: "block.c", directory: "/tmp")61!2 = !{}62!4 = distinct !DISubprogram(name: "foo", line: 3, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, scopeLine: 3, file: !1, scope: !5, type: !6, retainedNodes: !2)63!5 = !DIFile(filename: "block.c", directory: "/tmp")64!6 = !DISubroutineType(types: !7)65!7 = !{null}66!8 = !{i32 2, !"Dwarf Version", i32 2}67!9 = !{i32 2, !"Debug Info Version", i32 3}68!10 = !{i32 1, !"PIC Level", i32 2}69!11 = !{!"clang version 3.6.0 (trunk 223120) (llvm/trunk 223119)"}70!12 = !DILocalVariable(name: "x", line: 4, scope: !4, file: !5, type: !13)71!13 = !DICompositeType(tag: DW_TAG_structure_type, size: 224, file: !1, scope: !5, elements: !14)72!14 = !{!15, !17, !18, !20, !21}73!15 = !DIDerivedType(tag: DW_TAG_member, name: "__isa", size: 64, align: 64, file: !1, scope: !5, baseType: !16)74!16 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: null)75!17 = !DIDerivedType(tag: DW_TAG_member, name: "__forwarding", size: 64, align: 64, offset: 64, file: !1, scope: !5, baseType: !16)76!18 = !DIDerivedType(tag: DW_TAG_member, name: "__flags", size: 32, align: 32, offset: 128, file: !1, scope: !5, baseType: !19)77!19 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)78!20 = !DIDerivedType(tag: DW_TAG_member, name: "__size", size: 32, align: 32, offset: 160, file: !1, scope: !5, baseType: !19)79!21 = !DIDerivedType(tag: DW_TAG_member, name: "x", size: 32, align: 32, offset: 192, file: !1, scope: !5, baseType: !19)80!22 = !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_plus_uconst, 24)81!23 = !DILocation(line: 4, column: 15, scope: !4)82!24 = !DILocation(line: 4, column: 3, scope: !4)83!25 = !DILocation(line: 5, column: 3, scope: !4)84!26 = !DILocation(line: 6, column: 1, scope: !4)85