2013-11-14 09:10:52 +08:00
; RUN: opt -S -dse < %s | FileCheck %s
2014-10-17 19:56:00 +08:00
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
2013-11-14 09:10:52 +08:00
; If there are two stores to the same location, DSE should be able to remove
; the first store if the two stores are separated by no more than 98
; instructions. The existence of debug intrinsics between the stores should
; not affect this instruction limit.
@x = global i32 0 , align 4
; Function Attrs: nounwind
2015-11-06 06:03:56 +08:00
define i32 @test_within_limit ( ) !dbg !4 {
2013-11-14 09:10:52 +08:00
entry:
; The first store; later there is a second store to the same location,
; so this store should be optimized away by DSE.
; CHECK-NOT: store i32 1, i32* @x, align 4
store i32 1 , i32 * @x , align 4
; Insert 98 dummy instructions between the two stores
%0 = bitcast i32 0 to i32
%1 = bitcast i32 0 to i32
%2 = bitcast i32 0 to i32
%3 = bitcast i32 0 to i32
%4 = bitcast i32 0 to i32
%5 = bitcast i32 0 to i32
%6 = bitcast i32 0 to i32
%7 = bitcast i32 0 to i32
%8 = bitcast i32 0 to i32
%9 = bitcast i32 0 to i32
%10 = bitcast i32 0 to i32
%11 = bitcast i32 0 to i32
%12 = bitcast i32 0 to i32
%13 = bitcast i32 0 to i32
%14 = bitcast i32 0 to i32
%15 = bitcast i32 0 to i32
%16 = bitcast i32 0 to i32
%17 = bitcast i32 0 to i32
%18 = bitcast i32 0 to i32
%19 = bitcast i32 0 to i32
%20 = bitcast i32 0 to i32
%21 = bitcast i32 0 to i32
%22 = bitcast i32 0 to i32
%23 = bitcast i32 0 to i32
%24 = bitcast i32 0 to i32
%25 = bitcast i32 0 to i32
%26 = bitcast i32 0 to i32
%27 = bitcast i32 0 to i32
%28 = bitcast i32 0 to i32
%29 = bitcast i32 0 to i32
%30 = bitcast i32 0 to i32
%31 = bitcast i32 0 to i32
%32 = bitcast i32 0 to i32
%33 = bitcast i32 0 to i32
%34 = bitcast i32 0 to i32
%35 = bitcast i32 0 to i32
%36 = bitcast i32 0 to i32
%37 = bitcast i32 0 to i32
%38 = bitcast i32 0 to i32
%39 = bitcast i32 0 to i32
%40 = bitcast i32 0 to i32
%41 = bitcast i32 0 to i32
%42 = bitcast i32 0 to i32
%43 = bitcast i32 0 to i32
%44 = bitcast i32 0 to i32
%45 = bitcast i32 0 to i32
%46 = bitcast i32 0 to i32
%47 = bitcast i32 0 to i32
%48 = bitcast i32 0 to i32
%49 = bitcast i32 0 to i32
%50 = bitcast i32 0 to i32
%51 = bitcast i32 0 to i32
%52 = bitcast i32 0 to i32
%53 = bitcast i32 0 to i32
%54 = bitcast i32 0 to i32
%55 = bitcast i32 0 to i32
%56 = bitcast i32 0 to i32
%57 = bitcast i32 0 to i32
%58 = bitcast i32 0 to i32
%59 = bitcast i32 0 to i32
%60 = bitcast i32 0 to i32
%61 = bitcast i32 0 to i32
%62 = bitcast i32 0 to i32
%63 = bitcast i32 0 to i32
%64 = bitcast i32 0 to i32
%65 = bitcast i32 0 to i32
%66 = bitcast i32 0 to i32
%67 = bitcast i32 0 to i32
%68 = bitcast i32 0 to i32
%69 = bitcast i32 0 to i32
%70 = bitcast i32 0 to i32
%71 = bitcast i32 0 to i32
%72 = bitcast i32 0 to i32
%73 = bitcast i32 0 to i32
%74 = bitcast i32 0 to i32
%75 = bitcast i32 0 to i32
%76 = bitcast i32 0 to i32
%77 = bitcast i32 0 to i32
%78 = bitcast i32 0 to i32
%79 = bitcast i32 0 to i32
%80 = bitcast i32 0 to i32
%81 = bitcast i32 0 to i32
%82 = bitcast i32 0 to i32
%83 = bitcast i32 0 to i32
%84 = bitcast i32 0 to i32
%85 = bitcast i32 0 to i32
%86 = bitcast i32 0 to i32
%87 = bitcast i32 0 to i32
%88 = bitcast i32 0 to i32
%89 = bitcast i32 0 to i32
%90 = bitcast i32 0 to i32
%91 = bitcast i32 0 to i32
%92 = bitcast i32 0 to i32
%93 = bitcast i32 0 to i32
%94 = bitcast i32 0 to i32
%95 = bitcast i32 0 to i32
%96 = bitcast i32 0 to i32
%97 = bitcast i32 0 to i32
; Insert a meaningless dbg.value intrinsic; it should have no
; effect on the working of DSE in any way.
2017-07-29 04:21:02 +08:00
call void @llvm.dbg.value ( metadata i32 undef , metadata !10 , metadata !DIExpression ( ) ) , !dbg !DILocation ( scope: !4 )
2013-11-14 09:10:52 +08:00
; CHECK: store i32 -1, i32* @x, align 4
store i32 -1 , i32 * @x , align 4
ret i32 0
}
; Function Attrs: nounwind
define i32 @test_outside_limit ( ) {
entry:
; The first store; later there is a second store to the same location
; CHECK: store i32 1, i32* @x, align 4
store i32 1 , i32 * @x , align 4
; Insert 99 dummy instructions between the two stores; this is
; one too many instruction for the DSE to take place.
%0 = bitcast i32 0 to i32
%1 = bitcast i32 0 to i32
%2 = bitcast i32 0 to i32
%3 = bitcast i32 0 to i32
%4 = bitcast i32 0 to i32
%5 = bitcast i32 0 to i32
%6 = bitcast i32 0 to i32
%7 = bitcast i32 0 to i32
%8 = bitcast i32 0 to i32
%9 = bitcast i32 0 to i32
%10 = bitcast i32 0 to i32
%11 = bitcast i32 0 to i32
%12 = bitcast i32 0 to i32
%13 = bitcast i32 0 to i32
%14 = bitcast i32 0 to i32
%15 = bitcast i32 0 to i32
%16 = bitcast i32 0 to i32
%17 = bitcast i32 0 to i32
%18 = bitcast i32 0 to i32
%19 = bitcast i32 0 to i32
%20 = bitcast i32 0 to i32
%21 = bitcast i32 0 to i32
%22 = bitcast i32 0 to i32
%23 = bitcast i32 0 to i32
%24 = bitcast i32 0 to i32
%25 = bitcast i32 0 to i32
%26 = bitcast i32 0 to i32
%27 = bitcast i32 0 to i32
%28 = bitcast i32 0 to i32
%29 = bitcast i32 0 to i32
%30 = bitcast i32 0 to i32
%31 = bitcast i32 0 to i32
%32 = bitcast i32 0 to i32
%33 = bitcast i32 0 to i32
%34 = bitcast i32 0 to i32
%35 = bitcast i32 0 to i32
%36 = bitcast i32 0 to i32
%37 = bitcast i32 0 to i32
%38 = bitcast i32 0 to i32
%39 = bitcast i32 0 to i32
%40 = bitcast i32 0 to i32
%41 = bitcast i32 0 to i32
%42 = bitcast i32 0 to i32
%43 = bitcast i32 0 to i32
%44 = bitcast i32 0 to i32
%45 = bitcast i32 0 to i32
%46 = bitcast i32 0 to i32
%47 = bitcast i32 0 to i32
%48 = bitcast i32 0 to i32
%49 = bitcast i32 0 to i32
%50 = bitcast i32 0 to i32
%51 = bitcast i32 0 to i32
%52 = bitcast i32 0 to i32
%53 = bitcast i32 0 to i32
%54 = bitcast i32 0 to i32
%55 = bitcast i32 0 to i32
%56 = bitcast i32 0 to i32
%57 = bitcast i32 0 to i32
%58 = bitcast i32 0 to i32
%59 = bitcast i32 0 to i32
%60 = bitcast i32 0 to i32
%61 = bitcast i32 0 to i32
%62 = bitcast i32 0 to i32
%63 = bitcast i32 0 to i32
%64 = bitcast i32 0 to i32
%65 = bitcast i32 0 to i32
%66 = bitcast i32 0 to i32
%67 = bitcast i32 0 to i32
%68 = bitcast i32 0 to i32
%69 = bitcast i32 0 to i32
%70 = bitcast i32 0 to i32
%71 = bitcast i32 0 to i32
%72 = bitcast i32 0 to i32
%73 = bitcast i32 0 to i32
%74 = bitcast i32 0 to i32
%75 = bitcast i32 0 to i32
%76 = bitcast i32 0 to i32
%77 = bitcast i32 0 to i32
%78 = bitcast i32 0 to i32
%79 = bitcast i32 0 to i32
%80 = bitcast i32 0 to i32
%81 = bitcast i32 0 to i32
%82 = bitcast i32 0 to i32
%83 = bitcast i32 0 to i32
%84 = bitcast i32 0 to i32
%85 = bitcast i32 0 to i32
%86 = bitcast i32 0 to i32
%87 = bitcast i32 0 to i32
%88 = bitcast i32 0 to i32
%89 = bitcast i32 0 to i32
%90 = bitcast i32 0 to i32
%91 = bitcast i32 0 to i32
%92 = bitcast i32 0 to i32
%93 = bitcast i32 0 to i32
%94 = bitcast i32 0 to i32
%95 = bitcast i32 0 to i32
%96 = bitcast i32 0 to i32
%97 = bitcast i32 0 to i32
%98 = bitcast i32 0 to i32
; CHECK: store i32 -1, i32* @x, align 4
store i32 -1 , i32 * @x , align 4
ret i32 0
}
; Function Attrs: nounwind readnone
2017-07-29 04:21:02 +08:00
declare void @llvm.dbg.value ( metadata , metadata , metadata )
2013-11-14 09:10:52 +08:00
!llvm.dbg.cu = ! { !0 }
2013-11-23 05:49:45 +08:00
!llvm.module.flags = ! { !11 , !13 }
2013-11-14 09:10:52 +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: true , 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: "test.c" , directory: "/home/tmp" )
2015-03-17 05:10:12 +08:00
!2 = ! { }
[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
!4 = distinct !DISubprogram ( name: "test_within_limit" , line: 3 , 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: 4 , file: !1 , scope: !5 , type: !6 , retainedNodes: !2 )
2015-04-30 00:38:44 +08:00
!5 = !DIFile ( filename: "test.c" , directory: "/home/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 }
2015-04-30 00:38:44 +08:00
!8 = !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
!9 = ! { !10 }
2015-08-01 02:58:39 +08:00
!10 = !DILocalVariable ( name: "x" , scope: !4 , type: !8 )
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 = ! { i32 2 , !"Dwarf Version" , i32 4 }
!12 = ! { i32 * undef }
2013-11-14 09:10:52 +08:00
2015-03-04 01:24:31 +08:00
!13 = ! { i32 1 , !"Debug Info Version" , i32 3 }