2014-11-13 11:20:23 +08:00
; REQUIRES: object-emission
; RUN: llc -mtriple=x86_64-apple-macosx10.10.0 -o %t %s
; Testcase generated from:
; #include <stdint.h>
; int foo(int a) {
; int b = (int16_t)a + 8;
; int c = (int16_t)b + 8;
; int d = (int16_t)c + 8;
; int e = (int16_t)d + 8;
; int f = (int16_t)e + 8;
; return f;
; }
; by emitting the IR and then manually applying mem2reg to it.
; This testcase would trigger the assert commited along with it if the
; fix of r221709 isn't applied. There is no other check except the successful
; run of llc.
; What happened before r221709, is that SDDbgInfo (the data structure helping
; SelectionDAG to keep track of dbg.values) kept a map keyed by SDNode pointers.
; This map was never purged when the SDNodes were deallocated and thus if a new
; SDNode was allocated in the same memory, it would have an entry in the SDDbgInfo
; map upon creation (Reallocation in the same memory can happen easily as
; SelectionDAG uses a Recycling allocator). This behavior could turn into a
; pathological memory consumption explosion if the DAG combiner hit the 'right'
; allocation patterns as could be seen in PR20893.
; By nature, this test could bitrot quite easily. If it doesn't trigger an assert
; when run with r221709 reverted, then it really doesn't test anything anymore.
; Function Attrs: nounwind ssp uwtable
2015-11-06 06:03:56 +08:00
define i32 @foo ( i32 %a ) #0 !dbg !8 {
2014-11-13 11:20:23 +08:00
entry:
2017-07-29 04:21:02 +08:00
call void @llvm.dbg.value ( metadata i32 %a , metadata !16 , metadata !17 ) , !dbg !18
2014-11-13 11:20:23 +08:00
%conv = trunc i32 %a to i16 , !dbg !19
%conv1 = sext i16 %conv to i32 , !dbg !19
%add = add nsw i32 %conv1 , 8 , !dbg !19
2017-07-29 04:21:02 +08:00
call void @llvm.dbg.value ( metadata i32 %add , metadata !20 , metadata !17 ) , !dbg !21
2014-11-13 11:20:23 +08:00
%conv2 = trunc i32 %add to i16 , !dbg !22
%conv3 = sext i16 %conv2 to i32 , !dbg !22
%add4 = add nsw i32 %conv3 , 8 , !dbg !22
2017-07-29 04:21:02 +08:00
call void @llvm.dbg.value ( metadata i32 %add4 , metadata !23 , metadata !17 ) , !dbg !24
2014-11-13 11:20:23 +08:00
%conv5 = trunc i32 %add4 to i16 , !dbg !25
%conv6 = sext i16 %conv5 to i32 , !dbg !25
%add7 = add nsw i32 %conv6 , 8 , !dbg !25
2017-07-29 04:21:02 +08:00
call void @llvm.dbg.value ( metadata i32 %add7 , metadata !26 , metadata !17 ) , !dbg !27
2014-11-13 11:20:23 +08:00
%conv8 = trunc i32 %add7 to i16 , !dbg !28
%conv9 = sext i16 %conv8 to i32 , !dbg !28
%add10 = add nsw i32 %conv9 , 8 , !dbg !28
2017-07-29 04:21:02 +08:00
call void @llvm.dbg.value ( metadata i32 %add10 , metadata !29 , metadata !17 ) , !dbg !30
2014-11-13 11:20:23 +08:00
%conv11 = trunc i32 %add10 to i16 , !dbg !31
%conv12 = sext i16 %conv11 to i32 , !dbg !31
%add13 = add nsw i32 %conv12 , 8 , !dbg !31
2017-07-29 04:21:02 +08:00
call void @llvm.dbg.value ( metadata i32 %add13 , metadata !32 , metadata !17 ) , !dbg !33
2014-11-13 11:20:23 +08:00
ret i32 %add13 , !dbg !34
}
; Function Attrs: nounwind readnone
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) #1
; Function Attrs: nounwind readnone
2017-07-29 04:21:02 +08:00
declare void @llvm.dbg.value ( metadata , metadata , metadata ) #1
2014-11-13 11:20:23 +08:00
attributes #0 = { nounwind ssp uwtable "less-precise-fpmad" = "false" "no-frame-pointer-elim" = "true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math" = "false" "no-nans-fp-math" = "false" "stack-protector-buffer-size" = "8" "unsafe-fp-math" = "false" "use-soft-float" = "false" }
attributes #1 = { nounwind readnone }
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !13 , !14 }
!llvm.ident = ! { !15 }
2016-04-15 23:57:41 +08:00
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , producer: "clang version 3.6.0 " , isOptimized: false , emissionKind: F u l l D e b u g , file: !1 , enums: !2 , retainedTypes: !3 , globals: !2 , imports: !2 )
2015-04-30 00:38:44 +08:00
!1 = !DIFile ( filename: "ghost-sdnode-dbgvalues.c" , 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 = ! { }
!3 = ! { !4 }
2015-04-30 00:38:44 +08:00
!4 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "int16_t" , line: 30 , file: !5 , baseType: !6 )
!5 = !DIFile ( filename: "/usr/include/sys/_types/_int16_t.h" , directory: "/tmp" )
!6 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "short" , size: 16 , align: 16 , encoding: D W _ A T E _ s i g n e d )
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
!8 = distinct !DISubprogram ( name: "foo" , line: 3 , isLocal: false , isDefinition: true , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , scopeLine: 3 , file: !1 , scope: !9 , type: !10 , retainedNodes: !2 )
2015-04-30 00:38:44 +08:00
!9 = !DIFile ( filename: "ghost-sdnode-dbgvalues.c" , directory: "/tmp" )
!10 = !DISubroutineType ( types: !11 )
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
!11 = ! { !12 , !12 }
2015-04-30 00:38:44 +08:00
!12 = !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
!13 = ! { i32 2 , !"Dwarf Version" , i32 2 }
2015-03-04 01:24:31 +08:00
!14 = ! { i32 2 , !"Debug Info Version" , i32 3 }
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
!15 = ! { !"clang version 3.6.0 " }
2015-08-01 02:58:39 +08:00
!16 = !DILocalVariable ( name: "a" , line: 3 , arg: 1 , scope: !8 , file: !9 , type: !12 )
2015-04-30 00:38:44 +08:00
!17 = !DIExpression ( )
!18 = !DILocation ( line: 3 , column: 13 , scope: !8 )
!19 = !DILocation ( line: 4 , column: 5 , scope: !8 )
2015-08-01 02:58:39 +08:00
!20 = !DILocalVariable ( name: "b" , line: 4 , scope: !8 , file: !9 , type: !12 )
2015-04-30 00:38:44 +08:00
!21 = !DILocation ( line: 4 , column: 9 , scope: !8 )
!22 = !DILocation ( line: 5 , column: 5 , scope: !8 )
2015-08-01 02:58:39 +08:00
!23 = !DILocalVariable ( name: "c" , line: 5 , scope: !8 , file: !9 , type: !12 )
2015-04-30 00:38:44 +08:00
!24 = !DILocation ( line: 5 , column: 9 , scope: !8 )
!25 = !DILocation ( line: 6 , column: 5 , scope: !8 )
2015-08-01 02:58:39 +08:00
!26 = !DILocalVariable ( name: "d" , line: 6 , scope: !8 , file: !9 , type: !12 )
2015-04-30 00:38:44 +08:00
!27 = !DILocation ( line: 6 , column: 9 , scope: !8 )
!28 = !DILocation ( line: 7 , column: 5 , scope: !8 )
2015-08-01 02:58:39 +08:00
!29 = !DILocalVariable ( name: "e" , line: 7 , scope: !8 , file: !9 , type: !12 )
2015-04-30 00:38:44 +08:00
!30 = !DILocation ( line: 7 , column: 9 , scope: !8 )
!31 = !DILocation ( line: 8 , column: 5 , scope: !8 )
2015-08-01 02:58:39 +08:00
!32 = !DILocalVariable ( name: "f" , line: 8 , scope: !8 , file: !9 , type: !12 )
2015-04-30 00:38:44 +08:00
!33 = !DILocation ( line: 8 , column: 9 , scope: !8 )
!34 = !DILocation ( line: 9 , column: 5 , scope: !8 )