[codeview] Implement FPO data assembler directives
Summary:
This adds a set of new directives that describe 32-bit x86 prologues.
The directives are limited and do not expose the full complexity of
codeview FPO data. They are merely a convenience for the compiler to
generate more readable assembly so we don't need to generate tons of
labels in CodeGen. If our prologue emission changes in the future, we
can change the set of available directives to suit our needs. These are
modelled after the .seh_ directives, which use a different format that
interacts with exception handling.
The directives are:
.cv_fpo_proc _foo
.cv_fpo_pushreg ebp/ebx/etc
.cv_fpo_setframe ebp/esi/etc
.cv_fpo_stackalloc 200
.cv_fpo_endprologue
.cv_fpo_endproc
.cv_fpo_data _foo
I tried to follow the implementation of ARM EHABI CFI directives by
sinking most directives out of MCStreamer and into X86TargetStreamer.
This helps avoid polluting non-X86 code with WinCOFF specific logic.
I used cdb to confirm that this can show locals in parent CSRs in a few
cases, most importantly the one where we use ESI as a frame pointer,
i.e. the one in http://crbug.com/756153#c28
Once we have cdb integration in debuginfo-tests, we can add integration
tests there.
Reviewers: majnemer, hans
Subscribers: aemerson, mgorny, kristof.beyls, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D38776
llvm-svn: 315513
2017-10-11 23:24:33 +02:00
; RUN: llc < %s | FileCheck %s
; C source:
; void escape(int *);
; int ssp(int a) {
; int arr[4] = {a, a, a, a};
; escape(&arr[0]);
; return a;
; }
; CHECK: _ssp: # @ssp
; CHECK: .cv_fpo_proc _ssp 4
; CHECK: pushl %esi
; CHECK: .cv_fpo_pushreg %esi
; CHECK: subl $20, %esp
; CHECK: .cv_fpo_stackalloc 20
; CHECK: .cv_fpo_endprologue
; CHECK: ___security_cookie
2020-08-27 00:21:55 +02:00
; CHECK: movl 28(%esp), %esi
[codeview] Implement FPO data assembler directives
Summary:
This adds a set of new directives that describe 32-bit x86 prologues.
The directives are limited and do not expose the full complexity of
codeview FPO data. They are merely a convenience for the compiler to
generate more readable assembly so we don't need to generate tons of
labels in CodeGen. If our prologue emission changes in the future, we
can change the set of available directives to suit our needs. These are
modelled after the .seh_ directives, which use a different format that
interacts with exception handling.
The directives are:
.cv_fpo_proc _foo
.cv_fpo_pushreg ebp/ebx/etc
.cv_fpo_setframe ebp/esi/etc
.cv_fpo_stackalloc 200
.cv_fpo_endprologue
.cv_fpo_endproc
.cv_fpo_data _foo
I tried to follow the implementation of ARM EHABI CFI directives by
sinking most directives out of MCStreamer and into X86TargetStreamer.
This helps avoid polluting non-X86 code with WinCOFF specific logic.
I used cdb to confirm that this can show locals in parent CSRs in a few
cases, most importantly the one where we use ESI as a frame pointer,
i.e. the one in http://crbug.com/756153#c28
Once we have cdb integration in debuginfo-tests, we can add integration
tests there.
Reviewers: majnemer, hans
Subscribers: aemerson, mgorny, kristof.beyls, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D38776
llvm-svn: 315513
2017-10-11 23:24:33 +02:00
; CHECK: movl %esi, {{[0-9]*}}(%esp)
; CHECK: movl %esi, {{[0-9]*}}(%esp)
; CHECK: movl %esi, {{[0-9]*}}(%esp)
; CHECK: movl %esi, {{[0-9]*}}(%esp)
; CHECK: calll _escape
; CHECK: calll @__security_check_cookie@4
; CHECK: movl %esi, %eax
; CHECK: addl $20, %esp
; CHECK: popl %esi
; CHECK: retl
2020-08-27 00:21:55 +02:00
; CHECK: Ltmp3:
[codeview] Implement FPO data assembler directives
Summary:
This adds a set of new directives that describe 32-bit x86 prologues.
The directives are limited and do not expose the full complexity of
codeview FPO data. They are merely a convenience for the compiler to
generate more readable assembly so we don't need to generate tons of
labels in CodeGen. If our prologue emission changes in the future, we
can change the set of available directives to suit our needs. These are
modelled after the .seh_ directives, which use a different format that
interacts with exception handling.
The directives are:
.cv_fpo_proc _foo
.cv_fpo_pushreg ebp/ebx/etc
.cv_fpo_setframe ebp/esi/etc
.cv_fpo_stackalloc 200
.cv_fpo_endprologue
.cv_fpo_endproc
.cv_fpo_data _foo
I tried to follow the implementation of ARM EHABI CFI directives by
sinking most directives out of MCStreamer and into X86TargetStreamer.
This helps avoid polluting non-X86 code with WinCOFF specific logic.
I used cdb to confirm that this can show locals in parent CSRs in a few
cases, most importantly the one where we use ESI as a frame pointer,
i.e. the one in http://crbug.com/756153#c28
Once we have cdb integration in debuginfo-tests, we can add integration
tests there.
Reviewers: majnemer, hans
Subscribers: aemerson, mgorny, kristof.beyls, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D38776
llvm-svn: 315513
2017-10-11 23:24:33 +02:00
; CHECK: .cv_fpo_endproc
; ModuleID = 't.c'
source_filename = "t.c"
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.11.25508"
; Function Attrs: nounwind sspstrong
define i32 @ssp ( i32 returned %a ) local_unnamed_addr #0 !dbg !8 {
entry:
%arr = alloca [ 4 x i32 ] , align 4
tail call void @llvm.dbg.value ( metadata i32 %a , metadata !13 , metadata !DIExpression ( ) ) , !dbg !18
%0 = bitcast [ 4 x i32 ] * %arr to i8 * , !dbg !19
call void @llvm.lifetime.start.p0i8 ( i64 16 , i8 * nonnull %0 ) #4 , !dbg !19
tail call void @llvm.dbg.declare ( metadata [ 4 x i32 ] * %arr , metadata !14 , metadata !DIExpression ( ) ) , !dbg !20
%arrayinit.begin = getelementptr inbounds [ 4 x i32 ] , [ 4 x i32 ] * %arr , i32 0 , i32 0 , !dbg !21
store i32 %a , i32 * %arrayinit.begin , align 4 , !dbg !21 , !tbaa !22
%arrayinit.element = getelementptr inbounds [ 4 x i32 ] , [ 4 x i32 ] * %arr , i32 0 , i32 1 , !dbg !21
store i32 %a , i32 * %arrayinit.element , align 4 , !dbg !21 , !tbaa !22
%arrayinit.element1 = getelementptr inbounds [ 4 x i32 ] , [ 4 x i32 ] * %arr , i32 0 , i32 2 , !dbg !21
store i32 %a , i32 * %arrayinit.element1 , align 4 , !dbg !21 , !tbaa !22
%arrayinit.element2 = getelementptr inbounds [ 4 x i32 ] , [ 4 x i32 ] * %arr , i32 0 , i32 3 , !dbg !21
store i32 %a , i32 * %arrayinit.element2 , align 4 , !dbg !21 , !tbaa !22
call void @escape ( i32 * nonnull %arrayinit.begin ) #4 , !dbg !26
call void @llvm.lifetime.end.p0i8 ( i64 16 , i8 * nonnull %0 ) #4 , !dbg !27
ret i32 %a , !dbg !28
}
; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) #1
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.start.p0i8 ( i64 , i8 * nocapture ) #2
declare void @escape ( i32 * ) local_unnamed_addr #3
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.end.p0i8 ( i64 , i8 * nocapture ) #2
; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.value ( metadata , metadata , metadata ) #1
2021-05-24 19:43:40 +02:00
attributes #0 = { nounwind sspstrong "correctly-rounded-divide-sqrt-fp-math" = "false" "disable-tail-calls" = "false" "less-precise-fpmad" = "false" "frame-pointer" = "none" "no-infs-fp-math" = "false" "no-jump-tables" = "false" "no-nans-fp-math" = "false" "no-signed-zeros-fp-math" = "false" "no-trapping-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" }
[codeview] Implement FPO data assembler directives
Summary:
This adds a set of new directives that describe 32-bit x86 prologues.
The directives are limited and do not expose the full complexity of
codeview FPO data. They are merely a convenience for the compiler to
generate more readable assembly so we don't need to generate tons of
labels in CodeGen. If our prologue emission changes in the future, we
can change the set of available directives to suit our needs. These are
modelled after the .seh_ directives, which use a different format that
interacts with exception handling.
The directives are:
.cv_fpo_proc _foo
.cv_fpo_pushreg ebp/ebx/etc
.cv_fpo_setframe ebp/esi/etc
.cv_fpo_stackalloc 200
.cv_fpo_endprologue
.cv_fpo_endproc
.cv_fpo_data _foo
I tried to follow the implementation of ARM EHABI CFI directives by
sinking most directives out of MCStreamer and into X86TargetStreamer.
This helps avoid polluting non-X86 code with WinCOFF specific logic.
I used cdb to confirm that this can show locals in parent CSRs in a few
cases, most importantly the one where we use ESI as a frame pointer,
i.e. the one in http://crbug.com/756153#c28
Once we have cdb integration in debuginfo-tests, we can add integration
tests there.
Reviewers: majnemer, hans
Subscribers: aemerson, mgorny, kristof.beyls, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D38776
llvm-svn: 315513
2017-10-11 23:24:33 +02:00
attributes #1 = { nounwind readnone s p e c u l a t a b l e }
attributes #2 = { argmemonly nounwind }
2021-05-24 19:43:40 +02:00
attributes #3 = { "correctly-rounded-divide-sqrt-fp-math" = "false" "disable-tail-calls" = "false" "less-precise-fpmad" = "false" "frame-pointer" = "none" "no-infs-fp-math" = "false" "no-nans-fp-math" = "false" "no-signed-zeros-fp-math" = "false" "no-trapping-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" }
[codeview] Implement FPO data assembler directives
Summary:
This adds a set of new directives that describe 32-bit x86 prologues.
The directives are limited and do not expose the full complexity of
codeview FPO data. They are merely a convenience for the compiler to
generate more readable assembly so we don't need to generate tons of
labels in CodeGen. If our prologue emission changes in the future, we
can change the set of available directives to suit our needs. These are
modelled after the .seh_ directives, which use a different format that
interacts with exception handling.
The directives are:
.cv_fpo_proc _foo
.cv_fpo_pushreg ebp/ebx/etc
.cv_fpo_setframe ebp/esi/etc
.cv_fpo_stackalloc 200
.cv_fpo_endprologue
.cv_fpo_endproc
.cv_fpo_data _foo
I tried to follow the implementation of ARM EHABI CFI directives by
sinking most directives out of MCStreamer and into X86TargetStreamer.
This helps avoid polluting non-X86 code with WinCOFF specific logic.
I used cdb to confirm that this can show locals in parent CSRs in a few
cases, most importantly the one where we use ESI as a frame pointer,
i.e. the one in http://crbug.com/756153#c28
Once we have cdb integration in debuginfo-tests, we can add integration
tests there.
Reviewers: majnemer, hans
Subscribers: aemerson, mgorny, kristof.beyls, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D38776
llvm-svn: 315513
2017-10-11 23:24:33 +02:00
attributes #4 = { nounwind }
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !3 , !4 , !5 , !6 }
!llvm.ident = ! { !7 }
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , file: !1 , producer: "clang version 6.0.0 " , isOptimized: true , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !2 )
!1 = !DIFile ( filename: "t.c" , directory: "C:\5Csrc\5Cllvm-project\5Cbuild" , checksumkind: C S K _ M D 5 , checksum: "df0c1a43acd19a1255d45a3f2802cf9f" )
!2 = ! { }
!3 = ! { i32 1 , !"NumRegisterParameters" , i32 0 }
!4 = ! { i32 2 , !"CodeView" , i32 1 }
!5 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!6 = ! { i32 1 , !"wchar_size" , i32 2 }
!7 = ! { !"clang version 6.0.0 " }
[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 04:40:45 +02:00
!8 = distinct !DISubprogram ( name: "ssp" , scope: !1 , file: !1 , line: 2 , type: !9 , isLocal: false , isDefinition: true , scopeLine: 2 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !0 , retainedNodes: !12 )
[codeview] Implement FPO data assembler directives
Summary:
This adds a set of new directives that describe 32-bit x86 prologues.
The directives are limited and do not expose the full complexity of
codeview FPO data. They are merely a convenience for the compiler to
generate more readable assembly so we don't need to generate tons of
labels in CodeGen. If our prologue emission changes in the future, we
can change the set of available directives to suit our needs. These are
modelled after the .seh_ directives, which use a different format that
interacts with exception handling.
The directives are:
.cv_fpo_proc _foo
.cv_fpo_pushreg ebp/ebx/etc
.cv_fpo_setframe ebp/esi/etc
.cv_fpo_stackalloc 200
.cv_fpo_endprologue
.cv_fpo_endproc
.cv_fpo_data _foo
I tried to follow the implementation of ARM EHABI CFI directives by
sinking most directives out of MCStreamer and into X86TargetStreamer.
This helps avoid polluting non-X86 code with WinCOFF specific logic.
I used cdb to confirm that this can show locals in parent CSRs in a few
cases, most importantly the one where we use ESI as a frame pointer,
i.e. the one in http://crbug.com/756153#c28
Once we have cdb integration in debuginfo-tests, we can add integration
tests there.
Reviewers: majnemer, hans
Subscribers: aemerson, mgorny, kristof.beyls, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D38776
llvm-svn: 315513
2017-10-11 23:24:33 +02:00
!9 = !DISubroutineType ( types: !10 )
!10 = ! { !11 , !11 }
!11 = !DIBasicType ( name: "int" , size: 32 , encoding: D W _ A T E _ s i g n e d )
!12 = ! { !13 , !14 }
!13 = !DILocalVariable ( name: "a" , arg: 1 , scope: !8 , file: !1 , line: 2 , type: !11 )
!14 = !DILocalVariable ( name: "arr" , scope: !8 , file: !1 , line: 3 , type: !15 )
!15 = !DICompositeType ( tag: D W _ T A G _ a r r a y _ type , baseType: !11 , size: 128 , elements: !16 )
!16 = ! { !17 }
!17 = !DISubrange ( count: 4 )
!18 = !DILocation ( line: 2 , column: 13 , scope: !8 )
!19 = !DILocation ( line: 3 , column: 3 , scope: !8 )
!20 = !DILocation ( line: 3 , column: 7 , scope: !8 )
!21 = !DILocation ( line: 3 , column: 16 , scope: !8 )
!22 = ! { !23 , !23 , i64 0 }
!23 = ! { !"int" , !24 , i64 0 }
!24 = ! { !"omnipotent char" , !25 , i64 0 }
!25 = ! { !"Simple C/C++ TBAA" }
!26 = !DILocation ( line: 4 , column: 3 , scope: !8 )
!27 = !DILocation ( line: 6 , column: 1 , scope: !8 )
!28 = !DILocation ( line: 5 , column: 3 , scope: !8 )