Will gcc work correctly if "+ m" is used as output limitation?

According to gcc docs in extended assembler:

You should only use read and write operands when restrictions on the operand [...] allow case.

This seems pretty straightforward: you cannot use + m for output.

However, I saw how this was done several times. In fact, Linus Torvalds in the record , saying

Gcc docs are secondary. They are not updated, they are false, they do not reflect reality, and they do not matter. The only right thing to use is "+ m" for such things

I do not want to use + m if the compiler terminates with my code. And even studying the output to see if this works, does not mean that tomorrow, when I change some seemingly unrelated thing, it will still work. Or that it will still work when I receive the next gcc update.

If the documents are correct, and I cannot depend on this work, I want to know that I can pursue other options (most of which are unpleasantly painful). If the documents are wrong, let me know how to fix them.

+6
source share
2 answers

As it turns out, the problem is in the documents (see email ). In case the connection freezes:

This part of the documents was incorrect for a while. The document was fixed for 4.8, but it was incorrect for earlier versions.

Since I am using the rubenvb x64 compiler, which tells version 4.7.2 what version of the documents I read. However, the actual code check was in 2004, so Iโ€™m sure that the changes are included in the code that I run.

+2
source

Please do not quote what Linus had to say on gcc in 2001 (!), When rcc gcc / egcs was just starting to heal (it ended around 2000). Yes, handling asm constraints was a terrifying mess in this timeframe (Alan Cox was a bit of a mess clearing, as the compiler really began to take into account the constraints, I added some patches to this).

The current GCC is a completely different beast, it has undergone extensive reengineering inside.

Believe the documentation, do not write down bad restrictions. They are limitations, if you lie to the compiler, it may just be unsuccessful selection arguments that work most of the time. One day it will break.

If you have an example showing that an invalid restriction entry is being accepted (which the compiler can verify!), Report it.

If you have an example of a constraint that the compiler is not considering, report it.

If you have code that does things that may (or may not) work depending on the parameters that the compiler can legitimately accept according to what ypu said and that sometimes works and sometimes not, fine, do it for your own guilt and the wise. Do not lie to your compiler, he will gain bloody revenge.

0
source

All Articles