This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Make basic asm implicitly clobber memory


On 5/5/2016 10:29 AM, Bernd Edlinger wrote:
Hi!

this patch is inspired by recent discussion about basic asm:

Currently a basic asm is an instruction scheduling barrier,
but not a memory barrier, and most surprising, basic asm
does _not_ implicitly clobber CC on targets where
extended asm always implicitly clobbers CC, even if
nothing is in the clobber section.

This patch makes basic asm implicitly clobber CC on certain
targets, and makes the basic asm implicitly clobber memory,
but no general registers, which is what could be expected.

This is however only done for basic asm with non-empty
assembler string, which is in sync with David's proposed
basic asm warnings patch.

Due to the change in the tree representation, where
ASM_INPUT can now be the first element of a
PARALLEL block with the implicit clobber elements,
there are some changes necessary.

Most of the changes in the middle end, were necessary
because extract_asm_operands can not be used to find out
if a PARALLEL block is an asm statement, but in most cases
asm_noperands can be used instead.

There are also changes necessary in two targets: pa, and ia64.
I have successfully built cross-compilers for these targets.

Boot-strapped and reg-tested on x86_64-pc-linux-gnu
OK for trunk?

A few questions:

1) I'm not clear precisely what problem this patch fixes. It's true that some people have incorrectly assumed that basic asm clobbers memory and this change would fix their code. But some people also incorrectly assume it clobbers registers. I assume that's why Jeff Law proposed making basic asm "an opaque blob that read/write/clobber any register or memory location." Do we have enough problem reports from users to know which is the real solution here?

2) The -Wbasic-asm warning patch wasn't approved for v6. If we are going to change this behavior now, is it time?

3) I assume there are good reasons why extended asm can't be used at top level. Will adding these clobbers cause those problems in basic asm too?

4) There are more basic asm docs that need to change: "It also does not know about side effects of the assembler code, such as modifications to memory or registers. Unlike some compilers, GCC assumes that no changes to either memory or registers occur. This assumption may change in a future release."

dw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]