Bug 21621 - [avr] Wrong / missing warning "skipping two-word instruction"
Summary: [avr] Wrong / missing warning "skipping two-word instruction"
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.29
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-19 13:52 UTC by Georg-Johann Lay
Modified: 2017-10-19 15:24 UTC (History)
1 user (show)

See Also:
Host:
Target: avr
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Georg-Johann Lay 2017-06-19 13:52:35 UTC
$ avr-as frag.s -o frag.o && avr-objdump -d frag.o

== frag.s ==

.text
    cpse 0,0
.subsection 1
    lds 0,0
.previous
    clc


.text
    cpse 1,1
.subsection 1
    sec
.previous
    lds 1,1

== gas output ==

frag.s: Assembler messages:
frag.s:4: Warning: skipping two-word instruction


The first snip should *not* issue a skip warning whereas the second one *should* issue one for the last line.  Due to the .subsection, the insn following CPSE in the source is not the one which is skipped.

FYI, objdump's ouput is:

00000000 <.text>:
   0:   00 10           cpse    r0, r0
   2:   88 94           clc
   4:   11 10           cpse    r1, r1
   6:   10 90 01 00     lds     r1, 0x0001      ;  0x800001
   a:   00 90 00 00     lds     r0, 0x0000      ;  0x800000
   e:   08 94           sec


The problem is in tc-avr.c::avr_operands() which holds static state on previous opcode in "prev".  However, this state should go into the current fragment's target-specific info in .tc_frag_data. (The right place would actually be the respective fragment chain, not the fragment itself, but the chain doesn't allow to add target-specific extensions whereas struct frag does.)
Comment 1 Sourceware Commits 2017-10-19 15:23:09 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=95e42ad4425f0ab0ebfb90035a891be576f9fca4

commit 95e42ad4425f0ab0ebfb90035a891be576f9fca4
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu Oct 19 16:21:51 2017 +0100

    Fix the AVR assembler so that it will correctly issue warnings about skipped instructions even if subsections are used.
    
    	PR 21621
    	* config/tc-avr.h (struct avr_frag_data): Add prev_opcode field.
    	(TC_FRAG_INIT): Define.
    	(avr_frag_init): Add prototype.
    	* config/tc-avr.c (avr_frag_init): New function.
    	(avr_operands): Replace static local 'prev' variable with
    	prev_opcode field in current frag.
    	* testsuite/gas/avr/pr21621.s: New test source file.
    	* testsuite/gas/avr/pr21621.d: New test driver file.
    	* testsuite/gas/avr/pr21621.s: New test error output file.
Comment 2 Nick Clifton 2017-10-19 15:24:27 UTC
Hi Georg-Johann,

  Fixed as you suggested. :-)

Cheers
  Nick