2016-06-18 00:11:20 +08:00
; RUN: llc -mcpu=core2 -mtriple=i686-pc-win32 -o - -O0 -filetype=obj < %s \
; RUN: | llvm-readobj -codeview | FileCheck %s
; C++ source to regenerate:
; namespace foo {
; int bar(int x) { return x * 2; }
; }
; template <typename T, int (*)(int)>
; void fn_tmpl() {}
; template void fn_tmpl<int, foo::bar>();
; void f() {
; fn_tmpl<int, foo::bar>();
; }
; CHECK: ProcStart {
; CHECK: FunctionType: bar ({{.*}})
; CHECK: DisplayName: foo::bar{{$}}
; CHECK-NEXT: LinkageName: ?bar@foo@@YAHH@Z
2014-11-13 04:21:20 +08:00
; CHECK: ProcStart {
2016-06-18 00:11:20 +08:00
; CHECK: FunctionType: fn_tmpl ({{.*}})
; CHECK: DisplayName: foo::fn_tmpl<int,&foo::bar>
; CHECK-NEXT: LinkageName: ??$fn_tmpl@H$1?bar@foo@@YAHH@Z@foo@@YAXXZ
; ModuleID = 't.cpp'
source_filename = "t.cpp"
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i386-pc-windows-msvc19.0.23918"
2014-11-13 04:21:20 +08:00
2016-06-18 00:11:20 +08:00
$ "\01??$fn_tmpl@H$1?bar@foo@@YAHH@Z@foo@@YAXXZ" = comdat any
; Function Attrs: nounwind
define i32 @"\01?bar@foo@@YAHH@Z" ( i32 %x ) #0 !dbg !6 {
2014-11-13 04:21:20 +08:00
entry:
%x.addr = alloca i32 , align 4
store i32 %x , i32 * %x.addr , align 4
2016-06-18 00:11:20 +08:00
call void @llvm.dbg.declare ( metadata i32 * %x.addr , metadata !11 , metadata !12 ) , !dbg !13
%0 = load i32 , i32 * %x.addr , align 4 , !dbg !14
%mul = mul nsw i32 %0 , 2 , !dbg !15
ret i32 %mul , !dbg !16
2014-11-13 04:21:20 +08:00
}
2016-01-14 08:12:54 +08:00
; Function Attrs: nounwind readnone
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) #1
2016-06-18 00:11:20 +08:00
; Function Attrs: nounwind
define weak_odr void @"\01??$fn_tmpl@H$1?bar@foo@@YAHH@Z@foo@@YAXXZ" ( ) #0 comdat !dbg !17 {
entry:
ret void , !dbg !24
}
attributes #0 = { nounwind "disable-tail-calls" = "false" "less-precise-fpmad" = "false" "no-frame-pointer-elim" = "true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math" = "false" "no-jump-tables" = "false" "no-nans-fp-math" = "false" "stack-protector-buffer-size" = "8" "target-cpu" = "pentium4" "target-features" = "+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math" = "false" "use-soft-float" = "false" }
2016-01-14 08:12:54 +08:00
attributes #1 = { nounwind readnone }
2014-11-13 04:21:20 +08:00
!llvm.dbg.cu = ! { !0 }
2016-06-18 00:11:20 +08:00
!llvm.module.flags = ! { !3 , !4 }
!llvm.ident = ! { !5 }
2014-11-13 04:21:20 +08:00
2016-06-18 00:11:20 +08:00
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , file: !1 , producer: "clang version 3.9.0 " , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !2 )
!1 = !DIFile ( filename: "t.cpp" , directory: "D:\5Csrc\5Cllvm\5Cbuild" )
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
!2 = ! { }
2016-06-18 00:11:20 +08:00
!3 = ! { i32 2 , !"CodeView" , i32 1 }
!4 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!5 = ! { !"clang version 3.9.0 " }
!6 = distinct !DISubprogram ( name: "bar" , linkageName: "\01?bar@foo@@YAHH@Z" , scope: !7 , file: !1 , line: 2 , type: !8 , isLocal: false , isDefinition: true , scopeLine: 2 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , variables: !2 )
2017-04-29 06:25:46 +08:00
!7 = !DINamespace ( name: "foo" , scope: null )
2016-06-18 00:11:20 +08:00
!8 = !DISubroutineType ( types: !9 )
!9 = ! { !10 , !10 }
!10 = !DIBasicType ( name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
!11 = !DILocalVariable ( name: "x" , arg: 1 , scope: !6 , file: !1 , line: 2 , type: !10 )
!12 = !DIExpression ( )
!13 = !DILocation ( line: 2 , column: 13 , scope: !6 )
!14 = !DILocation ( line: 2 , column: 25 , scope: !6 )
!15 = !DILocation ( line: 2 , column: 27 , scope: !6 )
!16 = !DILocation ( line: 2 , column: 18 , scope: !6 )
!17 = distinct !DISubprogram ( name: "fn_tmpl<int,&foo::bar>" , linkageName: "\01??$fn_tmpl@H$1?bar@foo@@YAHH@Z@foo@@YAXXZ" , scope: !7 , file: !1 , line: 4 , type: !18 , isLocal: false , isDefinition: true , scopeLine: 4 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , templateParams: !20 , variables: !2 )
!18 = !DISubroutineType ( types: !19 )
!19 = ! { null }
!20 = ! { !21 , !22 }
!21 = !DITemplateTypeParameter ( name: "T" , type: !10 )
!22 = !DITemplateValueParameter ( type: !23 , value: i32 ( i32 ) * @"\01?bar@foo@@YAHH@Z" )
!23 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !8 , size: 32 , align: 32 )
!24 = !DILocation ( line: 4 , column: 17 , scope: !17 )