diff options
| author | Frederic Riss <friss@apple.com> | 2015-06-05 23:06:11 +0000 |
|---|---|---|
| committer | Frederic Riss <friss@apple.com> | 2015-06-05 23:06:11 +0000 |
| commit | 5a642079d71cd0766524db4b6ec4211e143a54ac (patch) | |
| tree | 3053656ab1b6683eb7d08992461457f486bb4a3b /llvm/test/tools | |
| parent | 8423df927eb6b24e8821d557c1a26c4cd0f44fcf (diff) | |
| download | bcm5719-llvm-5a642079d71cd0766524db4b6ec4211e143a54ac.tar.gz bcm5719-llvm-5a642079d71cd0766524db4b6ec4211e143a54ac.zip | |
[dsymutil] Add support for linking the debug_frame section.
Linking the debug frame section is actually very easy as we just have to
patch the start address in the FDE header and then copy the rest of the
FDE without even looking at it. The only small complexity comes from the
handling of the CIEs that we should unique across object file. This is
also really easy by using a StringMap keyed on the raw contents of the
CIE.
llvm-svn: 239198
Diffstat (limited to 'llvm/test/tools')
| -rw-r--r-- | llvm/test/tools/dsymutil/Inputs/frame-dw2.ll | 71 | ||||
| -rw-r--r-- | llvm/test/tools/dsymutil/Inputs/frame-dw4.ll | 71 | ||||
| -rw-r--r-- | llvm/test/tools/dsymutil/Inputs/frame.c | 10 | ||||
| -rw-r--r-- | llvm/test/tools/dsymutil/X86/frame-1.test | 32 | ||||
| -rw-r--r-- | llvm/test/tools/dsymutil/X86/frame-2.test | 47 |
5 files changed, 231 insertions, 0 deletions
diff --git a/llvm/test/tools/dsymutil/Inputs/frame-dw2.ll b/llvm/test/tools/dsymutil/Inputs/frame-dw2.ll new file mode 100644 index 00000000000..7ffc9339731 --- /dev/null +++ b/llvm/test/tools/dsymutil/Inputs/frame-dw2.ll @@ -0,0 +1,71 @@ +; Generated from frame.c on Darwin with '-arch i386 -g -emit-llvm' +; ModuleID = 'frame.c' +target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128" +target triple = "i386-apple-macosx10.11.0" + +; Function Attrs: nounwind ssp +define i32 @bar(i32 %b) #0 { +entry: + %b.addr = alloca i32, align 4 + %var = alloca i32, align 4 + store i32 %b, i32* %b.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !13, metadata !14), !dbg !15 + call void @llvm.dbg.declare(metadata i32* %var, metadata !16, metadata !14), !dbg !17 + %0 = load i32, i32* %b.addr, align 4, !dbg !18 + %add = add nsw i32 %0, 1, !dbg !19 + store i32 %add, i32* %var, align 4, !dbg !17 + %call = call i32 @foo(i32* %var), !dbg !20 + ret i32 %call, !dbg !21 +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +declare i32 @foo(i32*) #2 + +; Function Attrs: nounwind ssp +define i32 @baz(i32 %b) #0 { +entry: + %b.addr = alloca i32, align 4 + store i32 %b, i32* %b.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !22, metadata !14), !dbg !23 + %0 = load i32, i32* %b.addr, align 4, !dbg !24 + %call = call i32 @bar(i32 %0), !dbg !25 + ret i32 %call, !dbg !26 +} + +attributes #0 = { nounwind ssp "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" "target-cpu"="yonah" "target-features"="+cx16,+sse,+sse2,+sse3" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } +attributes #2 = { "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" "target-cpu"="yonah" "target-features"="+cx16,+sse,+sse2,+sse3" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!9, !10, !11} +!llvm.ident = !{!12} + +!0 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 239176) (llvm/trunk 239190)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) +!1 = !DIFile(filename: "frame.c", directory: "/tmp") +!2 = !{} +!3 = !{!4, !8} +!4 = !DISubprogram(name: "bar", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, function: i32 (i32)* @bar, variables: !2) +!5 = !DISubroutineType(types: !6) +!6 = !{!7, !7} +!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!8 = !DISubprogram(name: "baz", scope: !1, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, function: i32 (i32)* @baz, variables: !2) +!9 = !{i32 2, !"Dwarf Version", i32 2} +!10 = !{i32 2, !"Debug Info Version", i32 3} +!11 = !{i32 1, !"PIC Level", i32 2} +!12 = !{!"clang version 3.7.0 (trunk 239176) (llvm/trunk 239190)"} +!13 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "b", arg: 1, scope: !4, file: !1, line: 3, type: !7) +!14 = !DIExpression() +!15 = !DILocation(line: 3, column: 13, scope: !4) +!16 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "var", scope: !4, file: !1, line: 4, type: !7) +!17 = !DILocation(line: 4, column: 6, scope: !4) +!18 = !DILocation(line: 4, column: 12, scope: !4) +!19 = !DILocation(line: 4, column: 14, scope: !4) +!20 = !DILocation(line: 5, column: 9, scope: !4) +!21 = !DILocation(line: 5, column: 2, scope: !4) +!22 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "b", arg: 1, scope: !8, file: !1, line: 8, type: !7) +!23 = !DILocation(line: 8, column: 13, scope: !8) +!24 = !DILocation(line: 9, column: 13, scope: !8) +!25 = !DILocation(line: 9, column: 9, scope: !8) +!26 = !DILocation(line: 9, column: 2, scope: !8) diff --git a/llvm/test/tools/dsymutil/Inputs/frame-dw4.ll b/llvm/test/tools/dsymutil/Inputs/frame-dw4.ll new file mode 100644 index 00000000000..c8674b13e58 --- /dev/null +++ b/llvm/test/tools/dsymutil/Inputs/frame-dw4.ll @@ -0,0 +1,71 @@ +; Generated from frame.c on Darwin with '-arch i386 -gdwarf-4 -emit-llvm' +; ModuleID = 'frame.c' +target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128" +target triple = "i386-apple-macosx10.11.0" + +; Function Attrs: nounwind ssp +define i32 @bar(i32 %b) #0 { +entry: + %b.addr = alloca i32, align 4 + %var = alloca i32, align 4 + store i32 %b, i32* %b.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !13, metadata !14), !dbg !15 + call void @llvm.dbg.declare(metadata i32* %var, metadata !16, metadata !14), !dbg !17 + %0 = load i32, i32* %b.addr, align 4, !dbg !18 + %add = add nsw i32 %0, 1, !dbg !19 + store i32 %add, i32* %var, align 4, !dbg !17 + %call = call i32 @foo(i32* %var), !dbg !20 + ret i32 %call, !dbg !21 +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +declare i32 @foo(i32*) #2 + +; Function Attrs: nounwind ssp +define i32 @baz(i32 %b) #0 { +entry: + %b.addr = alloca i32, align 4 + store i32 %b, i32* %b.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !22, metadata !14), !dbg !23 + %0 = load i32, i32* %b.addr, align 4, !dbg !24 + %call = call i32 @bar(i32 %0), !dbg !25 + ret i32 %call, !dbg !26 +} + +attributes #0 = { nounwind ssp "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" "target-cpu"="yonah" "target-features"="+cx16,+sse,+sse2,+sse3" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } +attributes #2 = { "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" "target-cpu"="yonah" "target-features"="+cx16,+sse,+sse2,+sse3" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!9, !10, !11} +!llvm.ident = !{!12} + +!0 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 239176) (llvm/trunk 239190)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) +!1 = !DIFile(filename: "frame.c", directory: "/tmp") +!2 = !{} +!3 = !{!4, !8} +!4 = !DISubprogram(name: "bar", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, function: i32 (i32)* @bar, variables: !2) +!5 = !DISubroutineType(types: !6) +!6 = !{!7, !7} +!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!8 = !DISubprogram(name: "baz", scope: !1, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, function: i32 (i32)* @baz, variables: !2) +!9 = !{i32 2, !"Dwarf Version", i32 4} +!10 = !{i32 2, !"Debug Info Version", i32 3} +!11 = !{i32 1, !"PIC Level", i32 2} +!12 = !{!"clang version 3.7.0 (trunk 239176) (llvm/trunk 239190)"} +!13 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "b", arg: 1, scope: !4, file: !1, line: 3, type: !7) +!14 = !DIExpression() +!15 = !DILocation(line: 3, column: 13, scope: !4) +!16 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "var", scope: !4, file: !1, line: 4, type: !7) +!17 = !DILocation(line: 4, column: 6, scope: !4) +!18 = !DILocation(line: 4, column: 12, scope: !4) +!19 = !DILocation(line: 4, column: 14, scope: !4) +!20 = !DILocation(line: 5, column: 9, scope: !4) +!21 = !DILocation(line: 5, column: 2, scope: !4) +!22 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "b", arg: 1, scope: !8, file: !1, line: 8, type: !7) +!23 = !DILocation(line: 8, column: 13, scope: !8) +!24 = !DILocation(line: 9, column: 13, scope: !8) +!25 = !DILocation(line: 9, column: 9, scope: !8) +!26 = !DILocation(line: 9, column: 2, scope: !8) diff --git a/llvm/test/tools/dsymutil/Inputs/frame.c b/llvm/test/tools/dsymutil/Inputs/frame.c new file mode 100644 index 00000000000..9ca082d4ae5 --- /dev/null +++ b/llvm/test/tools/dsymutil/Inputs/frame.c @@ -0,0 +1,10 @@ +int foo(int *f); + +int bar(int b) { + int var = b + 1; + return foo(&var); +} + +int baz(int b) { + return bar(b); +} diff --git a/llvm/test/tools/dsymutil/X86/frame-1.test b/llvm/test/tools/dsymutil/X86/frame-1.test new file mode 100644 index 00000000000..7852e68a142 --- /dev/null +++ b/llvm/test/tools/dsymutil/X86/frame-1.test @@ -0,0 +1,32 @@ +# REQUIRES: object-emission +# RUN: rm -rf %t +# RUN: mkdir -p %t +# RUN: llc -filetype=obj %p/../Inputs/frame-dw2.ll -o %t/frame-dw2.o +# RUN: llvm-dsymutil -oso-prepend-path=%t -y %s -o - | llvm-dwarfdump -debug-dump=frames - | FileCheck %s + +# This test is meant to verify that identical CIEs will get reused +# in the same file but also inbetween files. For this to happen, we +# link twice the same file using this made-up debug map: + +--- +triple: 'i386-unknown-unknown-macho' +objects: + - filename: frame-dw2.o + symbols: + - { sym: _bar, objAddr: 0x0, binAddr: 0x1000, size: 0x12 } + - { sym: _baz, objAddr: 0x0, binAddr: 0x2000, size: 0x12 } + - filename: frame-dw2.o + symbols: + - { sym: _baz, objAddr: 0x0, binAddr: 0x3000, size: 0x12 } +... + +# CHECK: .debug_frame contents: +# CHECK: 00000000 {{[0-9a-f]*}} ffffffff CIE +# CHECK-NOT: FDE +# CHECK: FDE cie=00000000 pc=00001000...00001 +# CHECK-NOT: FDE +# CHECK: FDE cie=00000000 pc=00002000...00002 +# CHECK-NOT: FDE +# CHECK: FDE cie=00000000 pc=00003000...00003 +# CHECK-NOT: FDE + diff --git a/llvm/test/tools/dsymutil/X86/frame-2.test b/llvm/test/tools/dsymutil/X86/frame-2.test new file mode 100644 index 00000000000..168e342a4f7 --- /dev/null +++ b/llvm/test/tools/dsymutil/X86/frame-2.test @@ -0,0 +1,47 @@ +# REQUIRES: object-emission +# RUN: rm -rf %t +# RUN: mkdir -p %t +# RUN: llc -filetype=obj %p/../Inputs/frame-dw2.ll -o %t/frame-dw2.o +# RUN: llc -filetype=obj %p/../Inputs/frame-dw4.ll -o %t/frame-dw4.o +# RUN: llvm-dsymutil -oso-prepend-path=%t -y %s -o - | llvm-dwarfdump -debug-dump=frames - | FileCheck %s + +# Check the handling of multiple different CIEs. To have CIEs that +# appear to be different, use a dwarf2 version of the file along with +# a dwarf 4 version. The CIE header version (and layout) will be different. +# FIXME: this test also checks that we didn't reuse the first CIE when it +# appears again. This is a behavior we inherited from dsymutil-classic +# but this should be fixed (see comment in patchFrameInfoForObject()) +--- +triple: 'i386-unknown-unknown-macho' +objects: + - filename: frame-dw2.o + symbols: + - { sym: _bar, objAddr: 0x0, binAddr: 0x1000, size: 0x12 } + - { sym: _baz, objAddr: 0x0, binAddr: 0x2000, size: 0x12 } + - filename: frame-dw4.o + symbols: + - { sym: _baz, objAddr: 0x0, binAddr: 0x3000, size: 0x12 } + - filename: frame-dw2.o + symbols: + - { sym: _bar, objAddr: 0x0, binAddr: 0x4000, size: 0x12 } +... + +# CHECK: .debug_frame contents: +# CHECK: 00000000 {{[0-9a-f]*}} ffffffff CIE +# CHECK-NEXT: Version:{{.*}}1 +# CHECK-NOT: FDE +# CHECK: FDE cie=00000000 pc=00001000...00001 +# CHECK-NOT: FDE +# CHECK: FDE cie=00000000 pc=00002000...00002 +# CHECK-NOT: FDE +# CHECK: [[CIEDW4:[0-9a-f]*]] 00000010 ffffffff CIE +# CHECK-NEXT: Version:{{.*}}4 +# CHECK-NOT: FDE +# CHECK: FDE cie=[[CIEDW4]] pc=00003000...00003 +# CHECK-NOT: FDE +# CHECK: [[CIEDW2:[0-9a-f]*]] {{[0-9a-f]*}} ffffffff CIE +# CHECK-NEXT: Version:{{.*}}1 +# CHECK-NOT: FDE +# CHECK: FDE cie=[[CIEDW2]] pc=00004000...00004 +# CHECK-NOT: FDE + |

