2017-01-02 11:00:19 +08:00
; RUN: llc -filetype=asm -O0 -mtriple=x86_64-linux-gnu < %s -dwarf-version 2 | FileCheck -check-prefixes=CHECK,ELF-ASM %s
; RUN: llc -filetype=obj -O0 %s -mtriple=x86_64-linux-gnu -o %t-2 -dwarf-version 2
; RUN: llvm-dwarfdump %t-2 | FileCheck %s -check-prefix=CHECK-DWARF
; RUN: llc -filetype=obj -O0 %s -mtriple=x86_64-linux-gnu -o %t-4 -dwarf-version 2
; RUN: llvm-dwarfdump %t-4 | FileCheck %s -check-prefix=CHECK-DWARF
2013-11-01 01:54:35 +08:00
2017-01-02 11:00:19 +08:00
; RUN: llc -filetype=asm -O0 -mtriple=x86_64-apple-darwin < %s -dwarf-version 2 | FileCheck -check-prefixes=CHECK,DARWIN-ASM2 %s
; RUN: llc -filetype=asm -O0 -mtriple=x86_64-apple-darwin < %s -dwarf-version 4 | FileCheck -check-prefixes=CHECK,DARWIN-ASM4 %s
; RUN: llc -filetype=obj %s -mtriple=x86_64-apple-darwin -o %t2-2 -dwarf-version 2
; RUN: llvm-dwarfdump %t2-2 | FileCheck %s -check-prefix=CHECK-DWARF
; RUN: llc -filetype=obj %s -mtriple=x86_64-apple-darwin -o %t2-4 -dwarf-version 4
; RUN: llvm-dwarfdump %t2-4 | FileCheck %s -check-prefix=CHECK-DWARF
; RUN: llc -filetype=asm -O0 -mtriple=x86_64-pc-win32 < %s -dwarf-version 2 | FileCheck -check-prefixes=CHECK,COFF-ASM %s
; RUN: llc -filetype=asm -O0 -mtriple=x86_64-pc-win32 < %s -dwarf-version 4 | FileCheck -check-prefixes=CHECK,COFF-ASM %s
; RUN: llc -filetype=obj -O0 %s -mtriple=x86_64-pc-win32 -o %t3-2 -dwarf-version 2
; RUN: llvm-dwarfdump %t3-2 | FileCheck %s -check-prefix=CHECK-DWARF2
; RUN: llc -filetype=obj -O0 %s -mtriple=x86_64-pc-win32 -o %t3-4 -dwarf-version 4
; RUN: llvm-dwarfdump %t3-4 | FileCheck %s -check-prefix=CHECK-DWARF
2013-11-01 01:54:35 +08:00
; Testing case generated from:
; clang++ tu1.cpp tu2.cpp -g -emit-llvm -c
; llvm-link tu1.bc tu2.bc -o tu12.ll -S
; cat hdr.h
; struct foo {
; };
; cat tu1.cpp
; #include "hdr.h"
; foo f;
; cat tu2.cpp
; #include "hdr.h"
; foo g;
; Make sure we use relocation for ref_addr on non-darwin platforms.
; CHECK: DW_TAG_compile_unit
; CHECK: DW_TAG_variable
2017-01-02 11:00:19 +08:00
; ELF-ASM: .long [[TYPE:.*]] # DW_AT_type
; DARWIN-ASM2: .long [[TYPE:.*]] ## DW_AT_type
; DARWIN-ASM4: .long [[TYPE:.*]] ## DW_AT_type
; COFF-ASM: .long [[TYPE:.*]] # DW_AT_type
2013-11-01 01:54:35 +08:00
; CHECK: DW_TAG_structure_type
2015-03-10 11:58:36 +08:00
; CHECK: cu_begin1
2013-11-01 01:54:35 +08:00
; CHECK: DW_TAG_compile_unit
; CHECK-NOT: DW_TAG_structure_type
; This variable's type is in the 1st CU.
; CHECK: DW_TAG_variable
; Make sure this is relocatable.
2017-01-02 11:00:19 +08:00
; and test that we don't create the labels to emit a correct COFF relocation
2017-02-03 05:26:06 +08:00
; ELF-ASM: .quad .debug_info+[[TYPE]] # DW_AT_type
2017-01-02 11:00:19 +08:00
; COFF-ASM: .secrel32 .Lsection_info+[[TYPE]] # DW_AT_type
; DARWIN-ASM2: .quad [[TYPE]] ## DW_AT_type
; DARWIN-ASM4: .long [[TYPE]] ## DW_AT_type
2013-11-01 01:54:35 +08:00
; CHECK-NOT: DW_TAG_structure_type
2014-11-02 07:07:14 +08:00
; CHECK: .section
2013-11-01 01:54:35 +08:00
; CHECK-DWARF: DW_TAG_compile_unit
; CHECK-DWARF: 0x[[ADDR:.*]]: DW_TAG_structure_type
; CHECK-DWARF: DW_TAG_compile_unit
; CHECK-DWARF: DW_TAG_variable
; CHECK-DWARF: DW_AT_type [DW_FORM_ref_addr] {{.*}}[[ADDR]])
2017-01-02 11:00:19 +08:00
; CHECK-DWARF2: DW_TAG_compile_unit
; CHECK-DWARF2: DW_TAG_variable
; CHECK-DWARF2: DW_AT_type [DW_FORM_ref4] {{.*}} => {[[ADDR:.*]]})
; CHECK-DWARF2: [[ADDR]]: DW_TAG_structure_type
2013-11-01 01:54:35 +08:00
2016-12-22 08:45:21 +08:00
source_filename = "test/DebugInfo/X86/ref_addr_relocation.ll"
2013-11-01 01:54:35 +08:00
%struct.foo = type { i8 }
2016-12-22 08:45:21 +08:00
@f = global %struct.foo zeroinitializer , align 1 , !dbg !0
@g = global %struct.foo zeroinitializer , align 1 , !dbg !6
2013-11-01 01:54:35 +08:00
2016-12-22 08:45:21 +08:00
!llvm.dbg.cu = ! { !9 , !12 }
2013-11-23 05:49:45 +08:00
!llvm.module.flags = ! { !14 , !15 }
2013-11-01 01:54:35 +08:00
2016-12-22 08:45:21 +08:00
!0 = !DIGlobalVariableExpression ( var: !1 )
!1 = !DIGlobalVariable ( name: "f" , scope: null , file: !2 , line: 2 , type: !3 , isLocal: false , isDefinition: true )
!2 = !DIFile ( filename: "tu1.cpp" , directory: "/Users/manmanren/test-Nov/type_unique_air/ref_addr" )
!3 = !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "foo" , file: !4 , line: 1 , size: 8 , align: 8 , elements: !5 , identifier: "_ZTS3foo" )
!4 = !DIFile ( filename: "./hdr.h" , directory: "/Users/manmanren/test-Nov/type_unique_air/ref_addr" )
!5 = ! { }
!6 = !DIGlobalVariableExpression ( var: !7 )
!7 = !DIGlobalVariable ( name: "g" , scope: null , file: !8 , line: 2 , type: !3 , isLocal: false , isDefinition: true )
!8 = !DIFile ( filename: "tu2.cpp" , directory: "/Users/manmanren/test-Nov/type_unique_air/ref_addr" )
!9 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , file: !2 , producer: "clang version 3.4 (trunk 191799)" , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !5 , retainedTypes: !10 , globals: !11 , imports: !5 )
!10 = ! { !3 }
!11 = ! { !0 }
!12 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , file: !8 , producer: "clang version 3.4 (trunk 191799)" , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !5 , retainedTypes: !10 , globals: !13 , imports: !5 )
!13 = ! { !6 }
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
!14 = ! { i32 2 , !"Dwarf Version" , i32 2 }
2015-03-04 01:24:31 +08:00
!15 = ! { i32 1 , !"Debug Info Version" , i32 3 }
2016-12-22 08:45:21 +08:00