[patch] current_insn_predicate vs. inline asm

Paul Brook paul@codesourcery.com
Wed Aug 9 16:52:00 GMT 2006


The Arm port uses %? in format strings to generate mnemonic suffixes for 
conditionally executed instructions. These expand to different things 
depending on the value of current_insn_predicate.

It turns out that there's a fair amount of kernel code that includes %? in 
inline assembly fragments. This is arguably a bug in the kernel. However, 
given gcc never conditionaly executes inline asm it's not entirely 
unreasonable to expect this to "work". i.e. should expand to the 
unconditional form.

Currently final_scan_insn doesn't set current_insn_predicate until after asm 
fragments have been output. This means inline asm incorrectly inherits its 
conditionalness from the previous insn.

The attached patch resets current_insn_predicate earlier, so inline asm output 
is unconditional. It fixes an arm-linux kernel miscompilation.

Tested with cross to arm-none-eabi.
Ok for mainline and 4.1?

Paul

2006-08-09  Paul Brook  <paul@codesourcery.com>

	gcc/
	* final.c (final_scan_insn): Clear current_insn_predicate before
	outputting inline asm.

	gcc/testsuite/
	* gcc.target/arm/cond-asm.c: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.cond_asm
Type: text/x-diff
Size: 1347 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060809/a7e18625/attachment.bin>


More information about the Gcc-patches mailing list