2015-03-01 05:38:32 +08:00
; RUN: opt < %s -S -inline | FileCheck %s
;
; The purpose of this test is to check that inline pass preserves debug info
; for variable using the dbg.declare intrinsic.
;
;; This test was generated by running this command:
;; clang.exe -S -O0 -emit-llvm -g foo.c
;;
;; foo.c
;; ==========================
;; float foo(float x)
;; {
;; return x;
;; }
;;
;; void bar(float *dst)
;; {
;; dst[0] = foo(dst[0]);
;; }
;; ==========================
target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
target triple = "i686-pc-windows-msvc"
; Function Attrs: nounwind
define float @foo ( float %x ) #0 {
entry:
%x.addr = alloca float , align 4
store float %x , float * %x.addr , align 4
call void @llvm.dbg.declare ( metadata float * %x.addr , metadata !16 , metadata !17 ) , !dbg !18
%0 = load float , float * %x.addr , align 4 , !dbg !19
ret float %0 , !dbg !19
}
; Function Attrs: nounwind readnone
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) #1
; CHECK: define void @bar
; Function Attrs: nounwind
define void @bar ( float * %dst ) #0 {
entry:
; CHECK: [[x_addr_i:%[a-zA-Z0-9.]+]] = alloca float, align 4
%dst.addr = alloca float * , align 4
store float * %dst , float * * %dst.addr , align 4
call void @llvm.dbg.declare ( metadata float * * %dst.addr , metadata !20 , metadata !17 ) , !dbg !21
%0 = load float * , float * * %dst.addr , align 4 , !dbg !22
%arrayidx = getelementptr inbounds float , float * %0 , i32 0 , !dbg !22
%1 = load float , float * %arrayidx , align 4 , !dbg !22
%call = call float @foo ( float %1 ) , !dbg !22
; CHECK-NOT: call float @foo
2015-03-04 01:24:31 +08:00
; CHECK: void @llvm.dbg.declare(metadata float* [[x_addr_i]], metadata [[m23:![0-9]+]], metadata !{{[0-9]+}}), !dbg [[m24:![0-9]+]]
2015-03-01 05:38:32 +08:00
%2 = load float * , float * * %dst.addr , align 4 , !dbg !22
%arrayidx1 = getelementptr inbounds float , float * %2 , i32 0 , !dbg !22
store float %call , float * %arrayidx1 , align 4 , !dbg !22
ret void , !dbg !23
}
attributes #0 = { nounwind }
attributes #1 = { nounwind readnone }
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !13 , !14 }
!llvm.ident = ! { !15 }
2015-03-04 01:24:31 +08:00
!0 = !MDCompileUnit ( language: D W _ L A N G _ C 99 , producer: "clang version 3.6.0 (trunk)" , isOptimized: false , emissionKind: 1 , file: !1 , enums: !2 , retainedTypes: !2 , subprograms: !3 , globals: !2 , imports: !2 )
!1 = !MDFile ( filename: "foo.c" , directory: "" )
2015-03-01 05:38:32 +08:00
!2 = ! { }
!3 = ! { !4 , !9 }
2015-03-04 01:24:31 +08:00
!4 = !MDSubprogram ( name: "foo" , line: 1 , isLocal: false , isDefinition: true , flags: D I F l a g P r o t o t y p e d , isOptimized: false , scopeLine: 2 , file: !1 , scope: !5 , type: !6 , function: float ( float ) * @foo , variables: !2 )
!5 = !MDFile ( filename: "foo.c" , directory: "" )
!6 = !MDSubroutineType ( types: !7 )
2015-03-01 05:38:32 +08:00
!7 = ! { !8 , !8 }
2015-03-04 01:24:31 +08:00
!8 = !MDBasicType ( tag: D W _ T A G _ b a s e _ type , name: "float" , size: 32 , align: 32 , encoding: D W _ A T E _ float )
!9 = !MDSubprogram ( name: "bar" , line: 6 , isLocal: false , isDefinition: true , flags: D I F l a g P r o t o t y p e d , isOptimized: false , scopeLine: 7 , file: !1 , scope: !5 , type: !10 , function: void ( float * ) * @bar , variables: !2 )
!10 = !MDSubroutineType ( types: !11 )
2015-03-01 05:38:32 +08:00
!11 = ! { null , !12 }
2015-03-04 01:24:31 +08:00
!12 = !MDDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , size: 32 , align: 32 , baseType: !8 )
2015-03-01 05:38:32 +08:00
!13 = ! { i32 2 , !"Dwarf Version" , i32 4 }
2015-03-04 01:24:31 +08:00
!14 = ! { i32 2 , !"Debug Info Version" , i32 3 }
2015-03-01 05:38:32 +08:00
!15 = ! { !"clang version 3.6.0 (trunk)" }
2015-03-04 01:24:31 +08:00
!16 = !MDLocalVariable ( tag: D W _ T A G _ a r g _ v a r i a b l e , name: "x" , line: 1 , arg: 1 , scope: !4 , file: !5 , type: !8 )
!17 = !MDExpression ( )
2015-03-01 05:38:32 +08:00
!18 = !MDLocation ( line: 1 , column: 17 , scope: !4 )
!19 = !MDLocation ( line: 3 , column: 5 , scope: !4 )
2015-03-04 01:24:31 +08:00
!20 = !MDLocalVariable ( tag: D W _ T A G _ a r g _ v a r i a b l e , name: "dst" , line: 6 , arg: 1 , scope: !9 , file: !5 , type: !12 )
2015-03-01 05:38:32 +08:00
!21 = !MDLocation ( line: 6 , column: 17 , scope: !9 )
!22 = !MDLocation ( line: 8 , column: 14 , scope: !9 )
!23 = !MDLocation ( line: 9 , column: 1 , scope: !9 )
2015-03-04 01:24:31 +08:00
; CHECK: [[FOO:![0-9]+]] = !MDSubprogram(name: "foo",
; CHECK: [[BAR:![0-9]+]] = !MDSubprogram(name: "bar",
2015-04-16 06:29:27 +08:00
; CHECK: [[m23]] = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "x", arg: 1, scope: [[FOO]]
2015-03-04 01:24:31 +08:00
; CHECK: [[CALL_SITE:![0-9]+]] = distinct !MDLocation(line: 8, column: 14, scope: [[BAR]])
; CHECK: [[m24]] = !MDLocation(line: 1, column: 17, scope: [[FOO]], inlinedAt: [[CALL_SITE]])