2014-02-15 01:19:07 +08:00
; ARM EHABI integrated test
; This test case checks whether the ARM DWARF stack frame directives
; are properly generated or not.
; We have to check several cases:
2019-01-14 18:55:55 +08:00
; (1) arm with -frame-pointer=all
; (2) arm without -frame-pointer=all
; (3) armv7 with -frame-pointer=all
; (4) armv7 without -frame-pointer=all
; (5) thumb with -frame-pointer=all
; (6) thumb without -frame-pointer=all
; (7) thumbv7 with -frame-pointer=all
; (8) thumbv7 without -frame-pointer=all
2014-03-13 23:56:41 +08:00
; (9) thumbv7 with -no-integrated-as
2014-02-15 01:19:07 +08:00
; RUN: llc -mtriple arm-unknown-linux-gnueabi \
2019-01-14 18:55:55 +08:00
; RUN: -frame-pointer=all -filetype=asm -o - %s \
2014-02-15 01:19:07 +08:00
; RUN: | FileCheck %s --check-prefix=CHECK-FP
; RUN: llc -mtriple arm-unknown-linux-gnueabi \
; RUN: -filetype=asm -o - %s \
; RUN: | FileCheck %s --check-prefix=CHECK-FP-ELIM
; RUN: llc -mtriple armv7-unknown-linux-gnueabi \
2019-01-14 18:55:55 +08:00
; RUN: -frame-pointer=all -filetype=asm -o - %s \
2014-02-15 01:19:07 +08:00
; RUN: | FileCheck %s --check-prefix=CHECK-V7-FP
; RUN: llc -mtriple armv7-unknown-linux-gnueabi \
; RUN: -filetype=asm -o - %s \
; RUN: | FileCheck %s --check-prefix=CHECK-V7-FP-ELIM
2015-12-09 03:59:01 +08:00
; RUN: llc -mtriple thumbv5-unknown-linux-gnueabi \
2019-01-14 18:55:55 +08:00
; RUN: -frame-pointer=all -filetype=asm -o - %s \
2014-02-15 01:19:07 +08:00
; RUN: | FileCheck %s --check-prefix=CHECK-THUMB-FP
2015-12-09 03:59:01 +08:00
; RUN: llc -mtriple thumbv5-unknown-linux-gnueabi \
2014-02-15 01:19:07 +08:00
; RUN: -filetype=asm -o - %s \
; RUN: | FileCheck %s --check-prefix=CHECK-THUMB-FP-ELIM
; RUN: llc -mtriple thumbv7-unknown-linux-gnueabi \
2019-01-14 18:55:55 +08:00
; RUN: -frame-pointer=all -filetype=asm -o - %s \
2014-02-15 01:19:07 +08:00
; RUN: | FileCheck %s --check-prefix=CHECK-THUMB-V7-FP
; RUN: llc -mtriple thumbv7-unknown-linux-gnueabi \
; RUN: -filetype=asm -o - %s \
; RUN: | FileCheck %s --check-prefix=CHECK-THUMB-V7-FP-ELIM
2014-03-13 23:56:41 +08:00
; RUN: llc -mtriple thumbv7-unknown-linux-gnueabi \
2019-01-14 18:55:55 +08:00
; RUN: -frame-pointer=all -no-integrated-as -filetype=asm -o - %s \
2014-03-13 23:56:41 +08:00
; RUN: | FileCheck %s --check-prefix=CHECK-THUMB-V7-FP-NOIAS
2014-02-15 01:19:07 +08:00
;-------------------------------------------------------------------------------
; Test 1
;-------------------------------------------------------------------------------
; This is the LLVM assembly generated from following C++ code:
;
; extern void print(int, int, int, int, int);
; extern void print(double, double, double, double, double);
;
; void test(int a, int b, int c, int d, int e,
; double m, double n, double p, double q, double r) {
; try {
; print(a, b, c, d, e);
; } catch (...) {
; print(m, n, p, q, r);
; }
; }
declare void @_Z5printiiiii ( i32 , i32 , i32 , i32 , i32 )
declare void @_Z5printddddd ( double , double , double , double , double )
define void @_Z4testiiiiiddddd ( i32 %a , i32 %b , i32 %c , i32 %d , i32 %e ,
double %m , double %n , double %p ,
2015-06-18 04:52:32 +08:00
double %q , double %r ) personality i8 * bitcast ( i32 ( . . . ) * @__gxx_personality_v0 to i8 * ) {
2014-02-15 01:19:07 +08:00
entry:
invoke void @_Z5printiiiii ( i32 %a , i32 %b , i32 %c , i32 %d , i32 %e )
to label %try.cont unwind label %lpad
lpad:
%0 = landingpad { i8 * , i32 }
catch i8 * null
%1 = extractvalue { i8 * , i32 } %0 , 0
%2 = tail call i8 * @__cxa_begin_catch ( i8 * %1 )
invoke void @_Z5printddddd ( double %m , double %n , double %p ,
double %q , double %r )
to label %invoke.cont2 unwind label %lpad1
invoke.cont2:
tail call void @__cxa_end_catch ( )
br label %try.cont
try.cont:
ret void
lpad1:
%3 = landingpad { i8 * , i32 }
cleanup
invoke void @__cxa_end_catch ( )
to label %eh.resume unwind label %terminate.lpad
eh.resume:
resume { i8 * , i32 } %3
terminate.lpad:
%4 = landingpad { i8 * , i32 }
catch i8 * null
%5 = extractvalue { i8 * , i32 } %4 , 0
tail call void @__clang_call_terminate ( i8 * %5 )
unreachable
}
declare void @__clang_call_terminate ( i8 * )
declare i32 @__gxx_personality_v0 ( . . . )
declare i8 * @__cxa_begin_catch ( i8 * )
declare void @__cxa_end_catch ( )
declare void @_ZSt9terminatev ( )
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !10 , !11 }
!llvm.ident = ! { !12 }
2016-04-15 23:57:41 +08:00
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , producer: "clang version 3.5 " , isOptimized: false , emissionKind: F u l l D e b u g , file: !1 , enums: !2 , retainedTypes: !2 , globals: !2 , imports: !2 )
2015-04-30 00:38:44 +08:00
!1 = !DIFile ( filename: "exp.cpp" , directory: "/tmp" )
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 = ! { }
[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
!4 = distinct !DISubprogram ( name: "test" , linkageName: "_Z4testiiiiiddddd" , line: 4 , isLocal: false , isDefinition: true , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , scopeLine: 5 , file: !1 , scope: !5 , type: !6 , retainedNodes: !2 )
2015-04-30 00:38:44 +08:00
!5 = !DIFile ( filename: "exp.cpp" , directory: "/tmp" )
!6 = !DISubroutineType ( types: !7 )
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
!7 = ! { null , !8 , !8 , !8 , !8 , !8 , !9 , !9 , !9 , !9 , !9 }
2015-04-30 00:38:44 +08:00
!8 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
!9 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "double" , size: 64 , align: 64 , encoding: D W _ A T E _ float )
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
!10 = ! { i32 2 , !"Dwarf Version" , i32 4 }
2015-03-04 01:24:31 +08:00
!11 = ! { i32 1 , !"Debug Info Version" , i32 3 }
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
!12 = ! { !"clang version 3.5 " }
2015-08-01 02:58:39 +08:00
!13 = !DILocalVariable ( name: "a" , line: 4 , arg: 1 , scope: !4 , file: !5 , type: !8 )
2015-04-30 00:38:44 +08:00
!14 = !DILocation ( line: 4 , scope: !4 )
2015-08-01 02:58:39 +08:00
!15 = !DILocalVariable ( name: "b" , line: 4 , arg: 2 , scope: !4 , file: !5 , type: !8 )
!16 = !DILocalVariable ( name: "c" , line: 4 , arg: 3 , scope: !4 , file: !5 , type: !8 )
!17 = !DILocalVariable ( name: "d" , line: 4 , arg: 4 , scope: !4 , file: !5 , type: !8 )
!18 = !DILocalVariable ( name: "e" , line: 4 , arg: 5 , scope: !4 , file: !5 , type: !8 )
!19 = !DILocalVariable ( name: "m" , line: 5 , arg: 6 , scope: !4 , file: !5 , type: !9 )
2015-04-30 00:38:44 +08:00
!20 = !DILocation ( line: 5 , scope: !4 )
2015-08-01 02:58:39 +08:00
!21 = !DILocalVariable ( name: "n" , line: 5 , arg: 7 , scope: !4 , file: !5 , type: !9 )
!22 = !DILocalVariable ( name: "p" , line: 5 , arg: 8 , scope: !4 , file: !5 , type: !9 )
!23 = !DILocalVariable ( name: "q" , line: 5 , arg: 9 , scope: !4 , file: !5 , type: !9 )
!24 = !DILocalVariable ( name: "r" , line: 5 , arg: 10 , scope: !4 , file: !5 , type: !9 )
2015-04-30 00:38:44 +08:00
!25 = !DILocation ( line: 7 , scope: !26 )
!26 = distinct !DILexicalBlock ( line: 6 , column: 0 , file: !1 , scope: !4 )
!27 = !DILocation ( line: 8 , scope: !26 )
!28 = !DILocation ( line: 11 , scope: !26 )
!29 = !DILocation ( line: 9 , scope: !30 )
!30 = distinct !DILexicalBlock ( line: 8 , column: 0 , file: !1 , scope: !4 )
!31 = !DILocation ( line: 10 , scope: !30 )
!32 = !DILocation ( line: 10 , scope: !4 )
!33 = !DILocation ( line: 11 , scope: !4 )
!34 = !DILocation ( line: 11 , scope: !30 )
2014-02-15 01:19:07 +08:00
; CHECK-FP-LABEL: _Z4testiiiiiddddd:
; CHECK-FP: .cfi_startproc
; CHECK-FP: push {r4, r5, r6, r7, r8, r9, r10, r11, lr}
; CHECK-FP: .cfi_def_cfa_offset 36
2014-03-13 23:56:41 +08:00
; CHECK-FP: .cfi_offset lr, -4
; CHECK-FP: .cfi_offset r11, -8
; CHECK-FP: .cfi_offset r10, -12
; CHECK-FP: .cfi_offset r9, -16
; CHECK-FP: .cfi_offset r8, -20
; CHECK-FP: .cfi_offset r7, -24
; CHECK-FP: .cfi_offset r6, -28
; CHECK-FP: .cfi_offset r5, -32
; CHECK-FP: .cfi_offset r4, -36
2014-02-15 01:19:07 +08:00
; CHECK-FP: add r11, sp, #28
2014-03-13 23:56:41 +08:00
; CHECK-FP: .cfi_def_cfa r11, 8
2015-05-09 07:52:00 +08:00
; CHECK-FP: sub sp, sp, #44
2014-02-15 01:19:07 +08:00
; CHECK-FP: .cfi_endproc
; CHECK-FP-ELIM-LABEL: _Z4testiiiiiddddd:
; CHECK-FP-ELIM: .cfi_startproc
; CHECK-FP-ELIM: push {r4, r5, r6, r7, r8, r9, r10, r11, lr}
; CHECK-FP-ELIM: .cfi_def_cfa_offset 36
2014-03-13 23:56:41 +08:00
; CHECK-FP-ELIM: .cfi_offset lr, -4
; CHECK-FP-ELIM: .cfi_offset r11, -8
; CHECK-FP-ELIM: .cfi_offset r10, -12
; CHECK-FP-ELIM: .cfi_offset r9, -16
; CHECK-FP-ELIM: .cfi_offset r8, -20
; CHECK-FP-ELIM: .cfi_offset r7, -24
; CHECK-FP-ELIM: .cfi_offset r6, -28
; CHECK-FP-ELIM: .cfi_offset r5, -32
; CHECK-FP-ELIM: .cfi_offset r4, -36
2015-05-09 07:52:00 +08:00
; CHECK-FP-ELIM: sub sp, sp, #36
; CHECK-FP-ELIM: .cfi_def_cfa_offset 72
2014-02-15 01:19:07 +08:00
; CHECK-FP-ELIM: .cfi_endproc
; CHECK-V7-FP-LABEL: _Z4testiiiiiddddd:
; CHECK-V7-FP: .cfi_startproc
2014-05-07 04:43:01 +08:00
; CHECK-V7-FP: push {r4, r10, r11, lr}
; CHECK-V7-FP: .cfi_def_cfa_offset 16
2014-03-13 23:56:41 +08:00
; CHECK-V7-FP: .cfi_offset lr, -4
; CHECK-V7-FP: .cfi_offset r11, -8
2014-05-07 04:43:01 +08:00
; CHECK-V7-FP: .cfi_offset r10, -12
; CHECK-V7-FP: .cfi_offset r4, -16
; CHECK-V7-FP: add r11, sp, #8
2014-03-13 23:56:41 +08:00
; CHECK-V7-FP: .cfi_def_cfa r11, 8
2014-02-15 01:19:07 +08:00
; CHECK-V7-FP: vpush {d8, d9, d10, d11, d12}
2014-03-13 23:56:41 +08:00
; CHECK-V7-FP: .cfi_offset d12, -24
; CHECK-V7-FP: .cfi_offset d11, -32
; CHECK-V7-FP: .cfi_offset d10, -40
; CHECK-V7-FP: .cfi_offset d9, -48
; CHECK-V7-FP: .cfi_offset d8, -56
2014-05-07 04:43:01 +08:00
; CHECK-V7-FP: sub sp, sp, #24
2014-02-15 01:19:07 +08:00
; CHECK-V7-FP: .cfi_endproc
; CHECK-V7-FP-ELIM-LABEL: _Z4testiiiiiddddd:
; CHECK-V7-FP-ELIM: .cfi_startproc
; CHECK-V7-FP-ELIM: push {r4, lr}
; CHECK-V7-FP-ELIM: .cfi_def_cfa_offset 8
2014-03-13 23:56:41 +08:00
; CHECK-V7-FP-ELIM: .cfi_offset lr, -4
; CHECK-V7-FP-ELIM: .cfi_offset r4, -8
2014-02-15 01:19:07 +08:00
; CHECK-V7-FP-ELIM: vpush {d8, d9, d10, d11, d12}
; CHECK-V7-FP-ELIM: .cfi_def_cfa_offset 48
2014-03-13 23:56:41 +08:00
; CHECK-V7-FP-ELIM: .cfi_offset d12, -16
; CHECK-V7-FP-ELIM: .cfi_offset d11, -24
; CHECK-V7-FP-ELIM: .cfi_offset d10, -32
; CHECK-V7-FP-ELIM: .cfi_offset d9, -40
; CHECK-V7-FP-ELIM: .cfi_offset d8, -48
2014-02-15 01:19:07 +08:00
; CHECK-V7-FP-ELIM: sub sp, sp, #24
; CHECK-V7-FP-ELIM: .cfi_def_cfa_offset 72
; CHECK-V7-FP-ELIM: .cfi_endproc
; CHECK-THUMB-FP-LABEL: _Z4testiiiiiddddd:
; CHECK-THUMB-FP: .cfi_startproc
; CHECK-THUMB-FP: push {r4, r5, r6, r7, lr}
; CHECK-THUMB-FP: .cfi_def_cfa_offset 20
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-FP: .cfi_offset lr, -4
; CHECK-THUMB-FP: .cfi_offset r7, -8
; CHECK-THUMB-FP: .cfi_offset r6, -12
; CHECK-THUMB-FP: .cfi_offset r5, -16
; CHECK-THUMB-FP: .cfi_offset r4, -20
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-FP: add r7, sp, #12
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-FP: .cfi_def_cfa r7, 8
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-FP: sub sp, #60
; CHECK-THUMB-FP: .cfi_endproc
; CHECK-THUMB-FP-ELIM-LABEL: _Z4testiiiiiddddd:
; CHECK-THUMB-FP-ELIM: .cfi_startproc
; CHECK-THUMB-FP-ELIM: push {r4, r5, r6, r7, lr}
; CHECK-THUMB-FP-ELIM: .cfi_def_cfa_offset 20
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-FP-ELIM: .cfi_offset lr, -4
; CHECK-THUMB-FP-ELIM: .cfi_offset r7, -8
; CHECK-THUMB-FP-ELIM: .cfi_offset r6, -12
; CHECK-THUMB-FP-ELIM: .cfi_offset r5, -16
; CHECK-THUMB-FP-ELIM: .cfi_offset r4, -20
[ARM] Eliminate redundant "mov rN, sp" instructions in Thumb1.
This takes sequences like "mov r4, sp; str r0, [r4]", and optimizes them
to something like "str r0, [sp]".
For regular stack variables, this optimization was already implemented:
we lower loads and stores using frame indexes, which are expanded later.
However, when constructing a call frame for a call with more than four
arguments, the existing optimization doesn't apply. We need to use
stores which are actually relative to the current value of sp, and don't
have an associated frame index.
This patch adds a special case to handle that construct. At the DAG
level, this is an ISD::STORE where the address is a CopyFromReg from SP
(plus a small constant offset).
This applies only to Thumb1: in Thumb2 or ARM mode, a regular store
instruction can access SP directly, so the COPY gets eliminated by
existing code.
The change to ARMDAGToDAGISel::SelectThumbAddrModeSP is a related
cleanup: we shouldn't pretend that it can select anything other than
frame indexes.
Differential Revision: https://reviews.llvm.org/D59568
llvm-svn: 356601
2019-03-21 03:40:45 +08:00
; CHECK-THUMB-FP-ELIM: sub sp, #52
; CHECK-THUMB-FP-ELIM: .cfi_def_cfa_offset 72
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-FP-ELIM: .cfi_endproc
; CHECK-THUMB-V7-FP-LABEL: _Z4testiiiiiddddd:
; CHECK-THUMB-V7-FP: .cfi_startproc
2015-04-24 04:31:26 +08:00
; CHECK-THUMB-V7-FP: push {r4, r6, r7, lr}
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-V7-FP: .cfi_def_cfa_offset 16
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP: .cfi_offset lr, -4
2015-04-24 04:31:26 +08:00
; CHECK-THUMB-V7-FP: .cfi_offset r7, -8
; CHECK-THUMB-V7-FP: .cfi_offset r6, -12
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP: .cfi_offset r4, -16
2015-04-24 04:31:26 +08:00
; CHECK-THUMB-V7-FP: add r7, sp, #8
; CHECK-THUMB-V7-FP: .cfi_def_cfa r7, 8
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-V7-FP: vpush {d8, d9, d10, d11, d12}
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP: .cfi_offset d12, -24
; CHECK-THUMB-V7-FP: .cfi_offset d11, -32
; CHECK-THUMB-V7-FP: .cfi_offset d10, -40
; CHECK-THUMB-V7-FP: .cfi_offset d9, -48
; CHECK-THUMB-V7-FP: .cfi_offset d8, -56
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-V7-FP: sub sp, #24
; CHECK-THUMB-V7-FP: .cfi_endproc
; CHECK-THUMB-V7-FP-ELIM-LABEL: _Z4testiiiiiddddd:
; CHECK-THUMB-V7-FP-ELIM: .cfi_startproc
; CHECK-THUMB-V7-FP-ELIM: push {r4, lr}
; CHECK-THUMB-V7-FP-ELIM: .cfi_def_cfa_offset 8
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP-ELIM: .cfi_offset lr, -4
; CHECK-THUMB-V7-FP-ELIM: .cfi_offset r4, -8
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-V7-FP-ELIM: vpush {d8, d9, d10, d11, d12}
; CHECK-THUMB-V7-FP-ELIM: .cfi_def_cfa_offset 48
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP-ELIM: .cfi_offset d12, -16
; CHECK-THUMB-V7-FP-ELIM: .cfi_offset d11, -24
; CHECK-THUMB-V7-FP-ELIM: .cfi_offset d10, -32
; CHECK-THUMB-V7-FP-ELIM: .cfi_offset d9, -40
; CHECK-THUMB-V7-FP-ELIM: .cfi_offset d8, -48
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-V7-FP-ELIM: sub sp, #24
; CHECK-THUMB-V7-FP-ELIM: .cfi_def_cfa_offset 72
; CHECK-THUMB-V7-FP-ELIM: .cfi_endproc
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP-NOIAS-LABEL: _Z4testiiiiiddddd:
; CHECK-THUMB-V7-FP-NOIAS: .cfi_startproc
2015-04-24 04:31:26 +08:00
; CHECK-THUMB-V7-FP-NOIAS: push {r4, r6, r7, lr}
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP-NOIAS: .cfi_def_cfa_offset 16
; CHECK-THUMB-V7-FP-NOIAS: .cfi_offset 14, -4
2015-04-24 04:31:26 +08:00
; CHECK-THUMB-V7-FP-NOIAS: .cfi_offset 7, -8
; CHECK-THUMB-V7-FP-NOIAS: .cfi_offset 6, -12
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP-NOIAS: .cfi_offset 4, -16
2015-04-24 04:31:26 +08:00
; CHECK-THUMB-V7-FP-NOIAS: add r7, sp, #8
; CHECK-THUMB-V7-FP-NOIAS: .cfi_def_cfa 7, 8
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP-NOIAS: vpush {d8, d9, d10, d11, d12}
; CHECK-THUMB-V7-FP-NOIAS: .cfi_offset 268, -24
; CHECK-THUMB-V7-FP-NOIAS: .cfi_offset 267, -32
; CHECK-THUMB-V7-FP-NOIAS: .cfi_offset 266, -40
; CHECK-THUMB-V7-FP-NOIAS: .cfi_offset 265, -48
; CHECK-THUMB-V7-FP-NOIAS: .cfi_offset 264, -56
; CHECK-THUMB-V7-FP-NOIAS: sub sp, #24
; CHECK-THUMB-V7-FP-NOIAS: .cfi_endproc
2014-02-15 01:19:07 +08:00
;-------------------------------------------------------------------------------
; Test 2
;-------------------------------------------------------------------------------
declare void @throw_exception_2 ( )
define void @test2 ( ) {
entry:
2014-03-11 23:09:44 +08:00
call void @throw_exception_2 ( )
2014-02-15 01:19:07 +08:00
ret void
}
; CHECK-FP-LABEL: test2:
; CHECK-FP: .cfi_startproc
; CHECK-FP: push {r11, lr}
; CHECK-FP: .cfi_def_cfa_offset 8
2014-03-13 23:56:41 +08:00
; CHECK-FP: .cfi_offset lr, -4
; CHECK-FP: .cfi_offset r11, -8
2014-02-15 01:19:07 +08:00
; CHECK-FP: mov r11, sp
2014-03-13 23:56:41 +08:00
; CHECK-FP: .cfi_def_cfa_register r11
2014-02-15 01:19:07 +08:00
; CHECK-FP: pop {r11, lr}
; CHECK-FP: mov pc, lr
; CHECK-FP: .cfi_endproc
; CHECK-FP-ELIM-LABEL: test2:
; CHECK-FP-ELIM: .cfi_startproc
; CHECK-FP-ELIM: push {r11, lr}
; CHECK-FP-ELIM: .cfi_def_cfa_offset 8
2014-03-13 23:56:41 +08:00
; CHECK-FP-ELIM: .cfi_offset lr, -4
; CHECK-FP-ELIM: .cfi_offset r11, -8
2014-02-15 01:19:07 +08:00
; CHECK-FP-ELIM: pop {r11, lr}
; CHECK-FP-ELIM: mov pc, lr
; CHECK-FP-ELIM: .cfi_endproc
; CHECK-V7-FP-LABEL: test2:
; CHECK-V7-FP: .cfi_startproc
; CHECK-V7-FP: push {r11, lr}
; CHECK-V7-FP: .cfi_def_cfa_offset 8
2014-03-13 23:56:41 +08:00
; CHECK-V7-FP: .cfi_offset lr, -4
; CHECK-V7-FP: .cfi_offset r11, -8
2014-02-15 01:19:07 +08:00
; CHECK-V7-FP: mov r11, sp
2014-03-13 23:56:41 +08:00
; CHECK-V7-FP: .cfi_def_cfa_register r11
2014-02-15 01:19:07 +08:00
; CHECK-V7-FP: pop {r11, pc}
; CHECK-V7-FP: .cfi_endproc
; CHECK-V7-FP-ELIM-LABEL: test2:
; CHECK-V7-FP-ELIM: .cfi_startproc
; CHECK-V7-FP-ELIM: push {r11, lr}
; CHECK-V7-FP-ELIM: .cfi_def_cfa_offset 8
2014-03-13 23:56:41 +08:00
; CHECK-V7-FP-ELIM: .cfi_offset lr, -4
; CHECK-V7-FP-ELIM: .cfi_offset r11, -8
2014-02-15 01:19:07 +08:00
; CHECK-V7-FP-ELIM: pop {r11, pc}
; CHECK-V7-FP-ELIM: .cfi_endproc
; CHECK-THUMB-FP-LABEL: test2:
; CHECK-THUMB-FP: .cfi_startproc
; CHECK-THUMB-FP: push {r7, lr}
; CHECK-THUMB-FP: .cfi_def_cfa_offset 8
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-FP: .cfi_offset lr, -4
; CHECK-THUMB-FP: .cfi_offset r7, -8
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-FP: add r7, sp, #0
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-FP: .cfi_def_cfa_register r7
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-FP: pop {r7, pc}
; CHECK-THUMB-FP: .cfi_endproc
; CHECK-THUMB-FP-ELIM-LABEL: test2:
; CHECK-THUMB-FP-ELIM: .cfi_startproc
; CHECK-THUMB-FP-ELIM: push {r7, lr}
; CHECK-THUMB-FP-ELIM: .cfi_def_cfa_offset 8
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-FP-ELIM: .cfi_offset lr, -4
; CHECK-THUMB-FP-ELIM: .cfi_offset r7, -8
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-FP-ELIM: pop {r7, pc}
; CHECK-THUMB-FP-ELIM: .cfi_endproc
; CHECK-THUMB-V7-FP-LABEL: test2:
; CHECK-THUMB-V7-FP: .cfi_startproc
; CHECK-THUMB-V7-FP: push {r7, lr}
; CHECK-THUMB-V7-FP: .cfi_def_cfa_offset 8
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP: .cfi_offset lr, -4
; CHECK-THUMB-V7-FP: .cfi_offset r7, -8
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-V7-FP: mov r7, sp
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP: .cfi_def_cfa_register r7
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-V7-FP: pop {r7, pc}
; CHECK-THUMB-V7-FP: .cfi_endproc
; CHECK-THUMB-V7-FP-ELIM-LABEL: test2:
; CHECK-THUMB-V7-FP-ELIM: .cfi_startproc
2015-04-24 04:31:26 +08:00
; CHECK-THUMB-V7-FP-ELIM: push {r7, lr}
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-V7-FP-ELIM: .cfi_def_cfa_offset 8
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP-ELIM: .cfi_offset lr, -4
2015-04-24 04:31:26 +08:00
; CHECK-THUMB-V7-FP-ELIM: .cfi_offset r7, -8
; CHECK-THUMB-V7-FP-ELIM: pop {r7, pc}
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-V7-FP-ELIM: .cfi_endproc
;-------------------------------------------------------------------------------
; Test 3
;-------------------------------------------------------------------------------
declare void @throw_exception_3 ( i32 )
define i32 @test3 ( i32 %a , i32 %b , i32 %c , i32 %d ,
i32 %e , i32 %f , i32 %g , i32 %h ) {
entry:
%add = add nsw i32 %b , %a
%add1 = add nsw i32 %add , %c
%add2 = add nsw i32 %add1 , %d
tail call void @throw_exception_3 ( i32 %add2 )
%add3 = add nsw i32 %f , %e
%add4 = add nsw i32 %add3 , %g
%add5 = add nsw i32 %add4 , %h
tail call void @throw_exception_3 ( i32 %add5 )
%add6 = add nsw i32 %add5 , %add2
ret i32 %add6
}
; CHECK-FP-LABEL: test3:
; CHECK-FP: .cfi_startproc
; CHECK-FP: push {r4, r5, r11, lr}
; CHECK-FP: .cfi_def_cfa_offset 16
2014-03-13 23:56:41 +08:00
; CHECK-FP: .cfi_offset lr, -4
; CHECK-FP: .cfi_offset r11, -8
; CHECK-FP: .cfi_offset r5, -12
; CHECK-FP: .cfi_offset r4, -16
2014-02-15 01:19:07 +08:00
; CHECK-FP: add r11, sp, #8
2014-03-13 23:56:41 +08:00
; CHECK-FP: .cfi_def_cfa r11, 8
2014-02-15 01:19:07 +08:00
; CHECK-FP: pop {r4, r5, r11, lr}
; CHECK-FP: mov pc, lr
; CHECK-FP: .cfi_endproc
; CHECK-FP-ELIM-LABEL: test3:
; CHECK-FP-ELIM: .cfi_startproc
; CHECK-FP-ELIM: push {r4, r5, r11, lr}
; CHECK-FP-ELIM: .cfi_def_cfa_offset 16
2014-03-13 23:56:41 +08:00
; CHECK-FP-ELIM: .cfi_offset lr, -4
; CHECK-FP-ELIM: .cfi_offset r11, -8
; CHECK-FP-ELIM: .cfi_offset r5, -12
; CHECK-FP-ELIM: .cfi_offset r4, -16
2014-02-15 01:19:07 +08:00
; CHECK-FP-ELIM: pop {r4, r5, r11, lr}
; CHECK-FP-ELIM: mov pc, lr
; CHECK-FP-ELIM: .cfi_endproc
; CHECK-V7-FP-LABEL: test3:
; CHECK-V7-FP: .cfi_startproc
; CHECK-V7-FP: push {r4, r5, r11, lr}
; CHECK-V7-FP: .cfi_def_cfa_offset 16
2014-03-13 23:56:41 +08:00
; CHECK-V7-FP: .cfi_offset lr, -4
; CHECK-V7-FP: .cfi_offset r11, -8
; CHECK-V7-FP: .cfi_offset r5, -12
; CHECK-V7-FP: .cfi_offset r4, -16
2014-02-15 01:19:07 +08:00
; CHECK-V7-FP: add r11, sp, #8
2014-03-13 23:56:41 +08:00
; CHECK-V7-FP: .cfi_def_cfa r11, 8
2014-02-15 01:19:07 +08:00
; CHECK-V7-FP: pop {r4, r5, r11, pc}
; CHECK-V7-FP: .cfi_endproc
; CHECK-V7-FP-ELIM-LABEL: test3:
; CHECK-V7-FP-ELIM: .cfi_startproc
; CHECK-V7-FP-ELIM: push {r4, r5, r11, lr}
; CHECK-V7-FP-ELIM: .cfi_def_cfa_offset 16
2014-03-13 23:56:41 +08:00
; CHECK-V7-FP-ELIM: .cfi_offset lr, -4
; CHECK-V7-FP-ELIM: .cfi_offset r11, -8
; CHECK-V7-FP-ELIM: .cfi_offset r5, -12
; CHECK-V7-FP-ELIM: .cfi_offset r4, -16
2014-02-15 01:19:07 +08:00
; CHECK-V7-FP-ELIM: pop {r4, r5, r11, pc}
; CHECK-V7-FP-ELIM: .cfi_endproc
; CHECK-THUMB-FP-LABEL: test3:
; CHECK-THUMB-FP: .cfi_startproc
; CHECK-THUMB-FP: push {r4, r5, r7, lr}
; CHECK-THUMB-FP: .cfi_def_cfa_offset 16
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-FP: .cfi_offset lr, -4
; CHECK-THUMB-FP: .cfi_offset r7, -8
; CHECK-THUMB-FP: .cfi_offset r5, -12
; CHECK-THUMB-FP: .cfi_offset r4, -16
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-FP: add r7, sp, #8
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-FP: .cfi_def_cfa r7, 8
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-FP: pop {r4, r5, r7, pc}
; CHECK-THUMB-FP: .cfi_endproc
; CHECK-THUMB-FP-ELIM-LABEL: test3:
; CHECK-THUMB-FP-ELIM: .cfi_startproc
; CHECK-THUMB-FP-ELIM: push {r4, r5, r7, lr}
; CHECK-THUMB-FP-ELIM: .cfi_def_cfa_offset 16
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-FP-ELIM: .cfi_offset lr, -4
; CHECK-THUMB-FP-ELIM: .cfi_offset r7, -8
; CHECK-THUMB-FP-ELIM: .cfi_offset r5, -12
; CHECK-THUMB-FP-ELIM: .cfi_offset r4, -16
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-FP-ELIM: pop {r4, r5, r7, pc}
; CHECK-THUMB-FP-ELIM: .cfi_endproc
; CHECK-THUMB-V7-FP-LABEL: test3:
; CHECK-THUMB-V7-FP: .cfi_startproc
; CHECK-THUMB-V7-FP: push {r4, r5, r7, lr}
; CHECK-THUMB-V7-FP: .cfi_def_cfa_offset 16
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP: .cfi_offset lr, -4
; CHECK-THUMB-V7-FP: .cfi_offset r7, -8
; CHECK-THUMB-V7-FP: .cfi_offset r5, -12
; CHECK-THUMB-V7-FP: .cfi_offset r4, -16
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-V7-FP: add r7, sp, #8
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP: .cfi_def_cfa r7, 8
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-V7-FP: pop {r4, r5, r7, pc}
; CHECK-THUMB-V7-FP: .cfi_endproc
; CHECK-THUMB-V7-FP-ELIM-LABEL: test3:
; CHECK-THUMB-V7-FP-ELIM: .cfi_startproc
2015-04-24 04:31:26 +08:00
; CHECK-THUMB-V7-FP-ELIM: push {r4, r5, r7, lr}
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-V7-FP-ELIM: .cfi_def_cfa_offset 16
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP-ELIM: .cfi_offset lr, -4
2015-04-24 04:31:26 +08:00
; CHECK-THUMB-V7-FP-ELIM: .cfi_offset r7, -8
2014-03-13 23:56:41 +08:00
; CHECK-THUMB-V7-FP-ELIM: .cfi_offset r5, -12
; CHECK-THUMB-V7-FP-ELIM: .cfi_offset r4, -16
2015-04-24 04:31:26 +08:00
; CHECK-THUMB-V7-FP-ELIM: pop {r4, r5, r7, pc}
2014-02-15 01:19:07 +08:00
; CHECK-THUMB-V7-FP-ELIM: .cfi_endproc
;-------------------------------------------------------------------------------
; Test 4
;-------------------------------------------------------------------------------
define void @test4 ( ) nounwind {
entry:
ret void
}
; CHECK-FP-LABEL: test4:
; CHECK-FP: mov pc, lr
; CHECK-FP-NOT: .cfi_def_cfa_offset
; CHECK-FP-ELIM-LABEL: test4:
; CHECK-FP-ELIM: mov pc, lr
; CHECK-FP-ELIM-NOT: .cfi_def_cfa_offset
; CHECK-V7-FP-LABEL: test4:
; CHECK-V7-FP: bx lr
; CHECK-V7-FP-NOT: .cfi_def_cfa_offset
; CHECK-V7-FP-ELIM-LABEL: test4:
; CHECK-V7-FP-ELIM: bx lr
; CHECK-V7-FP-ELIM-NOT: .cfi_def_cfa_offset
; CHECK-THUMB-FP-LABEL: test4:
; CHECK-THUMB-FP: bx lr
; CHECK-THUMB-FP-NOT: .cfi_def_cfa_offset
; CHECK-THUMB-FP-ELIM-LABEL: test4:
; CHECK-THUMB-FP-ELIM: bx lr
; CHECK-THUMB-FP-ELIM-NOT: .cfi_def_cfa_offset
; CHECK-THUMB-V7-FP-LABEL: test4:
; CHECK-THUMB-V7-FP: bx lr
; CHECK-THUMB-V7-FP-NOT: .cfi_def_cfa_offset
; CHECK-THUMB-V7-FP-ELIM-LABEL: test4:
; CHECK-THUMB-V7-FP-ELIM: bx lr
; CHECK-THUMB-V7-FP-ELIM-NOT: .cfi_def_cfa_offset