bugAVR C Runtime Library - Bugs: bug #37026, ABI documentation and 8-bit...

 
 

bug #37026: ABI documentation and 8-bit integer promotion of function return

Submitted by:  Georg-Johann Lay <gjlayde>
Submitted on:  Sat 04 Aug 2012 12:48:57 PM UTC  
 
Category:  Documentation Severity:  3 - Normal
Priority:  9 - Immediate Item Group:  Documentation
Status:  None Percent Complete:  0%
Assigned to:  None Open/Closed:  Open
Release:  1.8.0 Fixed Release:  None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 04 Aug 2012 12:48:57 PM UTC, original submission:

The current ABI documentation [1] reads:


  • Return values: [...] 8-bit return values are zero/sign-extended to 16 bits by the called function [...]

avr-gcc up to 4.2 actually performed that promotion. However, that promotion was not per design, it was just a missed optimization in the compiler (and thus is not suposed to work reliably) and since 4.3 (including respective WinAVR releases) that promotion is no more performed.

There were off-list e-mail threads "AVR GCC 8-bit return values" from 2011-04-02 and "[off-list]: Updating avr-gcc ABI" from 2011-04-20 between Eric, Jörg, Denis and me with the conclusion that the above clause shall be dropped from the ABI.

The changed promotion behavior affects assembler code that calls C function with an 8-bit integer return value and expects that the return value is promoted to 16 bits.

Even the older versions <= 4.2 of the compiler that perform the promotion won't make use of that: Suppose a caller that calls a function returning 8-bit, and the caller needs a 16-bit value. Then the caller performs that extention explicitly and does not rely on the callee returning a 16-bit integer. Sample code:

The ABI document should mention that the promotion performed by the compiler changed with 4.2 -> 4.3 and the promotion up to 4.2 does not work reliably.

Moreover (and unrelated to promotion) the ABI should mention that T-flag in SREG is used the same way like R0 aka. _tmp_reg_.

Georg-Johann Lay <gjlayde>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by arcanum (Updated the item)
  • -email is unavailable- added by gjlayde (Submitted the item)
  •  

     

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-11-16 arcanum Priority5 - Normal => 9 - Immediate

    Back to the top


    Powered by Savane 3.3