[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}}
|
2016-09-13 09:12:59 +08:00
|
|
|
; CHECK: DW_AT_location [DW_FORM_exprloc] (<0x5> 03 [[ADDR:.. .. .. ..]] )
|
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 {{.*}} "x2"
|
|
|
|
; CHECK-NOT: {{DW_TAG|NULL}}
|
2016-09-13 09:12:59 +08:00
|
|
|
; CHECK: DW_AT_location [DW_FORM_exprloc] (<0x7> 03 [[ADDR]] 23 04 )
|
2011-08-03 09:25:46 +08:00
|
|
|
|
2016-12-22 08:45:21 +08:00
|
|
|
source_filename = "test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll"
|
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"
|
|
|
|
|
2016-12-22 08:45:21 +08:00
|
|
|
@x1 = internal unnamed_addr global i32 1, align 4, !dbg !0
|
|
|
|
@x2 = internal unnamed_addr global i32 2, align 4, !dbg !6
|
2011-08-03 09:25:46 +08:00
|
|
|
@x3 = internal unnamed_addr global i32 3, align 4
|
|
|
|
@x4 = internal unnamed_addr global i32 4, align 4
|
|
|
|
@x5 = global i32 0, align 4
|
|
|
|
|
2016-12-22 08:45:21 +08:00
|
|
|
; Function Attrs: nounwind optsize ssp
|
|
|
|
define i32 @get1(i32 %a) #0 !dbg !10 {
|
2017-07-29 04:21:02 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %a, metadata !14, metadata !17), !dbg !18
|
2016-12-22 08:45:21 +08:00
|
|
|
%1 = load i32, i32* @x1, align 4, !dbg !19
|
2017-07-29 04:21:02 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %1, metadata !15, metadata !17), !dbg !19
|
2016-12-22 08:45:21 +08:00
|
|
|
store i32 %a, i32* @x1, align 4, !dbg !19
|
|
|
|
ret i32 %1, !dbg !19
|
2011-08-03 09:25:46 +08:00
|
|
|
}
|
|
|
|
|
2016-12-22 08:45:21 +08:00
|
|
|
; Function Attrs: nounwind optsize ssp
|
|
|
|
|
|
|
|
define i32 @get2(i32 %a) #0 !dbg !20 {
|
2017-07-29 04:21:02 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %a, metadata !22, metadata !17), !dbg !25
|
2016-12-22 08:45:21 +08:00
|
|
|
%1 = load i32, i32* @x2, align 4, !dbg !26
|
2017-07-29 04:21:02 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %1, metadata !23, metadata !17), !dbg !26
|
2016-12-22 08:45:21 +08:00
|
|
|
store i32 %a, i32* @x2, align 4, !dbg !26
|
|
|
|
ret i32 %1, !dbg !26
|
2011-08-03 09:25:46 +08:00
|
|
|
}
|
|
|
|
|
2016-12-22 08:45:21 +08:00
|
|
|
; Function Attrs: nounwind optsize ssp
|
|
|
|
|
|
|
|
define i32 @get3(i32 %a) #0 !dbg !27 {
|
2017-07-29 04:21:02 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %a, metadata !29, metadata !17), !dbg !32
|
2016-12-22 08:45:21 +08:00
|
|
|
%1 = load i32, i32* @x3, align 4, !dbg !33
|
2017-07-29 04:21:02 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %1, metadata !30, metadata !17), !dbg !33
|
2016-12-22 08:45:21 +08:00
|
|
|
store i32 %a, i32* @x3, align 4, !dbg !33
|
|
|
|
ret i32 %1, !dbg !33
|
2011-08-03 09:25:46 +08:00
|
|
|
}
|
|
|
|
|
2016-12-22 08:45:21 +08:00
|
|
|
; Function Attrs: nounwind optsize ssp
|
|
|
|
|
|
|
|
define i32 @get4(i32 %a) #0 !dbg !34 {
|
2017-07-29 04:21:02 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %a, metadata !36, metadata !17), !dbg !39
|
2016-12-22 08:45:21 +08:00
|
|
|
%1 = load i32, i32* @x4, align 4, !dbg !40
|
2017-07-29 04:21:02 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %1, metadata !37, metadata !17), !dbg !40
|
2016-12-22 08:45:21 +08:00
|
|
|
store i32 %a, i32* @x4, align 4, !dbg !40
|
|
|
|
ret i32 %1, !dbg !40
|
2011-08-03 09:25:46 +08:00
|
|
|
}
|
|
|
|
|
2016-12-22 08:45:21 +08:00
|
|
|
; Function Attrs: nounwind optsize ssp
|
|
|
|
|
|
|
|
define i32 @get5(i32 %a) #0 !dbg !41 {
|
2017-07-29 04:21:02 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %a, metadata !43, metadata !17), !dbg !46
|
2016-12-22 08:45:21 +08:00
|
|
|
%1 = load i32, i32* @x5, align 4, !dbg !47
|
2017-07-29 04:21:02 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %1, metadata !44, metadata !17), !dbg !47
|
2016-12-22 08:45:21 +08:00
|
|
|
store i32 %a, i32* @x5, align 4, !dbg !47
|
|
|
|
ret i32 %1, !dbg !47
|
2011-08-03 09:25:46 +08:00
|
|
|
}
|
|
|
|
|
2016-12-22 08:45:21 +08:00
|
|
|
; Function Attrs: nounwind readnone
|
|
|
|
|
2017-07-29 04:21:02 +08:00
|
|
|
declare void @llvm.dbg.value(metadata, metadata, metadata) #1
|
2016-12-22 08:45:21 +08:00
|
|
|
|
|
|
|
attributes #0 = { nounwind optsize ssp }
|
|
|
|
attributes #1 = { nounwind readnone }
|
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!2}
|
|
|
|
!llvm.module.flags = !{!9}
|
|
|
|
|
|
|
|
!0 = !DIGlobalVariableExpression(var: !1)
|
|
|
|
!1 = !DIGlobalVariable(name: "x1", scope: !2, file: !3, line: 4, type: !8, isLocal: true, isDefinition: true)
|
|
|
|
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !4, globals: !5, imports: !4)
|
|
|
|
!3 = !DIFile(filename: "ss3.c", directory: "/private/tmp")
|
|
|
|
!4 = !{}
|
|
|
|
!5 = !{!0, !6}
|
|
|
|
!6 = !DIGlobalVariableExpression(var: !7)
|
|
|
|
!7 = !DIGlobalVariable(name: "x2", scope: !2, file: !3, line: 7, type: !8, isLocal: true, isDefinition: true)
|
|
|
|
!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
|
|
|
!9 = !{i32 1, !"Debug Info Version", i32 3}
|
|
|
|
!10 = distinct !DISubprogram(name: "get1", scope: !3, file: !3, line: 5, type: !11, isLocal: false, isDefinition: true, scopeLine: 5, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !2, variables: !13)
|
|
|
|
!11 = !DISubroutineType(types: !12)
|
|
|
|
!12 = !{!8}
|
|
|
|
!13 = !{!14, !15}
|
|
|
|
!14 = !DILocalVariable(name: "a", arg: 1, scope: !10, file: !3, line: 5, type: !8)
|
|
|
|
!15 = !DILocalVariable(name: "b", scope: !16, file: !3, line: 5, type: !8)
|
|
|
|
!16 = distinct !DILexicalBlock(scope: !10, file: !3, line: 5, column: 19)
|
|
|
|
!17 = !DIExpression()
|
|
|
|
!18 = !DILocation(line: 5, column: 16, scope: !10)
|
|
|
|
!19 = !DILocation(line: 5, column: 32, scope: !16)
|
|
|
|
!20 = distinct !DISubprogram(name: "get2", scope: !3, file: !3, line: 8, type: !11, isLocal: false, isDefinition: true, scopeLine: 8, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !2, variables: !21)
|
|
|
|
!21 = !{!22, !23}
|
|
|
|
!22 = !DILocalVariable(name: "a", arg: 1, scope: !20, file: !3, line: 8, type: !8)
|
|
|
|
!23 = !DILocalVariable(name: "b", scope: !24, file: !3, line: 8, type: !8)
|
|
|
|
!24 = distinct !DILexicalBlock(scope: !20, file: !3, line: 8, column: 17)
|
|
|
|
!25 = !DILocation(line: 8, column: 14, scope: !20)
|
|
|
|
!26 = !DILocation(line: 8, column: 29, scope: !24)
|
|
|
|
!27 = distinct !DISubprogram(name: "get3", scope: !3, file: !3, line: 11, type: !11, isLocal: false, isDefinition: true, scopeLine: 11, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !2, variables: !28)
|
|
|
|
!28 = !{!29, !30}
|
|
|
|
!29 = !DILocalVariable(name: "a", arg: 1, scope: !27, file: !3, line: 11, type: !8)
|
|
|
|
!30 = !DILocalVariable(name: "b", scope: !31, file: !3, line: 11, type: !8)
|
|
|
|
!31 = distinct !DILexicalBlock(scope: !27, file: !3, line: 11, column: 19)
|
|
|
|
!32 = !DILocation(line: 11, column: 16, scope: !27)
|
|
|
|
!33 = !DILocation(line: 11, column: 32, scope: !31)
|
|
|
|
!34 = distinct !DISubprogram(name: "get4", scope: !3, file: !3, line: 14, type: !11, isLocal: false, isDefinition: true, scopeLine: 14, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !2, variables: !35)
|
|
|
|
!35 = !{!36, !37}
|
|
|
|
!36 = !DILocalVariable(name: "a", arg: 1, scope: !34, file: !3, line: 14, type: !8)
|
|
|
|
!37 = !DILocalVariable(name: "b", scope: !38, file: !3, line: 14, type: !8)
|
|
|
|
!38 = distinct !DILexicalBlock(scope: !34, file: !3, line: 14, column: 19)
|
|
|
|
!39 = !DILocation(line: 14, column: 16, scope: !34)
|
|
|
|
!40 = !DILocation(line: 14, column: 32, scope: !38)
|
|
|
|
!41 = distinct !DISubprogram(name: "get5", scope: !3, file: !3, line: 17, type: !11, isLocal: false, isDefinition: true, scopeLine: 17, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !2, variables: !42)
|
|
|
|
!42 = !{!43, !44}
|
|
|
|
!43 = !DILocalVariable(name: "a", arg: 1, scope: !41, file: !3, line: 17, type: !8)
|
|
|
|
!44 = !DILocalVariable(name: "b", scope: !45, file: !3, line: 17, type: !8)
|
|
|
|
!45 = distinct !DILexicalBlock(scope: !41, file: !3, line: 17, column: 19)
|
|
|
|
!46 = !DILocation(line: 17, column: 16, scope: !41)
|
|
|
|
!47 = !DILocation(line: 17, column: 32, scope: !45)
|
|
|
|
|