[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
|
|
|
|
|
|
|
|
define i32 @get1(i32 %a) nounwind optsize ssp {
|
2015-03-04 01:24:31 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !10, metadata !MDExpression()), !dbg !30
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* @x1, align 4, !dbg !31
|
2015-03-04 01:24:31 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %1, i64 0, metadata !11, metadata !MDExpression()), !dbg !31
|
2011-08-03 09:25:46 +08:00
|
|
|
store i32 %a, i32* @x1, align 4, !dbg !31
|
|
|
|
ret i32 %1, !dbg !31
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @get2(i32 %a) nounwind optsize ssp {
|
2015-03-04 01:24:31 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !13, metadata !MDExpression()), !dbg !32
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* @x2, align 4, !dbg !33
|
2015-03-04 01:24:31 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %1, i64 0, metadata !14, metadata !MDExpression()), !dbg !33
|
2011-08-03 09:25:46 +08:00
|
|
|
store i32 %a, i32* @x2, align 4, !dbg !33
|
|
|
|
ret i32 %1, !dbg !33
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @get3(i32 %a) nounwind optsize ssp {
|
2015-03-04 01:24:31 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !16, metadata !MDExpression()), !dbg !34
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* @x3, align 4, !dbg !35
|
2015-03-04 01:24:31 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %1, i64 0, metadata !17, metadata !MDExpression()), !dbg !35
|
2011-08-03 09:25:46 +08:00
|
|
|
store i32 %a, i32* @x3, align 4, !dbg !35
|
|
|
|
ret i32 %1, !dbg !35
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @get4(i32 %a) nounwind optsize ssp {
|
2015-03-04 01:24:31 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !19, metadata !MDExpression()), !dbg !36
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* @x4, align 4, !dbg !37
|
2015-03-04 01:24:31 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %1, i64 0, metadata !20, metadata !MDExpression()), !dbg !37
|
2011-08-03 09:25:46 +08:00
|
|
|
store i32 %a, i32* @x4, align 4, !dbg !37
|
|
|
|
ret i32 %1, !dbg !37
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @get5(i32 %a) nounwind optsize ssp {
|
2015-03-04 01:24:31 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !27, metadata !MDExpression()), !dbg !38
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* @x5, align 4, !dbg !39
|
2015-03-04 01:24:31 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %1, i64 0, metadata !28, metadata !MDExpression()), !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
|
|
|
|
2015-03-04 01:24:31 +08:00
|
|
|
!0 = !MDCompileUnit(language: DW_LANG_C99, producer: "clang", isOptimized: true, emissionKind: 1, file: !47, enums: !48, retainedTypes: !48, subprograms: !40, globals: !41, imports: !48)
|
|
|
|
!1 = !MDSubprogram(name: "get1", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 5, file: !47, scope: !2, type: !3, function: i32 (i32)* @get1, variables: !42)
|
|
|
|
!2 = !MDFile(filename: "ss3.c", directory: "/private/tmp")
|
|
|
|
!3 = !MDSubroutineType(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-03-04 01:24:31 +08:00
|
|
|
!5 = !MDBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
|
|
|
!6 = !MDSubprogram(name: "get2", line: 8, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 8, file: !47, scope: !2, type: !3, function: i32 (i32)* @get2, variables: !43)
|
|
|
|
!7 = !MDSubprogram(name: "get3", line: 11, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 11, file: !47, scope: !2, type: !3, function: i32 (i32)* @get3, variables: !44)
|
|
|
|
!8 = !MDSubprogram(name: "get4", line: 14, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 14, file: !47, scope: !2, type: !3, function: i32 (i32)* @get4, variables: !45)
|
|
|
|
!9 = !MDSubprogram(name: "get5", line: 17, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 17, file: !47, scope: !2, type: !3, function: i32 (i32)* @get5, variables: !46)
|
|
|
|
!10 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "a", line: 5, arg: 1, scope: !1, file: !2, type: !5)
|
|
|
|
!11 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "b", line: 5, scope: !12, file: !2, type: !5)
|
|
|
|
!12 = distinct !MDLexicalBlock(line: 5, column: 19, file: !47, scope: !1)
|
|
|
|
!13 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "a", line: 8, arg: 1, scope: !6, file: !2, type: !5)
|
|
|
|
!14 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "b", line: 8, scope: !15, file: !2, type: !5)
|
|
|
|
!15 = distinct !MDLexicalBlock(line: 8, column: 17, file: !47, scope: !6)
|
|
|
|
!16 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "a", line: 11, arg: 1, scope: !7, file: !2, type: !5)
|
|
|
|
!17 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "b", line: 11, scope: !18, file: !2, type: !5)
|
|
|
|
!18 = distinct !MDLexicalBlock(line: 11, column: 19, file: !47, scope: !7)
|
|
|
|
!19 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "a", line: 14, arg: 1, scope: !8, file: !2, type: !5)
|
|
|
|
!20 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "b", line: 14, scope: !21, file: !2, type: !5)
|
|
|
|
!21 = distinct !MDLexicalBlock(line: 14, column: 19, file: !47, scope: !8)
|
|
|
|
!25 = !MDGlobalVariable(name: "x1", line: 4, isLocal: true, isDefinition: true, scope: !0, file: !2, type: !5, variable: i32* @x1)
|
|
|
|
!26 = !MDGlobalVariable(name: "x2", line: 7, isLocal: true, isDefinition: true, scope: !0, file: !2, type: !5, variable: i32* @x2)
|
|
|
|
!27 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "a", line: 17, arg: 1, scope: !9, file: !2, type: !5)
|
|
|
|
!28 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "b", line: 17, scope: !29, file: !2, type: !5)
|
|
|
|
!29 = distinct !MDLexicalBlock(line: 17, column: 19, file: !47, scope: !9)
|
2015-01-15 06:27:36 +08:00
|
|
|
!30 = !MDLocation(line: 5, column: 16, scope: !1)
|
|
|
|
!31 = !MDLocation(line: 5, column: 32, scope: !12)
|
|
|
|
!32 = !MDLocation(line: 8, column: 14, scope: !6)
|
|
|
|
!33 = !MDLocation(line: 8, column: 29, scope: !15)
|
|
|
|
!34 = !MDLocation(line: 11, column: 16, scope: !7)
|
|
|
|
!35 = !MDLocation(line: 11, column: 32, scope: !18)
|
|
|
|
!36 = !MDLocation(line: 14, column: 16, scope: !8)
|
|
|
|
!37 = !MDLocation(line: 14, column: 32, scope: !21)
|
|
|
|
!38 = !MDLocation(line: 17, column: 16, scope: !9)
|
|
|
|
!39 = !MDLocation(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
|
|
|
!40 = !{!1, !6, !7, !8, !9}
|
|
|
|
!41 = !{!25, !26}
|
|
|
|
!42 = !{!10, !11}
|
|
|
|
!43 = !{!13, !14}
|
|
|
|
!44 = !{!16, !17}
|
|
|
|
!45 = !{!19, !20}
|
|
|
|
!46 = !{!27, !28}
|
2015-03-04 01:24:31 +08:00
|
|
|
!47 = !MDFile(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}
|