[GlobalMerge] Look at uses to create smaller global sets.
Instead of merging everything together, look at the users of
GlobalVariables, and try to group them by function, to create
sets of globals used "together".
Using that information, a less-aggressive alternative is to keep merging
everything together *except* globals that are only ever used alone, that
is, those for which it's clearly non-profitable to merge with others.
In my testing, grouping by Function is too aggressive, but grouping by
BasicBlock is too conservative. Anything in-between isn't trivially
available, so stick with Function grouping for now.
cl::opts are added for testing; both enabled by default.
A few of the testcases aren't testing the merging proper, but just
various edge cases when merging does occur. Update them to use the
previous grouping behavior. Also, one of the tests is unrelated to
GlobalMerge; change it accordingly.
While there, switch to r234666' flags rather than the brutal -O3.
Differential Revision: http://reviews.llvm.org/D8070
llvm-svn: 235249
2015-04-18 09:21:58 +08:00
|
|
|
; RUN: llc -arm-global-merge -global-merge-group-by-use=false -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
|
2011-08-03 09:25:46 +08:00
|
|
|
|
|
|
|
; Check debug info output for merged global.
|
|
|
|
; DW_AT_location
|
DebugInfo: Fix a bunch of tests that, owing to their compile_unit metadata not including a 13th field, had some subtle behavior.
Without the 13th field, the "emission kind" field defaults to 0 (which
is not equal to either of the values of the emission kind enum (1 ==
full debug info, 2 == line tables only)).
In this particular instance, the comparison with "FullDebugInfo" was
done when adding elements to the ranges list - so for these test cases
no values were added to the ranges list.
This got weirder when emitting debug_loc entries as the addresses should
be relative to the range of the CU if the CU has only one range (the
reasonable assumption is that if we're emitting debug_loc lists for a CU
that CU has at least one range - but due to the above situation, it has
zero) so the ranges were emitted relative to the start of the section
rather than relative to the start of the CU's singular range.
Fix these tests by accounting for the difference in the description of
debug_loc entries (in some cases making the test ignorant to these
differences, in others adding the extra label difference expression,
etc) or the presence/absence of high/low_pc on the CU, and add the 13th
field to their CUs to enable proper "full debug info" emission here.
In a future commit I'll fix up a bunch of other test cases that are not
so rigorously depending on this behavior, but still doing similarly
weird things due to the missing 13th field.
llvm-svn: 214937
2014-08-06 07:57:31 +08:00
|
|
|
; 0x03 DW_OP_addr
|
|
|
|
; 0x.. .long __MergedGlobals
|
|
|
|
; 0x10 DW_OP_constu
|
|
|
|
; 0x.. offset
|
|
|
|
; 0x22 DW_OP_plus
|
2011-08-03 09:25:46 +08:00
|
|
|
|
DebugInfo: Fix a bunch of tests that, owing to their compile_unit metadata not including a 13th field, had some subtle behavior.
Without the 13th field, the "emission kind" field defaults to 0 (which
is not equal to either of the values of the emission kind enum (1 ==
full debug info, 2 == line tables only)).
In this particular instance, the comparison with "FullDebugInfo" was
done when adding elements to the ranges list - so for these test cases
no values were added to the ranges list.
This got weirder when emitting debug_loc entries as the addresses should
be relative to the range of the CU if the CU has only one range (the
reasonable assumption is that if we're emitting debug_loc lists for a CU
that CU has at least one range - but due to the above situation, it has
zero) so the ranges were emitted relative to the start of the section
rather than relative to the start of the CU's singular range.
Fix these tests by accounting for the difference in the description of
debug_loc entries (in some cases making the test ignorant to these
differences, in others adding the extra label difference expression,
etc) or the presence/absence of high/low_pc on the CU, and add the 13th
field to their CUs to enable proper "full debug info" emission here.
In a future commit I'll fix up a bunch of other test cases that are not
so rigorously depending on this behavior, but still doing similarly
weird things due to the missing 13th field.
llvm-svn: 214937
2014-08-06 07:57:31 +08:00
|
|
|
; CHECK: DW_TAG_variable
|
|
|
|
; CHECK-NOT: DW_TAG
|
|
|
|
; CHECK: DW_AT_name {{.*}} "x1"
|
|
|
|
; CHECK-NOT: {{DW_TAG|NULL}}
|
|
|
|
; CHECK: DW_AT_location [DW_FORM_exprloc] (<0x8> 03 [[ADDR:.. .. .. ..]] 10 00 22 )
|
|
|
|
; CHECK: DW_TAG_variable
|
|
|
|
; CHECK-NOT: DW_TAG
|
|
|
|
; CHECK: DW_AT_name {{.*}} "x2"
|
|
|
|
; CHECK-NOT: {{DW_TAG|NULL}}
|
|
|
|
; CHECK: DW_AT_location [DW_FORM_exprloc] (<0x8> 03 [[ADDR]] 10 04 22 )
|
2011-08-03 09:25:46 +08:00
|
|
|
|
|
|
|
target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32"
|
|
|
|
target triple = "thumbv7-apple-macosx10.7.0"
|
|
|
|
|
|
|
|
@x1 = internal unnamed_addr global i32 1, align 4
|
|
|
|
@x2 = internal unnamed_addr global i32 2, align 4
|
|
|
|
@x3 = internal unnamed_addr global i32 3, align 4
|
|
|
|
@x4 = internal unnamed_addr global i32 4, align 4
|
|
|
|
@x5 = global i32 0, align 4
|
|
|
|
|
2015-11-06 06:03:56 +08:00
|
|
|
define i32 @get1(i32 %a) nounwind optsize ssp !dbg !1 {
|
2015-04-30 00:38:44 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !10, metadata !DIExpression()), !dbg !30
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* @x1, align 4, !dbg !31
|
2015-04-30 00:38:44 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %1, i64 0, metadata !11, metadata !DIExpression()), !dbg !31
|
2011-08-03 09:25:46 +08:00
|
|
|
store i32 %a, i32* @x1, align 4, !dbg !31
|
|
|
|
ret i32 %1, !dbg !31
|
|
|
|
}
|
|
|
|
|
2015-11-06 06:03:56 +08:00
|
|
|
define i32 @get2(i32 %a) nounwind optsize ssp !dbg !6 {
|
2015-04-30 00:38:44 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !13, metadata !DIExpression()), !dbg !32
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* @x2, align 4, !dbg !33
|
2015-04-30 00:38:44 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %1, i64 0, metadata !14, metadata !DIExpression()), !dbg !33
|
2011-08-03 09:25:46 +08:00
|
|
|
store i32 %a, i32* @x2, align 4, !dbg !33
|
|
|
|
ret i32 %1, !dbg !33
|
|
|
|
}
|
|
|
|
|
2015-11-06 06:03:56 +08:00
|
|
|
define i32 @get3(i32 %a) nounwind optsize ssp !dbg !7 {
|
2015-04-30 00:38:44 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !16, metadata !DIExpression()), !dbg !34
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* @x3, align 4, !dbg !35
|
2015-04-30 00:38:44 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %1, i64 0, metadata !17, metadata !DIExpression()), !dbg !35
|
2011-08-03 09:25:46 +08:00
|
|
|
store i32 %a, i32* @x3, align 4, !dbg !35
|
|
|
|
ret i32 %1, !dbg !35
|
|
|
|
}
|
|
|
|
|
2015-11-06 06:03:56 +08:00
|
|
|
define i32 @get4(i32 %a) nounwind optsize ssp !dbg !8 {
|
2015-04-30 00:38:44 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !19, metadata !DIExpression()), !dbg !36
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* @x4, align 4, !dbg !37
|
2015-04-30 00:38:44 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %1, i64 0, metadata !20, metadata !DIExpression()), !dbg !37
|
2011-08-03 09:25:46 +08:00
|
|
|
store i32 %a, i32* @x4, align 4, !dbg !37
|
|
|
|
ret i32 %1, !dbg !37
|
|
|
|
}
|
|
|
|
|
2015-11-06 06:03:56 +08:00
|
|
|
define i32 @get5(i32 %a) nounwind optsize ssp !dbg !9 {
|
2015-04-30 00:38:44 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !27, metadata !DIExpression()), !dbg !38
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* @x5, align 4, !dbg !39
|
2015-04-30 00:38:44 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %1, i64 0, metadata !28, metadata !DIExpression()), !dbg !39
|
2011-08-03 09:25:46 +08:00
|
|
|
store i32 %a, i32* @x5, align 4, !dbg !39
|
|
|
|
ret i32 %1, !dbg !39
|
|
|
|
}
|
|
|
|
|
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.value(metadata, i64, metadata, metadata) nounwind readnone
|
2011-08-03 09:25:46 +08:00
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!0}
|
2013-11-23 05:49:45 +08:00
|
|
|
!llvm.module.flags = !{!49}
|
2011-08-03 09:25:46 +08:00
|
|
|
|
2016-04-15 23:57:41 +08:00
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang", isOptimized: true, emissionKind: FullDebug, file: !47, enums: !48, retainedTypes: !48, globals: !41, imports: !48)
|
|
|
|
!1 = distinct !DISubprogram(name: "get1", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 5, file: !47, scope: !2, type: !3, variables: !42)
|
2015-04-30 00:38:44 +08:00
|
|
|
!2 = !DIFile(filename: "ss3.c", directory: "/private/tmp")
|
|
|
|
!3 = !DISubroutineType(types: !4)
|
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
|
|
|
!4 = !{!5}
|
2015-04-30 00:38:44 +08:00
|
|
|
!5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
2016-04-15 23:57:41 +08:00
|
|
|
!6 = distinct !DISubprogram(name: "get2", line: 8, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 8, file: !47, scope: !2, type: !3, variables: !43)
|
|
|
|
!7 = distinct !DISubprogram(name: "get3", line: 11, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 11, file: !47, scope: !2, type: !3, variables: !44)
|
|
|
|
!8 = distinct !DISubprogram(name: "get4", line: 14, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 14, file: !47, scope: !2, type: !3, variables: !45)
|
|
|
|
!9 = distinct !DISubprogram(name: "get5", line: 17, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 17, file: !47, scope: !2, type: !3, variables: !46)
|
2015-08-01 02:58:39 +08:00
|
|
|
!10 = !DILocalVariable(name: "a", line: 5, arg: 1, scope: !1, file: !2, type: !5)
|
|
|
|
!11 = !DILocalVariable(name: "b", line: 5, scope: !12, file: !2, type: !5)
|
2015-04-30 00:38:44 +08:00
|
|
|
!12 = distinct !DILexicalBlock(line: 5, column: 19, file: !47, scope: !1)
|
2015-08-01 02:58:39 +08:00
|
|
|
!13 = !DILocalVariable(name: "a", line: 8, arg: 1, scope: !6, file: !2, type: !5)
|
|
|
|
!14 = !DILocalVariable(name: "b", line: 8, scope: !15, file: !2, type: !5)
|
2015-04-30 00:38:44 +08:00
|
|
|
!15 = distinct !DILexicalBlock(line: 8, column: 17, file: !47, scope: !6)
|
2015-08-01 02:58:39 +08:00
|
|
|
!16 = !DILocalVariable(name: "a", line: 11, arg: 1, scope: !7, file: !2, type: !5)
|
|
|
|
!17 = !DILocalVariable(name: "b", line: 11, scope: !18, file: !2, type: !5)
|
2015-04-30 00:38:44 +08:00
|
|
|
!18 = distinct !DILexicalBlock(line: 11, column: 19, file: !47, scope: !7)
|
2015-08-01 02:58:39 +08:00
|
|
|
!19 = !DILocalVariable(name: "a", line: 14, arg: 1, scope: !8, file: !2, type: !5)
|
|
|
|
!20 = !DILocalVariable(name: "b", line: 14, scope: !21, file: !2, type: !5)
|
2015-04-30 00:38:44 +08:00
|
|
|
!21 = distinct !DILexicalBlock(line: 14, column: 19, file: !47, scope: !8)
|
|
|
|
!25 = !DIGlobalVariable(name: "x1", line: 4, isLocal: true, isDefinition: true, scope: !0, file: !2, type: !5, variable: i32* @x1)
|
|
|
|
!26 = !DIGlobalVariable(name: "x2", line: 7, isLocal: true, isDefinition: true, scope: !0, file: !2, type: !5, variable: i32* @x2)
|
2015-08-01 02:58:39 +08:00
|
|
|
!27 = !DILocalVariable(name: "a", line: 17, arg: 1, scope: !9, file: !2, type: !5)
|
|
|
|
!28 = !DILocalVariable(name: "b", line: 17, scope: !29, file: !2, type: !5)
|
2015-04-30 00:38:44 +08:00
|
|
|
!29 = distinct !DILexicalBlock(line: 17, column: 19, file: !47, scope: !9)
|
|
|
|
!30 = !DILocation(line: 5, column: 16, scope: !1)
|
|
|
|
!31 = !DILocation(line: 5, column: 32, scope: !12)
|
|
|
|
!32 = !DILocation(line: 8, column: 14, scope: !6)
|
|
|
|
!33 = !DILocation(line: 8, column: 29, scope: !15)
|
|
|
|
!34 = !DILocation(line: 11, column: 16, scope: !7)
|
|
|
|
!35 = !DILocation(line: 11, column: 32, scope: !18)
|
|
|
|
!36 = !DILocation(line: 14, column: 16, scope: !8)
|
|
|
|
!37 = !DILocation(line: 14, column: 32, scope: !21)
|
|
|
|
!38 = !DILocation(line: 17, column: 16, scope: !9)
|
|
|
|
!39 = !DILocation(line: 17, column: 32, scope: !29)
|
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
|
|
|
!41 = !{!25, !26}
|
|
|
|
!42 = !{!10, !11}
|
|
|
|
!43 = !{!13, !14}
|
|
|
|
!44 = !{!16, !17}
|
|
|
|
!45 = !{!19, !20}
|
|
|
|
!46 = !{!27, !28}
|
2015-04-30 00:38:44 +08:00
|
|
|
!47 = !DIFile(filename: "ss3.c", directory: "/private/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
|
|
|
!48 = !{}
|
2015-03-04 01:24:31 +08:00
|
|
|
!49 = !{i32 1, !"Debug Info Version", i32 3}
|