2013-07-23 04:15:21 +08:00
; RUN: llc -filetype=obj -O0 < %s
2013-07-11 04:43:29 +08:00
; Test that we handle DBG_VALUEs in a register without crashing.
2013-07-11 05:08:02 +08:00
;
2013-07-16 06:28:45 +08:00
; Generated from clang with -fsanitize=address:
; struct A {
; A();
; A(const A&);
2013-07-11 05:08:02 +08:00
; };
2013-07-16 06:28:45 +08:00
;
; A func(int) {
; A a;
2013-07-12 05:16:14 +08:00
; return a;
2013-07-11 05:08:02 +08:00
; }
2013-07-12 05:16:14 +08:00
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
2013-07-16 06:28:45 +08:00
target triple = "x86_64-unknown-linux-gnu"
2013-07-12 05:16:14 +08:00
2013-07-16 06:28:45 +08:00
%struct.A = type { i8 }
2013-07-12 05:16:14 +08:00
2013-07-16 06:28:45 +08:00
@__asan_mapping_offset = linkonce_odr constant i64 2147450880
2013-07-12 05:16:14 +08:00
@__asan_mapping_scale = linkonce_odr constant i64 3
@llvm.global_ctors = appending global [ 1 x { i32 , void ( ) * } ] [ { i32 , void ( ) * } { i32 1 , void ( ) * @asan.module_ctor } ]
2013-07-16 06:28:45 +08:00
@__asan_gen_ = private unnamed_addr constant [ 16 x i8 ] c "1 32 4 5 .addr \00" , align 1
2013-07-12 05:16:14 +08:00
2013-07-16 06:28:45 +08:00
; Function Attrs: sanitize_address uwtable
2015-11-06 06:03:56 +08:00
define void @_Z4funci ( %struct.A * noalias sret %agg.result , i32 ) #0 "stack-protector-buffer-size" = "1" !dbg !4 {
2013-07-11 04:43:29 +08:00
entry:
%MyAlloca = alloca [ 96 x i8 ] , align 32
2013-07-16 06:28:45 +08:00
%1 = ptrtoint [ 96 x i8 ] * %MyAlloca to i64
%2 = add i64 %1 , 32
%3 = inttoptr i64 %2 to i32 *
%4 = inttoptr i64 %1 to i64 *
store i64 1102416563 , i64 * %4
%5 = add i64 %1 , 8
%6 = inttoptr i64 %5 to i64 *
store i64 ptrtoint ( [ 16 x i8 ] * @__asan_gen_ to i64 ) , i64 * %6
%7 = add i64 %1 , 16
%8 = inttoptr i64 %7 to i64 *
store i64 ptrtoint ( void ( %struct.A * , i32 ) * @_Z4funci to i64 ) , i64 * %8
%9 = lshr i64 %1 , 3
%10 = add i64 %9 , 2147450880
%11 = inttoptr i64 %10 to i32 *
store i32 -235802127 , i32 * %11
%12 = add i64 %10 , 4
%13 = inttoptr i64 %12 to i32 *
store i32 -185273340 , i32 * %13
%14 = add i64 %10 , 8
%15 = inttoptr i64 %14 to i32 *
store i32 -202116109 , i32 * %15
%16 = ptrtoint i32 * %3 to i64
%17 = lshr i64 %16 , 3
%18 = add i64 %17 , 2147450880
%19 = inttoptr i64 %18 to i8 *
2015-02-28 05:17:42 +08:00
%20 = load i8 , i8 * %19
2013-07-16 06:28:45 +08:00
%21 = icmp ne i8 %20 , 0
2015-04-30 00:38:44 +08:00
call void @llvm.dbg.declare ( metadata i32 * %3 , metadata !23 , metadata !28 ) , !dbg !DILocation ( scope: !4 )
2013-07-16 06:28:45 +08:00
br i1 %21 , label %22 , label %28
; <label>:22 ; preds = %entry
%23 = and i64 %16 , 7
%24 = add i64 %23 , 3
%25 = trunc i64 %24 to i8
%26 = icmp sge i8 %25 , %20
br i1 %26 , label %27 , label %28
; <label>:27 ; preds = %22
call void @__asan_report_store4 ( i64 %16 )
2013-07-12 05:16:14 +08:00
call void asm sideeffect "" , "" ( )
2013-07-11 04:43:29 +08:00
unreachable
2013-07-12 05:16:14 +08:00
2013-07-16 06:28:45 +08:00
; <label>:28 ; preds = %22, %entry
store i32 %0 , i32 * %3 , align 4
2015-04-30 00:38:44 +08:00
call void @llvm.dbg.declare ( metadata %struct.A * %agg.result , metadata !24 , metadata !DIExpression ( D W _ O P _ d e r e f ) ) , !dbg !25
2013-07-16 06:28:45 +08:00
call void @_ZN1AC1Ev ( %struct.A * %agg.result ) , !dbg !25
store i64 1172321806 , i64 * %4 , !dbg !26
%29 = inttoptr i64 %10 to i32 * , !dbg !26
store i32 0 , i32 * %29 , !dbg !26
%30 = add i64 %10 , 4 , !dbg !26
%31 = inttoptr i64 %30 to i32 * , !dbg !26
store i32 0 , i32 * %31 , !dbg !26
%32 = add i64 %10 , 8 , !dbg !26
%33 = inttoptr i64 %32 to i32 * , !dbg !26
store i32 0 , i32 * %33 , !dbg !26
ret void , !dbg !26
2013-07-12 05:16:14 +08:00
}
; Function Attrs: nounwind readnone
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
llvm-svn: 218787
2014-10-02 02:55:02 +08:00
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) #1
2013-07-12 05:16:14 +08:00
2013-07-16 06:28:45 +08:00
declare void @_ZN1AC1Ev ( %struct.A * ) #2
2013-07-12 05:16:14 +08:00
2013-07-23 04:15:21 +08:00
define internal void @asan.module_ctor ( ) "stack-protector-buffer-size" = "1" {
2013-07-12 05:16:14 +08:00
call void @__asan_init_v3 ( )
2015-02-28 05:17:42 +08:00
%1 = load volatile i64 , i64 * @__asan_mapping_offset
%2 = load volatile i64 , i64 * @__asan_mapping_scale
2013-07-12 05:16:14 +08:00
ret void
2013-07-11 04:43:29 +08:00
}
2013-07-12 05:16:14 +08:00
declare void @__asan_init_v3 ( )
declare void @__asan_report_load1 ( i64 )
declare void @__asan_report_load2 ( i64 )
declare void @__asan_report_load4 ( i64 )
declare void @__asan_report_load8 ( i64 )
declare void @__asan_report_load16 ( i64 )
declare void @__asan_report_store1 ( i64 )
declare void @__asan_report_store2 ( i64 )
declare void @__asan_report_store4 ( i64 )
declare void @__asan_report_store8 ( i64 )
declare void @__asan_report_store16 ( i64 )
declare void @__asan_report_load_n ( i64 , i64 )
declare void @__asan_report_store_n ( i64 , i64 )
declare void @__asan_handle_no_return ( )
declare i64 @__asan_stack_malloc ( i64 , i64 )
declare void @__asan_stack_free ( i64 , i64 , i64 )
declare void @__asan_poison_stack_memory ( i64 , i64 )
declare void @__asan_unpoison_stack_memory ( i64 , i64 )
declare void @__asan_before_dynamic_init ( i64 )
declare void @__asan_after_dynamic_init ( )
declare void @__asan_register_globals ( i64 , i64 )
declare void @__asan_unregister_globals ( i64 , i64 )
2013-07-16 06:28:45 +08:00
attributes #0 = { sanitize_address uwtable "less-precise-fpmad" = "false" "no-frame-pointer-elim" = "true" "no-frame-pointer-elim-non-leaf" = "true" "no-infs-fp-math" = "false" "no-nans-fp-math" = "false" "ssp-buffer-size" = "8" "unsafe-fp-math" = "false" "use-soft-float" = "false" }
2013-07-12 05:16:14 +08:00
attributes #1 = { nounwind readnone }
2013-07-16 06:28:45 +08:00
attributes #2 = { "less-precise-fpmad" = "false" "no-frame-pointer-elim" = "true" "no-frame-pointer-elim-non-leaf" = "true" "no-infs-fp-math" = "false" "no-nans-fp-math" = "false" "ssp-buffer-size" = "8" "unsafe-fp-math" = "false" "use-soft-float" = "false" }
2013-07-12 05:16:14 +08:00
2013-07-11 04:43:29 +08:00
!llvm.dbg.cu = ! { !0 }
2013-11-23 05:49:45 +08:00
!llvm.module.flags = ! { !22 , !27 }
2013-07-12 05:16:14 +08:00
2016-04-15 23:57:41 +08:00
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , producer: "clang version 3.4 " , isOptimized: false , emissionKind: F u l l D e b u g , file: !1 , enums: !2 , retainedTypes: !2 , globals: !2 , imports: !2 )
2015-04-30 00:38:44 +08:00
!1 = !DIFile ( filename: "crash.cpp" , directory: "/tmp" )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
!2 = ! { }
2016-04-15 23:57:41 +08:00
!4 = distinct !DISubprogram ( name: "func" , linkageName: "_Z4funci" , line: 6 , isLocal: false , isDefinition: true , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , scopeLine: 6 , file: !1 , scope: !5 , type: !6 , variables: !2 )
2015-04-30 00:38:44 +08:00
!5 = !DIFile ( filename: "crash.cpp" , directory: "/tmp" )
!6 = !DISubroutineType ( types: !7 )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
!7 = ! { !8 , !21 }
2015-04-30 00:38:44 +08:00
!8 = !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "A" , line: 1 , size: 8 , align: 8 , file: !1 , elements: !9 )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
!9 = ! { !10 , !15 }
2015-04-30 00:38:44 +08:00
!10 = !DISubprogram ( name: "A" , line: 2 , isLocal: false , isDefinition: false , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , scopeLine: 2 , file: !1 , scope: !8 , type: !11 )
!11 = !DISubroutineType ( types: !12 )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
!12 = ! { null , !13 }
2015-04-30 00:38:44 +08:00
!13 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , size: 64 , align: 64 , flags: D I F l a g A r t i f i c i a l | D I F l a g O b j e c t P o i n t e r , baseType: !8 )
!15 = !DISubprogram ( name: "A" , line: 3 , isLocal: false , isDefinition: false , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , scopeLine: 3 , file: !1 , scope: !8 , type: !16 )
!16 = !DISubroutineType ( types: !17 )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
!17 = ! { null , !13 , !18 }
2015-04-30 00:38:44 +08:00
!18 = !DIDerivedType ( tag: D W _ T A G _ r e f e r e n c e _ type , baseType: !19 )
!19 = !DIDerivedType ( tag: D W _ T A G _ c o n s t _ type , baseType: !8 )
!21 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
!22 = ! { i32 2 , !"Dwarf Version" , i32 3 }
2015-08-01 02:58:39 +08:00
!23 = !DILocalVariable ( name: "" , line: 6 , arg: 1 , scope: !4 , file: !5 , type: !21 )
!24 = !DILocalVariable ( name: "a" , line: 7 , scope: !4 , file: !5 , type: !8 )
2015-04-30 00:38:44 +08:00
!25 = !DILocation ( line: 7 , scope: !4 )
!26 = !DILocation ( line: 8 , scope: !4 )
2015-03-04 01:24:31 +08:00
!27 = ! { i32 1 , !"Debug Info Version" , i32 3 }
2015-04-30 00:38:44 +08:00
!28 = !DIExpression ( D W _ O P _ d e r e f )