------- Comment #2 from jakub at gcc dot gnu dot org 2009-09-03 16:29 ------- Created an attachment (id=18480) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18480&action=view) gcc45-pr41246.patch
I'm afraid there is nothing that can make that unmodified testcase work for -mregparm=3. It is true that gcc is buggy and doesn't force regparm(2) for nested functions with -mregparm=3 (regparm(3) is impossible, due to the static chain in %ecx), we only error if explicit __attribute__((regparm (3))) is used on nested functions. But if we silently change the call to regparm(2), there is no way for the compiler to know whether the hook is using regparm(3) or regparm(2) calling convention (if you pass it a non-nested function, it will be regparm(3), if you pass a nested function, it will be regparm(2). So, perhaps we should just error out whenever we see in -m32 mode on i?86/x86_64 a nested function in -mregparm=3 mode. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41246