This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/58192] G++ emits incorrect code when passing enum classes as function parameters
- From: "ubizjak at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 19 Sep 2014 13:06:58 +0000
- Subject: [Bug c++/58192] G++ emits incorrect code when passing enum classes as function parameters
- Auto-submitted: auto-generated
- References: <bug-58192-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58192
--- Comment #9 from UroÅ Bizjak <ubizjak at gmail dot com> ---
Looking at dumps, obtained with -m32 -O1, we have following sequence before the
call to _ZN2S1Ut_3setE3Foo:
_.dfinit:
(insn 7 3 8 2 (parallel [
(set (reg:SI 88)
(lshiftrt:SI (reg/v:SI 86 [ t ])
(const_int 16 [0x10])))
(clobber (reg:CC 17 flags))
]) 539 {*lshrsi3_1}
(nil))
(insn 8 7 9 2 (parallel [
(set (reg:QI 85 [ t$2 ])
(and:QI (subreg:QI (reg:SI 88) 0)
(const_int -1 [0xffffffffffffffff])))
(clobber (reg:CC 17 flags))
]) 379 {*andqi_1}
(nil))
...
(insn 10 9 11 2 (set (reg:QI 1 dx)
(reg:QI 85 [ t$2 ])) gcc-bug.cc:72 93 {*movqi_internal}
(nil))
...
(call_insn 12 11 13 2 (call (mem:QI (symbol_ref:SI ("_ZN2S1Ut_3setE3Foo")
[flags 0x3] <function_decl 0x2ad94c491438 set>) [0 set S1 A8])
(const_int 0 [0])) gcc-bug.cc:72 651 {*call}
(expr_list:REG_EH_REGION (const_int 0 [0])
(nil))
(expr_list:SI (use (reg:SI 0 ax))
(expr_list:QI (use (reg:QI 1 dx))
(nil))))
_.cse1 mangles argument setup to:
(insn 8 7 9 2 (set (reg:QI 85 [ t$2 ])
(subreg:QI (reg:SI 88) 0)) 93 {*movqi_internal}
(expr_list:REG_DEAD (reg:SI 88)
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil))))
...
(insn 10 9 11 2 (set (reg:QI 1 dx)
(subreg:QI (reg:SI 88) 0)) gcc-bug.cc:72 93 {*movqi_internal}
(nil))
and _.fwprop1 merges both to:
(insn 10 9 11 2 (set (reg:QI 1 dx)
(subreg:QI (reg:SI 88) 0)) gcc-bug.cc:72 93 {*movqi_internal}
(nil))
resulting in:
#(insn 10 9 34 2 (set (reg:QI 1 dx)
# (reg:QI 3 bx [88])) gcc-bug.cc:72 93 {*movqi_internal}
# (nil))
movl %ebx, %edx # 10 *movqi_internal/1 [length = 2]
However, x86 ABI mandates that arguments should be properly extended in the
call to the function. I don't think original (insn 8) is correct, as it is
effectively a NOP.