2015-10-01 03:55:43 +08:00
|
|
|
; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
|
|
|
|
|
|
|
|
; Test debug location for the local variables moved onto the unsafe stack.
|
|
|
|
|
2015-12-01 08:40:05 +08:00
|
|
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
|
|
target triple = "x86_64-unknown-linux-gnu"
|
2015-10-01 03:55:43 +08:00
|
|
|
|
2015-12-01 08:40:05 +08:00
|
|
|
%struct.S = type { [100 x i8] }
|
2015-10-01 03:55:43 +08:00
|
|
|
|
2015-12-01 08:40:05 +08:00
|
|
|
; Function Attrs: safestack uwtable
|
|
|
|
define void @f(%struct.S* byval align 8 %zzz) #0 !dbg !12 {
|
|
|
|
; CHECK: define void @f
|
2015-10-01 03:55:43 +08:00
|
|
|
|
2015-12-01 08:40:05 +08:00
|
|
|
entry:
|
|
|
|
; CHECK: %[[USP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr
|
2015-10-01 03:55:43 +08:00
|
|
|
|
2015-12-01 08:40:05 +08:00
|
|
|
%xxx = alloca %struct.S, align 1
|
|
|
|
call void @llvm.dbg.declare(metadata %struct.S* %zzz, metadata !18, metadata !19), !dbg !20
|
|
|
|
call void @llvm.dbg.declare(metadata %struct.S* %xxx, metadata !21, metadata !19), !dbg !22
|
2015-10-01 03:55:43 +08:00
|
|
|
|
2015-12-01 08:40:05 +08:00
|
|
|
; dbg.declare for %zzz and %xxx are gone; replaced with dbg.declare based off the unsafe stack pointer
|
|
|
|
; CHECK-NOT: call void @llvm.dbg.declare
|
2017-08-24 04:31:27 +08:00
|
|
|
; CHECK: call void @llvm.dbg.declare(metadata i8* %[[USP]], metadata ![[VAR_ARG:.*]], metadata !DIExpression(DW_OP_constu, 104, DW_OP_minus))
|
2015-12-01 08:40:05 +08:00
|
|
|
; CHECK-NOT: call void @llvm.dbg.declare
|
2017-08-24 04:31:27 +08:00
|
|
|
; CHECK: call void @llvm.dbg.declare(metadata i8* %[[USP]], metadata ![[VAR_LOCAL:.*]], metadata !DIExpression(DW_OP_constu, 208, DW_OP_minus))
|
2015-12-01 08:40:05 +08:00
|
|
|
; CHECK-NOT: call void @llvm.dbg.declare
|
2015-10-01 03:55:43 +08:00
|
|
|
|
2015-12-01 08:40:05 +08:00
|
|
|
call void @Capture(%struct.S* %zzz), !dbg !23
|
|
|
|
call void @Capture(%struct.S* %xxx), !dbg !24
|
2015-10-01 03:55:43 +08:00
|
|
|
|
2015-12-01 08:40:05 +08:00
|
|
|
; dbg.declare appears before the first use
|
|
|
|
; CHECK: call void @Capture
|
|
|
|
; CHECK: call void @Capture
|
2015-10-01 03:55:43 +08:00
|
|
|
|
2015-12-01 08:40:05 +08:00
|
|
|
ret void, !dbg !25
|
2015-10-01 03:55:43 +08:00
|
|
|
}
|
|
|
|
|
2015-12-01 08:40:05 +08:00
|
|
|
; CHECK-DAG: ![[VAR_ARG]] = !DILocalVariable(name: "zzz"
|
|
|
|
; 100 aligned up to 8
|
2015-10-01 03:55:43 +08:00
|
|
|
|
2015-12-01 08:40:05 +08:00
|
|
|
; CHECK-DAG: ![[VAR_LOCAL]] = !DILocalVariable(name: "xxx"
|
2015-10-01 03:55:43 +08:00
|
|
|
|
2015-12-01 08:40:05 +08:00
|
|
|
; Function Attrs: nounwind readnone
|
|
|
|
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
|
2015-10-01 03:55:43 +08:00
|
|
|
|
2015-12-01 08:40:05 +08:00
|
|
|
declare void @Capture(%struct.S*) #2
|
2015-10-01 03:55:43 +08:00
|
|
|
|
2015-12-01 08:40:05 +08:00
|
|
|
attributes #0 = { safestack uwtable "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-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
|
|
|
attributes #1 = { nounwind readnone }
|
|
|
|
attributes #2 = { "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-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
2015-10-01 03:55:43 +08:00
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!0}
|
2015-12-01 08:40:05 +08:00
|
|
|
!llvm.module.flags = !{!15, !16}
|
|
|
|
!llvm.ident = !{!17}
|
2015-10-01 03:55:43 +08:00
|
|
|
|
2016-04-15 23:57:41 +08:00
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 254019) (llvm/trunk 254036)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3)
|
2015-12-01 08:40:05 +08:00
|
|
|
!1 = !DIFile(filename: "../llvm/2.cc", directory: "/code/build-llvm")
|
2015-10-01 03:55:43 +08:00
|
|
|
!2 = !{}
|
|
|
|
!3 = !{!4}
|
2015-12-01 08:40:05 +08:00
|
|
|
!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !1, line: 4, size: 800, align: 8, elements: !5, identifier: "_ZTS1S")
|
|
|
|
!5 = !{!6}
|
2016-04-24 05:08:00 +08:00
|
|
|
!6 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !4, file: !1, line: 5, baseType: !7, size: 800, align: 8)
|
2015-12-01 08:40:05 +08:00
|
|
|
!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 800, align: 8, elements: !9)
|
|
|
|
!8 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
|
|
|
|
!9 = !{!10}
|
|
|
|
!10 = !DISubrange(count: 100)
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
|
|
|
!12 = distinct !DISubprogram(name: "f", linkageName: "_Z1f1S", scope: !1, file: !1, line: 10, type: !13, isLocal: false, isDefinition: true, scopeLine: 10, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
|
2015-12-01 08:40:05 +08:00
|
|
|
!13 = !DISubroutineType(types: !14)
|
2016-04-24 05:08:00 +08:00
|
|
|
!14 = !{null, !4}
|
2015-12-01 08:40:05 +08:00
|
|
|
!15 = !{i32 2, !"Dwarf Version", i32 4}
|
|
|
|
!16 = !{i32 2, !"Debug Info Version", i32 3}
|
|
|
|
!17 = !{!"clang version 3.8.0 (trunk 254019) (llvm/trunk 254036)"}
|
2016-04-24 05:08:00 +08:00
|
|
|
!18 = !DILocalVariable(name: "zzz", arg: 1, scope: !12, file: !1, line: 10, type: !4)
|
2015-12-01 08:40:05 +08:00
|
|
|
!19 = !DIExpression()
|
|
|
|
!20 = !DILocation(line: 10, column: 10, scope: !12)
|
2016-04-24 05:08:00 +08:00
|
|
|
!21 = !DILocalVariable(name: "xxx", scope: !12, file: !1, line: 11, type: !4)
|
2015-12-01 08:40:05 +08:00
|
|
|
!22 = !DILocation(line: 11, column: 5, scope: !12)
|
|
|
|
!23 = !DILocation(line: 12, column: 3, scope: !12)
|
|
|
|
!24 = !DILocation(line: 13, column: 3, scope: !12)
|
|
|
|
!25 = !DILocation(line: 14, column: 1, scope: !12)
|