Bug 67648 - No need to save callee-saved registers in interrupt handler
Summary: No need to save callee-saved registers in interrupt handler
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: 6.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 67552
  Show dependency treegraph
 
Reported: 2015-09-20 14:10 UTC by H.J. Lu
Modified: 2016-01-04 00:52 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2015-09-20 14:10:13 UTC
[hjl@gnu-6 interrupt-1]$ cat call-1.i
extern void bar (void);

void
 __attribute__ ((interrupt))
foo (void)
{
  bar ();
}
[hjl@gnu-6 interrupt-1]$ make call-1.s
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -S -o call-1.s call-1.i
[hjl@gnu-6 interrupt-1]$ cat call-1.s
	.file	"call-1.i"
	.section	.text.unlikely,"ax",@progbits
.LCOLDB0:
	.text
.LHOTB0:
	.p2align 4,,15
	.globl	foo
	.type	foo, @function
foo:
.LFB0:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%r11
	.cfi_def_cfa_offset 48
	.cfi_offset 11, -48
	pushq	%r10
	.cfi_def_cfa_offset 56
	.cfi_offset 10, -56
	pushq	%r9
	.cfi_def_cfa_offset 64
	.cfi_offset 9, -64
	pushq	%r8
	.cfi_def_cfa_offset 72
	.cfi_offset 8, -72
	pushq	%rbp
	.cfi_def_cfa_offset 80
	.cfi_offset 6, -80
	pushq	%rdi
	.cfi_def_cfa_offset 88
	.cfi_offset 5, -88
	pushq	%rsi
	.cfi_def_cfa_offset 96
	.cfi_offset 4, -96
	pushq	%rbx
	.cfi_def_cfa_offset 104
	.cfi_offset 3, -104
	pushq	%rcx
	.cfi_def_cfa_offset 112
	.cfi_offset 2, -112
	pushq	%rdx
	.cfi_def_cfa_offset 120
	.cfi_offset 1, -120
	pushq	%rax
	.cfi_def_cfa_offset 128
	.cfi_offset 0, -128
	subq	$256, %rsp
	.cfi_def_cfa_offset 384
	movups	%xmm0, (%rsp)
	movups	%xmm1, 16(%rsp)
	movups	%xmm2, 32(%rsp)
	movups	%xmm3, 48(%rsp)
	movups	%xmm4, 64(%rsp)
	movups	%xmm5, 80(%rsp)
	movups	%xmm6, 96(%rsp)
	movups	%xmm7, 112(%rsp)
	movups	%xmm8, 128(%rsp)
	movups	%xmm9, 144(%rsp)
	movups	%xmm10, 160(%rsp)
	movups	%xmm11, 176(%rsp)
	movups	%xmm12, 192(%rsp)
	movups	%xmm13, 208(%rsp)
	movups	%xmm14, 224(%rsp)
	movups	%xmm15, 240(%rsp)
	.cfi_offset 17, -384
	.cfi_offset 18, -368
	.cfi_offset 19, -352
	.cfi_offset 20, -336
	.cfi_offset 21, -320
	.cfi_offset 22, -304
	.cfi_offset 23, -288
	.cfi_offset 24, -272
	.cfi_offset 25, -256
	.cfi_offset 26, -240
	.cfi_offset 27, -224
	.cfi_offset 28, -208
	.cfi_offset 29, -192
	.cfi_offset 30, -176
	.cfi_offset 31, -160
	.cfi_offset 32, -144
	call	bar
	movups	(%rsp), %xmm0
	movups	16(%rsp), %xmm1
	movups	32(%rsp), %xmm2
	movups	48(%rsp), %xmm3
	movups	64(%rsp), %xmm4
	movups	80(%rsp), %xmm5
	movups	96(%rsp), %xmm6
	movups	112(%rsp), %xmm7
	movups	128(%rsp), %xmm8
	movups	144(%rsp), %xmm9
	movups	160(%rsp), %xmm10
	movups	176(%rsp), %xmm11
	movups	192(%rsp), %xmm12
	movups	208(%rsp), %xmm13
	movups	224(%rsp), %xmm14
	movups	240(%rsp), %xmm15
	addq	$256, %rsp
	.cfi_restore 32
	.cfi_restore 31
	.cfi_restore 30
	.cfi_restore 29
	.cfi_restore 28
	.cfi_restore 27
	.cfi_restore 26
	.cfi_restore 25
	.cfi_restore 24
	.cfi_restore 23
	.cfi_restore 22
	.cfi_restore 21
	.cfi_restore 20
	.cfi_restore 19
	.cfi_restore 18
	.cfi_restore 17
	.cfi_def_cfa_offset 128
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
	popq	%rcx
	.cfi_def_cfa_offset 104
	popq	%rbx
	.cfi_def_cfa_offset 96
	popq	%rsi
	.cfi_def_cfa_offset 88
	popq	%rdi
	.cfi_def_cfa_offset 80
	popq	%rbp
	.cfi_def_cfa_offset 72
	popq	%r8
	.cfi_def_cfa_offset 64
	popq	%r9
	.cfi_def_cfa_offset 56
	popq	%r10
	.cfi_def_cfa_offset 48
	popq	%r11
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	iret
	.cfi_endproc
.LFE0:
	.size	foo, .-foo
	.section	.text.unlikely
.LCOLDE0:
	.text
.LHOTE0:
	.ident	"GCC: (GNU) 6.0.0 20150917 (experimental)"
	.section	.note.GNU-stack,"",@progbits
[hjl@gnu-6 interrupt-1]$ 

Since RBX and R12-R15 registers are callee-saved, we don't need
to save and restore them in interrupt handler unless they are
modified.
Comment 1 H.J. Lu 2015-09-20 14:43:55 UTC
Julia, we should avoid changing call_used_regs in ix86_conditional_register_usage.   Instead, we should
only save and restore caller-saved registers changed by
interrupt handler.
Comment 2 H.J. Lu 2015-09-20 19:50:46 UTC
We should update the "IRET" pattern to indicate which
registers should be preserved.
Comment 3 H.J. Lu 2015-09-20 22:16:31 UTC
I checked a fix into hjl/interrupt/master branch:

https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=b21f445ed3e067ac1b401798b953a1ec5b093202

Please take a look.
Comment 4 H.J. Lu 2016-01-04 00:52:58 UTC
Fixed on hjl/interrupt/stage1 branch.