I had a conversation with Russell King about asm("") and historical problems
with it.  He told me that in old versions of GCC, it was necessary to either
clobber conds or else use %?; otherwise GCC could mistakenly omit a branch
around the inline asm.

When (around GCC 3.0) we started to use final.c in addition to
arm_final_prescan_insn, this changed.  Suddenly %? could be filled in by a
bogus condition more easily.  So using %? in inline asm is no longer viable. 
However, the old code, which predicated instructions unless they clobbered
conds, is still present.  We don't know exactly why, but Paul tells me that it
still triggers once in a while.

I believe that if it triggers, it may mistakenly "conditionalize" instructions
which don't use %?.  I don't have a testcase.

The simplest fix is probably to check the relatively new predicable attribute. 
A more complete fix might be to figure out when the old code triggers, adjust
the rest of the compiler to handle those cases if desired, and remove the ARM
backend-specific bits entirely.


-- 
           Summary: ARM inline assembly can be mispredicated.
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: drow at gcc dot gnu dot org
GCC target triplet: arm-none-linux-gnueabi


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28872

Reply via email to