2014-04-26 04:49:25 +08:00
|
|
|
; ModuleID = 'array.c'
|
|
|
|
;
|
|
|
|
; From (clang -g -c -O1):
|
|
|
|
;
|
|
|
|
; void f(int* p) {
|
|
|
|
; p[0] = 42;
|
|
|
|
; }
|
|
|
|
;
|
|
|
|
; int main(int argc, char** argv) {
|
|
|
|
; int array[4] = { 0, 1, 2, 3 };
|
|
|
|
; f(array);
|
|
|
|
; return array[0];
|
|
|
|
; }
|
|
|
|
;
|
|
|
|
; RUN: llc -filetype=asm %s -o - | FileCheck %s
|
2017-09-12 07:05:20 +08:00
|
|
|
; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump -v - ---debug-info | FileCheck %s --check-prefix=DWARF
|
[DebugInfo] Don't turn dbg.declare into DBG_VALUE for static allocas
Summary:
We already have information about static alloca stack locations in our
side table. Emitting instructions for them is inefficient, and it only
happens when the address of the alloca has been materialized within the
current block, which isn't often.
Reviewers: aprantl, probinson, dblaikie
Subscribers: jfb, dschuff, sbc100, jgravelle-google, hiraditya, llvm-commits, aheejin
Differential Revision: https://reviews.llvm.org/D36117
llvm-svn: 309729
2017-08-02 03:45:09 +08:00
|
|
|
|
|
|
|
; CHECK-LABEL: _main:
|
|
|
|
; CHECK: movaps {{.*}}, (%rsp)
|
2017-05-26 02:54:10 +08:00
|
|
|
; CHECK: movq %rsp, %rdi
|
[DebugInfo] Don't turn dbg.declare into DBG_VALUE for static allocas
Summary:
We already have information about static alloca stack locations in our
side table. Emitting instructions for them is inefficient, and it only
happens when the address of the alloca has been materialized within the
current block, which isn't often.
Reviewers: aprantl, probinson, dblaikie
Subscribers: jfb, dschuff, sbc100, jgravelle-google, hiraditya, llvm-commits, aheejin
Differential Revision: https://reviews.llvm.org/D36117
llvm-svn: 309729
2017-08-02 03:45:09 +08:00
|
|
|
; CHECK: callq _f
|
|
|
|
|
|
|
|
; DWARF: DW_TAG_variable
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-30 05:41:21 +08:00
|
|
|
; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_fbreg +0)
|
[DebugInfo] Don't turn dbg.declare into DBG_VALUE for static allocas
Summary:
We already have information about static alloca stack locations in our
side table. Emitting instructions for them is inefficient, and it only
happens when the address of the alloca has been materialized within the
current block, which isn't often.
Reviewers: aprantl, probinson, dblaikie
Subscribers: jfb, dschuff, sbc100, jgravelle-google, hiraditya, llvm-commits, aheejin
Differential Revision: https://reviews.llvm.org/D36117
llvm-svn: 309729
2017-08-02 03:45:09 +08:00
|
|
|
; DWARF-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}} = "array")
|
|
|
|
|
2017-05-26 02:54:10 +08:00
|
|
|
; ModuleID = '/tmp/array.c'
|
|
|
|
source_filename = "/tmp/array.c"
|
2014-04-26 04:49:25 +08:00
|
|
|
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
2017-05-26 02:54:10 +08:00
|
|
|
target triple = "x86_64-apple-macosx10.12.0"
|
2014-04-26 04:49:25 +08:00
|
|
|
|
|
|
|
@main.array = private unnamed_addr constant [4 x i32] [i32 0, i32 1, i32 2, i32 3], align 16
|
|
|
|
|
|
|
|
; Function Attrs: nounwind ssp uwtable
|
2017-05-26 02:54:10 +08:00
|
|
|
define void @f(i32* nocapture %p) local_unnamed_addr #0 !dbg !8 {
|
|
|
|
entry:
|
2017-07-29 04:21:02 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32* %p, metadata !14, metadata !15), !dbg !16
|
2017-05-26 02:54:10 +08:00
|
|
|
store i32 42, i32* %p, align 4, !dbg !17, !tbaa !18
|
|
|
|
ret void, !dbg !22
|
2014-04-26 04:49:25 +08:00
|
|
|
}
|
|
|
|
|
2017-05-26 02:54:10 +08:00
|
|
|
; Function Attrs: nounwind readnone speculatable
|
|
|
|
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
|
|
|
|
|
2014-04-26 04:49:25 +08:00
|
|
|
; Function Attrs: nounwind ssp uwtable
|
2017-05-26 02:54:10 +08:00
|
|
|
define i32 @main(i32 %argc, i8** nocapture readnone %argv) local_unnamed_addr #0 !dbg !23 {
|
|
|
|
entry:
|
2014-04-26 04:49:25 +08:00
|
|
|
%array = alloca [4 x i32], align 16
|
2017-07-29 04:21:02 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %argc, metadata !30, metadata !15), !dbg !36
|
|
|
|
tail call void @llvm.dbg.value(metadata i8** %argv, metadata !31, metadata !15), !dbg !37
|
2017-05-26 02:54:10 +08:00
|
|
|
%0 = bitcast [4 x i32]* %array to i8*, !dbg !38
|
|
|
|
call void @llvm.lifetime.start.p0i8(i64 16, i8* nonnull %0) #3, !dbg !38
|
|
|
|
tail call void @llvm.dbg.declare(metadata [4 x i32]* %array, metadata !32, metadata !15), !dbg !39
|
|
|
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull %0, i8* bitcast ([4 x i32]* @main.array to i8*), i64 16, i32 16, i1 false), !dbg !39
|
|
|
|
%arraydecay = getelementptr inbounds [4 x i32], [4 x i32]* %array, i64 0, i64 0, !dbg !40
|
|
|
|
call void @f(i32* nonnull %arraydecay), !dbg !41
|
|
|
|
%1 = load i32, i32* %arraydecay, align 16, !dbg !42, !tbaa !18
|
|
|
|
call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull %0) #3, !dbg !43
|
|
|
|
ret i32 %1, !dbg !44
|
2014-04-26 04:49:25 +08:00
|
|
|
}
|
|
|
|
|
2017-05-26 02:54:10 +08:00
|
|
|
; Function Attrs: argmemonly nounwind
|
|
|
|
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #2
|
|
|
|
|
|
|
|
; Function Attrs: argmemonly nounwind
|
|
|
|
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #2
|
|
|
|
|
|
|
|
; Function Attrs: argmemonly nounwind
|
|
|
|
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #2
|
2014-04-26 04:49:25 +08:00
|
|
|
|
2017-05-26 02:54:10 +08:00
|
|
|
; Function Attrs: nounwind readnone speculatable
|
2017-07-29 04:21:02 +08:00
|
|
|
declare void @llvm.dbg.value(metadata, metadata, metadata) #1
|
2014-04-26 04:49:25 +08:00
|
|
|
|
|
|
|
attributes #0 = { nounwind ssp uwtable }
|
2017-05-26 02:54:10 +08:00
|
|
|
attributes #1 = { nounwind readnone speculatable }
|
|
|
|
attributes #2 = { argmemonly nounwind }
|
|
|
|
attributes #3 = { nounwind }
|
2014-04-26 04:49:25 +08:00
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!0}
|
2017-05-26 02:54:10 +08:00
|
|
|
!llvm.module.flags = !{!3, !4, !5, !6}
|
|
|
|
!llvm.ident = !{!7}
|
2014-04-26 04:49:25 +08:00
|
|
|
|
2017-05-26 02:54:10 +08:00
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 5.0.0 (trunk 303873) (llvm/trunk 303875)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
|
|
|
|
!1 = !DIFile(filename: "/tmp/array.c", directory: "/")
|
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 = !{}
|
2017-05-26 02:54:10 +08:00
|
|
|
!3 = !{i32 2, !"Dwarf Version", i32 4}
|
|
|
|
!4 = !{i32 2, !"Debug Info Version", i32 3}
|
|
|
|
!5 = !{i32 1, !"wchar_size", i32 4}
|
|
|
|
!6 = !{i32 7, !"PIC Level", i32 2}
|
|
|
|
!7 = !{!"clang version 5.0.0 (trunk 303873) (llvm/trunk 303875)"}
|
|
|
|
!8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !13)
|
|
|
|
!9 = !DISubroutineType(types: !10)
|
|
|
|
!10 = !{null, !11}
|
|
|
|
!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
|
|
|
|
!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
|
|
|
!13 = !{!14}
|
|
|
|
!14 = !DILocalVariable(name: "p", arg: 1, scope: !8, file: !1, line: 1, type: !11)
|
|
|
|
!15 = !DIExpression()
|
|
|
|
!16 = !DILocation(line: 1, column: 13, scope: !8)
|
|
|
|
!17 = !DILocation(line: 2, column: 8, scope: !8)
|
|
|
|
!18 = !{!19, !19, i64 0}
|
|
|
|
!19 = !{!"int", !20, i64 0}
|
|
|
|
!20 = !{!"omnipotent char", !21, i64 0}
|
|
|
|
!21 = !{!"Simple C/C++ TBAA"}
|
|
|
|
!22 = !DILocation(line: 3, column: 1, scope: !8)
|
|
|
|
!23 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 5, type: !24, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !29)
|
|
|
|
!24 = !DISubroutineType(types: !25)
|
|
|
|
!25 = !{!12, !12, !26}
|
|
|
|
!26 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !27, size: 64)
|
|
|
|
!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64)
|
|
|
|
!28 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
|
|
|
|
!29 = !{!30, !31, !32}
|
|
|
|
!30 = !DILocalVariable(name: "argc", arg: 1, scope: !23, file: !1, line: 5, type: !12)
|
|
|
|
!31 = !DILocalVariable(name: "argv", arg: 2, scope: !23, file: !1, line: 5, type: !26)
|
|
|
|
!32 = !DILocalVariable(name: "array", scope: !23, file: !1, line: 6, type: !33)
|
|
|
|
!33 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, size: 128, elements: !34)
|
|
|
|
!34 = !{!35}
|
|
|
|
!35 = !DISubrange(count: 4)
|
|
|
|
!36 = !DILocation(line: 5, column: 14, scope: !23)
|
|
|
|
!37 = !DILocation(line: 5, column: 27, scope: !23)
|
|
|
|
!38 = !DILocation(line: 6, column: 3, scope: !23)
|
|
|
|
!39 = !DILocation(line: 6, column: 7, scope: !23)
|
|
|
|
!40 = !DILocation(line: 7, column: 5, scope: !23)
|
|
|
|
!41 = !DILocation(line: 7, column: 3, scope: !23)
|
|
|
|
!42 = !DILocation(line: 8, column: 10, scope: !23)
|
|
|
|
!43 = !DILocation(line: 9, column: 1, scope: !23)
|
|
|
|
!44 = !DILocation(line: 8, column: 3, scope: !23)
|