This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Optimization breaks inline asm code w/ptrs
- From: Alan Modra <amodra at gmail dot com>
- To: David Wohlferd <dw at LimeGreenSocks dot com>
- Cc: Andrew Pinski <pinskia at gmail dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Sun, 13 Aug 2017 22:25:14 +0930
- Subject: Re: Optimization breaks inline asm code w/ptrs
- Authentication-results: sourceware.org; auth=none
- References: <b3d08a25-9b08-2c31-5286-1c0c20c73f4e@LimeGreenSocks.com> <CA+=Sn1m0iaqCtnWwxS-TtV+x89XJKuWRGX9Eb830m7GBs4zDTw@mail.gmail.com> <CA+=Sn1m4vjvkBVF4XNTAu6YbVDMLUYv9n+LGU0e1VNsHCf_DSA@mail.gmail.com> <5131719f-625a-24a6-e255-617731745799@LimeGreenSocks.com>
On Sun, Aug 13, 2017 at 03:35:15AM -0700, David Wohlferd wrote:
> Using "m"(*pStr) as an (unused) input parameter has no effect.
Use "m" (*(const void *)pStr) and ignore the warning, or use
"m" (*(const struct {char a; char x[];} *) pStr).
The issue is one of letting gcc know what memory is accessed by the
asm, if you don't want to use a "memory" clobber. And there are very
good reasons to avoid clobbering all memory.
"m"(*pStr) ought to work IMO, but apparently just tells gcc you are
only interested in the first character. Of course that is exactly
what *pStr is, but in this context it would be nicer if it meant the
entire array.
--
Alan Modra
Australia Development Lab, IBM