From owner-freebsd-ppc@freebsd.org Fri Mar 15 01:33:49 2019 Return-Path: Delivered-To: freebsd-ppc@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 26E701536A5C for ; Fri, 15 Mar 2019 01:33:49 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic304-25.consmr.mail.gq1.yahoo.com (sonic304-25.consmr.mail.gq1.yahoo.com [98.137.68.206]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 83807779ED for ; Fri, 15 Mar 2019 01:33:47 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: wRZX4gQVM1m7oWD3udlOD3dUMYjwmQ.VHBJ1Ay2Igtg2V4FNnDODcL6VqFRLIBF RXqIORRTt6iSpsxGLxheu57QsYMrF_RLS7RRRZhSbd5PR9PCOvxpbPY.K3Omy9.UuRkG_VMkMMVx aIiLScx4v1lIGL6V6eQIf6kVuvBn7CJhWhAX6E9sTsm1RB5xD9WS9xQT4TvwDpZB78K_I8m8GzWR ejuJyJM3wvT.c0bRHC3pvExtMQJsZOsmLCH2oT1OQIOeEg1KmlC19rNMCLQ3gOIFp53_0b_fvUTc .wQdZ9hTgAvRh8CWw0kmHQBxC6On373KqSdDSu.k5q1NIrSxRgm7aFITYh50yiCbqo_lNcL9U4bh qzdJ3OzP68SlTKBQy7Y721GQjGmyXMbztB.ij8uHvBwjNbAaBHKvr6lxin5iLzU6bbQv8iynY4jb 7oeAewcxdMGGh0EaxWeF87eN1AUKjFup8Fe_x8cOzTf9rNqc9Bg9Slb24AY31panoG591wYUWKjN XbEUPLxNGZaJgE8EZy3.orEexwzZcq05X8WzHEtxN6RMePZEQeUisaiwWwyKSctOTbSe5IJfPX6q ZGBqsX0ripuuP8LP8Qy8jbnhdWORnjgzCeSt5pYdOcZfwlkgSJGHEsF2uTArJooFWDa5CuFRoP1b LUS_4SwdlkKsEhIDJAlKsR4CoePiq0bs16l9EPqrpRmo9ncLD6PLBA8NuAy3ga7kwsNpUvR3Qa5X NDv7iWpjiyS7CgWKPh73L46uDePyGbm.7z8WZVU7rwKSWiJCWMssvsg0yUOn2NDALy6jDX2exIzQ CByzGjRUUSzzzW92vxYSeyvHqBdxxDmKNwr_TW8Wcbd30AiglM7wKKB0YJ7KJDvtaPlSxAmOw4s3 QtvncT8eNL36VKG_Z7Ayp5txJLgO8AaCT8alzeyR8BnjCBaMwx4xio9lz8vT1qD0HvcnA8poKOBh XJgJwTfINILpkcTlP0LC4StChR7DNvXDEEcVH6QYI2FCZ0_ZoPCTv2E_OBa4ogiMAVTFobf_a5rA _M3n4oRRvZUdebHoBN84kh4Fc5YjJwfGLRwSc1uE2Lt__BlXUUHVvCamP8PBZaE4_cmoQPexZDoH adlPIR8Hd Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.gq1.yahoo.com with HTTP; Fri, 15 Mar 2019 01:33:40 +0000 Received: from c-67-170-167-181.hsd1.or.comcast.net (EHLO [192.168.1.115]) ([67.170.167.181]) by smtp403.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 39434808bbff3548ebbad8c6df877feb; Fri, 15 Mar 2019 01:23:31 +0000 (UTC) From: Mark Millard Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: llvm submittal 41050 created for powerpc64 C++ exception code generation: ld r2,40(r1) missing or skipped before bl __cxa_begin_catch code Date: Thu, 14 Mar 2019 18:23:30 -0700 References: <0AD5D131-C5E3-424E-A276-D960ABDBDFCD@yahoo.com> <2429D922-3214-4D40-9616-56BC0CB93A15@yahoo.com> To: FreeBSD Toolchain , FreeBSD PowerPC ML In-Reply-To: <2429D922-3214-4D40-9616-56BC0CB93A15@yahoo.com> Message-Id: <795BBC02-6CE9-401E-8D9F-84FB9FB31364@yahoo.com> X-Mailer: Apple Mail (2.3445.102.3) X-Rspamd-Queue-Id: 83807779ED X-Spamd-Bar: - X-Spamd-Result: default: False [-1.41 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ptr:yahoo.com]; MV_CASE(0.50)[]; FREEMAIL_FROM(0.00)[yahoo.com]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[yahoo.com:+]; MX_GOOD(-0.01)[cached: mta6.am0.yahoodns.net]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[yahoo.com,reject]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[yahoo.com]; ASN(0.00)[asn:36647, ipnet:98.137.64.0/21, country:US]; MID_RHS_MATCH_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[yahoo.com.dwl.dnswl.org : 127.0.5.0]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.75)[-0.749,0]; R_DKIM_ALLOW(-0.20)[yahoo.com:s=s2048]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(0.49)[0.492,0]; NEURAL_HAM_LONG(-0.98)[-0.983,0]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(0.34)[ipnet: 98.137.64.0/21(0.98), asn: 36647(0.78), country: US(-0.07)]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[206.68.137.98.list.dnswl.org : 127.0.5.0] X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Mar 2019 01:33:49 -0000 [ELFv2 vs. ELFv1 ABI differences may lead to the fix only applying to one of them: ELFv2's ABI.] On 2019-Mar-13, at 19:14, Mark Millard wrote: > On 2019-Mar-12, at 22:08, Mark Millard wrote: >=20 >> I have submitted: >>=20 >> https://bugs.llvm.org//show_bug.cgi?id=3D41050 >>=20 >> for the clang 8 code generation problem of >> no code for setting r2 appropriately before >> the: >>=20 >> bl . . . <00000018.plt_call.__cxa_begin_catch@@CXXABI_1.3> >>=20 >> in unoptimized code ( no -O ). For the -O2 code: >>=20 >> ld r2,40(r1) >>=20 >> is present but is being skipped by the libunwind return >> to the code: it returns to the just-following bl >> instruction (like above) instead. >>=20 >> In both cases: >>=20 >> (gdb) x/32i 0x100007c0 >> 0x100007c0 <00000018.plt_call.__cxa_begin_catch@@CXXABI_1.3>: = std r2,40(r1) >> 0x100007c4 <00000018.plt_call.__cxa_begin_catch@@CXXABI_1.3+4>: = ld r12,-32608(r2) >> 0x100007c8 <00000018.plt_call.__cxa_begin_catch@@CXXABI_1.3+8>: = mtctr r12 >> 0x100007cc <00000018.plt_call.__cxa_begin_catch@@CXXABI_1.3+12>: = ld r11,-32592(r2) >> 0x100007d0 <00000018.plt_call.__cxa_begin_catch@@CXXABI_1.3+16>: = ld r2,-32600(r2) >> 0x100007d4 <00000018.plt_call.__cxa_begin_catch@@CXXABI_1.3+20>: = bctr >> 0x100007d8 <00000018.plt_call.__cxa_begin_catch@@CXXABI_1.3+24>: = .long 0x0 >> 0x100007dc <00000018.plt_call.__cxa_begin_catch@@CXXABI_1.3+28>: = .long 0x0 >> . . . >>=20 >> with an inappropriate r2 value leads to jumping to >> inappropriate places. >>=20 >> The example source code was: >>=20 >> #include >>=20 >> int main(void) >> { >> try { throw std::exception(); } >> catch (std::exception& e) {} >> return 0; >> } >>=20 >>=20 >>=20 >> Note: >>=20 >> This is from investigations of head -r345044 using >> WITH_LLVM_LIBUNWIND=3D on powerpc64. >>=20 >=20 > The discussion on https://bugs.llvm.org//show_bug.cgi?id=3D41050 > indicates that the ld r2,??? to restore the value appropriate to > the a.out code in my example should be happening via the library > holding libunwind's code instead of the ld executing in the > a.out code. >=20 > So: thus far it is viewed as a libunwind issue instead of a clang > one. Both ELFv2 and ELFv1 are currently broken because of r2 (TOC) mishanding. Looks like that when libunwind is fixed, it might not support the ELFv1 ABI (just the ELFv2 ABI): handling r2 (TOC) is different because of the differences in the stack frame header . . . ELFv1 has r2 save area at 40(r1) [because of the compiler and = link-editor doublewords] ELFV2 has r2 save area at 24(r1) [no compiler or link-editor = doublewords] A simple update to libunwind/src/UnwindRegistersRestore.S for = powerpc64's _ZN9libunwind15Registers_ppc646jumptoE is (an ELFv2 ABI example): - PPC64_LR(2) + // skip r2 for now and: PPC64_LR(4) PPC64_LR(1) PPC64_LR(3) + ld %r2, 24(%r1) bctr (That is from comment #16.) I've no clue if more would be done to handle the ELFv1 ABI as well. As I understand FreeBSD plans to support the ELFv2 ABI at some point. I'm not sure of the intent after that for the ELFv1 ABI. =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)