[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC] Eliminate NESTED_ATTR_FUNC
From: |
Bean |
Subject: |
Re: [RFC] Eliminate NESTED_ATTR_FUNC |
Date: |
Wed, 2 Sep 2009 12:20:19 +0800 |
On Tue, Sep 1, 2009 at 11:43 PM, Bean<address@hidden> wrote:
> I make an assembly dump of the code generated by gcc-4.2. Apparently,
> the "FIX" is achieved by ignoring the regparm attribute at all.
> __attribute__ ((__regparm__ (3))) doesn't have any effect any more, it
> always pass the parameters on the stack. This defeats the original
> purpose of -mregparm=3, which passes parameters using register and
> therefore reduce module size. In fact, if we are going to use stack,
> we could just remove -mregparm=3 option, this works for all version of
> gcc.
Hi,
Oh, I was wrong previously, gcc does respect __attribute__
((__regparm__ (3))) flag (I forget to add -Os so it still uses stack
to store value). And the bug is still there ! Try this test program:
#include <stdio.h>
void foo (int a, int b, void (*hook) (int aa, int bb, int cc))
{
b += a;
hook (a, b, a + b);
}
void qq (int a)
{
auto void q1 (int aa, int bb, int cc);
void q1 (int aa, int bb, int cc)
{
printf ("%d %d %d\n", a, aa + bb, cc);
}
foo (a, a + 1, q1);
}
int main()
{
qq (10);
}
Compile with:
gcc -m32 -mregparm=3 -Os test.c
./a.out
10 31 -6674368
gcc is 4.3.4 from debian.
---
Bean
gitgrub home: http://github.com/grub/grub/
my fork page: http://github.com/bean123/grub/
- [RFC] Eliminate NESTED_ATTR_FUNC, Vladimir 'phcoder' Serbinenko, 2009/09/01
- Re: [RFC] Eliminate NESTED_ATTR_FUNC, Bean, 2009/09/01
- Re: [RFC] Eliminate NESTED_ATTR_FUNC, Robert Millan, 2009/09/01
- Re: [RFC] Eliminate NESTED_ATTR_FUNC, Bean, 2009/09/01
- Re: [RFC] Eliminate NESTED_ATTR_FUNC, Yves Blusseau, 2009/09/01
- Re: [RFC] Eliminate NESTED_ATTR_FUNC, David Miller, 2009/09/01
- Re: [RFC] Eliminate NESTED_ATTR_FUNC, Vladimir 'phcoder' Serbinenko, 2009/09/03
- Re: [RFC] Eliminate NESTED_ATTR_FUNC, David Miller, 2009/09/03
- Message not available
- Message not available
- Fwd: [RFC] Eliminate NESTED_ATTR_FUNC, Vladimir 'phcoder' Serbinenko, 2009/09/06
- Re: Fwd: [RFC] Eliminate NESTED_ATTR_FUNC, Robert Millan, 2009/09/08
Re: [RFC] Eliminate NESTED_ATTR_FUNC,
Bean <=
Re: [RFC] Eliminate NESTED_ATTR_FUNC, Robert Millan, 2009/09/03
Re: [RFC] Eliminate NESTED_ATTR_FUNC, Felix Zielcke, 2009/09/03
Re: [RFC] Eliminate NESTED_ATTR_FUNC, Vladimir 'phcoder' Serbinenko, 2009/09/03
Re: [RFC] Eliminate NESTED_ATTR_FUNC, Bean, 2009/09/03