[Bug target/84530] New: -mfunction-return=thunk does not work for simple_return_pop_internal insn
marxin at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Feb 23 15:08:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84530
Bug ID: 84530
Summary: -mfunction-return=thunk does not work for
simple_return_pop_internal insn
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: marxin at gcc dot gnu.org
CC: hjl at gcc dot gnu.org, hubicka at ucw dot cz
Target Milestone: ---
Target: i586
i386.md contains:
13100 (define_insn "simple_return_pop_internal"
13101 [(simple_return)
13102 (use (match_operand:SI 0 "const_int_operand"))]
13103 "reload_completed"
13104 "%!ret\t%0"
13105 [(set_attr "length" "3")
13106 (set_attr "atom_unit" "jeu")
13107 (set_attr "length_immediate" "2")
13108 (set_attr "modrm" "0")
13109 (set_attr "maybe_prefix_bnd" "1")])
Thus:
$ cat stdarg.c
struct s { _Complex unsigned short x; };
struct s gs = { 100 + 200i };
struct s __attribute__((noinline)) foo (void) { return gs; }
$ gcc stdarg.c -S -O2 -m32 -o/dev/stdout -mfunction-return=thunk
.file "stdarg.c"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
movl 4(%esp), %eax
movl gs, %edx
movl %edx, (%eax)
ret $4
.cfi_endproc
.LFE0:
.size foo, .-foo
.globl gs
.data
.align 4
.type gs, @object
.size gs, 4
gs:
.value 100
.value 200
.ident "GCC: (GNU) 8.0.1 20180223 (experimental)"
.section .note.GNU-stack,"",@progbits
While x86-64 works:
gcc stdarg.c -S -O2 -o/dev/stdout -mfunction-return=thunk
.file "stdarg.c"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
movzwl gs+2(%rip), %eax
sall $16, %eax
movl %eax, %edx
movzwl gs(%rip), %eax
orl %edx, %eax
jmp __x86_return_thunk
.cfi_endproc
.LFE0:
.size foo, .-foo
.globl gs
.data
.align 2
.type gs, @object
.size gs, 4
gs:
.value 100
.value 200
.section
.text.__x86_indirect_thunk,"axG",@progbits,__x86_indirect_thunk,comdat
.globl __x86_indirect_thunk
.hidden __x86_indirect_thunk
.type __x86_indirect_thunk, @function
__x86_indirect_thunk:
.set __x86_return_thunk,__x86_indirect_thunk
.globl __x86_return_thunk
.hidden __x86_return_thunk
.LFB1:
.cfi_startproc
call .LIND1
.LIND0:
pause
lfence
jmp .LIND0
.LIND1:
lea 8(%rsp), %rsp
ret
.cfi_endproc
.LFE1:
.ident "GCC: (GNU) 8.0.1 20180223 (experimental)"
.section .note.GNU-stack,"",@progbits
More information about the Gcc-bugs
mailing list