This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: noreturn function attribute and ret asm instruction


> No.  If you are trying to write assembly language code, then write
> assembly language code not C code with asms.

I am not trying to inject asms in C code this time, even though I see
your point given that the optimizer does not know if the flow was
changed by an asm.

This time I am referring to this example:

int a = 8;
int c = 5;

void test3()
{
  c = a + c;
}

Dump of assembler code for function test3:
0x80483cc <test3>:      push   %ebp
0x80483cd <test3+1>:    mov    %esp,%ebp
0x80483cf <test3+3>:    mov    0x80494f4,%eax
0x80483d4 <test3+8>:    add    %eax,0x80494f8
0x80483da <test3+14>:   leave  
0x80483db <test3+15>:   ret    
End of assembler dump.


Here %eax is used and it's previous value is not preserved. Again
conceptually I should be able to write in a high-level language such as
C with the option to tell gcc to preserve the registers it will end up
using on its own. Agreed, writing intuitively in asm would solve the
problem of preserving the registers, but not the problem of trying to
write in a high-level language.

Should this feature be implemented for gcc, would it be accepted ? What
would be the best way to implement it ? As a function attribute ?

Please excuse once again my inexperience with gcc internals.

> Some targets have an "interrupt" attribute that can be used to write

I am familiar with it. 

> get a return from interrupt instruction at the end of the function

And this is their only pitfall. Otherwise the state of clobbered
registers is preserved. Well pointed out.

Thanks,
Kristis



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]